Skip to content

Commit 34f13ea

Browse files
committed
Changed embed colours to a variable
1 parent 0783553 commit 34f13ea

File tree

7 files changed

+56
-16
lines changed

7 files changed

+56
-16
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
"dotenv",
88
"Flegg",
99
"infile",
10+
"lemmatize",
11+
"lemmatized",
12+
"lemmatizer",
1013
"logtostderr",
1114
"matthewflegg",
15+
"nltk",
1216
"nocheckcertificate",
1317
"noplaylist",
1418
"nostdin",
1519
"outtmpl",
20+
"spacy",
1621
"unban",
1722
"Unbans",
1823
"YOUTUBEDL",

files/blacklist.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
{
2-
"782644704193937409": [
3-
"ass",
4-
"frick",
5-
"beans"
6-
]
7-
}
1+
{}

modules/admin.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"""
44

55
import discord.ext.commands as commands
6+
import discord.ui as UI
67
import helpers
78
import asyncio
89
import discord
10+
import start
911
import json
1012

1113

@@ -14,7 +16,8 @@
1416

1517
@commands.command()
1618
@commands.has_permissions(manage_messages=True)
17-
async def clear(ctx: commands.Context, amount: int):
19+
@commands.cooldown(1, 15, commands.BucketType.user)
20+
async def clear(ctx: commands.Context, amount: int | None):
1821
"""
1922
Clears messages from a text channel.
2023
@@ -27,11 +30,35 @@ async def clear(ctx: commands.Context, amount: int):
2730
amount (int):
2831
The number of messages to clear.
2932
"""
30-
await ctx.channel.purge(limit=amount)
33+
if amount is not None: # If the user selected an amount, clear that amount of messages
34+
await ctx.send(embed=discord.Embed(title=f'🛠️ Deleting **{amount}** messages.'))
35+
return await ctx.channel.purge(limit=amount)
36+
37+
# Else, create two buttons
38+
# Then ask the user if they would like to clear all messages in the channel
39+
yes_button = UI.Button(label='Yes', style=discord.ButtonStyle.green)
40+
no_button = UI.Button(label='No', style=discord.ButtonStyle.red)
41+
42+
yes_button.callback = lambda interaction: \
43+
(await interaction.channel.purge(limit=None) for _ in '_').__anext__()
44+
no_button.callback = lambda interaction: \
45+
(await interaction.message.delete() for _ in '_').__anext__()
46+
47+
view = UI.View()
48+
view.add_item(yes_button)
49+
view.add_item(no_button)
50+
51+
return await ctx.send(
52+
f':warning: {ctx.author.mention}: You have not selected a number of messages to clear.\n'
53+
+ 'Would you like to clear all messages in this channel?',
54+
view=view
55+
)
56+
3157

3258

3359
@commands.command()
3460
@commands.has_permissions(kick_members=True)
61+
@commands.cooldown(1, 30, commands.BucketType.user)
3562
async def kick(ctx: commands.Context, member: discord.Member, *, reason=None):
3663
"""
3764
Kicks a specified member from a server.
@@ -53,6 +80,7 @@ async def kick(ctx: commands.Context, member: discord.Member, *, reason=None):
5380

5481
@commands.command()
5582
@commands.has_permissions(ban_members=True)
83+
@commands.cooldown(1, 30, commands.BucketType.user)
5684
async def ban(ctx: commands.Context, member: discord.Member, *, reason=None):
5785
"""
5886
Bans a specified member from a server.
@@ -74,6 +102,7 @@ async def ban(ctx: commands.Context, member: discord.Member, *, reason=None):
74102

75103
@commands.command()
76104
@commands.has_permissions(ban_members=True)
105+
@commands.cooldown(1, 30, commands.BucketType.user)
77106
async def softban(ctx: commands.Context, member: discord.Member, days=1, reason=None):
78107
"""
79108
Temporarily bans a specified member from a server.
@@ -99,6 +128,7 @@ async def softban(ctx: commands.Context, member: discord.Member, days=1, reason=
99128

100129
@commands.command()
101130
@commands.has_permissions(ban_members=True)
131+
@commands.cooldown(1, 2, commands.BucketType.user)
102132
async def unban(ctx: commands.Context, user: discord.User):
103133
"""
104134
Unbans a specified user from a server.
@@ -117,6 +147,7 @@ async def unban(ctx: commands.Context, user: discord.User):
117147

118148
@commands.command()
119149
@commands.has_permissions(manage_messages=True)
150+
@commands.cooldown(1, 2, commands.BucketType.user)
120151
async def blacklist(ctx: commands.Context, *, word: str):
121152
"""
122153
Adds a word to a list of disallowed words in a server.
@@ -133,7 +164,7 @@ async def blacklist(ctx: commands.Context, *, word: str):
133164
filepath = 'files/blacklist.json'
134165
id = str(ctx.guild.id)
135166

136-
with open(filepath, "r") as file:
167+
with open(filepath, 'r') as file:
137168
blacklist: dict = json.load(file)
138169

139170
if id not in blacklist.keys():
@@ -147,7 +178,8 @@ async def blacklist(ctx: commands.Context, *, word: str):
147178

148179
with open(filepath, 'w') as file:
149180
json.dump(blacklist, file, indent=4)
150-
await ctx.send(f':tools: \'{word}\' has been added to the blacklist.')
181+
182+
await ctx.send(f':tools: \'{word}\' has been added to the blacklist.')
151183

152184

153185
# |----- REGISTERING MODULE -----|

modules/help.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import discord.ext.commands as commands
66
import discord
7+
import start
78

89

910
# |---------- COMMANDS ----------|
@@ -22,7 +23,7 @@ async def help(ctx: commands.Context):
2223
"""
2324
embed = discord.Embed(
2425
title="Beep Boop Bot Documentation",
25-
color=0x486572,
26+
color=start.colour,
2627
url="https://github.com/matthewflegg/beepboop/blob/main/README.md",
2728
description="View the official commands list for Beep Boop Bot on GitHub.",
2829
)

modules/misc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import random
88
import discord
99
import json
10+
import start
1011
import requests
1112

1213

@@ -46,7 +47,7 @@ async def meme(ctx: commands.Context):
4647

4748
meme = discord.Embed(
4849
title=str(data["title"]),
49-
color=0x486572
50+
color=start.colour
5051
)
5152

5253
meme.set_image(url=str(data['url']))
@@ -66,7 +67,7 @@ async def poll(ctx: commands.Context, *poll: str):
6667
"""
6768
embed = discord.Embed(
6869
title=f'Poll by **{ctx.author.name}**:',
69-
color=0x486572,
70+
color=start.colour,
7071
description=' '.join(poll)
7172
)
7273

modules/music.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Contains music player commands.
3+
"""
4+
15
import discord
26
import discord.ext.commands as commands
37
import asyncio
@@ -12,7 +16,7 @@
1216
# |---------- CONFIG ----------|
1317

1418

15-
COLOR = discord.Color(0x486572)
19+
COLOR = start.colour
1620

1721
ytdl_options = {
1822
'format': 'bestaudio/best',

start.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
import discord.ext.commands as commands
1111
import discord.ext.tasks as tasks
1212
import itertools
13+
import dotenv
1314

1415

1516
# |---------- CONFIG ----------|
1617

1718

19+
dotenv.load_dotenv('files/.env')
20+
1821
intents = discord.Intents.all()
1922
intents.members = True
2023

2124
prefix = "~"
2225
colour = 0x486572
23-
status = itertools.cycle(["~help", "~ai", "~play"])
26+
status = itertools.cycle(['~help', '~ai', '~play'])
2427
client = commands.Bot(prefix, intents=intents, help_command=None) # Help command = none so we can override it
2528

2629
PATH = './modules'

0 commit comments

Comments
 (0)