Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AEnterprise committed May 8, 2020
1 parent 0d81247 commit 72d6be9
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 32 deletions.
11 changes: 1 addition & 10 deletions src/core/context/cache.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
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;
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 {
Expand Down
2 changes: 0 additions & 2 deletions src/core/context/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/core/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/core/context/permissions.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/handlers/commands.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use log::{debug, info};
use log::debug;
use twilight::gateway::cluster::Event;

use crate::core::Context;
Expand Down
1 change: 0 additions & 1 deletion src/core/handlers/modlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Context>) -> Result<(), Error> {
match &event {
Expand Down
2 changes: 0 additions & 2 deletions src/database/guild.rs
Original file line number Diff line number Diff line change
@@ -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<GuildConfig, Error> {
Expand Down
4 changes: 1 addition & 3 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/utils/errors.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/utils/matchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,23 @@ pub fn get_emoji_parts(msg: &str) -> Vec<EmojiInfo> {
}

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! {
Expand All @@ -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! {
Expand All @@ -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)]
Expand Down

0 comments on commit 72d6be9

Please sign in to comment.