A custom Discord bot for my server.
- Respond to commands either by prefix or when mentioned like a regular user.
- Play sounds in voice channels.
- Passively respond to messages that contain certain keywords
- User management like kicking and banning
- Greet people when they come online
- Other crap I don't need but 99% of other bots seem to do
Debian systems prior to 9 (Stretch) and Ubuntu systems prior to 15.04
use libav instead of ffmpeg. Therefore you need to have the environment
variable SERVOSKULL_AVCONV
with any value present on those systems
before running the bot. If it doesn't exist, the bot won't be able to
play sounds in voice channels because it assumes an ffmpeg
executable
to be present in $PATH
.
- Build the Docker image:
docker build -t servoskull .
- Run a Docker container:
docker run --name servoskull --restart=always -e SERVOSKULL_TOKEN=<YOUR_DISCORD_TOKEN> servoskull
- Open
https://discordapp.com/api/oauth2/authorize?scope=bot&permissions=0&client_id=<YOUR_DISCORD_CLIENT_ID>
. You can get your client ID from your Discord dev dashboard.
If you want to change the default command prefix !
to something else, add another parameters
-e SERVOSKULL_PREFIX=<PREFIX>
e. g. -e SERVOSKULL_PREFIX=#
All commands must either return None
, a str
or a discord.Embed
object.
A regular command is a command that does something and optionally returns a string. Create a new class in regular.py
, inherit from Command
and override the execute
method where you can do anything. If you want the bot to respond with a message, just return a string. Finally register your class with the annotation @registry.register('yourcommand')
with yourcommand
being the string that triggers the command.
A sound command is a command that requires the bot to be connected to a voice channel before running the command. E. g. a command that plays a sound. Create a new class in sound.py
, inherit from SoundCommand
and override the execute_sound
method (not the execute
method). Finally register your class with the annotation @registry.register('yourcommand', sound=True)
.
A passive command is a command that can be triggered by any message the bot can listen to. Create a new class in passive.py
, inherit from PassiveCommand
and override is_triggered
as well as execute
. If somebody writes a message in Discord, the bot listens to it and uses the is_triggered
method to check if it should call the class's execute
method. Finally register your class with the annotation @registry.register('Your command', passive=True)
with 'Your command'
being a short description for the !help
command.