removed language_manager.rs. framework reworked for slash commands. updated info commands for new framework
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
use serenity::model::channel::Channel;
|
||||
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use serenity::model::channel::Channel;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
pub struct ChannelData {
|
||||
pub id: u32,
|
||||
|
@ -1,8 +1,6 @@
|
||||
use serenity::model::guild::Guild;
|
||||
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use log::error;
|
||||
use serenity::model::guild::Guild;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use crate::consts::DEFAULT_PREFIX;
|
||||
|
||||
|
@ -4,22 +4,18 @@ pub mod reminder;
|
||||
pub mod timer;
|
||||
pub mod user_data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use guild_data::GuildData;
|
||||
use serenity::{
|
||||
async_trait,
|
||||
model::id::{GuildId, UserId},
|
||||
prelude::Context,
|
||||
};
|
||||
|
||||
use crate::{consts::DEFAULT_PREFIX, GuildDataCache, SQLPool};
|
||||
|
||||
use guild_data::GuildData;
|
||||
|
||||
use crate::models::user_data::UserData;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{consts::DEFAULT_PREFIX, models::user_data::UserData, GuildDataCache, SQLPool};
|
||||
|
||||
#[async_trait]
|
||||
pub trait CtxData {
|
||||
async fn guild_data<G: Into<GuildId> + Send + Sync>(
|
||||
|
@ -1,3 +1,7 @@
|
||||
use std::{collections::HashSet, fmt::Display};
|
||||
|
||||
use chrono::{Duration, NaiveDateTime, Utc};
|
||||
use chrono_tz::Tz;
|
||||
use serenity::{
|
||||
client::Context,
|
||||
http::CacheHttp,
|
||||
@ -8,9 +12,7 @@ use serenity::{
|
||||
},
|
||||
Result as SerenityResult,
|
||||
};
|
||||
|
||||
use chrono::{Duration, NaiveDateTime, Utc};
|
||||
use chrono_tz::Tz;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use crate::{
|
||||
consts::{MAX_TIME, MIN_INTERVAL},
|
||||
@ -23,10 +25,6 @@ use crate::{
|
||||
SQLPool,
|
||||
};
|
||||
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use std::{collections::HashSet, fmt::Display};
|
||||
|
||||
async fn create_webhook(
|
||||
ctx: impl CacheHttp,
|
||||
channel: GuildChannel,
|
||||
|
@ -1,6 +1,5 @@
|
||||
use serenity::model::{channel::Message, guild::Guild, misc::Mentionable};
|
||||
|
||||
use regex::Captures;
|
||||
use serenity::model::{channel::Message, guild::Guild, misc::Mentionable};
|
||||
|
||||
use crate::{consts::REGEX_CONTENT_SUBSTITUTION, models::reminder::errors::ContentError};
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
use crate::consts::{CHARACTERS, DAY, HOUR, MINUTE};
|
||||
|
||||
use num_integer::Integer;
|
||||
|
||||
use rand::{rngs::OsRng, seq::IteratorRandom};
|
||||
|
||||
use crate::consts::{CHARACTERS, DAY, HOUR, MINUTE};
|
||||
|
||||
pub fn longhand_displacement(seconds: u64) -> String {
|
||||
let (days, seconds) = seconds.div_rem(&DAY);
|
||||
let (hours, seconds) = seconds.div_rem(&HOUR);
|
||||
|
@ -4,13 +4,19 @@ pub mod errors;
|
||||
mod helper;
|
||||
pub mod look_flags;
|
||||
|
||||
use serenity::{
|
||||
client::Context,
|
||||
model::id::{ChannelId, GuildId, UserId},
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
env,
|
||||
};
|
||||
|
||||
use chrono::{NaiveDateTime, TimeZone};
|
||||
use chrono_tz::Tz;
|
||||
use ring::hmac;
|
||||
use serenity::{
|
||||
client::Context,
|
||||
model::id::{ChannelId, GuildId, UserId},
|
||||
};
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use crate::{
|
||||
models::reminder::{
|
||||
@ -21,14 +27,6 @@ use crate::{
|
||||
SQLPool,
|
||||
};
|
||||
|
||||
use ring::hmac;
|
||||
|
||||
use sqlx::MySqlPool;
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
env,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum ReminderAction {
|
||||
Delete,
|
||||
|
@ -1,6 +1,5 @@
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
pub struct Timer {
|
||||
pub name: String,
|
||||
|
@ -1,47 +1,22 @@
|
||||
use chrono_tz::Tz;
|
||||
use log::error;
|
||||
use serenity::{
|
||||
http::CacheHttp,
|
||||
model::{id::UserId, user::User},
|
||||
};
|
||||
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use chrono_tz::Tz;
|
||||
|
||||
use log::error;
|
||||
|
||||
use crate::consts::{LOCAL_LANGUAGE, LOCAL_TIMEZONE};
|
||||
use crate::consts::LOCAL_TIMEZONE;
|
||||
|
||||
pub struct UserData {
|
||||
pub id: u32,
|
||||
pub user: u64,
|
||||
pub name: String,
|
||||
pub dm_channel: u32,
|
||||
pub language: String,
|
||||
pub timezone: String,
|
||||
}
|
||||
|
||||
impl UserData {
|
||||
pub async fn language_of<U>(user: U, pool: &MySqlPool) -> String
|
||||
where
|
||||
U: Into<UserId>,
|
||||
{
|
||||
let user_id = user.into().as_u64().to_owned();
|
||||
|
||||
match sqlx::query!(
|
||||
"
|
||||
SELECT language FROM users WHERE user = ?
|
||||
",
|
||||
user_id
|
||||
)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
Ok(r) => r.language,
|
||||
|
||||
Err(_) => LOCAL_LANGUAGE.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn timezone_of<U>(user: U, pool: &MySqlPool) -> Tz
|
||||
where
|
||||
U: Into<UserId>,
|
||||
@ -75,9 +50,9 @@ SELECT timezone FROM users WHERE user = ?
|
||||
match sqlx::query_as_unchecked!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, user, name, dm_channel, IF(language IS NULL, ?, language) AS language, IF(timezone IS NULL, ?, timezone) AS timezone FROM users WHERE user = ?
|
||||
SELECT id, user, name, dm_channel, IF(timezone IS NULL, ?, timezone) AS timezone FROM users WHERE user = ?
|
||||
",
|
||||
*LOCAL_LANGUAGE, *LOCAL_TIMEZONE, user_id
|
||||
*LOCAL_TIMEZONE, user_id
|
||||
)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
@ -101,15 +76,15 @@ INSERT IGNORE INTO channels (channel) VALUES (?)
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO users (user, name, dm_channel, language, timezone) VALUES (?, ?, (SELECT id FROM channels WHERE channel = ?), ?, ?)
|
||||
", user_id, user.name, dm_id, *LOCAL_LANGUAGE, *LOCAL_TIMEZONE)
|
||||
INSERT INTO users (user, name, dm_channel, timezone) VALUES (?, ?, (SELECT id FROM channels WHERE channel = ?), ?)
|
||||
", user_id, user.name, dm_id, *LOCAL_TIMEZONE)
|
||||
.execute(&pool_c)
|
||||
.await?;
|
||||
|
||||
Ok(sqlx::query_as_unchecked!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, user, name, dm_channel, language, timezone FROM users WHERE user = ?
|
||||
SELECT id, user, name, dm_channel, timezone FROM users WHERE user = ?
|
||||
",
|
||||
user_id
|
||||
)
|
||||
@ -128,10 +103,9 @@ SELECT id, user, name, dm_channel, language, timezone FROM users WHERE user = ?
|
||||
pub async fn commit_changes(&self, pool: &MySqlPool) {
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE users SET name = ?, language = ?, timezone = ? WHERE id = ?
|
||||
UPDATE users SET name = ?, timezone = ? WHERE id = ?
|
||||
",
|
||||
self.name,
|
||||
self.language,
|
||||
self.timezone,
|
||||
self.id
|
||||
)
|
||||
|
Reference in New Issue
Block a user