delete reminders when the user cannot be direct messaged
This commit is contained in:
parent
c4087bf569
commit
8eb46f1f23
@ -7,7 +7,7 @@ use regex::{Captures, Regex};
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serenity::{
|
use serenity::{
|
||||||
builder::CreateEmbed,
|
builder::CreateEmbed,
|
||||||
http::{CacheHttp, Http, StatusCode},
|
http::{CacheHttp, Http, HttpError, StatusCode},
|
||||||
model::{
|
model::{
|
||||||
channel::{Channel, Embed as SerenityEmbed},
|
channel::{Channel, Embed as SerenityEmbed},
|
||||||
id::ChannelId,
|
id::ChannelId,
|
||||||
@ -569,10 +569,15 @@ UPDATE `channels` SET paused = 0, paused_until = NULL WHERE `channel` = ?
|
|||||||
|
|
||||||
if let Error::Http(error) = e {
|
if let Error::Http(error) = e {
|
||||||
if error.status_code() == Some(StatusCode::NOT_FOUND) {
|
if error.status_code() == Some(StatusCode::NOT_FOUND) {
|
||||||
error!("Seeing channel is deleted. Removing reminder");
|
warn!("Seeing channel is deleted. Removing reminder");
|
||||||
self.force_delete(pool).await;
|
self.force_delete(pool).await;
|
||||||
} else {
|
} else if let HttpError::UnsuccessfulRequest(error) = *error {
|
||||||
self.refresh(pool).await;
|
if error.error.code == 50007 {
|
||||||
|
warn!("User cannot receive DMs");
|
||||||
|
self.force_delete(pool).await;
|
||||||
|
} else {
|
||||||
|
self.refresh(pool).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.refresh(pool).await;
|
self.refresh(pool).await;
|
||||||
|
@ -71,7 +71,7 @@ INSERT IGNORE INTO channels (channel) VALUES (?)
|
|||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"
|
"
|
||||||
INSERT INTO users (user, dm_channel, timezone) VALUES (?, (SELECT id FROM channels WHERE channel = ?), ?)
|
INSERT INTO users (name, user, dm_channel, timezone) VALUES ('', ?, (SELECT id FROM channels WHERE channel = ?), ?)
|
||||||
",
|
",
|
||||||
user_id.0,
|
user_id.0,
|
||||||
dm_channel.id.0,
|
dm_channel.id.0,
|
||||||
|
Loading…
Reference in New Issue
Block a user