show embed description if message not there

This commit is contained in:
jude 2020-11-04 21:09:15 +00:00
parent 41e5f32374
commit 43824bc374
3 changed files with 41 additions and 9 deletions

2
Cargo.lock generated
View File

@ -1175,7 +1175,7 @@ dependencies = [
[[package]] [[package]]
name = "reminder_rs" name = "reminder_rs"
version = "1.1.8" version = "1.1.9"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"async-trait", "async-trait",

View File

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

View File

@ -359,8 +359,19 @@ impl LookFlags {
struct LookReminder { struct LookReminder {
id: u32, id: u32,
time: u32, time: u32,
content: String,
channel: u64, channel: u64,
content: String,
description: String,
}
impl LookReminder {
fn display_content(&self) -> &str {
if self.content.len() > 0 {
self.content.as_str()
} else {
self.description.as_str()
}
}
} }
#[command("look")] #[command("look")]
@ -389,7 +400,7 @@ async fn look(ctx: &Context, msg: &Message, args: String) {
LookReminder, LookReminder,
" "
SELECT SELECT
reminders.id, reminders.time, channels.channel, messages.content reminders.id, reminders.time, channels.channel, messages.content, embeds.description
FROM FROM
reminders reminders
INNER JOIN INNER JOIN
@ -400,6 +411,10 @@ INNER JOIN
messages messages
ON ON
messages.id = reminders.message_id messages.id = reminders.message_id
INNER JOIN
embeds
ON
embeds.id = messages.embed_id
WHERE WHERE
channels.guild_id = (SELECT id FROM guilds WHERE guild = ?) AND channels.guild_id = (SELECT id FROM guilds WHERE guild = ?) AND
channels.channel = ? AND channels.channel = ? AND
@ -421,7 +436,7 @@ LIMIT
LookReminder, LookReminder,
" "
SELECT SELECT
reminders.id, reminders.time, messages.content, channels.channel reminders.id, reminders.time, channels.channel, messages.content, embeds.description
FROM FROM
reminders reminders
LEFT OUTER JOIN LEFT OUTER JOIN
@ -432,6 +447,10 @@ INNER JOIN
messages messages
ON ON
messages.id = reminders.message_id messages.id = reminders.message_id
INNER JOIN
embeds
ON
embeds.id = messages.embed_id
WHERE WHERE
channels.channel = ? AND channels.channel = ? AND
FIND_IN_SET(reminders.enabled, ?) FIND_IN_SET(reminders.enabled, ?)
@ -474,7 +493,12 @@ LIMIT
} }
}; };
format!("'{}' *{}* **{}**", reminder.content, &inter, time_display) format!(
"'{}' *{}* **{}**",
reminder.display_content(),
&inter,
time_display
)
}); });
let _ = msg.channel_id.say_lines(&ctx, display).await; let _ = msg.channel_id.say_lines(&ctx, display).await;
@ -504,7 +528,7 @@ async fn delete(ctx: &Context, msg: &Message, _args: String) {
LookReminder, LookReminder,
" "
SELECT SELECT
reminders.id, reminders.time, messages.content, channels.channel reminders.id, reminders.time, channels.channel, messages.content, embeds.description
FROM FROM
reminders reminders
LEFT OUTER JOIN LEFT OUTER JOIN
@ -515,6 +539,10 @@ INNER JOIN
messages messages
ON ON
messages.id = reminders.message_id messages.id = reminders.message_id
INNER JOIN
embeds
ON
embeds.id = messages.embed_id
WHERE WHERE
channels.guild_id = (SELECT id FROM guilds WHERE guild = ?) channels.guild_id = (SELECT id FROM guilds WHERE guild = ?)
", ",
@ -527,13 +555,17 @@ WHERE
LookReminder, LookReminder,
" "
SELECT SELECT
reminders.id, reminders.time, messages.content, channels.channel reminders.id, reminders.time, channels.channel, messages.content, embeds.description
FROM FROM
reminders reminders
INNER JOIN INNER JOIN
messages messages
ON ON
reminders.message_id = messages.id reminders.message_id = messages.id
INNER JOIN
embeds
ON
embeds.id = messages.embed_id
INNER JOIN INNER JOIN
channels channels
ON ON
@ -557,7 +589,7 @@ WHERE
format!( format!(
"**{}**: '{}' *<#{}>* at {}", "**{}**: '{}' *<#{}>* at {}",
count + 1, count + 1,
reminder.content, reminder.display_content(),
reminder.channel, reminder.channel,
time.format("%Y-%m-%d %H:%M:%S") time.format("%Y-%m-%d %H:%M:%S")
) )