Skip to main content

Discord

How to Integrate Discord Bot with Jan​

Discord bot can enhances your discord server interactions. By integrating Jan with it, you can significantly boost responsiveness and user engaggement in your discord server.

To integrate Jan with a Discord bot, follow the steps below:

Step 1: Clone the repository​

To make this integration successful, it is necessary to clone the discord bot's repository.

Step 2: Install the Required Libraries​

After cloning the repository, run the following command:

pip install -r requirements.txt

Step 3: Set the Environment​

  1. Create a copy of .env.example.
  2. Change the name to .env.
  3. Set the environment with the following options:
SettingInstructions
DISCORD_BOT_TOKENGenerate a new Discord application at discord.com/developers/applications, obtain a token from the Bot tab, and enable MESSAGE CONTENT INTENT.
LLMFor Jan, set to local/openai/(MODEL_NAME), where (MODEL_NAME) is your loaded model's name.
CUSTOM_SYSTEM_PROMPTAdjust the bot's behavior as needed.
CUSTOM_DISCORD_STATUSSet a custom message for the bot's Discord profile. (Max 128 characters)
ALLOWED_CHANNEL_IDSEnter Discord channel IDs where the bot can send messages, separated by commas. Leave blank to allow all channels.
ALLOWED_ROLE_IDSEnter Discord role IDs allowed to use the bot, separated by commas. Leave blank to allow everyone. Including at least one role also disables DMs.
MAX_IMAGESMax number of image attachments allowed per message when using a vision model. (Default: 5)
MAX_MESSAGESMax messages allowed in a reply chain. (Default: 20)
LOCAL_SERVER_URLURL of your local API server for LLMs starting with local/. (Default: http://localhost:5000/v1)
LOCAL_API_KEYAPI key for your local API server with LLMs starting with local/. Usually safe to leave blank.

Step 4: Insert the Bot​

Invite the bot to your Discord server using the following URL:

https://discord.com/api/oauth2/authorize?client_id=(CLIENT_ID)&permissions=412317273088&scope=bot
note

Replace CLIENT_ID with your Discord application's client ID from the OAuth2 tab

Step 5: Run the bot​

Run the bot by using the following command in your command prompt:

python llmcord.py