Skip to content

Commit 7661858

Browse files
authored
Merge pull request #36 from matthewflegg/dev
Bug fixes and UI improvements
2 parents 8ff5221 + 0381143 commit 7661858

23 files changed

+308
-193
lines changed

cogs/admin/admin_cog.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ async def clear(self, ctx: commands.Context, amount: int | None):
3939
```
4040
"""
4141
if isinstance(amount, int) and amount is not None:
42-
await ctx.channel.purge(limit=amount)
43-
return await ctx.send(f"🛠️ Deleted **{amount}** messages.")
42+
return await ctx.channel.purge(limit=amount)
4443

4544
embed = discord.Embed(
46-
title="⚠️ You have not selected a number of messages to clear.",
45+
title="⚠️ You Have Not Selected a Number of Messages to Clear",
4746
description="❓ Would you like to clear all messages in this channel?",
4847
)
4948

@@ -87,6 +86,8 @@ async def softban(
8786
"""
8887
⚙️ Temporarily bans a member from a server.
8988
89+
❓ If a number of days is not specified, the user is kicked for 1 day.
90+
9091
Usage:
9192
```
9293
~softban <member> [days] [reason]
@@ -125,27 +126,29 @@ async def blacklist(self, ctx: commands.Context, *, words: str = None):
125126
if not words:
126127
view = BlacklistAddView(ctx)
127128
embed = discord.Embed(
128-
title="🛠️ Please enter one or more words to blacklist."
129+
title="🛠️ Please Enter One or More Words to Blacklist"
129130
)
130131
view.message = await ctx.send(embed=embed, view=view)
131132
return
132133

133134
id = str(ctx.guild.id)
134-
words = [word.lower() for word in words.split(" ")]
135+
words = {word.strip().lower() for word in words.split(" ")} - {
136+
""
137+
} # Remove empty strings ''
135138

136139
blacklist = self.client.cache.blacklist
137140
if id not in blacklist.keys():
138141
blacklist[id] = []
139142

140143
# Remove words that are already in the blacklist from the words to add.
141144
# Make a copy so we can add a footer if any words were removed
142-
words_ = set(words) - set(blacklist[id])
145+
words_ = words - set(blacklist[id])
143146

144147
# If the list of words is zero, we know that none of the words
145148
# can be added. So, send an error message
146149
if not words_:
147-
return await ctx.send(
148-
f"❌ {ctx.author.mention}: Sorry. Those words are already in the blacklist."
150+
return await ctx.reply(
151+
f"❌ Those words are already in the blacklist.", delete_after=20
149152
)
150153

151154
# If duplicate words have been removed, add non-duplicates
@@ -156,7 +159,7 @@ async def blacklist(self, ctx: commands.Context, *, words: str = None):
156159
self.client.update_json(FILEPATH, blacklist)
157160

158161
embed = discord.Embed(
159-
title=f"🛠️ Words successfully added.",
162+
title=f"🛠️ Words Successfully Added",
160163
description=" ".join(f"`{word}`" for word in words_),
161164
)
162165

@@ -178,15 +181,14 @@ async def clearblacklist(self, ctx: commands.Context):
178181
"""
179182
id = str(ctx.guild.id)
180183
blacklist = self.client.cache.blacklist
181-
mention = ctx.author.mention
182184

183185
if id not in blacklist.keys():
184-
return await ctx.send(
185-
f"❌ {mention}: This server does not have any words blacklisted."
186+
return await ctx.reply(
187+
f"❌ This server does not have any words blacklisted.", delete_after=20
186188
)
187189

188190
embed = discord.Embed(
189-
title=f"⚠️ Are you sure you'd like to clear your server's blacklist?\n",
191+
title=f"⚠️ Are You Sure You'd Like to Clear Your Server's Blacklist?\n",
190192
description=f"❗ This action cannot be undone.",
191193
)
192194

@@ -208,11 +210,11 @@ async def showblacklist(self, ctx: commands.Context):
208210
server_id = str(ctx.guild.id)
209211

210212
if server_id not in blacklist.keys() or not blacklist[server_id]:
211-
return await ctx.send(
212-
f"❌ {ctx.author.mention}: This server does not have any words blacklisted."
213+
return await ctx.reply(
214+
f"❌ This server does not have any words blacklisted.", delete_after=20
213215
)
214216

215-
embed = discord.Embed(title="⛔ Blacklist:")
217+
embed = discord.Embed(title="⛔ Blacklist")
216218
embed.description = "".join([f" `{word}` " for word in blacklist[server_id]])
217219

218220
await ctx.send(embed=embed)
@@ -230,30 +232,30 @@ async def blacklistremove(self, ctx: commands.Context, *, words: str = None):
230232
"""
231233
if not words:
232234
view = BlacklistRemoveView(ctx)
233-
embed = discord.Embed(
234-
title="🛠️ Please enter one or more words to remove from the blacklist."
235-
)
235+
embed = discord.Embed(title="🛠️ Please Enter One or More Words to Remove")
236236

237237
view.message = await ctx.send(embed=embed, view=view)
238238
return
239239

240240
id = str(ctx.guild.id)
241-
words = {word.lower() for word in words.split(" ")}
241+
words = {word.strip().lower() for word in words.split(" ")} - {
242+
""
243+
} # Remove empty strings ''
242244

243245
blacklist = self.client.cache.blacklist
244246

245247
if id not in blacklist.keys():
246-
return await ctx.send(
247-
f"❌ {ctx.author.mention}: This server does not have any words blacklisted."
248+
return await ctx.reply(
249+
f"❌ This server does not have any words blacklisted.", delete_after=20
248250
)
249251

250252
# Only remove words that are already in the blacklist from the words to remove.
251253
# Make a copy so we can add a footer if any words were removed
252254
words_ = words & set(blacklist[id])
253255

254256
if not words_:
255-
return await ctx.send(
256-
f"❌ {ctx.author.mention}: Sorry. Those words are not in the blacklist."
257+
return await ctx.reply(
258+
f"❌ Those words are not in the blacklist.", delete_after=20
257259
)
258260

259261
# If duplicate words have been removed, remove non-duplicates
@@ -264,7 +266,7 @@ async def blacklistremove(self, ctx: commands.Context, *, words: str = None):
264266
self.client.update_json(FILEPATH, blacklist)
265267

266268
embed = discord.Embed(
267-
title=f"🛠️ Words successfully removed.",
269+
title=f"🛠️ Words Successfully Removed",
268270
description=" ".join(f"`{word}`" for word in words_),
269271
)
270272

cogs/help/help_cog.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ async def docs(self, ctx: commands.Context):
5050
icon_url="https://imagemagick.org/image/convex-hull.png",
5151
)
5252

53-
embed.set_thumbnail(
54-
url="https://media.istockphoto.com/vectors/robot-avatar-icon-vector-id908807494?k=20&m=908807494&s=612x612&w=0&h=N050SIC8pgzsf_LaJT-ZyEE6HHMXLU5PYfMpixuinas="
55-
)
56-
5753
embed.set_footer(
5854
text="Contribute to the open source Beep Boop Bot GitHub repository."
5955
)

cogs/help/help_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ async def send_bot_help(self, mapping: dict):
7474
Sends a bot help command.
7575
"""
7676
embed = await self.help_embed(
77-
title="Bot Commands",
78-
description="BB.Bot commands. See our GitHub repository for more information."
77+
title="📝 Bot Commands",
78+
description="BB.Bot's full command list. See our GitHub repository for more information."
7979
+ f"\n\nUse **~help <command name>** for more information about a command."
8080
+ f"\nUse **~help <cog name>** for more information about a cog.",
8181
mapping=mapping,

cogs/misc/misc_cog.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, client: commands.Bot):
2121
self.client = client
2222

2323
@commands.command()
24-
async def twitch(self, ctx: commands.Context, *, name: str):
24+
async def twitch(self, ctx: commands.Context, *, name: str = None):
2525
"""
2626
🎲 Shows information about a Twitch stream.
2727
@@ -36,8 +36,13 @@ async def twitch(self, ctx: commands.Context, *, name: str):
3636
/twitch <streamer name>
3737
```
3838
"""
39+
if name is None:
40+
return await ctx.reply(
41+
f"❌ You need to specify a streamer name.", delete_after=20
42+
)
43+
3944
client = self.client.twitch
40-
name = name.lower()
45+
name = name.strip().lower()
4146
broadcaster_data = await client.connect("helix/users", login=name)
4247
broad_list = broadcaster_data["data"]
4348

@@ -48,8 +53,8 @@ async def twitch(self, ctx: commands.Context, *, name: str):
4853
json = await client.connect("helix/streams", user_id=str(broadcaster_id))
4954

5055
if not json["data"]:
51-
return await ctx.send(
52-
f":x: {ctx.author.mention}: {broadcaster_name} isn't live."
56+
return await ctx.reply(
57+
f"❌ **{broadcaster_name}** isn't live.", delete_after=20
5358
)
5459

5560
stream: TwitchBroadcast = await client.return_information(json)
@@ -82,8 +87,8 @@ async def twitch(self, ctx: commands.Context, *, name: str):
8287

8388
return await ctx.send(embed=embed, file=file)
8489

85-
return await ctx.send(
86-
f":x: {ctx.author.mention}: I couldn't find a streamer with the name '{name}'."
90+
return await ctx.reply(
91+
f":x: I couldn't find a streamer with the name '{name}'.", delete_after=20
8792
)
8893

8994
@commands.command()
@@ -105,15 +110,16 @@ async def choose(self, ctx: commands.Context, *choices: str):
105110
# Display some error messages if the user's input is invalid.
106111
# This is because it's kinda awkward to do this in the on_command_error event.
107112
if len(choices) < 1:
108-
return await ctx.send(
109-
f":x: {ctx.author.mention}: You need to give me choices to choose from."
113+
return await ctx.reply(
114+
f":x: You need to give me choices to choose from.", delete_after=20
110115
)
111116
if len(choices) == 1:
112-
return await ctx.send(
113-
f":x: {ctx.author.mention}: I need more than one choice!"
114-
)
117+
return await ctx.reply(f":x: I need more than one choice!", delete_after=20)
115118

116-
embed = discord.Embed(title=f"🎲 I choose {random.choice(choices)}")
119+
embed = discord.Embed(
120+
title=f"🎲 I Choose",
121+
description=f"```{random.choice(choices)}```",
122+
)
117123
await ctx.send(embed=embed)
118124

119125
@commands.command()
@@ -158,7 +164,7 @@ async def poll(self, ctx: commands.Context, *poll: str):
158164
"""
159165
if not poll:
160166
return await ctx.reply(
161-
f":x: {ctx.author.mention}: You need to specify a question."
167+
f":x: You need to specify a question.", delete_after=20
162168
)
163169

164170
embed = discord.Embed(

0 commit comments

Comments
 (0)