From 1a8a6eca29afe2178c6cf17abce9ab7e229ca26c Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Thu, 24 Jan 2019 20:03:25 -0500 Subject: improve imports further and fix compile warnings --- src/commands/meme.rs | 32 ++++++++++++++++++++------------ src/commands/mod.rs | 15 +++++++-------- src/commands/playback/mod.rs | 7 ++++--- src/commands/roll.rs | 13 +++++++------ src/commands/sound.rs | 17 +++++++++++++++-- 5 files changed, 53 insertions(+), 31 deletions(-) (limited to 'src/commands') 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> = 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 @@ -83,9 +85,6 @@ pub fn register_commands(f: StandardFramework) -> StandardFramework { #[cfg(feature = "diesel")] mod meme; -#[cfg(feature = "diesel")] -pub use self::meme::*; - #[cfg(feature = "diesel")] fn register_db(f: StandardFramework) -> StandardFramework { f 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 { let channel_id = ChannelId(must_env_lookup::("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; -- cgit v1.3.1