Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Last active February 27, 2022 00:28
Show Gist options
  • Save Rapptz/2a7a299aa075427357e9b8a970747c2c to your computer and use it in GitHub Desktop.
Save Rapptz/2a7a299aa075427357e9b8a970747c2c to your computer and use it in GitHub Desktop.
Slash Command DSL
from discord import slash
class Permissions(slash.SlashCommand):
"""manage permissions of a member"""
pass
class PermissionsGet(slash.SlashCommand, parent=Permissions, name='get'):
"""get permissions of a member"""
member: discord.Member = slash.argument(description='the member to get permissions of')
async def run(self, interaction: discord.Interaction):
...
class PermissionsSet(slash.SlashCommand, parent=Permissions, name='set'):
"""set permissions of a member"""
member: discord.Member = slash.argument(description='the member to edit permissions for')
permissions: int = slash.argument(description='the permissions number to give')
async def run(self, interaction: discord.Interaction):
...
class PermissionsCheck(slash.SlashCommand, parent=Permissions, name='check'):
"""check permissions of a member"""
member: discord.Member = slash.argument(description='the member to check permissions of')
channel: discord.TextChannel = slash.argument(description='the channel to check permissions in')
async def run(self, interaction: discord.Interaction):
...
@slash.command()
async def permissions(interaction):
"""manage permissions of a member"""
...
@permissions.command(name='get')
async def permissions_get(
interaction: discord.Interaction,
member: discord.Member = slash.argument(description='the member to get permissions of'),
):
"""get permissions of a member"""
pass
@permissions.command(name='set')
async def permissions_set(
interaction: discord.Interaction,
member: discord.Member = slash.argument(description='the member to edit permissions for'),
permissions: int = slash.argument(description='the permissions number to give'),
):
"""set permissions of a member"""
pass
@permissions.command(name='check')
async def permissions_check(
interaction: discord.Interaction,
member: discord.Member = slash.argument(description='the member to check permissions of'),
channel: discord.TextChannel = slash.argument(description='the channel to check permissions in'),
):
"""check permissions of a member"""
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment