Bump ver. Use Discord's error codes where possible to improve logging

This commit is contained in:
jude 2023-07-30 12:44:01 +01:00
parent a58b9866ea
commit 8d2232f0da
3 changed files with 26 additions and 14 deletions

2
Cargo.lock generated
View File

@ -2217,7 +2217,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]]
name = "reminder-rs"
version = "1.6.24"
version = "1.6.25"
dependencies = [
"base64 0.21.2",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "reminder-rs"
version = "1.6.24"
version = "1.6.25"
authors = ["Jude Southworth <judesouthworth@pm.me>"]
edition = "2021"
license = "AGPL-3.0 only"

View File

@ -7,7 +7,7 @@ use regex::{Captures, Regex};
use serde::Deserialize;
use serenity::{
builder::CreateEmbed,
http::{CacheHttp, Http, HttpError, StatusCode},
http::{CacheHttp, Http, HttpError},
model::{
channel::{Channel, Embed as SerenityEmbed},
id::ChannelId,
@ -591,23 +591,35 @@ WHERE
if let Err(e) = result {
if let Error::Http(error) = e {
if error.status_code() == Some(StatusCode::NOT_FOUND) {
error!(
"Reminder {} could not be sent as channel doesn't exist: {:?}",
self.id, e
);
self.force_delete(pool).await;
} else if let HttpError::UnsuccessfulRequest(error) = *error {
if error.error.code == 50007 {
if let HttpError::UnsuccessfulRequest(http_error) = *error {
if http_error.error.code == 50007 {
error!(
"Reminder {} could not be sent as user has DMs disabled: {:?}",
self.id, e
"Reminder {} could not be sent as user has DMs disabled",
self.id
);
self.force_delete(pool).await;
} else if http_error.error.code == 10003 {
error!(
"Reminder {} could not be sent as channel does not exist",
self.id
);
self.force_delete(pool).await;
} else if http_error.error.code == 10004 {
error!(
"Reminder {} could not be sent as guild does not exist",
self.id
);
self.force_delete(pool).await;
} else {
error!("HTTP Error sending reminder {}: {:?}", self.id, e);
error!("HTTP Error sending reminder {}: {:?}", self.id, http_error);
self.refresh(pool).await;
}
} else {
error!(
"(Likely) a parsing error when sending reminder {}: {:?}",
self.id, error
);
self.refresh(pool).await;
}
} else {
error!("Non-HTTP Error sending reminder {}: {:?}", self.id, e);