From 7a90770f6abc642f74708b3ce438ef354cc30e8c Mon Sep 17 00:00:00 2001 From: Agatha Rose Date: Sat, 23 May 2020 19:51:43 +0300 Subject: [PATCH] Make pinned message number 1-indexed --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 089083b..2cb1f40 100755 --- a/src/main.rs +++ b/src/main.rs @@ -655,7 +655,10 @@ fn pinned(ctx: &mut Context, message: &Message, mut args: Args) -> CommandResult )); } }; - let idx = args.single::().unwrap_or(0); + let mut idx = args.single::().unwrap_or(1); + if idx != 0 { + idx -= 1; + } if pinned.is_empty() { 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| { m.embed(|e| { - e.title(format!("Pinned message #{}", idx)) + e.title(format!("Pinned message #{}", idx + 1)) .description(&pinned[idx].content) .timestamp(&pinned[idx].timestamp); e.author(|a| {