- Features
- Running the bot yourself
- Structure of the bot
- Possible errors
- Contributing
- Todo
- Related gists
n!help
- Shows a help similar to this readme.n!play <url>
- Play audio in a voice channel (.mp3 url, youtube url or youtube search).n!join
- Join the user's channel.n!join_channel <channel_name>
- Join the specified channel.n!leave
- Leaves the current channel.n!pause
- Pauses the audio.n!resume
- Resumes the audio.n!stop
- Stops the audio without leaving the channel.
n!ping
- The bot reacts to your message to make sure it is online.n!memes
- Le funny.n!version
- Compares the current version (Whale emoji) with the remote version (Check or cross emoji depending if they match). Alson!ver
.
This commands will only work if you are the bot owner or if you are in the whitelist.
n!kick @someone
to kick a user.n!ban @someone
to ban a user.n!move @someone <channel>
to move a user.n!mute @someone
to mute a user. Alson!m
.n!unmute @someone
to unmute a user. Alson!um
.n!deafen @someone
to deafen a user. Alson!d
.n!undeafen @someone
to undeafen a user. Alson!ud
.n!purge @someone <messages_to_check>
will check X messages, and will delete them if the author is the specified user. Alson!clean
.n!spam <amount> <message>
will spam the specified messae in the current channel the amount of times.
This commands will only work if you are the bot owner or you are in the am whitelist:
n!am
if you want to know about this one, check the code yourself :)
ping
orn!ping
to make sure it works.- Detects if a message contains
uwu
, then screams. - Leaves the channel if alone for 30 seconnds.
- Has a
n!play
blacklist in case someone listens to k-pop. - Has a whitelist for administration commands (Checks the whitelist instead of the role).
- Send custom embeds to a custom channel with
console.py
. - Can autoreact to user's messages. See this link for emote names.
- Tries to find regional discord emojis in the
custom_emojis
dictionary. If it doesn't find it tries to use the emoji module with 2 different languages.
- Tries to find regional discord emojis in the
- Logs with a new system:
[W]
for warnings.[E]
for errors (discord_log_path
)[ET]
for error timestamps (Wrote todiscord_log_path
, reference a date inbot_error_path
)[Module]
It also has a small tag about the module used (Music
,Administration
, ...)
- Fetches the last remote repo information and compares the last origin/main commit with the head commit. See
n!version
First, you will need to edit the .env_default
file (move it to .env
), and replace there your bot token.
# .env
DISCORD_TOKEN={YOUR_TOKEN_HERE}
You will also need to edit the configuration file (settings.py
) and the whitelists file (config/config.json.default
which you will need to move to config.json
).
vim settings.py
vim config/config.json
You can then run the bot with docker:
# You may want to edit docker.sh if:
# - You use another root command like doas
# - If you want to use a different image or container name
# - If you want to change the docker flags
sudo chmod +x docker.sh # Give permission to execute the file
./docker.sh clean # Will remove the image if existing (discord-bot:latest)
./docker.sh build # Will build the docker image (discord-bot:latest)
./docker.sh run # Will run the docker image (discord-bot:latest)
# By default it will run it in daemon mode with the container name discord-bot
Or run it normally:
# You will need to install some depencencies
python3 -m pip install -r requirements.txt
# Make it executable and start it. This script will then create a screen session
chmod +x start-bot.sh
./start-bot.sh
After running the bot, a screen session named DiscordBot
.
screen -ls # To list the sessions
screen -r DiscordBot # Resume
# Ctrl+D + Ctrl+A to detach the session again
The bot uses cogs
to organize the functions (commands) into different files.
The structure of the bot is the following:
DiscordBot.py
is the main file. It will create the bot and manage all the cogs.- In the
config
folder you can edit theconfig.json
file. This file contains all the whitelists and blacklists for the bot.
You can check itsreadme.md
. - The
logs
folder is the folder that the commands will write when events happen. - The
modules
folder contains all the python files needed for the bot to work.- In the
cogs
folder you can find a file for each cog, divided by categories. These are the commands itself. - In the
functions
folder you can find files for functions or classes that the bot needs, for exampledebug_print()
orerror_print()
, that show the events that the bot recieves.
The filebotclass.py
contains the class of the bot itself. - In the
variables
folder you can find files that contain variables or data that the bot needs. For examplecustom_emotes.py
contains all the regional emotes in unicode format needed for reactions.
- In the
Thanks to the discord.py community for being so kind and helping me out. :)
- The bot can't download age-restricted content.
- The bot might fail depending on the youtube servers.
- The bot can't play playlists right now.
Check CONTRIBUTE.md.
- Bot needs to be on a channel to play music, if you use
n!play <song>
the bot will join, but you will need to type the command again for it to work. You can usen!join
to make the bot join the channel before usingn!play
. - Add a
n!help
command. - Make the bot "stream" the songs instead of downloading them.
- Add autorreactions for users and guilds.
- Add autorreact command for appending to the json?
- Move whitelists to json file and read it from there instead of the code (so users can edit it easily).
- Separate code into multiple files.
- Add tags to
debug_print()
- Add
n!version
for checking the commit hash with git. - Change messages (joined, playing...) to embeds.
- Move
n!help
and message events to cogs. - Wanna play blackjack with the bot :^)
- Add queue system.
- Add
n!stats
command.- Show uptime? -> From inside docker
- Add
n!poll
andn!roles
(that reads fromconfig.json
) command for starting polls or giving roles based on message reactions.
- discord_purge.py - Discord bot purge 1.
- discord_purge2.py - Discord bot purge 2.
- discord_purge3.py - Discord bot purge 3.
- check_inactive.py - Check if the bot is alone in a channel for X secconds.