Wip commit

This commit is contained in:
claude Bot committed 2024-01-07 17:10:22 +00:00
1 parent cce0de7c75
commit e4e9af2bb4
37 files changed
+1051 -1366

No files matched your search

+11 -8
View File
@@ -1,4 +1,4 @@
use std::{collections::HashSet, fmt::Display};
use std::collections::HashSet;
use chrono::{Duration, NaiveDateTime, Utc};
use chrono_tz::Tz;
@@ -9,8 +9,9 @@ use poise::serenity_prelude::{
id::{ChannelId, GuildId, UserId},
webhook::Webhook,
},
ChannelType, Result as SerenityResult,
ChannelType, CreateWebhook, Result as SerenityResult,
};
use secrecy::ExposeSecret;
use sqlx::MySqlPool;
use crate::{
@@ -27,9 +28,9 @@ use crate::{
async fn create_webhook(
ctx: impl CacheHttp,
channel: GuildChannel,
name: impl Display,
name: impl Into<String>,
) -> SerenityResult<Webhook> {
channel.create_webhook_with_avatar(ctx.http(), name, DEFAULT_AVATAR.clone()).await
channel.create_webhook(ctx.http(), CreateWebhook::new(name).avatar(&*DEFAULT_AVATAR)).await
}
#[derive(Hash, PartialEq, Eq)]
@@ -230,7 +231,7 @@ impl<'a> MultiReminderBuilder<'a> {
let thread_id = None;
let db_channel_id = match scope {
ReminderScope::User(user_id) => {
if let Ok(user) = UserId(user_id).to_user(&self.ctx).await {
if let Ok(user) = UserId::new(user_id).to_user(&self.ctx).await {
let user_data = UserData::from_user(
&user,
&self.ctx.serenity_context(),
@@ -257,7 +258,8 @@ impl<'a> MultiReminderBuilder<'a> {
}
}
ReminderScope::Channel(channel_id) => {
let channel = ChannelId(channel_id).to_channel(&self.ctx).await.unwrap();
let channel =
ChannelId::new(channel_id).to_channel(&self.ctx).await.unwrap();
if let Some(mut guild_channel) = channel.clone().guild() {
if Some(guild_channel.guild_id) != self.guild_id {
@@ -290,8 +292,9 @@ impl<'a> MultiReminderBuilder<'a> {
{
Ok(webhook) => {
channel_data.webhook_id =
Some(webhook.id.as_u64().to_owned());
channel_data.webhook_token = webhook.token;
Some(webhook.id.get().to_owned());
channel_data.webhook_token =
webhook.token.map(|s| s.expose_secret().clone());
channel_data
.commit_changes(&self.ctx.data().database)