Written in Python using discord.py.
Data are stored in an embedded SQLite3 database file.
This Discord bot is developed with Python 3.11. Use the same Python version to ensure maximum compatibility.
-
Download the whole source code using
git clone
. -
Rename
.env.example
to.env
and put your Discord token inside. -
Create a virtual python environment and install dependencies from
requirements.txt
. -
Run
python main.py
in your console to start up the bot. -
To use the music player, you need to run a Lavalink instance alongside the bot. Set
LAVALINK_URL
andLAVALINK_PASSWORD
in.env
.Example config file (
application.yml
) for Lavalink:
server:
port: 2333
address: 0.0.0.0
plugins:
youtube:
enabled: true
clients:
- MUSIC
- ANDROID
- WEB
- TVHTML5EMBEDDED
lavalink:
plugins:
# See https://github.com/lavalink-devs/youtube-source for the latest version of the plugin
- dependency: "dev.lavalink.youtube:youtube-plugin:1.3.0"
server:
password: "youshallnotpass"
sources:
youtube: false
- To use the AI chat command, set
OPENAI_API_KEY
andOPENAI_MODEL_NAME
in.env
.
If you prefer Docker, you can use the Docker Compose file here.
Note: The latest
tag refers to the latest stable version.
- A music player to play Youtube videos in any voice channel (requires a Lavalink server)
- Chat with AI (requires an OpenAI compatible API endpoint, e.g. text-generation-webui)
- A bunch of other commands I created for my needs...
- Bot commands:
- Music.play: Add Spotify support
- General.pixiv: Rewrite (refer to Phixiv implementation)
- AI.draw: Add stable-diffusion-webui support
- Allow passing arguments to FFMPEG (for hardware acceleration)
- Allow bot owner to run every command (including admin only commands)
Please use /help
to see the full list of commands!
The list below only shows a subset of commands which I think need further explanation.
(Parameters in [square brackets]
are mandatory; Those in <angled brackets>
are optional)
-
Reload application commands (i.e. slash commands) and syncing database.
Only the owner of the bot may use this command.
Please run this command once after first install and after every update!
Note: Replace
>>
with thePREFIX
you set in.env
(orcompose.yaml
if you are using Docker)
- Display all available commands
<command_name>
: Display the information of the command
- Post the
<image_number>
th picture (or video) of[pixiv_link]
.-
[pixiv_link]
: Pixiv image link -
<image_number>
: Image number (for albums with multiple images); 1 by default -
<animation_format>
:webm
orgif
. GIF can loop, but might fail to deliver due to much larger size;webm
by defaultgif
will have bad quality if the bot is not run in Linux!
-
To set the OAuth token, run gallery-dl oauth:pixiv
, then follow the instructions given.
-
If you are using Docker,
ffmpeg
has already been installed for you.Start the discord bot container, then run in console:
docker exec -it <container-name-or-id> /bin/bash
gallery-dl oauth:pixiv
- Follow the instructions given
-
Establish a new connection to the Lavalink server.
Use this command if the music player is not working while the Lavalink server is up.
Do NOT use this command while the bot is playing music!
-
Lavalink can be unstable (probably because YouTube changes their Innertube API often).
If the music player consistently produce errors, go to the Lavalink discord to check if there is a hotfix version of Lavalink.
-
Print the model name used by the
/chat
command.If
model_name
is set, change the model used by the/chat
command. (only the bot owner can do this!)