From 72d6be9c51161d233343a4a529b0578760c6cfd3 Mon Sep 17 00:00:00 2001 From: AEnterprise Date: Fri, 8 May 2020 20:57:38 +0200 Subject: [PATCH] more cleanup --- src/core/context/cache.rs | 11 +---------- src/core/context/database.rs | 2 -- src/core/context/mod.rs | 3 +-- src/core/context/permissions.rs | 2 -- src/core/handlers/commands.rs | 2 +- src/core/handlers/modlog.rs | 1 - src/database/guild.rs | 2 -- src/parser/mod.rs | 4 +--- src/utils/errors.rs | 2 -- src/utils/matchers.rs | 14 +++++++------- 10 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/core/context/cache.rs b/src/core/context/cache.rs index b1cc70b4..845400dc 100644 --- a/src/core/context/cache.rs +++ b/src/core/context/cache.rs @@ -1,5 +1,4 @@ use crate::core::Context; -use crate::utils::ParseError::MemberNotFoundById; use crate::utils::{Error, FetchError, ParseError}; use crate::{database, EncryptionKey}; use aes_gcm::aead::generic_array::GenericArray; @@ -7,22 +6,14 @@ use aes_gcm::{ aead::{Aead, NewAead}, Aes256Gcm, }; -use log::{debug, info, trace}; +use log::{debug, trace}; use postgres_types::Type; use rand::{thread_rng, RngCore}; use std::sync::Arc; -use tokio::sync::oneshot; -use twilight::http::error::Error::Response; -use twilight::http::error::ResponseError::{Client, Server}; -use twilight::http::error::{Error as HttpError, ResponseError}; use twilight::model::channel::message::MessageType; use twilight::model::channel::Message; -use twilight::model::gateway::payload::{MemberChunk, RequestGuildMembers}; -use twilight::model::gateway::presence::Presence; -use twilight::model::guild::Member; use twilight::model::id::{ChannelId, GuildId, MessageId, UserId}; use twilight::model::user::User; -use uuid::Uuid; #[derive(Debug)] pub struct UserMessage { diff --git a/src/core/context/database.rs b/src/core/context/database.rs index 95a74bd7..9cbdca2b 100644 --- a/src/core/context/database.rs +++ b/src/core/context/database.rs @@ -2,8 +2,6 @@ use crate::core::{Context, GuildConfig}; use crate::database::guild::{get_guild_config, set_guild_config}; use crate::utils::Error; use dashmap::mapref::one::Ref; -use log::{debug, info}; -use postgres_types::Type; use serde_json::to_value; use twilight::model::id::GuildId; diff --git a/src/core/context/mod.rs b/src/core/context/mod.rs index ac671da4..5e2e2bd1 100644 --- a/src/core/context/mod.rs +++ b/src/core/context/mod.rs @@ -6,9 +6,8 @@ use aes_gcm::aead::generic_array::GenericArray; use chrono::{DateTime, Utc}; use dashmap::DashMap; use deadpool_postgres::Pool; -use git_version::git_version; use std::sync::RwLock; -use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use tokio::sync::mpsc::UnboundedSender; use tokio::sync::oneshot::Sender; use twilight::cache::InMemoryCache; use twilight::gateway::Cluster; diff --git a/src/core/context/permissions.rs b/src/core/context/permissions.rs index 3d44fe7d..494de8a2 100644 --- a/src/core/context/permissions.rs +++ b/src/core/context/permissions.rs @@ -1,6 +1,4 @@ use crate::core::Context; -use log::debug; -use std::sync::Arc; use twilight::model::channel::permission_overwrite::PermissionOverwriteType; use twilight::model::channel::GuildChannel; use twilight::model::guild::Permissions; diff --git a/src/core/handlers/commands.rs b/src/core/handlers/commands.rs index 2ee8c361..4a059c8b 100644 --- a/src/core/handlers/commands.rs +++ b/src/core/handlers/commands.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use log::{debug, info}; +use log::debug; use twilight::gateway::cluster::Event; use crate::core::Context; diff --git a/src/core/handlers/modlog.rs b/src/core/handlers/modlog.rs index 24194397..65fe6c8c 100644 --- a/src/core/handlers/modlog.rs +++ b/src/core/handlers/modlog.rs @@ -6,7 +6,6 @@ use twilight::model::{gateway::payload::RequestGuildMembers, id::RoleId}; use crate::core::Context; use crate::utils::Error; -use log::debug; pub async fn handle_event(shard_id: u64, event: &Event, ctx: Arc) -> Result<(), Error> { match &event { diff --git a/src/database/guild.rs b/src/database/guild.rs index 30a348f5..5cd47683 100644 --- a/src/database/guild.rs +++ b/src/database/guild.rs @@ -1,9 +1,7 @@ use crate::core::{Context, GuildConfig}; use crate::utils::Error; -use deadpool_postgres::Pool; use log::info; use postgres_types::Type; -use rand::{thread_rng, RngCore}; use serde_json::Value; pub async fn get_guild_config(ctx: &Context, guild_id: u64) -> Result { diff --git a/src/parser/mod.rs b/src/parser/mod.rs index a297eb8c..85d515f1 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -7,10 +7,8 @@ use crate::commands; use crate::commands::meta::nodes::CommandNode; use crate::core::Context; use crate::utils::Emoji; -use crate::utils::{matchers, CommandError, Error, ParseError}; +use crate::utils::{matchers, Error, ParseError}; use twilight::cache::twilight_cache_inmemory::model::CachedMember; -use twilight::model::gateway::presence::Presence; -use twilight::model::guild::Member; use twilight::model::id::{GuildId, UserId}; use twilight::model::user::User; diff --git a/src/utils/errors.rs b/src/utils/errors.rs index fa121209..88b26bd7 100644 --- a/src/utils/errors.rs +++ b/src/utils/errors.rs @@ -1,7 +1,5 @@ use std::{error, fmt, io}; -use crate::parser::Parser; -use crate::utils::Emoji; use deadpool_postgres::PoolError; use serde::export::Formatter; use twilight::cache::twilight_cache_inmemory; diff --git a/src/utils/matchers.rs b/src/utils/matchers.rs index 7db540ad..97558e3c 100644 --- a/src/utils/matchers.rs +++ b/src/utils/matchers.rs @@ -132,23 +132,23 @@ pub fn get_emoji_parts(msg: &str) -> Vec { } lazy_static! { - static ref ID_MATCHER: Regex = { Regex::new(r"<@!?([0-9]+)>").unwrap() }; + static ref ID_MATCHER: Regex = Regex::new(r"<@!?([0-9]+)>").unwrap(); } lazy_static! { - static ref ROLE_ID_MATCHER: Regex = { Regex::new(r"<@&([0-9]+)>").unwrap() }; + static ref ROLE_ID_MATCHER: Regex = Regex::new(r"<@&([0-9]+)>").unwrap(); } lazy_static! { - static ref CHANNEL_ID_MATCHER: Regex = { Regex::new(r"<#([0-9]+)>").unwrap() }; + static ref CHANNEL_ID_MATCHER: Regex = Regex::new(r"<#([0-9]+)>").unwrap(); } lazy_static! { - static ref MENTION_MATCHER: Regex = { Regex::new(r"<@!?\d+>").unwrap() }; + static ref MENTION_MATCHER: Regex = Regex::new(r"<@!?\d+>").unwrap(); } lazy_static! { - static ref MENTION_MATCHER_SOLO: Regex = { Regex::new(r"^<@!?(\d+)>$").unwrap() }; + static ref MENTION_MATCHER_SOLO: Regex = Regex::new(r"^<@!?(\d+)>$").unwrap(); } lazy_static! { @@ -161,7 +161,7 @@ lazy_static! { } lazy_static! { - static ref EMOJI_MATCHER: Regex = { Regex::new(r"<(a?):([^:\n]+):([0-9]+)>").unwrap() }; + static ref EMOJI_MATCHER: Regex = Regex::new(r"<(a?):([^:\n]+):([0-9]+)>").unwrap(); } lazy_static! { @@ -171,7 +171,7 @@ lazy_static! { } lazy_static! { - static ref START_WITH_NUMBER_MATCHER: Regex = { Regex::new(r"^(\d+)").unwrap() }; + static ref START_WITH_NUMBER_MATCHER: Regex = Regex::new(r"^(\d+)").unwrap(); } #[cfg(test)]