Skip to content

Commit

Permalink
add !resetqueue command
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Aug 6, 2020
1 parent 308b622 commit 9f8edb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/classes/CartQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class CartQueue {
return true;
}

resetQueue(): void {
log.debug('Queue reset initialized.');
this.carts.splice(0);
}

getPosition(steamID: SteamID | string): number {
const steamID64 = steamID.toString();
return this.carts.findIndex(cart => cart.partner.toString() === steamID64);
Expand Down
8 changes: 8 additions & 0 deletions src/classes/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const ADMIN_COMMANDS: string[] = [
'!add - Add a pricelist entry ➕',
'!update - Update a pricelist entry',
'!relist - Perform relist if some of your listings are missing (you can run only once, then need to wait 30 minutes if you want to run it again)',
'resetqueue - Reset queue position to 0',
'!remove <sku=> OR <item=> - Remove a pricelist entry ➖',
'!get <sku=> OR <item=> - Get raw information about a pricelist entry',
'!pricecheck <sku=> OR <item=> - Requests an item to be priced by PricesTF',
Expand Down Expand Up @@ -159,6 +160,8 @@ export = class Commands {
this.checkoutCommand(steamID);
} else if (command === 'queue') {
this.queueCommand(steamID);
} else if (command === 'resetqueue') {
this.resetQueueCommand(steamID);
} else if (command === 'cancel') {
this.cancelCommand(steamID);
} else if (command === 'deposit' && isAdmin) {
Expand Down Expand Up @@ -750,6 +753,11 @@ export = class Commands {
}
}

private resetQueueCommand(steamID: SteamID): void {
this.cartQueue.resetQueue();
this.bot.sendMessage(steamID, '✅ Sucessfully reset queue!');
}

private cancelCommand(steamID: SteamID): void {
// Maybe have the cancel command only cancel the offer in the queue, and have a command for canceling the offer?

Expand Down

0 comments on commit 9f8edb4

Please sign in to comment.