update poise

This commit is contained in:
jude
2023-06-18 10:47:31 +01:00
parent c8c1a171d4
commit a66db37b33
9 changed files with 63 additions and 59 deletions

View File

@ -6,8 +6,8 @@ use crate::{models::CtxData, Context, Error, THEME_COLOR};
fn footer(
ctx: Context<'_>,
) -> impl FnOnce(&mut serenity::CreateEmbedFooter) -> &mut serenity::CreateEmbedFooter {
let shard_count = ctx.discord().cache.shard_count();
let shard = ctx.discord().shard_id;
let shard_count = ctx.serenity_context().cache.shard_count();
let shard = ctx.serenity_context().shard_id;
move |f| {
f.text(format!(

View File

@ -2,6 +2,7 @@ use std::{collections::HashSet, string::ToString};
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono_tz::Tz;
use log::warn;
use num_integer::Integer;
use poise::{
serenity_prelude::{
@ -215,7 +216,7 @@ pub async fn look(
}),
};
let channel_opt = ctx.channel_id().to_channel_cached(&ctx.discord());
let channel_opt = ctx.channel_id().to_channel_cached(&ctx);
let channel_id = if let Some(Channel::Guild(channel)) = channel_opt {
if Some(channel.guild_id) == ctx.guild_id() {
@ -227,12 +228,11 @@ pub async fn look(
ctx.channel_id()
};
let channel_name =
if let Some(Channel::Guild(channel)) = channel_id.to_channel_cached(&ctx.discord()) {
Some(channel.name)
} else {
None
};
let channel_name = if let Some(Channel::Guild(channel)) = channel_id.to_channel_cached(&ctx) {
Some(channel.name)
} else {
None
};
let reminders = Reminder::from_channel(&ctx.data().database, channel_id, &flags).await;
@ -294,8 +294,7 @@ pub async fn delete(ctx: Context<'_>) -> Result<(), Error> {
let timezone = ctx.timezone().await;
let reminders =
Reminder::from_guild(&ctx.discord(), &ctx.data().database, ctx.guild_id(), ctx.author().id)
.await;
Reminder::from_guild(&ctx, &ctx.data().database, ctx.guild_id(), ctx.author().id).await;
let resp = show_delete_page(&reminders, 0, timezone);
@ -585,19 +584,31 @@ pub async fn multiline(
timezone: Option<String>,
) -> Result<(), Error> {
let tz = timezone.map(|t| t.parse::<Tz>().ok()).flatten();
let data = ContentModal::execute(ctx).await?;
let data_opt = ContentModal::execute(ctx).await?;
create_reminder(
Context::Application(ctx),
time,
data.content,
channels,
interval,
expires,
tts,
tz,
)
.await
match data_opt {
Some(data) => {
create_reminder(
Context::Application(ctx),
time,
data.content,
channels,
interval,
expires,
tts,
tz,
)
.await
}
None => {
warn!("Unexpected None encountered in /multiline");
Ok(Context::Application(ctx)
.send(|m| m.content("Unexpected error.").ephemeral(true))
.await
.map(|_| ())?)
}
}
}
/// Create a reminder. Press "+4 more" for other options. Use "/multiline" for multiline content.
@ -681,9 +692,9 @@ async fn create_reminder(
};
let (processed_interval, processed_expires) = if let Some(repeat) = &interval {
if check_subscription(&ctx.discord(), ctx.author().id).await
if check_subscription(&ctx, ctx.author().id).await
|| (ctx.guild_id().is_some()
&& check_guild_subscription(&ctx.discord(), ctx.guild_id().unwrap()).await)
&& check_guild_subscription(&ctx, ctx.guild_id().unwrap()).await)
{
(
parse_duration(repeat)