Skip to content

Commit

Permalink
Merge pull request #33 from matthewflegg/dev
Browse files Browse the repository at this point in the history
Patched minor blacklisting errors
  • Loading branch information
v0idzdev authored Apr 2, 2022
2 parents adb921c + 4ef3ef5 commit 9aa2829
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
15 changes: 11 additions & 4 deletions cogs/admin/admin_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
import discord

from discord.ext import commands
from utils import BlacklistClearButton, BlacklistAddView, BlacklistRemoveView, ClearMessagesView, lift_ban, sanction
from utils import (
BlacklistClearButton,
BlacklistAddView,
BlacklistRemoveView,
ClearMessagesView,
lift_ban,
sanction,
)

FILEPATH = "files/blacklist.json"

Expand Down Expand Up @@ -106,7 +113,7 @@ async def unban(self, ctx: commands.Context, user: discord.User):
@commands.command(aliases=["bladd"])
@commands.has_permissions(manage_messages=True)
@commands.cooldown(1, 2, commands.BucketType.user)
async def blacklist(self, ctx: commands.Context, *, words: str=None):
async def blacklist(self, ctx: commands.Context, *, words: str = None):
"""
⚙️ Bans words from being used.
Expand Down Expand Up @@ -200,7 +207,7 @@ async def showblacklist(self, ctx: commands.Context):
blacklist = self.client.cache.blacklist
server_id = str(ctx.guild.id)

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

@commands.command(aliases=["blrem"])
@commands.has_permissions(manage_messages=True)
async def blacklistremove(self, ctx: commands.Context, *, words: str=None):
async def blacklistremove(self, ctx: commands.Context, *, words: str = None):
"""
⚙️ Removes a word from the list of banned words.
Expand Down
6 changes: 1 addition & 5 deletions files/blacklist.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"953054451999072276": [
"arse"
]
}
{}
5 changes: 3 additions & 2 deletions utils/views/blacklist_add_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional
from utils import BlacklistAddDropdown, BlacklistAddModal

FILEPATH = 'files/blacklist.json'
FILEPATH = "files/blacklist.json"


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

@discord.ui.button(label="Abort", style=discord.ButtonStyle.red, emoji="👎🏻")
async def abort(self, interaction: discord.Interaction, button: discord.Button):
await interaction.response.send_message(
f"❌ {interaction.user.mention}: Aborting command!", ephemeral=True
)
await self.disable_all_buttons(interaction)
await self.disable_all_buttons(interaction)
7 changes: 4 additions & 3 deletions utils/views/blacklist_remove_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional
from utils import BlacklistRemoveDropdown, BlacklistRemoveModal

FILEPATH = 'files/blacklist.json'
FILEPATH = "files/blacklist.json"


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

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

await interaction.followup.send(embed=embed)
await self.disable_all_buttons()

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

0 comments on commit 9aa2829

Please sign in to comment.