From 992979915126f9ea5018e8ffe2b0195c5eb4b7fa Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 9 Dec 2023 17:18:53 +0000 Subject: [PATCH] Fix dropnumber command (#109) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - Fix the dropnumber command #108 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/109 Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/commands/stage/dropnumber.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/commands/stage/dropnumber.ts b/src/commands/stage/dropnumber.ts index d311f33..a7de021 100644 --- a/src/commands/stage/dropnumber.ts +++ b/src/commands/stage/dropnumber.ts @@ -31,20 +31,18 @@ export default class Dropnumber extends Command { return; } - const series = CoreClient.Cards.find(x => x.cards.find(y => y.id == cardNumber.toString())); - - if (!series) { - await interaction.reply('Card not found'); - return; - } - - const card = series.cards.find(x => x.id == cardNumber.toString()); + const card = CoreClient.Cards + .flatMap(x => x.cards) + .find(x => x.id == cardNumber.value); if (!card) { await interaction.reply('Card not found'); return; } + const series = CoreClient.Cards + .find(x => x.cards.includes(card))!; + let image: Buffer; const imageFileName = card.path.split("/").pop()!;