Skip to content

Commit

Permalink
style: prepare for adding ytplay command
Browse files Browse the repository at this point in the history
  • Loading branch information
Plarpoon committed Apr 20, 2024
1 parent 5dda4c6 commit 9b66860
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
regex = "1.10.4"
lavalink-rs = "0.11.0"
5 changes: 4 additions & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// src/commands/mod.rs
mod help;
mod ping;
mod youtube;

pub use help::help;
pub use ping::ping;
pub use ping::ping;
pub use youtube::ytplay;
4 changes: 4 additions & 0 deletions src/commands/youtube/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// src/commands/youtube/mod.rs
pub mod ytplay;

pub use ytplay::ytplay;
16 changes: 16 additions & 0 deletions src/commands/youtube/ytplay.rs
Original file line number Diff line number Diff line change
@@ -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<dyn std::error::Error + Send + Sync>> {
ctx.defer().await?;

// ...

Ok(())
}
11 changes: 4 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error + Send + Sync>;
Expand Down Expand Up @@ -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()
},
Expand Down

0 comments on commit 9b66860

Please sign in to comment.