feat: started with basic commands, added dependencies, started working on lavalink impl

This commit is contained in:
moonleay 2024-02-21 09:58:26 +01:00
parent 9dad9bbda3
commit d6a2cb5c8b
Signed by: moonleay
GPG key ID: 82667543CCD715FB
13 changed files with 532 additions and 46 deletions

21
src/commands/info.rs Normal file
View file

@ -0,0 +1,21 @@
use chrono::Local;
use serenity::all::{CommandInteraction, Context};
use serenity::builder::{CreateCommand, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter};
use serenity::model::application::ResolvedOption;
pub fn run(ctx: &Context, command: &CommandInteraction, _options: &[ResolvedOption]) -> CreateEmbed {
let username = command.user.name.as_str();
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
CreateEmbed::new()
.author(CreateEmbedAuthor::new("Rustendo"))
.description("Botendo v7\ndeveloped by [moonleay](https://moonleay.net)\n\nCheck out the repository: https://git.moonleay.net/DiscordBots/Rustendo")
.footer(CreateEmbedFooter::new(format!(">{} | {}", current_time, username)))
}
pub fn register() -> CreateCommand {
CreateCommand::new("info").description("Infos about the bot")
}
// >18/02/2024 @ 19:01:59 - bartlo
// >2024-02-19 17:58:39 | moonleay

View file

@ -1 +1,3 @@
pub mod ping;
pub mod info;
pub mod play;
pub mod stop;

View file

@ -1,10 +0,0 @@
use serenity::builder::CreateCommand;
use serenity::model::application::ResolvedOption;
pub fn run(_options: &[ResolvedOption]) -> String {
"Hey, I'm alive!".to_string()
}
pub fn register() -> CreateCommand {
CreateCommand::new("ping").description("A ping command")
}

38
src/commands/play.rs Normal file
View file

@ -0,0 +1,38 @@
use chrono::Local;
use serenity::all::{CommandInteraction, Context, ResolvedOption, ResolvedValue};
use serenity::builder::{CreateCommand, CreateCommandOption, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter};
use serenity::model::application::CommandOptionType;
pub fn run(ctx: &Context, command: &CommandInteraction, options: &[ResolvedOption]) -> CreateEmbed {
let username = command.user.name.as_str();
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
let query = if let Some(ResolvedOption {
value: ResolvedValue::String(query), ..
}) = options.first()
{
query
} else {
return CreateEmbed::new()
.author(CreateEmbedAuthor::new("Rustendo"))
.title("Error 400")
.description("There is no query provied.")
.footer(CreateEmbedFooter::new(format!(">{} | {}", current_time, username)))
};
CreateEmbed::new()
.author(CreateEmbedAuthor::new("Rustendo"))
.title(format!("Searching for {}", query))
.footer(CreateEmbedFooter::new(format!(">{} | {}", current_time, username)))
}
pub fn register() -> CreateCommand {
CreateCommand::new("play")
.description("Play music")
.add_option(
CreateCommandOption::new(CommandOptionType::String, "query", "Link or search term")
.required(true)
)
}

21
src/commands/stop.rs Normal file
View file

@ -0,0 +1,21 @@
use chrono::Local;
use serenity::all::{CommandInteraction, Context};
use serenity::builder::{CreateCommand, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter};
use serenity::model::application::ResolvedOption;
pub fn run(ctx: &Context, command: &CommandInteraction, _options: &[ResolvedOption]) -> CreateEmbed {
let username = command.user.name.as_str();
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
CreateEmbed::new()
.author(CreateEmbedAuthor::new("Rustendo"))
.title("I stopped and left\nJust like your girlfriend.")
.footer(CreateEmbedFooter::new(format!(">{} | {}", current_time, username)))
}
pub fn register() -> CreateCommand {
CreateCommand::new("stop").description("Stop playing and start leavin'")
}
// >18/02/2024 @ 19:01:59 - bartlo
// >2024-02-19 17:58:39 | moonleay