This repository was made with the MetaGame DAO discord server in mind specifically. It is barebones and contains a single command 'timeoutpoll'.
Credits for helping me learn how to create a bot:
https://github.com/richardschwabe 's youtube tutorial series
Also, thanks @Polimyl for suggesting me to go with python instead of javascript.
This is a discord.py 2 bot that allows any user with the specified role to create a voting poll and timeout any user(except server owner). Based on the results, the bot will either timeout the tagged user for the specified duration or return the appropriate error, depending on its origin(Vote count, Permissions, ..)
Currently, the bot includes:
- Logging
- Automatic Cog Loading - Running the bot automatically loads cogs from /cogs
- Load, Unload and Reload commands for cogs
- Slash command utilization via hybrid commands
- Test examples - included in '/test_examples' for future expansion.
- Create a
logs
folder in the root directory. This is needed since error logging is included. Optional if logging is removed from main.py. - Create a
.env
file from a copy of.env.sample
. - Fill out the
.env
file with your discord bot token. Check below for instructions on how to get the token if you don't have one. GUILD_ID
not needed since it's server specific; there are no commands that require it currently.- Setup the virtual environment following the instructions on Discord.py Docs
- Run the
./main.py
script to start the bot.
- Prefix can be changed in
./main.py
- Required role to call the command can be changed in
./cogs/timeoutpoll.py
. Currently set to 'Player' - Goes without saying but, the bot should be hosted to have it running 24/7
It is important to note the Bot requires the following intents enabled in the Discord's developers portal:
- Presence Intent
- Server Members Intent
- Message Content Intent
Registering the bot and getting the token
- Navigate to https://discord.com/developers/applications and login
- Create a new application by clicking the button in the top right
New Application
- Fill out general info and navigate to the
Bot
tab on the right hand side - Name your bot and fill out info
- Make sure you leave
OAUTH2 CODE GRANT
disabled - Enable intents listed above and save
- Navigate to the
OAuth2 - URL GENERATOR
on the right hand side - For SCOPES pick
bot
and for BOT PERMISSIONS pickAdministrator
. It is usually recommended to pick exact permissions if full admin isn't needed. Caution - URL should be generated on the bottom. That is your bot invite link. Use it to invite your newly created bot to the server
- Back in the
Bot
tab, click onReset Token
to generate your Discord Bot token and store it securely. This token should be placed in the bots.env
file you'll create during setup.