Implement /viewquote last (#9952)

This commit is contained in:
Sergio 2023-12-11 19:32:31 +01:00 committed by GitHub
parent b3cda4b01d
commit a1ced8d4b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,7 +106,7 @@ export const commands: Chat.ChatCommands = {
const roomQuotes = quotes[room.roomid];
if (!roomQuotes?.length) return this.errorReply(`This room has no quotes.`);
const [num, showAuthor] = Utils.splitFirst(target, ',');
const index = parseInt(num) - 1;
const index = num === 'last' ? roomQuotes.length - 1 : parseInt(num) - 1;
if (isNaN(index)) {
return this.errorReply(`Invalid index.`);
}