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]] [[package]]
name = "reminder_rs" name = "reminder_rs"
version = "1.5.0-1" version = "1.5.1"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"chrono", "chrono",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reminder_rs" name = "reminder_rs"
version = "1.5.0-1" version = "1.5.1"
authors = ["jellywx <judesouthworth@pm.me>"] authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018" 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 { let db_channel_id = match scope_id {
ReminderScope::User(user_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(); 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 user_data.dm_channel
} else {
return Err(ReminderError::InvalidTag);
}
} }
ReminderScope::Channel(channel_id) => { ReminderScope::Channel(channel_id) => {