This is my own template for making disnake bots. This is not, in any way, the best way to make bots but is the way I am comfortable with.
Start with installing the required modules by using the following commands.
pip install disnake
pip install python-dotenv
-
Start with putting the guild id of your test guild in the test_guilds variable in the file main.py Multiple guild id should work as well.
test_guilds = [12345678901234, 13771298372174]
-
By default, it uses all intents as shown in the code. Change this or give the bot the necessary intents.
intents = disnake.Intents.all() # all intents = disnake.Intents.default() # all intents that don't require verification
-
Change the default bot settings. The default is a command bot meaning it acts as an interaction bot and a message bot.
# Default Interaction bot and Message bot bot = commands.Bot( command_prefix=commands.when_mentioned, intents=intents, test_guilds=test_guilds, help_command=commands.DefaultHelpCommand(), ) # Interaction bot only bot = commands.InteractionBot( intents=intents, test_guilds=test_guilds, help_command=commands.DefaultHelpCommand(), )
-
Create a file in the same directory as main.py and name it
token.env
. It should contain the token of the bot you are using in that format without spaces or quotation marks.DISCORD_TOKEN=1234TOKENHERE1234
Check out the guide in the cogs folder for a more in depth overview of how to use cogs.