Make owoify use last message's content if empty

This commit is contained in:
Agatha Lovelace 2020-07-10 19:59:23 +03:00
parent 450bd84515
commit 7ef4f51edf
No known key found for this signature in database
GPG Key ID: 2DB18BA2E0A80BC3
1 changed files with 17 additions and 2 deletions

View File

@ -306,7 +306,7 @@ fn bottom_rng(ctx: &mut Context, message: &Message, mut args: Args) -> CommandRe
.channel_id
.messages(&ctx.http, |get| get.before(message.id).limit(num));
if let Err(e) = messages {
let _ = message.channel_id.say(&ctx.http, format!("Error: {}", e));
return Err(CommandError(s!(format!("Error: {}", e))));
} else {
let mut messages = messages?;
// remove all messages by other users
@ -471,7 +471,22 @@ fn pfp(ctx: &mut Context, message: &Message) -> CommandResult {
fn owo(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
use owoify::OwOifiable;
let input: String = args.rest().trim().to_string();
let lastmsg = match message
.channel_id
.messages(&ctx.http, |get| get.before(message.id)
.limit(1)) {
Ok(v) => v,
Err(_) => return Err(CommandError(s!("Could not get last message!")))
};
let ref lastmsg = lastmsg[0].content;
let input: String = match args.is_empty() {
true => {
s!(lastmsg)
},
false => args.rest().trim().to_string()
};
let _ = message.channel_id.say(&ctx.http, input.owoify());
Ok(())