rustchain-discord-bot is a Discord bot designed to interact with users in real-time chat within a Discord thread using the /chat command. By default, the bot integrates with OpenAI to leverage various GPT models for dynamic and rich conversations. The underlying code is based on the Rust crate llm-chain, which is inspired by LangChain.
- Real-time chat interaction using the
/chatcommand. - Integration with OpenAI for conversation abilities.
- Customizable bot name and OpenAI model configurations.
- Extensible to LLM chains via
llm-chain.
-
Step 1: Navigate to Discord Developer Portal.
-
Step 2: Click on the
New Applicationbutton to create a new application. -
Step 3: Click on the
Botsection on the left sidebar.. Under thePrivileged Gateway Intentssection, ensure theMessage Content Intentis enabled. Alternatively, you may use the Permissions intent with a value of326417590272. -
Step 4: Reset bot token.
- Still on the
Botsection - Reset the bot token.
- Create a copy of
example.envand rename it to.env. - Fill in the value of
DISCORD_TOKENwith your bot token. - Ensure your bot's name here matches the bot name specified in the
config.rsunder the variableBOT_NAME.
- Still on the
-
Step 5: Invite the bot to your server
- In the
OAuth2section, subsectionURL Generator, create an invite URL and save it.- For bot permissinos, replicate those from step 3 (or at minimum
Send Messages,Create Public Threads,Send Messages in Threads,Manage Messages,Read Message History,Use Slash Commands)
- For bot permissinos, replicate those from step 3 (or at minimum
- Open this URL in a browser to add the bot to your server.
- In the
- Navigate to the
config.rsfile to set your bot name and OpenAI model. - Additional LLM settings, such as temperature, can be added in
llm.rsunder theoptionsfunction.
- Build and run the bot using the command:
cargo run.