Skip to content

Commit

Permalink
async settings and rework commands
Browse files Browse the repository at this point in the history
  • Loading branch information
pvyParts committed Oct 12, 2024
1 parent 67b2b35 commit 8a7c23e
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions aadiscordbot/cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def add_role_slash(self, ctx, channel: TextChannel, role: Role):
"""
Add a role as read/write to a channel....
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer()
Expand All @@ -56,7 +56,7 @@ async def add_role_read_slash(self, ctx, channel: TextChannel, role: Role):
"""

# https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer()
Expand All @@ -71,7 +71,7 @@ async def rem_role_slash(self, ctx, channel: TextChannel, role: Role):
"""
Remove a role from a channel....
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer()
Expand All @@ -86,7 +86,7 @@ async def new_channel_slash(self, ctx, category: CategoryChannel, channel_name:
"""
Create a new channel and add a role....
"""
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
# https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond(
"You do not have permission to use this command",
Expand Down Expand Up @@ -129,7 +129,7 @@ async def promote_role_to_god(self, ctx, role: Role):
"""
set role as admin....
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer(ephemeral=True)
Expand All @@ -144,7 +144,7 @@ async def demote_role_from_god(self, ctx, role: Role):
"""
revoke role admin....
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer(ephemeral=True)
Expand All @@ -159,7 +159,7 @@ async def empty_roles(self, ctx):
"""
Dump all roles with no members.
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer()
Expand All @@ -186,7 +186,7 @@ async def clear_empty_roles(self, ctx):
"""
delete all roles with no members.
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer()
Expand All @@ -211,7 +211,7 @@ async def orphans_slash(self, ctx):
"""
Returns a list of users on this server, who are not known to AA
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer()
Expand Down Expand Up @@ -253,7 +253,7 @@ async def get_webhooks(self, ctx):
"""
Returns the webhooks for the channel
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer(ephemeral=True)
Expand Down Expand Up @@ -284,7 +284,7 @@ async def uptime(self, ctx):
"""
Returns the uptime of the bot
"""
if ctx.author.id not in app_settings.get_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in await app_settings.aget_admins(): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
return await ctx.respond("You do not have permission to use this command", ephemeral=True)
try:
await ctx.respond(
Expand All @@ -303,7 +303,7 @@ async def versions(self, ctx):
await ctx.defer(ephemeral=True)

# https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)
try:
output = {}
Expand Down Expand Up @@ -342,12 +342,23 @@ async def versions(self, ctx):
async def command_list(self, ctx):
await ctx.defer(ephemeral=True)
helptext = Paginator()
helptext.add_line(
"Parent Command "
"Module "
"Type"
)
helptext.add_line("-" * 90)
coms = set()
for command in self.bot.walk_application_commands():
if isinstance(command, SlashCommandGroup):
continue
_parent = f"{command.full_parent_name}{' ' if command.full_parent_name else ''}"
_msg = f"{_parent}{command.name} ({command.module} - {command.__class__.__name__})"
helptext.add_line(_msg)
_parent = f"{command.full_parent_name.ljust(15)}{' ' if command.full_parent_name.rjust else ''}"
_msg = f"{_parent}{command.name.ljust(25)} {command.module.ljust(30)} {command.__class__.__name__}"
if _msg not in coms:
coms.add(_msg)
helptext.add_line(_msg)
else:
pass
for _str in helptext.pages:
await ctx.send(_str)
await ctx.respond("Done", ephemeral=True)
Expand All @@ -361,7 +372,7 @@ async def stats(self, ctx):
await ctx.defer(ephemeral=True)

# https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

embed = Embed(title="Bot Task Stats!")
Expand Down Expand Up @@ -414,7 +425,7 @@ async def slash_sync(
"""
Queue Update tasks for the character and all alts.
"""
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

try:
Expand All @@ -439,7 +450,7 @@ async def sync_commands(
"""
Re-Sync the commands to discord.
"""
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)

await ctx.defer(ephemeral=True)
Expand All @@ -451,7 +462,7 @@ async def sync_commands(
@commands.user_command(name="Group Sync", guild_ids=app_settings.get_all_servers())
async def group_sync_user_context(self, ctx, user):
# https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)
auth_user = DiscordUser.objects.get(uid=user.id)
update_groups.delay(auth_user.user_id)
Expand All @@ -460,7 +471,7 @@ async def group_sync_user_context(self, ctx, user):
@commands.user_command(name="Nickname Sync", guild_ids=app_settings.get_all_servers())
async def nick_sync_user_context(self, ctx, user):
# https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif
if ctx.author.id not in app_settings.get_admins():
if ctx.author.id not in await app_settings.aget_admins():
return await ctx.respond("You do not have permission to use this command", ephemeral=True)
auth_user = DiscordUser.objects.get(uid=user.id)
update_nickname.delay(auth_user.user_id)
Expand Down

0 comments on commit 8a7c23e

Please sign in to comment.