Skip to content

Commit

Permalink
moved admin util funcs into admin cog folder
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idzdev committed Apr 8, 2022
1 parent 0bd5bb8 commit 150e8a4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion client/client_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(
extension_paths: list[str],
handler_paths: list[str],
database_paths: dict[str, str],
test_guild_id: int = None,
test_guild_id: int,
**kwargs
) -> None:
super().__init__(**kwargs)
Expand Down
4 changes: 2 additions & 2 deletions cogs/admin/admin_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
BlacklistAddView,
BlacklistRemoveView,
ClearMessagesView,
lift_ban,
sanction,
)

from .admin_utils import *


class AdminCog(commands.Cog, name="Admin"):
"""
Expand Down
20 changes: 20 additions & 0 deletions utils/functions/sanction_.py → cogs/admin/admin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,23 @@ async def sanction(

embed = discord.Embed(title="🛠️ User Sanctioned", description=f"⚙️ {message}")
await ctx.send(embed=embed)


async def lift_ban(ctx: commands.Context, ban_type: str, user: discord.User):
"""
Utility function that unbans a member.
"""
try:
await ctx.guild.unban(user)

except commands.UserNotFound:
return await ctx.reply(f"❌ I couldn't find the user {user}.", delete_after=20)

except discord.NotFound:
return await ctx.reply(
f"❌ Unbanning **{user}** was not possible. Please check that they are currently banned.",
delete_after=20,
)

message = f":tools: {ctx.author.mention}: {user.name}'s {ban_type} ban was lifted."
await ctx.send(message)
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
status = itertools.cycle(["❓ ~help", "🎵 ~play", "📢 ~twitch"])
client = Client(
status,
extension_paths=EXTENSION_PATHS,
handler_paths=HANDLER_PATHS,
database_paths=DATABASE_PATHS,
test_guild_id=TEST_GUILD_ID,
EXTENSION_PATHS,
HANDLER_PATHS,
DATABASE_PATHS,
TEST_GUILD_ID,
command_prefix=get_prefix,
intents=intents,
case_insensitive=True,
Expand Down
4 changes: 1 addition & 3 deletions utils/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from .authorization_check_ import authorization_check
from .executor_ import executor
from .lift_ban_ import lift_ban
from .sanction_ import sanction
from .session_check_ import session_check
from .session_check_ import session_check
22 changes: 0 additions & 22 deletions utils/functions/lift_ban_.py

This file was deleted.

0 comments on commit 150e8a4

Please sign in to comment.