Skip to content

Commit 9aa2829

Browse files
authored
Merge pull request #33 from matthewflegg/dev
Patched minor blacklisting errors
2 parents adb921c + 4ef3ef5 commit 9aa2829

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

cogs/admin/admin_cog.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
import discord
77

88
from discord.ext import commands
9-
from utils import BlacklistClearButton, BlacklistAddView, BlacklistRemoveView, ClearMessagesView, lift_ban, sanction
9+
from utils import (
10+
BlacklistClearButton,
11+
BlacklistAddView,
12+
BlacklistRemoveView,
13+
ClearMessagesView,
14+
lift_ban,
15+
sanction,
16+
)
1017

1118
FILEPATH = "files/blacklist.json"
1219

@@ -106,7 +113,7 @@ async def unban(self, ctx: commands.Context, user: discord.User):
106113
@commands.command(aliases=["bladd"])
107114
@commands.has_permissions(manage_messages=True)
108115
@commands.cooldown(1, 2, commands.BucketType.user)
109-
async def blacklist(self, ctx: commands.Context, *, words: str=None):
116+
async def blacklist(self, ctx: commands.Context, *, words: str = None):
110117
"""
111118
⚙️ Bans words from being used.
112119
@@ -200,7 +207,7 @@ async def showblacklist(self, ctx: commands.Context):
200207
blacklist = self.client.cache.blacklist
201208
server_id = str(ctx.guild.id)
202209

203-
if server_id not in blacklist.keys():
210+
if server_id not in blacklist.keys() or not blacklist[server_id]:
204211
return await ctx.send(
205212
f"❌ {ctx.author.mention}: This server does not have any words blacklisted."
206213
)
@@ -212,7 +219,7 @@ async def showblacklist(self, ctx: commands.Context):
212219

213220
@commands.command(aliases=["blrem"])
214221
@commands.has_permissions(manage_messages=True)
215-
async def blacklistremove(self, ctx: commands.Context, *, words: str=None):
222+
async def blacklistremove(self, ctx: commands.Context, *, words: str = None):
216223
"""
217224
⚙️ Removes a word from the list of banned words.
218225

files/blacklist.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"953054451999072276": [
3-
"arse"
4-
]
5-
}
1+
{}

utils/views/blacklist_add_view.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional
55
from utils import BlacklistAddDropdown, BlacklistAddModal
66

7-
FILEPATH = 'files/blacklist.json'
7+
FILEPATH = "files/blacklist.json"
88

99

1010
class BlacklistAddView(discord.ui.View):
@@ -78,10 +78,11 @@ async def submit(self, interaction: discord.Interaction, button: discord.Button)
7878
if len(values) > len(words):
7979
embed.set_footer(text="⚠️ Some words were duplicates and were not added.")
8080
await interaction.followup.send(embed=embed)
81+
await self.disable_all_buttons()
8182

8283
@discord.ui.button(label="Abort", style=discord.ButtonStyle.red, emoji="👎🏻")
8384
async def abort(self, interaction: discord.Interaction, button: discord.Button):
8485
await interaction.response.send_message(
8586
f"❌ {interaction.user.mention}: Aborting command!", ephemeral=True
8687
)
87-
await self.disable_all_buttons(interaction)
88+
await self.disable_all_buttons(interaction)

utils/views/blacklist_remove_view.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional
55
from utils import BlacklistRemoveDropdown, BlacklistRemoveModal
66

7-
FILEPATH = 'files/blacklist.json'
7+
FILEPATH = "files/blacklist.json"
88

99

1010
class BlacklistRemoveView(discord.ui.View):
@@ -69,7 +69,7 @@ async def submit(self, interaction: discord.Interaction, button: discord.Button)
6969
if id not in blacklist.keys():
7070
return await interaction.followup.send(
7171
f"❌ {interaction.user.mention}: This server does not have any words blacklisted.",
72-
ephemeral=True
72+
ephemeral=True,
7373
)
7474

7575
print(values)
@@ -96,10 +96,11 @@ async def submit(self, interaction: discord.Interaction, button: discord.Button)
9696
embed.set_footer(text="⚠️ Some words were duplicates and were not added.")
9797

9898
await interaction.followup.send(embed=embed)
99+
await self.disable_all_buttons()
99100

100101
@discord.ui.button(label="Abort", style=discord.ButtonStyle.red, emoji="👎🏻")
101102
async def abort(self, interaction: discord.Interaction, button: discord.Button):
102103
await interaction.response.send_message(
103104
f"❌ {interaction.user.mention}: Aborting command!", ephemeral=True
104105
)
105-
await self.disable_all_buttons(interaction)
106+
await self.disable_all_buttons(interaction)

0 commit comments

Comments
 (0)