Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions commands/example.py
Original file line number Diff line number Diff line change
@@ -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!")
4 changes: 2 additions & 2 deletions commands/ping.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.isort]
profile = "black"
Loading