-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
256bc05
commit f12f42e
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// @ts-check | ||
import { CommandHaltReason, CommandType } from 'reciple'; | ||
|
||
/** | ||
* @type {import('reciple').CommandHaltData} | ||
*/ | ||
export default { | ||
id: 'org.reciple.js.handleerror', | ||
commandTypes: [CommandType.ContextMenuCommand, CommandType.MessageCommand, CommandType.SlashCommand], | ||
/** | ||
* | ||
* @param {import('reciple').AnyCommandHaltTriggerData} data | ||
* @returns | ||
*/ | ||
async halt(data) { | ||
if (data.reason !== CommandHaltReason.Error) return; | ||
|
||
const content = `An error occured while executing this command`; | ||
|
||
switch (data.commandType) { | ||
case CommandType.ContextMenuCommand: | ||
case CommandType.SlashCommand: | ||
const interaction = data.executeData.interaction; | ||
|
||
if (interaction.replied || interaction.deferred) { | ||
await interaction.editReply(content); | ||
} else { | ||
await interaction.reply(content); | ||
} | ||
break; | ||
case CommandType.MessageCommand: | ||
await data.executeData.message.reply(content); | ||
break; | ||
} | ||
|
||
console.log(data.error); | ||
|
||
return true; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters