fixed oversight where users could set DM reminders across servers

This commit is contained in:
jellywx 2021-07-10 13:25:12 +01:00
parent 2e153cffab
commit 7bcb3c4a70
3 changed files with 13 additions and 5 deletions

2
Cargo.lock generated
View File

@ -1285,7 +1285,7 @@ dependencies = [
[[package]]
name = "reminder_rs"
version = "1.5.0-1"
version = "1.5.1"
dependencies = [
"Inflector",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "reminder_rs"
version = "1.5.0-1"
version = "1.5.1"
authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018"

View File

@ -1593,11 +1593,19 @@ async fn create_reminder<'a, U: Into<u64>, T: TryInto<i64>>(
let db_channel_id = match scope_id {
ReminderScope::User(user_id) => {
let user = UserId(*user_id).to_user(&ctx).await.unwrap();
if let Ok(user) = UserId(*user_id).to_user(&ctx).await {
let user_data = UserData::from_user(&user, &ctx, &pool).await.unwrap();
if let Some(guild_id) = guild_id {
if guild_id.member(ctx, user).await.is_err() {
return Err(ReminderError::InvalidTag);
}
}
user_data.dm_channel
} else {
return Err(ReminderError::InvalidTag);
}
}
ReminderScope::Channel(channel_id) => {