Coflnet / discord-bot-node

GNU Affero General Public License v3.0
3 stars 6 forks source link

bot is crashing sometimes #81

Closed Flou21 closed 1 month ago

Flou21 commented 1 month ago

Sometimes the bot crashes with this error message: Can someone please fix that

2024-07-09 11:14:13.170 
TypeError: item.sort is not a function
2024-07-09 11:14:13.170 
    at Object.execute (/commands/profitAfterSellCommand.js:75:39)
2024-07-09 11:14:13.171 
    at runMicrotasks (<anonymous>)
2024-07-09 11:14:13.171 
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2024-07-09 11:14:13.171 
    at async Client.<anonymous> (/bot.js:65:9)
2024-07-09 11:14:13.182 
/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:89
2024-07-09 11:14:13.182 
    if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
2024-07-09 11:14:13.182 
                                             ^
2024-07-09 11:14:13.182 

2024-07-09 11:14:13.182 
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
2024-07-09 11:14:13.182 
    at CommandInteraction.reply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:89:46)
2024-07-09 11:14:13.182 
    at Client.<anonymous> (/bot.js:68:27)
2024-07-09 11:14:13.182 
    at runMicrotasks (<anonymous>)
2024-07-09 11:14:13.182 
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2024-07-09 11:14:13.182 
  [Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
2024-07-09 11:14:13.182 
}
2024-07-09 11:14:15.031 

2024-07-09 11:14:15.031 
> discord-bot@1.0.0 update-commands
2024-07-09 11:14:15.031 
> node updateCommands.js
2024-07-09 11:14:15.031 

2024-07-09 11:14:15.666 
Started refreshing application (/) commands.
2024-07-09 11:14:15.912 
Successfully reloaded application (/) commands.
2024-07-09 11:14:15.924 
npm notice 
2024-07-09 11:14:15.924 
npm notice New major version of npm available! 8.1.0 -> 10.8.1
2024-07-09 11:14:15.924 
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.1>
2024-07-09 11:14:15.924 
npm notice Run `npm install -g npm@10.8.1` to update!
2024-07-09 11:14:15.924 
npm notice 
2024-07-09 11:14:16.195 

2024-07-09 11:14:16.196 
> discord-bot@1.0.0 start
2024-07-09 11:14:16.196 
> node bot.js
2024-07-09 11:14:16.196 

2024-07-09 11:15:32.362 
TypeError: item.sort is not a function
2024-07-09 11:15:32.362 
    at Object.execute (/commands/profitAfterSellCommand.js:75:39)
2024-07-09 11:15:32.362 
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2024-07-09 11:15:32.362 
    at async Client.<anonymous> (/bot.js:65:9)
2024-07-09 11:15:32.365 
/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:89
2024-07-09 11:15:32.365 
    if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
2024-07-09 11:15:32.365 
                                             ^
2024-07-09 11:15:32.365 

2024-07-09 11:15:32.365 
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
2024-07-09 11:15:32.365 
    at CommandInteraction.reply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:89:46)
2024-07-09 11:15:32.365 
    at Client.<anonymous> (/bot.js:68:27)
2024-07-09 11:15:32.365 
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2024-07-09 11:15:32.365 
  [Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
2024-07-09 11:15:32.365 
}
2024-07-09 11:15:47.172 

2024-07-09 11:15:47.173 
> discord-bot@1.0.0 update-commands
2024-07-09 11:15:47.173 
> node updateCommands.js
2024-07-09 11:15:47.173 

2024-07-09 11:15:47.451 
Started refreshing application (/) commands.
2024-07-09 11:15:47.716 
Successfully reloaded application (/) commands.
2024-07-09 11:15:47.729 
npm notice 
2024-07-09 11:15:47.729 
npm notice New major version of npm available! 8.1.0 -> 10.8.1
2024-07-09 11:15:47.730 
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.1>
2024-07-09 11:15:47.730 
npm notice Run `npm install -g npm@10.8.1` to update!
2024-07-09 11:15:47.730 
npm notice 
2024-07-09 11:15:48.051 

2024-07-09 11:15:48.051 
> discord-bot@1.0.0 start
2024-07-09 11:15:48.051 
> node bot.js
2024-07-09 11:15:48.051 

2024-07-09 12:42:36.441 
TypeError: item.sort is not a function
2024-07-09 12:42:36.441 
    at Object.execute (/commands/profitAfterSellCommand.js:75:39)
2024-07-09 12:42:36.441 
    at runMicrotasks (<anonymous>)
2024-07-09 12:42:36.441 
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2024-07-09 12:42:36.441 
    at async Client.<anonymous> (/bot.js:65:9)
2024-07-09 12:42:36.445 
/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:89
2024-07-09 12:42:36.445 
    if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
2024-07-09 12:42:36.445 
                                             ^
2024-07-09 12:42:36.445 

2024-07-09 12:42:36.445 
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
2024-07-09 12:42:36.445 
    at CommandInteraction.reply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:89:46)
2024-07-09 12:42:36.445 
    at Client.<anonymous> (/bot.js:68:27)
2024-07-09 12:42:36.445 
    at runMicrotasks (<anonymous>)
2024-07-09 12:42:36.445 
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2024-07-09 12:42:36.445 
  [Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
2024-07-09 12:42:36.445 
}
2024-07-09 12:42:37.432 

2024-07-09 12:42:37.432 
> discord-bot@1.0.0 update-commands
2024-07-09 12:42:37.432 
> node updateCommands.js
2024-07-09 12:42:37.433 

2024-07-09 12:42:37.745 
Started refreshing application (/) commands.
2024-07-09 12:42:38.034 
Successfully reloaded application (/) commands.
2024-07-09 12:42:38.047 
npm notice 
2024-07-09 12:42:38.048 
npm notice New major version of npm available! 8.1.0 -> 10.8.1
2024-07-09 12:42:38.048 
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.1>
2024-07-09 12:42:38.048 
npm notice Run `npm install -g npm@10.8.1` to update!
2024-07-09 12:42:38.048 
npm notice 
2024-07-09 12:42:38.313 

2024-07-09 12:42:38.313 
> discord-bot@1.0.0 start
2024-07-09 12:42:38.313 
> node bot.js
2024-07-09 12:42:38.313 
YockerFX commented 1 month ago
1.  Check if item is an array before calling sort.
2.  Ensure that you are not responding multiple times to the same interaction.

By adding these checks, the errors should be resolved.

Flou21 commented 1 month ago

looks like the issue was fixed in this commit: https://github.com/Coflnet/discord-bot-node/commit/f69cdeec64e2d5d9163399c475e1c584646d279f