Update: As the Unoffical Poe API had been archived and is not working, the Poe bot will not work now.
The Discord ChatBot is a Python-based chatbot that supports following:
-
Poe bots (via Unoffical API), including
Sage
,GPT-4
,Claude+
,Claude-instant
,ChatGPT
, etc, as well as custom bots
To run the Discord ChatBot, follow these steps:
- Clone this repository using Git.
- Duplicate the
.env.example
file and rename it to.env
. Replace each key with the corresponding values. - Go to Discord Developer Portal and create a new application.
- Create a bot and copy its token.
- Paste the token into the
DISCORD_TOKEN
field in the.env
file.
Env variables | Description |
---|---|
DISCORD_TOKEN | Discord token, obtained from https://discord.com/developers/applications. |
POE_TOKEN | Poe token, should be the browser cookie for https://poe.com, refer to poe-api repository for more details. Leave empty if you don't intend to use the Poe bot. |
POE_MODEL | Default Poe bot (name), e.g., Sage , GPT-4 , Claude+ , Claude-instant , ChatGPT , etc. Leave empty if you don't intend to use the Poe bot. |
POE_PROXY | The default proxy. Leave empty if you don't intend to use the Poe bot or want to skip using a proxy. |
HUGGING_FACE_TOKEN | Hugging Face token, obtained from https://huggingface.co/settings/tokens. Leave empty if you don't intend to use the Hugging Face bot. |
HUGGING_FACE_MODEL | Default Hugging Face model, refer to Hugging Face conversational models. Leave empty if you don't intend to use the Hugging Face bot. |
DEBUG | Whether to use debug view. (Only used for Hugging Face chatbot) |
LOGGING_LEVEL | Console logging level, default to INFO (20) if not provided |
To use the Poe bot, follow the steps below:
- Refer to poe-api guide to obtain your token.
- Update the
POE_TOKEN
field in the.env
file. - Set the
POE_MODEL
field to the desired model (e.g.,ChatGPT
). - Optionally, set the
POE_PROXY
field for proxy settings.
To use the Hugging Face bot, follow the steps below:
- Obtain your Hugging Face API token from https://huggingface.co/settings/tokens.
- Set the
HUGGING_FACE_MODEL
field to the desired model. (Find the model from https://huggingface.co/models?pipeline_tag=conversational, then copy the model name, e.g.,facebook/blenderbot-3B
).
- Make sure you have Python 3.10 installed.
- Run
pip install -r requirements.txt
to install the required dependencies, using python virtual environment is recommended. - Run
python main.py
to start the bot.
You can also use the following command arguments:
Arugments | Description | Options |
---|---|---|
--bot [str] |
Select the chatbot to use. | poe , hugging-face |
--model [str] |
Select the chatbot model to use. | Depends on bot |
--channel-monitor-mode [str] |
Select the channel monitor mode. | all , none |
--enable-name-prefix [bool] |
Enable or disable prefixing user names to chat messages. | True , False |
Make sure you have python and docker installed
- Make sure you have Docker installed.
- run
docker-compose build
to build the docker image. - run
docker-compose up -d
to start the container.
Command | Description | Options |
---|---|---|
/send [str] |
Send a message to the chatbot. This command can bypass Discord's message limit for non-nitro users and allows messages up to 6000 characters in length. | |
/send_to_channel [str] |
Send a message to the chatbot on another channel, useful when multiple chatbots are monitoring the same channel. This command can bypass Discord's message limit for non-nitro users and allows messages up to 6000 characters in length. | |
/clear-context |
Clear the current context of the chatbot. | |
/get-bot |
Returns the current bot being used. | |
/get-available-bot |
Returns the available bots. | |
/change-bot [str] |
Changes the current bot being used. If an invalid bot is specified, the available bot names will be shown. | poe , hugging-face |
/reset-bot |
Resets the current bot to the default bot specified in .env. | |
/get-model |
Returns the current chatbot model being used. | |
/get-available-model |
Returns the current chatbot's available models. | |
/change-model [str] |
Changes the current chatbot model being used. If an invalid model is specified, the available model names will be shown. | Depends on the bot |
/reset-model |
Resets the current chatbot model to the default model specified in .env. | |
/change-token [str] |
Changes the API token for the chatbot. | |
/reset-token |
Resets the API token for the chatbot to the default token specified in .env. | |
/enable-channel-monitoring |
Enables monitoring of the current channel, will add the current channel to whitelist if channel-monitor-mode is set to none . |
|
/disable-channel-monitoring |
Disable monitoring of the current channel. | |
/get-channel-whitelist |
Returns the channel whitelist. | |
/get-channel-blacklist |
Returns the channel blacklist. | |
/get-channel-monitor-mode |
Returns the current monitoring mode. | |
/change-channel-monitor-mode [str] |
Changes the current monitoring mode. If an invalid mode is specified, the available modes will be shown. | all , none |
/enable-name-prefix |
Enables prefixing the chat messages with the username or nickname. | |
/disable-name-prefix |
Disables prefixing the chat messages with the username or nickname. | |
/register-nickname [str] |
Registers or updates a nickname. | |
/unregister-nickname |
Unregisters a nickname if it is registered. | |
/get-nickname |
Returns the registered nickname if there is one. |
- You can also use
$ignore
at the beginning of a message to instruct the bot to ignore that message. - In channel monitor mode, setting it to
all
will cause the bot to reply to messages in all channels, except for those in the blacklist. Setting it tonone
will prevent the bot from replying to messages in any channel, except for those in the whitelist. - When name prefix is enabled, the bot will automatically add the Discord username or nickname (if registered via the
/register-nickname
command) of the message author to the front of the message. For example, the messagehello
will becomeJoe: hello
when sent to the bot. This feature is useful for multi-person conversations, especially when giving the bot a prompt. - Nicknames, channel whitelist and blacklists are stored inside
config.json
file.
- Currently, the bot has only been tested on a single server and in direct messages.
- The bot is a single instance only, which means that any messages or commands sent in direct messages or different channels will be treated as if they came from the same source.
- This is just a simple holiday project, might not update in the future. 🙃