CampbellCrowley / SpikeyBot-Discord

SpikeyBot for Discord. Hunger Games simulator, and other helpful commands.
https://www.spikeybot.com
30 stars 13 forks source link

HG: NPC Creation Invalid embed.setDescription('') #120

Closed crispyross closed 2 years ago

crispyross commented 2 years ago

Describe the bug When creating an NPC, after confirmation, it fails.

In src/hungryGames.js:3617 of the 2022 unstable branch, embed.setDescription('') is called to clear to embed's description, which isn't allowed and creates a validation error:

  Received one or more errors

  1 ExpectedValidationError > s.literal(V)
  |   Expected values to be equals
  |
  |   Expected:
  |   | null
  |
  |   Received:
  |   | ''

  2 ExpectedConstraintError > s.string.lengthGreaterThanOrEqual
  |   Invalid string length
  |
  |   Expected: expected.length >= 1
  |
  |   Received:
  |   | ''

    at UnionValidator.handle (/home/$USER/SpikeyBot-Discord/node_modules/@sapphire/shapeshift/dist/index.js:1085:23)
    at UnionValidator.parse (/home/$USER/SpikeyBot-Discord/node_modules/@sapphire/shapeshift/dist/index.js:142:88)
    at EmbedBuilder.setDescription (/home/$USER/SpikeyBot-Discord/node_modules/@discordjs/builders/dist/messages/embed/Embed.cjs:57:37)
    at /home/$USER/SpikeyBot-Discord/src/hungryGames.js:3617:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

The solution: Replace the line with:

embed.setDescription(null);

To Reproduce Create an NPC with ?hg npc create Name Here

Expected behavior After confirming by reacting with the checkmark emoji, the NPC is created.

Additional context Solution is provided above.

CampbellCrowley commented 2 years ago

Thanks for reporting this! Fixed on unreviewed/2022 https://github.com/CampbellCrowley/SpikeyBot-Discord/commit/a80fd139bd7c2cb10284945d3673684d119a9b02 .