Create command.py

This commit is contained in:
ElBe 2023-01-14 11:07:42 +01:00 committed by GitHub
parent 1b03684511
commit 5c63b5a4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

29
Examples/command.py Normal file
View File

@ -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)