update for new database models

This commit is contained in:
jude 2022-05-13 10:03:45 +01:00
parent b88d046846
commit 88255032de
5 changed files with 627 additions and 456 deletions

1029
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ serde_json = "1.0"
rand = "0.7"
Inflector = "0.11"
levenshtein = "1.0"
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "next", features = ["collector", "unstable_discord_api"] }
serenity = { git = "https://github.com/serenity-rs/serenity", rev = "c83ba2a1d61bf8e29638da26bab9f94dd0d90c0f", features = ["collector", "unstable_discord_api"] }
sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono"]}
[dependencies.regex_command_attr]

View File

@ -8,9 +8,9 @@ use serenity::{
channel::{Channel, GuildChannel},
guild::Guild,
id::{ChannelId, GuildId, UserId},
misc::Mentionable,
webhook::Webhook,
},
prelude::Mentionable,
Result as SerenityResult,
};
@ -770,7 +770,7 @@ INSERT INTO reminders (
`embed_color`,
`channel_id`,
`utc_time`,
`interval`,
`interval_seconds`,
`set_by`,
`expires`
) VALUES (
@ -1393,7 +1393,7 @@ INSERT INTO reminders (
channel_id,
`utc_time`,
expires,
`interval`,
`interval_seconds`,
set_by
) VALUES (
?,

View File

@ -11,13 +11,13 @@ mod time_parser;
use serenity::{
async_trait,
cache::Cache,
client::{bridge::gateway::GatewayIntents, Client},
client::Client,
futures::TryFutureExt,
http::{client::Http, CacheHttp},
model::{
channel::GuildChannel,
channel::Message,
guild::{Guild, GuildUnavailable},
guild::Guild,
id::{GuildId, UserId},
interactions::Interaction,
},
@ -48,9 +48,11 @@ use tokio::sync::RwLock;
use chrono::Utc;
use chrono_tz::Tz;
use serenity::model::guild::UnavailableGuild;
use serenity::model::prelude::{
InteractionApplicationCommandCallbackDataFlags, InteractionResponseType,
};
use serenity::prelude::GatewayIntents;
struct GuildDataCache;
@ -232,7 +234,7 @@ DELETE FROM channels WHERE channel = ?
async fn guild_delete(
&self,
ctx: Context,
deleted_guild: GuildUnavailable,
deleted_guild: UnavailableGuild,
_guild: Option<Guild>,
) {
let pool = ctx
@ -301,7 +303,7 @@ DELETE FROM guilds WHERE guild = ?
1,
);
d.create_embed(|e| e.title(lm.get(&user_data.language, "timezone/set_p_title"))
d.embed(|e| e.title(lm.get(&user_data.language, "timezone/set_p_title"))
.color(*THEME_COLOR)
.description(content)
.footer(|f| f.text(footer_text)))
@ -325,7 +327,7 @@ DELETE FROM guilds WHERE guild = ?
.create_interaction_response(&ctx, |r| {
r.kind(InteractionResponseType::ChannelMessageWithSource)
.interaction_response_data(|d| {
d.create_embed(|e| {
d.embed(|e| {
e.title(
lm.get(&user_data.language, "lang/set_p_title"),
)
@ -355,7 +357,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment");
let http = Http::new_with_token(&token);
let http = Http::new(&token);
let logged_in_id = http
.get_current_user()
@ -414,8 +416,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let framework_arc = Arc::new(framework);
let mut client = Client::builder(&token)
.intents(if dm_enabled {
let mut client = Client::builder(
&token,
if dm_enabled {
GatewayIntents::GUILD_MESSAGES
| GatewayIntents::GUILDS
| GatewayIntents::GUILD_MESSAGE_REACTIONS
@ -425,12 +428,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
GatewayIntents::GUILD_MESSAGES
| GatewayIntents::GUILDS
| GatewayIntents::GUILD_MESSAGE_REACTIONS
})
.application_id(application_id.0)
.event_handler(Handler)
.framework_arc(framework_arc.clone())
.await
.expect("Error occurred creating client");
},
)
.application_id(application_id.0)
.event_handler(Handler)
.framework_arc(framework_arc.clone())
.await
.expect("Error occurred creating client");
{
let guild_data_cache = dashmap::DashMap::new();

View File

@ -37,7 +37,7 @@ pub struct Reminder {
pub uid: String,
pub channel: u64,
pub utc_time: NaiveDateTime,
pub interval: Option<u32>,
pub interval_seconds: Option<u32>,
pub expires: Option<NaiveDateTime>,
pub enabled: bool,
pub content: String,
@ -57,7 +57,7 @@ SELECT
reminders.uid,
channels.channel,
reminders.utc_time,
reminders.interval,
reminders.interval_seconds,
reminders.expires,
reminders.enabled,
reminders.content,
@ -101,7 +101,7 @@ SELECT
reminders.uid,
channels.channel,
reminders.utc_time,
reminders.interval,
reminders.interval_seconds,
reminders.expires,
reminders.enabled,
reminders.content,
@ -157,7 +157,7 @@ SELECT
reminders.uid,
channels.channel,
reminders.utc_time,
reminders.interval,
reminders.interval_seconds,
reminders.expires,
reminders.enabled,
reminders.content,
@ -189,7 +189,7 @@ SELECT
reminders.uid,
channels.channel,
reminders.utc_time,
reminders.interval,
reminders.interval_seconds,
reminders.expires,
reminders.enabled,
reminders.content,
@ -222,7 +222,7 @@ SELECT
reminders.uid,
channels.channel,
reminders.utc_time,
reminders.interval,
reminders.interval_seconds,
reminders.expires,
reminders.enabled,
reminders.content,
@ -264,7 +264,7 @@ WHERE
TimeDisplayType::Relative => format!("<t:{}:R>", self.utc_time.timestamp()),
};
if let Some(interval) = self.interval {
if let Some(interval) = self.interval_seconds {
format!(
"'{}' *{}* **{}**, repeating every **{}** (set by {})",
self.display_content(),