Shadowblade911 / MrLancer-v2

ISC License
0 stars 0 forks source link

deletePrompt and editPrompt do not check if the prompt ID exists #5

Closed jcotton42 closed 2 years ago

jcotton42 commented 2 years ago

In deletePrompt return value of getSuggestion is used without a null/undefined check. For users that have MANAGE_GUILD this will result in the misleading message "I have removed the suggestion from the list." For users without that it will instead result in the following error and the bot will crash.

import { SlashCommandBuilder } from "@discordjs/builders";               
                                                         ^               
TypeError: Cannot read properties of undefined (reading 'user_id')       
    at /app/src/commands/deletePrompt.ts:18:102                          
    at Generator.next (<anonymous>)                                      
    at fulfilled (/app/src/commands/deletePrompt.ts:5:58)                
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

An identical bug exists in editPrompt.