diff options
| author | Nathan Perry <avaglir@gmail.com> | 2019-01-24 20:03:25 -0500 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2019-01-24 20:03:25 -0500 |
| commit | 1a8a6eca29afe2178c6cf17abce9ab7e229ca26c (patch) | |
| tree | 15f15250ab2bc940dc5b64b26729183a7c4e39e0 /src/commands | |
| parent | 928fd4314db88c623ea991de4e6e669027f57848 (diff) | |
improve imports further and fix compile warnings
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/meme.rs | 32 | ||||
| -rw-r--r-- | src/commands/mod.rs | 15 | ||||
| -rw-r--r-- | src/commands/playback/mod.rs | 7 | ||||
| -rw-r--r-- | src/commands/roll.rs | 13 | ||||
| -rw-r--r-- | src/commands/sound.rs | 17 |
5 files changed, 53 insertions, 31 deletions
diff --git a/src/commands/meme.rs b/src/commands/meme.rs index de64ad5..6d50349 100644 --- a/src/commands/meme.rs +++ b/src/commands/meme.rs @@ -1,21 +1,29 @@ use std::sync::RwLock; +use diesel::PgConnection; +use failure::Error; +use lazy_static::lazy_static; +use rand::{Rng, thread_rng}; use serenity::{ - http::AttachmentType, builder::CreateMessage, framework::standard::Args, + http::AttachmentType, + model::channel::Message, + prelude::*, }; -use rand::{thread_rng, Rng}; -use diesel::PgConnection; -use failure::Error; -use lazy_static::lazy_static; - -use super::*; -use super::playback::CtxExt; - -use crate::db::*; -use crate::Result; +use crate::{ + commands::{ + playback::{ + CtxExt, + PlayArgs, + PlayQueue, + }, + send, + }, + db::*, + Result, +}; lazy_static! { static ref LAST_MEME: RwLock<Option<i32>> = RwLock::new(None); @@ -28,7 +36,7 @@ fn update_meme(meme: &Meme) -> Result<()> { Ok(()) } -pub fn meme(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> { +pub fn meme(ctx: &mut Context, msg: &Message, args: Args) -> Result<()> { if args.len() == 0 { return rand_meme(ctx, msg); } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index db304e3..f2e577b 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -4,23 +4,25 @@ use std::{ }; use serenity::{ - prelude::*, framework::StandardFramework, model::{ channel::Message, - id::MessageId, + id::ChannelId, }, + prelude::*, }; use crate::{must_env_lookup, Result, TARGET_GUILD_ID}; +#[cfg(feature = "diesel")] +pub use self::meme::*; +pub use self::playback::*; +pub use self::sound::*; + mod playback; mod sound; mod roll; -pub use self::sound::*; -pub use self::playback::*; - pub fn register_commands(f: StandardFramework) -> StandardFramework { let f: StandardFramework = register_db(f); f @@ -84,9 +86,6 @@ pub fn register_commands(f: StandardFramework) -> StandardFramework { mod meme; #[cfg(feature = "diesel")] -pub use self::meme::*; - -#[cfg(feature = "diesel")] fn register_db(f: StandardFramework) -> StandardFramework { f .command("meme", |c| c diff --git a/src/commands/playback/mod.rs b/src/commands/playback/mod.rs index efb2553..83732f2 100644 --- a/src/commands/playback/mod.rs +++ b/src/commands/playback/mod.rs @@ -1,11 +1,12 @@ use either::{Left, Right}; use serenity::{ - voice::{LockedAudio, ytdl}, - model::id::ChannelId, framework::standard::Args, + model::id::ChannelId, + voice::{LockedAudio, ytdl}, }; use super::*; + pub use self::types::*; mod types; @@ -24,7 +25,7 @@ impl CtxExt for Context { fn users_listening(&self) -> Result<bool> { let channel_id = ChannelId(must_env_lookup::<u64>("VOICE_CHANNEL")); - let channel = channel_id.get()?; + let channel = channel_id.to_channel()?; let res = channel.guild() .and_then(|ch| ch.read().guild()) .map(|g| (&g.read().voice_states) diff --git a/src/commands/roll.rs b/src/commands/roll.rs index 217b3a4..b3f7a38 100644 --- a/src/commands/roll.rs +++ b/src/commands/roll.rs @@ -1,14 +1,15 @@ +use rand::prelude::*; +use regex::Regex; use serenity::{ - prelude::*, framework::standard::Args, model::channel::Message, + prelude::*, }; -use regex::Regex; -use rand::prelude::*; -use crate::Result; - -use super::send; +use crate::{ + commands::send, + Result, +}; lazy_static! { static ref ROLL_REGEX: Regex = Regex::new(r"([0-9]+)?(?:d([0-9]+)(?:\s+\+\s+([0-9]+))?)") diff --git a/src/commands/sound.rs b/src/commands/sound.rs index 62db0e3..7465e2e 100644 --- a/src/commands/sound.rs +++ b/src/commands/sound.rs @@ -1,5 +1,18 @@ -use super::*; -use serenity::framework::standard::Args; +use serenity::{ + framework::standard::Args, + model::channel::Message, + prelude::*, + +}; + +use crate::{ + commands::{ + playback::{PlayQueue, VoiceManager}, + send, + }, + Result, + TARGET_GUILD_ID, +}; pub const DEFAULT_VOLUME: f32 = 0.10; |
