Skip to content

Commit

Permalink
add commands in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
pvyParts committed Aug 21, 2024
1 parent 30c5946 commit 1f6a8db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 19 additions & 0 deletions aadiscordbot/cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
)
from discord.commands import SlashCommandGroup
from discord.ext import commands
from discord.ext.commands import Paginator

from django.contrib.auth.models import Group
from django.core.exceptions import ObjectDoesNotExist
Expand Down Expand Up @@ -320,6 +321,24 @@ async def versions(self, ctx):
except Exception as e:
await ctx.respond(f"Something went wrong! {e}", ephemeral=True)

@admin_commands.command(name='commands', guild_ids=app_settings.get_all_servers())
async def command_list(self, ctx):
await ctx.defer(ephemeral=True)
helptext = Paginator()
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__})"
try:
helptext.add_line(_msg)
except RuntimeError:
helptext.close_page()
helptext.add_line(_msg)
for _str in helptext.pages:
await ctx.send(_str)
await ctx.respond("Done", ephemeral=True)

@admin_commands.command(name='stats', guild_ids=app_settings.get_all_servers())
async def stats(self, ctx):
"""
Expand Down
3 changes: 1 addition & 2 deletions aadiscordbot/cogs/reaction_roles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

from discord import reaction
from discord.ext import commands
from discord.utils import get

Expand Down Expand Up @@ -69,7 +68,7 @@ async def add_react_listener(self, payload):
try:
rr_binds = ReactionRoleBinding.objects.get(
message=rr_msg, emoji=payload.emoji.name)
except:
except Exception:
# admin adding new role?
if DiscordUser.objects.get(uid=payload.user_id).user.has_perm("aadiscordbot.manage_reactions"):
gld = get(self.bot.guilds, id=payload.guild_id)
Expand Down

0 comments on commit 1f6a8db

Please sign in to comment.