mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-25 07:22:09 -05:00
Add support to /removequote last (#10472)
* Allow removing last quote
Standarize with a1ced8d4b3
* Update server/chat-plugins/quotes.ts
* oops
---------
Co-authored-by: Mia <49593536+mia-pi-git@users.noreply.github.com>
This commit is contained in:
parent
90d35efe0d
commit
9c2da0a7fe
|
|
@ -83,17 +83,17 @@ export const commands: Chat.ChatCommands = {
|
|||
room = this.requireRoom();
|
||||
this.checkCan('mute', null, room);
|
||||
if (!quotes[room.roomid]?.length) return this.errorReply(`This room has no quotes.`);
|
||||
const index = parseInt(target.trim());
|
||||
const roomQuotes = quotes[room.roomid];
|
||||
const index = toID(target) === 'last' ? roomQuotes.length - 1 : parseInt(toID(target)) - 1;
|
||||
if (isNaN(index)) {
|
||||
return this.errorReply(`Invalid index.`);
|
||||
}
|
||||
const roomQuotes = quotes[room.roomid];
|
||||
if (!roomQuotes[index - 1]) {
|
||||
if (!roomQuotes[index]) {
|
||||
return this.errorReply(`Quote not found.`);
|
||||
}
|
||||
const [removed] = roomQuotes.splice(index - 1, 1);
|
||||
const [removed] = roomQuotes.splice(index, 1);
|
||||
const collapsedQuote = removed.quote.replace(/\n/g, ' ');
|
||||
this.privateModAction(`${user.name} removed quote indexed at ${index}: "${collapsedQuote}" (originally added by ${removed.userid}).`);
|
||||
this.privateModAction(`${user.name} removed quote indexed at ${index + 1}: "${collapsedQuote}" (originally added by ${removed.userid}).`);
|
||||
this.modlog(`REMOVEQUOTE`, null, collapsedQuote);
|
||||
saveQuotes();
|
||||
this.refreshPage(`quotes-${room.roomid}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user