Restrict reminder selection to one-per-guild during fetch loop
This commit is contained in:
parent
03f08f0a18
commit
2781f2923e
@ -38,7 +38,7 @@ async fn _initialize(ctx: Context, pool: impl Executor<'_, Database = Database>
|
||||
let reminders = sender::Reminder::fetch_reminders(pool).await;
|
||||
|
||||
if reminders.len() > 0 {
|
||||
info!("Preparing to send {} reminders.", reminders.len());
|
||||
println!("Preparing to send {} reminders.", reminders.len());
|
||||
|
||||
for reminder in reminders {
|
||||
reminder.send(pool, ctx.clone()).await;
|
||||
|
@ -292,6 +292,16 @@ INNER JOIN
|
||||
ON
|
||||
reminders.channel_id = channels.id
|
||||
WHERE
|
||||
reminders.id IN (
|
||||
SELECT
|
||||
MIN(reminders.id)
|
||||
FROM reminders
|
||||
INNER JOIN
|
||||
channels
|
||||
ON reminders.channel_id = channels.id
|
||||
WHERE reminders.`utc_time` < NOW()
|
||||
GROUP BY channels.guild_id
|
||||
) AND
|
||||
reminders.`utc_time` < NOW()"#,
|
||||
)
|
||||
.fetch_all(pool)
|
||||
|
@ -9,7 +9,7 @@ use chrono_tz::Tz;
|
||||
use num_integer::Integer;
|
||||
use poise::{
|
||||
serenity::{builder::CreateEmbed, model::channel::Channel},
|
||||
serenity_prelude::{ButtonStyle, ReactionType},
|
||||
serenity_prelude::{component::ButtonStyle, ReactionType},
|
||||
CreateReply,
|
||||
};
|
||||
|
||||
|
@ -9,11 +9,11 @@ use poise::{
|
||||
builder::CreateEmbed,
|
||||
client::Context,
|
||||
model::{
|
||||
channel::Channel,
|
||||
interactions::{
|
||||
application::interaction::{
|
||||
message_component::MessageComponentInteraction, InteractionResponseType,
|
||||
MessageFlags,
|
||||
},
|
||||
prelude::InteractionApplicationCommandCallbackDataFlags,
|
||||
channel::Channel,
|
||||
},
|
||||
},
|
||||
serenity_prelude as serenity,
|
||||
@ -260,7 +260,7 @@ WHERE guilds.guild = ?",
|
||||
r.kind(InteractionResponseType::ChannelMessageWithSource)
|
||||
.interaction_response_data(|d| {
|
||||
d.flags(
|
||||
InteractionApplicationCommandCallbackDataFlags::EPHEMERAL,
|
||||
MessageFlags::EPHEMERAL,
|
||||
)
|
||||
.content("Only the user who performed the command can use these components")
|
||||
})
|
||||
@ -314,7 +314,7 @@ WHERE guilds.guild = ?",
|
||||
r.kind(InteractionResponseType::ChannelMessageWithSource)
|
||||
.interaction_response_data(|d| {
|
||||
d.flags(
|
||||
InteractionApplicationCommandCallbackDataFlags::EPHEMERAL,
|
||||
MessageFlags::EPHEMERAL,
|
||||
)
|
||||
.content("Only the user who performed the command can use these components")
|
||||
})
|
||||
|
@ -1,8 +1,6 @@
|
||||
// todo split pager out into a single struct
|
||||
use chrono_tz::Tz;
|
||||
use poise::serenity::{
|
||||
builder::CreateComponents, model::interactions::message_component::ButtonStyle,
|
||||
};
|
||||
use poise::serenity::{builder::CreateComponents, model::application::component::ButtonStyle};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_repr::*;
|
||||
|
||||
|
@ -2,7 +2,7 @@ use std::{collections::HashMap, env, sync::atomic::Ordering};
|
||||
|
||||
use log::{error, info, warn};
|
||||
use poise::{
|
||||
serenity::{model::interactions::Interaction, utils::shard_id},
|
||||
serenity::{model::application::interaction::Interaction, utils::shard_id},
|
||||
serenity_prelude as serenity,
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use poise::serenity::model::{
|
||||
id::GuildId, interactions::application_command::ApplicationCommandInteractionDataOption,
|
||||
application::interaction::application_command::CommandDataOption, id::GuildId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -19,7 +19,7 @@ pub struct RecordedCommand<U, E> {
|
||||
#[serde(default = "default_none::<U, E>")]
|
||||
pub action: Option<Func<U, E>>,
|
||||
pub command_name: String,
|
||||
pub options: Vec<ApplicationCommandInteractionDataOption>,
|
||||
pub options: Vec<CommandDataOption>,
|
||||
}
|
||||
|
||||
pub struct CommandMacro<U, E> {
|
||||
|
@ -5,6 +5,7 @@ use poise::{
|
||||
model::id::{GuildId, UserId},
|
||||
},
|
||||
serenity_prelude as serenity,
|
||||
serenity_prelude::interaction::MessageFlags,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@ -102,6 +103,6 @@ pub fn send_as_initial_response(
|
||||
});
|
||||
}
|
||||
if ephemeral {
|
||||
f.flags(serenity::InteractionApplicationCommandCallbackDataFlags::EPHEMERAL);
|
||||
f.flags(MessageFlags::EPHEMERAL);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user