Store guild when creating reminders
This commit is contained in:
@ -10,6 +10,7 @@ pub struct ChannelData {
|
||||
pub webhook_id: Option<u64>,
|
||||
pub webhook_token: Option<String>,
|
||||
pub paused: bool,
|
||||
pub db_guild_id: Option<u32>,
|
||||
pub paused_until: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
@ -22,7 +23,7 @@ impl ChannelData {
|
||||
|
||||
if let Ok(c) = sqlx::query_as_unchecked!(
|
||||
Self,
|
||||
"SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until FROM channels WHERE channel = ?",
|
||||
"SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until, guild_id AS db_guild_id FROM channels WHERE channel = ?",
|
||||
channel_id
|
||||
)
|
||||
.fetch_one(pool)
|
||||
@ -46,7 +47,7 @@ impl ChannelData {
|
||||
Ok(sqlx::query_as_unchecked!(
|
||||
Self,
|
||||
"
|
||||
SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until FROM channels WHERE channel = ?
|
||||
SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until, guild_id AS db_guild_id FROM channels WHERE channel = ?
|
||||
",
|
||||
channel_id
|
||||
)
|
||||
|
@ -51,6 +51,7 @@ pub struct ReminderBuilder {
|
||||
pool: MySqlPool,
|
||||
uid: String,
|
||||
channel: u32,
|
||||
guild: Option<u32>,
|
||||
thread_id: Option<u64>,
|
||||
utc_time: NaiveDateTime,
|
||||
timezone: String,
|
||||
@ -86,6 +87,7 @@ impl ReminderBuilder {
|
||||
INSERT INTO reminders (
|
||||
`uid`,
|
||||
`channel_id`,
|
||||
`guild_id`,
|
||||
`utc_time`,
|
||||
`timezone`,
|
||||
`interval_seconds`,
|
||||
@ -110,11 +112,13 @@ INSERT INTO reminders (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?
|
||||
)
|
||||
",
|
||||
self.uid,
|
||||
self.channel,
|
||||
self.guild,
|
||||
utc_time,
|
||||
self.timezone,
|
||||
self.interval_seconds,
|
||||
@ -247,10 +251,10 @@ impl<'a> MultiReminderBuilder<'a> {
|
||||
{
|
||||
Err(ReminderError::UserBlockedDm)
|
||||
} else {
|
||||
Ok(user_data.dm_channel)
|
||||
Ok((user_data.dm_channel, None))
|
||||
}
|
||||
} else {
|
||||
Ok(user_data.dm_channel)
|
||||
Ok((user_data.dm_channel, None))
|
||||
}
|
||||
} else {
|
||||
Err(ReminderError::InvalidTag)
|
||||
@ -297,13 +301,13 @@ impl<'a> MultiReminderBuilder<'a> {
|
||||
.commit_changes(&self.ctx.data().database)
|
||||
.await;
|
||||
|
||||
Ok(channel_data.id)
|
||||
Ok((channel_data.id, channel_data.db_guild_id))
|
||||
}
|
||||
|
||||
Err(e) => Err(ReminderError::DiscordError(e.to_string())),
|
||||
}
|
||||
} else {
|
||||
Ok(channel_data.id)
|
||||
Ok((channel_data.id, channel_data.db_guild_id))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -317,7 +321,8 @@ impl<'a> MultiReminderBuilder<'a> {
|
||||
let builder = ReminderBuilder {
|
||||
pool: self.ctx.data().database.clone(),
|
||||
uid: generate_uid(),
|
||||
channel: c,
|
||||
channel: c.0,
|
||||
guild: c.1,
|
||||
thread_id,
|
||||
utc_time: self.utc_time,
|
||||
timezone: self.timezone.to_string(),
|
||||
|
Reference in New Issue
Block a user