This repository is a Discord bot built using Rust's Serenity. Hosting is provided by Shuttle.
Since it is still under development, it has quite a few features, but the following functions are available:
- When you make a mentions to the Bot, it gets the 5 latest messages and Claude 3.5 Sonnet will answer them.
- Messages longer than 2000 characters are automatically split into multiple messages to comply with Discord's message length limit.
- When a URL of x.com or twitter.com is pasted, it is converted to vxtwitter.com and posted
- Rust (stable channel)
- Cargo
- cargo-shuttle
Important
This project uses Rust edition 2021. The Cargo.toml file originally specified edition 2024, but this has been changed to 2021 for compatibility with the current stable version of Cargo.
Install various required packages using Cargo. Build is also performed at the same time.
cargo buildTo run this bot, you need a valid Discord token; login to the Discord Developer Portal.
The required authority is "MESSAGE CONTENT INTENT"
Note
The official Shuttle website describes how to install the Hello world bot, but it also describes the operation of the Discord Developers Portal, so please refer to that if you are not sure.
To run this bot, you need a valid Anthropic Claude API token; login to the Anthropic Console and create an API key.
Warning
You must have a valid Anthropic account to use Claude API.
Please install it beforehand, as it will be installed using cargo-binstall.
Install the cargo-shuttle binary.
cargo install cargo-shuttleLog in to Shuttle.
You will be asked to enter your API key, which can be obtained from the following location after logging into your browser dashboard: https://console.shuttle.rs/account/overview
cargo shuttle loginDISCORD_TOKEN="{{ token }}"
CLAUDE_TOKEN="{{ token }}"Tip
Shuttle refers to the value in Secrets.toml, not the env file.
Initial project setup for Shuttle. Here you can specify the project name, etc.
cargo shuttle initshuttle project new --idle-minutes 0Tip
Since the application sleeps after 30 minutes of inactivity, the --idle-minutes option can be used to set the application not to sleep when the project is created.
Use the --allow-dirty option to upload Secrets.toml to Shuttle, which will not be pushed to Git the first time.
https://docs.shuttle.rs/getting-started/shuttle-commands
cargo shuttle deploy --allow-dirtyNote
If you encounter an error related to Rust edition 2024, you may need to modify the Cargo.toml file to use edition 2021 instead:
[package]
name = "ideal-x"
version = "1.0.0"
edition = "2021" # Changed from 2024Check the online status of the bot you let join the Discord, and try mentions to see how it works!
The bot should be accessible at: https://[project-name].shuttle.app