Skip to content

Commit

Permalink
Change admin slash command registration
Browse files Browse the repository at this point in the history
  • Loading branch information
atomflunder committed Apr 6, 2024
1 parent 78fca90 commit 915c5b1
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Last updated: 26 May 2023

### Notes about required permissions:

- **Moderator only** means that you have to be the Server Owner, have Administrator Rights or the Moderator Role to use this Command.
- **Moderator only** means that you have to be the Server Owner, have Administrator Rights or the Moderator Role to use this Command. These commands only work within approved Guilds.
- **Admin only** means that you need to have Administrator Rights in order to use this Command.
- **Owner only** means that only the Bot's Owner can use this Command.

Expand Down
48 changes: 24 additions & 24 deletions cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.hybrid_group()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def clear(self, ctx: commands.Context, amount: int = 1) -> None:
Expand All @@ -38,7 +38,7 @@ async def clear(self, ctx: commands.Context, amount: int = 1) -> None:
await ctx.send(embed=embed)

@clear.command(name="amount")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(amount="The amount of messages to delete.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand All @@ -64,7 +64,7 @@ def check(m: discord.Message) -> bool:
)

@clear.command(name="after")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
message_after="The message to delete every other message in this channel.",
message_before="The message to stop deleting messages at.",
Expand Down Expand Up @@ -109,7 +109,7 @@ def check(m: discord.Message) -> bool:
await ctx.channel.send(message)

@clear.command(name="from")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user to delete the messages from in this channel.",
amount="The amount of messages to delete from the user.",
Expand Down Expand Up @@ -153,7 +153,7 @@ def check(m: discord.Message) -> bool:
)

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(user="The user to ban.", reason="The reason for the ban.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand Down Expand Up @@ -219,7 +219,7 @@ def check(m: discord.Message) -> bool:
return

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(user="The user to unban.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand All @@ -229,7 +229,7 @@ async def unban(self, ctx: commands.Context, user: discord.User) -> None:
await ctx.send(f"{user.mention} has been unbanned!")

@commands.hybrid_command(aliases=["syncbans"])
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(discord.Object(GuildIDs.BATTLEGROUNDS))
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def syncbanlist(self, ctx: commands.Context):
Expand Down Expand Up @@ -267,7 +267,7 @@ async def syncbanlist(self, ctx: commands.Context):
await ctx.send(f"Ban list was successfully synced. Banned {i} users.")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
member="The user to kick.", reason="The reason for the kick."
)
Expand Down Expand Up @@ -331,7 +331,7 @@ def check(m: discord.Message) -> bool:
return

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
member="The member to add a role to.", role="The role to add."
)
Expand All @@ -355,7 +355,7 @@ async def addrole_autocomplete(
)

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
member="The member to remove a role from.", role="The role to remove."
)
Expand All @@ -379,7 +379,7 @@ async def removerole_autocomplete(
)

@commands.hybrid_group()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def editrole(self, ctx: commands.Context) -> None:
Expand All @@ -399,7 +399,7 @@ async def editrole(self, ctx: commands.Context) -> None:
await ctx.send(embed=embed)

@editrole.command(name="name")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
role="The role to edit the name of.", name="The new name of the role."
)
Expand All @@ -420,7 +420,7 @@ async def editrole_name(
await ctx.send("I do not have the required permissions to edit this role.")

@editrole.command(name="colour", aliases=["color"])
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
role="The role to edit the colour of.",
hex_colour="The new colour, in the hex format.",
Expand Down Expand Up @@ -457,7 +457,7 @@ async def editrole_colour(
await ctx.send("I do not have the required permissions to edit this role.")

@editrole.command(name="icon")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def editrole_icon(
Expand Down Expand Up @@ -526,7 +526,7 @@ async def apply_icon(asset: Union[discord.Emoji, discord.Attachment]):
await ctx.send(f"Something went wrong:\n`{exc}`")

@editrole.command(name="mentionable", aliases=["mention"])
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
role="The role to edit the mentionable status of.",
mentionable="The new mentionable status (True/False).",
Expand All @@ -544,15 +544,15 @@ async def editrole_mentionable(
await ctx.send("I do not have the required permissions to edit this role.")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def records(self, ctx: commands.Context) -> None:
"""Links our ban records google doc."""
await ctx.send(f"Link to our ban records:\n{AdminVars.BAN_RECORDS}")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(member="The member to rename.", name="The new name.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand All @@ -566,7 +566,7 @@ async def rename(
)

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
messageable="Where to send the message/reply to (Channel, Thread, Message).",
message="The message I will send.",
Expand Down Expand Up @@ -602,7 +602,7 @@ async def say(
await ctx.send("Message sent!", ephemeral=True)

@commands.hybrid_command(aliases=["nicknames", "usernames", "aliases"])
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(user="The user you want to see the last tracked names of.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand Down Expand Up @@ -665,7 +665,7 @@ async def names(self, ctx: commands.Context, user: discord.User) -> None:
await ctx.send(embed=embed)

@commands.hybrid_group()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def modnote(self, ctx: commands.Context) -> None:
Expand All @@ -684,7 +684,7 @@ async def modnote(self, ctx: commands.Context) -> None:
await ctx.send(embed=embed)

@modnote.command(name="set")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user for which you want to set the note.",
note="The note of the user.",
Expand Down Expand Up @@ -721,7 +721,7 @@ async def modnote_set(
)

@modnote.command(name="view")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def modnote_view(self, ctx: commands.Context, user: discord.User) -> None:
Expand Down Expand Up @@ -751,7 +751,7 @@ async def modnote_view(self, ctx: commands.Context, user: discord.User) -> None:
await ctx.send(embed=embed)

@modnote.command(name="delete")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user for which you want to delete a note from.",
note_id="The ID of the note you want to delete.",
Expand Down Expand Up @@ -808,7 +808,7 @@ async def modnote_delete_autocomplete(
return choices[:25]

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(user="The user you want to look up.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand Down
12 changes: 6 additions & 6 deletions cogs/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def new_profile(self, user: discord.User) -> None:
await db.commit()

@commands.hybrid_group()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def badge(self, ctx: commands.Context) -> None:
Expand All @@ -56,7 +56,7 @@ async def badge(self, ctx: commands.Context) -> None:
await ctx.send(embed=embed)

@badge.command(name="add")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user to add the badges to.", badges="The badge(s) to add."
)
Expand Down Expand Up @@ -117,7 +117,7 @@ async def badge_add(
await ctx.send(f"Added badge(s) {' '.join(added_badges)} to {user.mention}.")

@badge.command(name="remove")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user to remove the badge from.", badge="The badge to remove."
)
Expand Down Expand Up @@ -165,7 +165,7 @@ async def badge_remove(
await ctx.send(f"Removed badge {badge} from {user.mention}.")

@badge.command(name="clear")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(user="The user to remove all badges from.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand All @@ -191,7 +191,7 @@ async def badge_clear(self, ctx: commands.Context, user: discord.User) -> None:
await ctx.send(f"Cleared all badges from {user.mention}.")

@badge.command(name="setinfo")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
badge="The badge you want to add information about.",
info_text="The new information text for the badge.",
Expand Down Expand Up @@ -245,7 +245,7 @@ async def badge_setinfo(
await ctx.send(f"Updated badgeinfo of {badge} to: \n`{info_text}`")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(badge="The badge you want to see the details of.")
async def badgeinfo(self, ctx: commands.Context, badge: str) -> None:
"""Gets you information about a given badge."""
Expand Down
6 changes: 3 additions & 3 deletions cogs/levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async def on_message(self, message: discord.Message) -> None:
pass

@commands.hybrid_group()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def xp(self, ctx: commands.Context):
Expand All @@ -258,7 +258,7 @@ async def xp(self, ctx: commands.Context):
await ctx.send(embed=embed)

@xp.command(name="add")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user to add the xp to.", amount="The amount of xp to add to the user."
)
Expand All @@ -285,7 +285,7 @@ async def xp_add(
)

@xp.command(name="remove")
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
user="The user to remove the xp from.",
amount="The amount of xp to remove from the user.",
Expand Down
4 changes: 2 additions & 2 deletions cogs/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def on_message(self, message: discord.Message) -> None:
await db.commit()

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def createmacro(self, ctx: commands.Context) -> None:
Expand All @@ -55,7 +55,7 @@ async def createmacro(self, ctx: commands.Context) -> None:
await ctx.send(view=view)

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(name="The name of the macro.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand Down
2 changes: 1 addition & 1 deletion cogs/matchmaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ async def recentpings(self, ctx: commands.Context) -> None:
)

@commands.hybrid_command(aliases=["clearmmrequests", "clearmm", "clearmatchmaking"])
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def clearmmpings(self, ctx: commands.Context) -> None:
Expand Down
10 changes: 5 additions & 5 deletions cogs/mute.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def remove_timeout(self, member: discord.Member) -> None:
)

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
member="The member to mute.", reason="The reason for the mute."
)
Expand Down Expand Up @@ -151,7 +151,7 @@ async def mute(
await ctx.send("This user was already muted!")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(member="The member to unmute.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand Down Expand Up @@ -179,7 +179,7 @@ async def unmute(self, ctx: commands.Context, member: discord.Member) -> None:
await ctx.send("This user was not muted!")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
member="The member to mute.",
mute_time="How long the mute should last.",
Expand Down Expand Up @@ -263,7 +263,7 @@ async def tempmute(
)

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(
member="The member to time out.",
mute_time="How long the time out should last.",
Expand Down Expand Up @@ -332,7 +332,7 @@ async def timeout(
await ctx.send(message)

@commands.hybrid_command(aliases=["untimeout"])
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.describe(member="The member to remove the time out from.")
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
Expand Down
2 changes: 1 addition & 1 deletion cogs/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async def deleteprofile(self, ctx: commands.Context) -> None:
await ctx.send(f"Successfully deleted your profile, {ctx.author.mention}.")

@commands.hybrid_command()
@app_commands.guilds(*GuildIDs.ALL_GUILDS)
@app_commands.guilds(*GuildIDs.ADMIN_GUILDS)
@app_commands.default_permissions(administrator=True)
@utils.check.is_moderator()
async def forcedeleteprofile(
Expand Down
Loading

0 comments on commit 915c5b1

Please sign in to comment.