Make pinned message number 1-indexed

This commit is contained in:
Agatha Rose 2020-05-23 19:51:43 +03:00
parent d555c3a39f
commit 7a90770f6a
1 changed files with 5 additions and 2 deletions

View File

@ -655,7 +655,10 @@ fn pinned(ctx: &mut Context, message: &Message, mut args: Args) -> CommandResult
)); ));
} }
}; };
let idx = args.single::<usize>().unwrap_or(0); let mut idx = args.single::<usize>().unwrap_or(1);
if idx != 0 {
idx -= 1;
}
if pinned.is_empty() { if pinned.is_empty() {
return Err(CommandError("No pinned messages found!".to_string())); return Err(CommandError("No pinned messages found!".to_string()));
} }
@ -665,7 +668,7 @@ fn pinned(ctx: &mut Context, message: &Message, mut args: Args) -> CommandResult
let _ = message.channel_id.send_message(&ctx.http, |m| { let _ = message.channel_id.send_message(&ctx.http, |m| {
m.embed(|e| { m.embed(|e| {
e.title(format!("Pinned message #{}", idx)) e.title(format!("Pinned message #{}", idx + 1))
.description(&pinned[idx].content) .description(&pinned[idx].content)
.timestamp(&pinned[idx].timestamp); .timestamp(&pinned[idx].timestamp);
e.author(|a| { e.author(|a| {