A Discord bot to organize secret santa gift exchanges using the discord.py Python library + some other admin-type stuff for my server
- This bot code must be pulled (or forked) and run locally
- If you don't want the admin-type stuff, just go in and comment out the add_cog(SantaAdministrative(...)) line
- python 3.6 or later (can be installed here)
- pip3
-
Run
pip3 install -r requirements.txt
-
Once all of the dependencies are installed, create a Discord bot token following the instructions here.
- IMPORTANT: you will need to explicitly enable the Server Members Intent under the Bot tab in the Discord Application Developer Portal
- IMPORTANT: you will need to explicitly enable the Server Members Intent under the Bot tab in the Discord Application Developer Portal
-
Replace variables in CONFIG.py (I have provided CONFIG.py.example as an example)
3a. Replace
discord_token
andclient_id
in CONFIG.py with your bot token - these two are REQUIRED for all functionality and for the bot to even start3b. Replace other variables as you want
- `role_channel` is REQUIRED for using reaction roles - will print an error in the console if left as -1 - `prefix` change it to whatever you want otherwise commands default to YOUR_PREFIX_HEREjoin, YOUR_PREFIX_HEREunpin_all, etc. - `bot_folder` this is where the .cfg for the Secret Santa participants, the debug log, and the SQLite database files are stored - `cfg_name`, `dbg_name`, `sqlite_name` don't *need* to do anything here unless you want to - `min_budget`, `max_budget` are used for the Secret Santa functionality and can be changed depending on what your Discord server agrees upon.
-
Run
python3 santa-bot.py
To keep SantaBot running even after restart you can create a service.
- Copy the
run_santa.sh
to/usr/local/bin/
directory
- sudo cp run_santa.sh /usr/local/bin/
- Edit
run_santa.sh
in/usr/local/bin
with your favorite editor to include the absolute path to the santa-bot.py script. For example/home/pi/Santabot/santa-bot.py
. If you're not sure the absolute, in the Santabot directory typepwd
-
pwd /home/pi/Santabot
-
sudo nano /usr/local/bin/run_santa.sh
- while true - do - python3 /home/pi/Santabot/santa-bot.py - sleep 10 - done
- Create a service file or edit the included
santabot.service
using your favorite text editor and add the default user name toUser=
and the Group they belong to inGroup=
. To find out what default group a user belongs useid -gn usernamehere
-
nano santabot.service
- [Unit] - Description=Santa Discord Bot - [Service] - User= root - Group= root - Restart=on-abort - WorkingDirectory= "Full Path to Santa Bot Here" - ExecStart= /usr/local/bin/run_santa.sh - [Install] - WantedBy=multi-user.target
- Copy the santabot.service to
/lib/systemd/system/
- sudo cp santabot.service /lib/systemd/system/
- Enable the service so it will autostart on reboot, then start with the commands:
- sudo systemctl enable santabot.service
- sudo systemctl start santabot.service
- Then check the status
- sudo systemctl status santabot.service
- When done using the bot for the season, to disable use both commands:
- sudo systemctl disable santabot.service
- sudo systemctl stop santabot.service
- What if my wishlist URL or preference is multiple words?
- The bot supports that, just surround it with quotation marks. (e.g.
s!setprefs dog "stuffed rabbit" cat
)
- The bot supports that, just surround it with quotation marks. (e.g.
- Does the wishlist have to be a URL? What if one of the Secret Santas prefers sending handmade gifts?
- No that field is really about having a destination for users to send their gifts. Feel free to use addresses instead of URLs if you so desire. Keep in mind that addresses will need to follow question #1 of this FAQ (e.g.
s!setwishlisturl amazonurl/123 "P Sherman 42 Wallaby Way" rightstufanime
)
- No that field is really about having a destination for users to send their gifts. Feel free to use addresses instead of URLs if you so desire. Keep in mind that addresses will need to follow question #1 of this FAQ (e.g.
s!join
= join the Secret Santas!leave
= leave the Secret Santas![setwishlisturl|swlurl] [wishlist URL]
= set your wishlist URL (replaces current). You may also add your mailing address. wishlist URL is required.s![getwishlisturl|gwlurl]
= bot will PM you your current wishlists![setprefs|sprefs] [specific preferences, the things you like]
= set preferences (replaces current). Put N/A if none. preferences are required.s![getprefs|gprefs]
= bot will PM you your current preferencess![listparticipants|lp]
(admin only) = get the current participantss![totalparticipants|tp]
= get the total number of participantss!partnerinfo
= be DM'd your partner's informations!start
(admin only) = assign Secret Santa partnerss!restart
(admin only) = attempt to restart Secret Santa after pause without changing partnerss!pause
(admin only) = pause Secret Santa (will requires!start
and will reshuffle partners)s!end
(admin only) = end Secret Santa
s!assign_role_channel CHANNEL
(admin only) = change the channel the bot looks at for reaction roless!archive_pins SRC_CHANNEL DEST_CHANNEL
(admin only) = archive all pins from the source channel to the destination channel as messages (ex.s!archive_pins #general #archive
)s!unpin_all [CHANNEL_ID]
(admin only) = unpin all messages in the indicated channel (defaults to the channel the command is called in)
s!emote [any number of emotes]
= returns the URL of the emote image/gif for conveniences![countdown|cd]
= set/check a countdown (global for the server, e.g. time until a Manga Club event) - help text is returns as needed
s!ping
= check if bot is alives!echo
= make the bot say stuffs!ding
= dong