From 5c63b5a4c0a187c63ad134f7a0c949ccc622726d Mon Sep 17 00:00:00 2001 From: ElBe <90863907+ElBe-Plaq@users.noreply.github.com> Date: Sat, 14 Jan 2023 11:07:42 +0100 Subject: [PATCH] Create command.py --- Examples/command.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Examples/command.py diff --git a/Examples/command.py b/Examples/command.py new file mode 100644 index 0000000..d0ef3fb --- /dev/null +++ b/Examples/command.py @@ -0,0 +1,29 @@ +''' +Example command for the discord.py Bot. +© by ElBe. +Version: 1.0 +''' +#Imports +import discord +import functions + +#Main +async def __init__(interaction: discord.Interaction, *args): + '''Example command cog. + + Usage: + `/example` + + Args: + interaction (discord.Interaction): Interaction provided by on_interaction. + ''' + + if interaction.data['name'] == 'example': + functions.log('Command /example was used by @' + str(interaction.user) + '.') + if functions.json_module.get_config('Commands')['example']: + print('This is an example!') + else: + commandDisabledEmbed = discord.Embed(title='Command disabled', description='This command was disabled in the bot config file. Ask a member with access to the bot to enable this command.') + commandDisabledEmbed.set_thumbnail(url=interaction.client.user.avatar.url) + commandDisabledEmbed.set_footer(text=functions.json_module.get_config('Config')['Footer']) + await interaction.response.send_message(embed=commandDisabledEmbed, ephemeral=True)