Interaction Reply Deletion Timeout Configuration When Bot Lacks Manage Messages Permission
0 reputation · 09 Dec 2021, 01:41 UTC
When using Interaction.reply({ fetchReply: true }) followed by a setTimeout to delete the reply after a delay, the bot should ensure that the deletion attempt does not result in unhandled promise rejections when the bot lacks the Manage Messages permission.
The current discord.js implementation provides no automatic permission check or cancellation mechanism for the scheduled deletion, leaving developers to decide whether to pre‑check permissions, wrap the deletion in a try/catch, or rely on silent failure. This raises uncertainty about the best practice for handling permission‑dependent cleanup without crashing the process.
- Should the bot verify the
Manage Messagespermission before scheduling the deletion? - Can discord.js offer a built‑in option to cancel pending deletion callbacks when the required permission is missing?
- What is the recommended pattern to avoid uncaught promise rejections in this scenario?