forked from sorceress/rustcord
Make owoify use last message's content if empty
This commit is contained in:
parent
450bd84515
commit
7ef4f51edf
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
|
.channel_id
|
||||||
.messages(&ctx.http, |get| get.before(message.id).limit(num));
|
.messages(&ctx.http, |get| get.before(message.id).limit(num));
|
||||||
if let Err(e) = messages {
|
if let Err(e) = messages {
|
||||||
let _ = message.channel_id.say(&ctx.http, format!("Error: {}", e));
|
return Err(CommandError(s!(format!("Error: {}", e))));
|
||||||
} else {
|
} else {
|
||||||
let mut messages = messages?;
|
let mut messages = messages?;
|
||||||
// remove all messages by other users
|
// 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 {
|
fn owo(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
|
||||||
use owoify::OwOifiable;
|
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());
|
let _ = message.channel_id.say(&ctx.http, input.owoify());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue