"A mystical mermaid, emerging from the depths of the ocean, ready to guide and enchant your server..."
Ningyo(u) (ไบบ้ญ) is a mystical mermaid-themed Discord bot, built with Rust and powered by the Serenity library. Designed to bring an oceanic and fantasy-inspired experience to your Discord server!
- ๐ฟ Graceful & lightweight like the waves
- ๐ Oceanic and mermaid-themed responses
- ๐ Powered by Rust & Tokio async runtime
- ๐ Modern Slash Commands for intuitive interaction
- Install Rust
- Set up a Discord Bot Token
- Create
.envfile with your bot token and application ID:DISCORD_TOKEN=your_bot_token_here APPLICATION_ID=your_application_id_here
git clone https://github.com/YourUsername/Ningyo-Discord-Bot.git
cd Ningyo-Discord-Bot
cargo runCreate a new file src/commands/wave.rs:
use async_trait::async_trait;
use serenity::model::application::interaction::application_command::ApplicationCommandInteraction;
use serenity::prelude::*;
use super::command_handler::SlashCommand;
pub struct WaveCommand;
#[async_trait]
impl SlashCommand for WaveCommand {
fn name(&self) -> &'static str {
"wave"
}
fn description(&self) -> &'static str {
"Wave at the mermaid!"
}
async fn run(&self, ctx: Context, command: ApplicationCommandInteraction) -> Result<(), String> {
command
.create_interaction_response(&ctx.http, |response| {
response.interaction_response_data(|message|
message.content("๐ *waves back with her magical tail* โจ")
)
})
.await
.map_err(|e| format!("Error sending response: {e:?}"))
}
}Create a new file src/commands/fortune.rs:
use async_trait::async_trait;
use serenity::model::application::interaction::application_command::ApplicationCommandInteraction;
use serenity::model::application::command::CommandOptionType;
use serenity::builder::CreateApplicationCommand;
use serenity::prelude::*;
use super::command_handler::SlashCommand;
pub struct FortuneCommand;
#[async_trait]
impl SlashCommand for FortuneCommand {
fn name(&self) -> &'static str {
"fortune"
}
fn description(&self) -> &'static str {
"Get your ocean fortune!"
}
async fn run(&self, ctx: Context, command: ApplicationCommandInteraction) -> Result<(), String> {
let options = &command.data.options;
// Get name parameter
let name = match options.first() {
Some(opt) => match opt.value.as_ref() {
Some(val) => val.as_str().unwrap_or("stranger"),
None => "stranger",
},
None => "stranger",
};
let fortune = format!("๐ฎ Dearest {}, the ocean whispers that great fortune awaits you! โจ", name);
command
.create_interaction_response(&ctx.http, |response| {
response.interaction_response_data(|message|
message.content(fortune)
)
})
.await
.map_err(|e| format!("Error sending response: {e:?}"))
}
fn register<'a>(&self, command: &'a mut CreateApplicationCommand) -> &'a mut CreateApplicationCommand {
command
.name(self.name())
.description(self.description())
.create_option(|option| {
option
.name("name")
.description("Your name")
.kind(CommandOptionType::String)
.required(true)
})
}
}Add to src/commands/mod.rs:
pub mod command_handler;
pub mod command_registry;
pub mod ping;
pub mod hello;
pub mod tax;
pub mod wave; // Add new commands
pub mod fortune;Update src/commands/command_registry.rs:
fn register_default_commands(commands: &mut HashMap<String, Box<dyn SlashCommand + Send + Sync>>) {
commands.insert("ping".to_string(), Box::new(PingCommand));
commands.insert("hello".to_string(), Box::new(HelloCommand));
commands.insert("tax".to_string(), Box::new(TaxCommand));
commands.insert("wave".to_string(), Box::new(WaveCommand)); // Add new commands
commands.insert("fortune".to_string(), Box::new(FortuneCommand));
}| Command | Description | Parameters |
|---|---|---|
/ping |
Echo from the deep! | None |
/hello |
Get a mystical greeting | None |
/tax |
Calculate income tax | income: number |
Ningyo-Discord-Bot/
โโโ Cargo.toml
โโโ .env
โโโ src/
โโโ main.rs
โโโ commands/
โ โโโ command_handler.rs
โ โโโ command_registry.rs
โ โโโ mod.rs
โ โโโ ping.rs
โ โโโ hello.rs
โ โโโ tax.rs
โโโ handlers/
โโโ mod.rs
โโโ interaction_handler.rs
- Fork the repository
- Create your feature branch (
git checkout -b feature/NewFeature) - Commit your changes (
git commit -m 'Add NewFeature') - Push to the branch (
git push origin feature/NewFeature) - Open a Pull Request
MIT License โ Free to use & modify!
