Documentation
Discord

Discord

Integrate Discord Bot with Jan

Discord bot can enhance your discord server interactions. Integrating Jan with it can significantly boost responsiveness and user engagement on your Discord server.

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

Step 1: Clone the Repository

Clone the discord bot's repository (opens in a new tab) by using the following command:


git clone https://github.com/jakobdylanc/discord-llm-chatbot.git

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 (opens in a new tab), obtain a token from the Bot tab, and enable MESSAGE CONTENT INTENT.
LLMFor Jan (opens in a new tab), 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 that are allowed to use the bot, separated by commas. Leave blank to allow everyone. This includes at least one role, which also turns off 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/. It is 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

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