create-reciple 9.7.2 → 9.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -44
- package/dist/bin.js +14 -3
- package/dist/bin.js.map +1 -1
- package/package.json +9 -9
- package/templates/javascript/modules/commands/PingCommand.js +68 -68
- package/templates/javascript/modules/events/WelcomeEvent.js +54 -54
- package/templates/javascript/modules/halts/CommandErrorHalt.js +59 -59
- package/templates/javascript/modules/preconditions/ExamplePrecondition.js +27 -27
- package/templates/javascript/nodemon.json +15 -15
- package/templates/javascript/package.json +17 -17
- package/templates/typescript/nodemon.json +16 -16
- package/templates/typescript/package.json +0 -1
- package/templates/typescript/src/commands/PingCommand.ts +53 -46
- package/templates/typescript/src/events/WelcomeEvent.ts +39 -37
- package/templates/typescript/src/halts/CommandErrorHalt.ts +44 -44
- package/templates/typescript/src/preconditions/ExamplePrecondition.ts +18 -18
- package/templates/typescript-decorators/dot.gitignore +133 -0
- package/templates/typescript-decorators/nodemon.json +17 -0
- package/templates/typescript-decorators/package.json +22 -0
- package/templates/typescript-decorators/src/commands/PingCommand.ts +46 -0
- package/templates/typescript-decorators/src/events/WelcomeEvent.ts +37 -0
- package/templates/typescript-decorators/src/halts/CommandErrorHalt.ts +44 -0
- package/templates/typescript-decorators/src/preconditions/ExamplePrecondition.ts +18 -0
- package/templates/typescript-decorators/template.json +4 -0
- package/templates/typescript-decorators/tsconfig.json +19 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AnyCommandHaltTriggerData, CommandHaltData, CommandHaltReason, CommandType, ContextMenuCommandHaltTriggerData, MessageCommandHaltTriggerData, SlashCommandHaltTriggerData } from 'reciple';
|
|
2
|
+
|
|
3
|
+
export class CommandErrorHalt implements CommandHaltData {
|
|
4
|
+
id = 'my.reciple.js.commanderrorhalt';
|
|
5
|
+
disabled = false;
|
|
6
|
+
|
|
7
|
+
contextMenuCommandHalt(data: ContextMenuCommandHaltTriggerData) {
|
|
8
|
+
return this.halt(data);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
messageCommandHalt(data: MessageCommandHaltTriggerData) {
|
|
12
|
+
return this.halt(data);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
slashCommandHalt(data: SlashCommandHaltTriggerData) {
|
|
16
|
+
return this.halt(data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async halt(data: AnyCommandHaltTriggerData) {
|
|
20
|
+
if (data.reason !== CommandHaltReason.Error) return;
|
|
21
|
+
|
|
22
|
+
const content = `An error occured while executing this command`;
|
|
23
|
+
|
|
24
|
+
switch (data.commandType) {
|
|
25
|
+
case CommandType.ContextMenuCommand:
|
|
26
|
+
case CommandType.SlashCommand:
|
|
27
|
+
const interaction = data.executeData.interaction;
|
|
28
|
+
|
|
29
|
+
if (interaction.replied || interaction.deferred) {
|
|
30
|
+
await interaction.editReply(content);
|
|
31
|
+
} else {
|
|
32
|
+
await interaction.reply(content);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case CommandType.MessageCommand:
|
|
36
|
+
await data.executeData.message.reply(content);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
reciple.logger?.error(data.error);
|
|
41
|
+
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommandPreconditionData, ContextMenuCommandExecuteData, MessageCommandExecuteData, SlashCommandExecuteData } from 'reciple';
|
|
2
|
+
|
|
3
|
+
export class ExamplePrecondition implements CommandPreconditionData {
|
|
4
|
+
id = 'my.reciple.js.exampleprecondition';
|
|
5
|
+
disabled = false;
|
|
6
|
+
|
|
7
|
+
contextMenuCommandExecute(execute: ContextMenuCommandExecuteData) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
messageCommandExecute(excute: MessageCommandExecuteData) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
slashCommandExecute(execute: SlashCommandExecuteData) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["./src/**/*"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./modules",
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"module": "NodeNext",
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"experimentalDecorators": true,
|
|
14
|
+
"emitDecoratorMetadata": true,
|
|
15
|
+
"paths": {
|
|
16
|
+
"@/*": ["./src/*"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|