diff --git a/commands/example.py b/commands/example.py new file mode 100644 index 0000000..691eed6 --- /dev/null +++ b/commands/example.py @@ -0,0 +1,77 @@ +from discord import Interaction +from ModuBotDiscord import ModuBotDiscord +from ModuBotDiscord.commands import ( + BaseCommand, + check_bot_owner, + check_bot_permission, + check_guild_owner, + check_permission, + send_message, +) +from ModuBotDiscord.enums import PermissionEnum + + +class ExampleCommand(BaseCommand): + async def register(self, bot: ModuBotDiscord): + @bot.tree.command( + name="check_bot_permission_example", + description="Example for `@check_bot_permission`", + ) + @check_bot_permission(PermissionEnum.ADMINISTRATOR) + async def check_bot_permission_example(interaction: Interaction): + await send_message( + interaction, + f"Bot has the Permission: `{PermissionEnum.ADMINISTRATOR}`", + True, + ) + + @bot.tree.command( + name="check_bot_permission2_example", + description="Example for `@check_bot_permission`", + ) + @check_bot_permission(PermissionEnum.KICK_MEMBERS, PermissionEnum.BAN_MEMBERS) + async def check_bot_permission_multiple_example(interaction: Interaction): + await send_message( + interaction, + f"Bot has the Permissions: `{PermissionEnum.KICK_MEMBERS}`, `{PermissionEnum.BAN_MEMBERS}`", + True, + ) + + @bot.tree.command( + name="check_permission_example", + description="Example for `@check_permission`", + ) + @check_permission(PermissionEnum.ADMINISTRATOR) + async def check_permission_example(interaction: Interaction): + await send_message( + interaction, + f"You have the Permission: `{PermissionEnum.ADMINISTRATOR}`", + True, + ) + + @bot.tree.command( + name="check_permission2_example", + description="Example for `@check_permission`", + ) + @check_permission(PermissionEnum.KICK_MEMBERS, PermissionEnum.BAN_MEMBERS) + async def check_permission_multiple_example(interaction: Interaction): + await send_message( + interaction, + f"You have the Permissions: `{PermissionEnum.KICK_MEMBERS}`, `{PermissionEnum.BAN_MEMBERS}`", + True, + ) + + @bot.tree.command( + name="check_bot_owner_example", description="Example for `@check_bot_owner`" + ) + @check_bot_owner() + async def check_bot_owner_example(interaction: Interaction): + await send_message(interaction, "You are the Owner of the Bot!") + + @bot.tree.command( + name="check_guild_owner_example", + description="Example for `@check_guild_owner`", + ) + @check_guild_owner() + async def check_guild_owner_example(interaction: Interaction): + await send_message(interaction, "You are the Owner of the Guild!") diff --git a/commands/ping.py b/commands/ping.py index 064620c..b829d31 100644 --- a/commands/ping.py +++ b/commands/ping.py @@ -1,10 +1,10 @@ from discord import Interaction from ModuBotDiscord import ModuBotDiscord -from ModuBotDiscord.commands import BaseCommand +from ModuBotDiscord.commands import BaseCommand, send_message class PingCommand(BaseCommand): async def register(self, bot: ModuBotDiscord): @bot.tree.command(name="ping", description="Responds with Pong!") async def ping(interaction: Interaction): - await interaction.response.send_message("Pong!", ephemeral=True) + await send_message(interaction, "Pong!", True) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5d7bf33 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.isort] +profile = "black"