Skip to content

Commit 150e8a4

Browse files
committed
moved admin util funcs into admin cog folder
1 parent 0bd5bb8 commit 150e8a4

File tree

6 files changed

+28
-32
lines changed

6 files changed

+28
-32
lines changed

client/client_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(
1919
extension_paths: list[str],
2020
handler_paths: list[str],
2121
database_paths: dict[str, str],
22-
test_guild_id: int = None,
22+
test_guild_id: int,
2323
**kwargs
2424
) -> None:
2525
super().__init__(**kwargs)

cogs/admin/admin_cog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
BlacklistAddView,
1313
BlacklistRemoveView,
1414
ClearMessagesView,
15-
lift_ban,
16-
sanction,
1715
)
1816

17+
from .admin_utils import *
18+
1919

2020
class AdminCog(commands.Cog, name="Admin"):
2121
"""

utils/functions/sanction_.py renamed to cogs/admin/admin_utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,23 @@ async def sanction(
2525

2626
embed = discord.Embed(title="🛠️ User Sanctioned", description=f"⚙️ {message}")
2727
await ctx.send(embed=embed)
28+
29+
30+
async def lift_ban(ctx: commands.Context, ban_type: str, user: discord.User):
31+
"""
32+
Utility function that unbans a member.
33+
"""
34+
try:
35+
await ctx.guild.unban(user)
36+
37+
except commands.UserNotFound:
38+
return await ctx.reply(f"❌ I couldn't find the user {user}.", delete_after=20)
39+
40+
except discord.NotFound:
41+
return await ctx.reply(
42+
f"❌ Unbanning **{user}** was not possible. Please check that they are currently banned.",
43+
delete_after=20,
44+
)
45+
46+
message = f":tools: {ctx.author.mention}: {user.name}'s {ban_type} ban was lifted."
47+
await ctx.send(message)

main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
status = itertools.cycle(["❓ ~help", "🎵 ~play", "📢 ~twitch"])
2525
client = Client(
2626
status,
27-
extension_paths=EXTENSION_PATHS,
28-
handler_paths=HANDLER_PATHS,
29-
database_paths=DATABASE_PATHS,
30-
test_guild_id=TEST_GUILD_ID,
27+
EXTENSION_PATHS,
28+
HANDLER_PATHS,
29+
DATABASE_PATHS,
30+
TEST_GUILD_ID,
3131
command_prefix=get_prefix,
3232
intents=intents,
3333
case_insensitive=True,

utils/functions/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
from .authorization_check_ import authorization_check
22
from .executor_ import executor
3-
from .lift_ban_ import lift_ban
4-
from .sanction_ import sanction
5-
from .session_check_ import session_check
3+
from .session_check_ import session_check

utils/functions/lift_ban_.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)