NOTE 📝:
This is a discord.py v2 cog template with a command and slash command
- Dice command a command / slash command to roll a 6 sided dice
To use this bot, follow these steps:
- set up a bot on https://discord.com/developers/applications
- get your bot token and put the token in the token.txt
- Invite the bot to your Discord server
- Run the bot by putting your token in the
"token.txt"
, no other characters
- Description: Roll a dice with 6 sides
- Usage:
.roll
- Description: Roll a cube with 6 sides
- Usage:
/roll
-
Clone the repository:
git clone https://github.com/TrapstarJannik/Discord-Cog-Template
cd Discord-Cog-Template
pip install -r requirements.txt
-
Run the bot:
python main.py
Important
You need to put your token in the config.json
or you will get an error!
- The bot's prefix is set to
.
by default. You can change it in theconfig.json
file. - add your discord bot token in the
config.json
by replacing the first line.
- This is a example how to run every cog in a specific folder (extentions)
# cogs loading
async def main():
async with bot:
for filename in os.listdir('./extensions'):
if filename.endswith('.py'):
await bot.load_extension(f'extensions.{filename[:-3]}')
await bot.start(TOKEN)
# run main.py
if __name__ == '__main__':
asyncio.run(main())
- In discord.py V2 you need to async def the setup function and await the bot.add_cog
# setup function
async def setup(bot):
await bot.add_cog(Dice(bot))