Make owoify use last message's content if empty
This commit is contained in:
parent
fdaf37061b
commit
1430bbf2a9
19
src/main.rs
19
src/main.rs
|
@ -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(())
|
||||
|
|
Loading…
Reference in New Issue