From 9b6686074f37834747aac47a1966add0afe09c3b Mon Sep 17 00:00:00 2001 From: Alessandro Suha Date: Sat, 20 Apr 2024 16:47:22 +0200 Subject: [PATCH] style: prepare for adding ytplay command --- Cargo.toml | 3 ++- src/commands.rs | 5 ++++- src/commands/youtube/mod.rs | 4 ++++ src/commands/youtube/ytplay.rs | 16 ++++++++++++++++ src/main.rs | 11 ++++------- 5 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 src/commands/youtube/mod.rs create mode 100644 src/commands/youtube/ytplay.rs diff --git a/Cargo.toml b/Cargo.toml index 17cc786..62e16c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ poise = "0.6.1" tokio = { version = "1.37.0", features = ["full", "rt-multi-thread"] } env_logger = "0.11.3" anyhow = "1.0.82" -regex = "1.10.4" \ No newline at end of file +regex = "1.10.4" +lavalink-rs = "0.11.0" \ No newline at end of file diff --git a/src/commands.rs b/src/commands.rs index 8feccc6..17bb543 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,5 +1,8 @@ +// src/commands/mod.rs mod help; mod ping; +mod youtube; pub use help::help; -pub use ping::ping; \ No newline at end of file +pub use ping::ping; +pub use youtube::ytplay; \ No newline at end of file diff --git a/src/commands/youtube/mod.rs b/src/commands/youtube/mod.rs new file mode 100644 index 0000000..6a8b974 --- /dev/null +++ b/src/commands/youtube/mod.rs @@ -0,0 +1,4 @@ +// src/commands/youtube/mod.rs +pub mod ytplay; + +pub use ytplay::ytplay; \ No newline at end of file diff --git a/src/commands/youtube/ytplay.rs b/src/commands/youtube/ytplay.rs new file mode 100644 index 0000000..32a0473 --- /dev/null +++ b/src/commands/youtube/ytplay.rs @@ -0,0 +1,16 @@ +use crate::Context; + +/// Description of the new function +/// +/// This command allows you to play a YouTube video in VC. +/// ``` +/// ~ytplay +/// ``` +#[poise::command(prefix_command, slash_command)] +pub async fn ytplay(ctx: Context<'_>) -> Result<(), Box> { + ctx.defer().await?; + + // ... + + Ok(()) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 27cf6bd..01dc65a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,7 @@ mod commands; use poise::serenity_prelude as serenity; -use std::{ - sync::Arc, - time::Duration, -}; +use std::{sync::Arc, time::Duration}; // Types used by all command functions type Error = Box; @@ -40,15 +37,15 @@ async fn main() { // FrameworkOptions contains all of poise's configuration option in one struct // Every option can be omitted to use its default value let options = poise::FrameworkOptions { - commands: vec![commands::help(), commands::ping()], + commands: vec![commands::help(), commands::ping(), commands::ytplay()], prefix_options: poise::PrefixFrameworkOptions { prefix: Some("~".into()), edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan( Duration::from_secs(3600), ))), additional_prefixes: vec![ - poise::Prefix::Literal("hey bot"), - poise::Prefix::Literal("hey bot,"), + poise::Prefix::Literal("hey EvilBunny"), + poise::Prefix::Literal("hey Red,"), ], ..Default::default() },