zumito-framework 1.1.48 → 1.1.50
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/dist/baseModule/events/discord/interactionCreate.js +23 -5
- package/dist/baseModule/events/discord/messageCreate.js +10 -2
- package/dist/types/Command.d.ts +3 -3
- package/dist/types/Command.js +4 -4
- package/dist/types/CommandParameters.d.ts +1 -0
- package/dist/types/SelectMenuParameters.d.ts +1 -0
- package/package.json +1 -1
|
@@ -30,20 +30,38 @@ export class InteractionCreate extends FrameworkEvent {
|
|
|
30
30
|
});
|
|
31
31
|
if (![CommandType.any, CommandType.separated, CommandType.slash].includes(commandInstance.type))
|
|
32
32
|
return;
|
|
33
|
+
const trans = (key, params) => {
|
|
34
|
+
if (key.startsWith('$')) {
|
|
35
|
+
return framework.translations.get(key.replace('$', ''), guildSettings.lang, params);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return framework.translations.get('command.' + commandInstance.name + '.' + key, guildSettings.lang, params);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
33
41
|
if (commandInstance.type === CommandType.separated || commandInstance.type === CommandType.slash) {
|
|
34
|
-
await commandInstance.executeSlashCommand({ client, interaction, args, framework, guildSettings });
|
|
42
|
+
await commandInstance.executeSlashCommand({ client, interaction, args, framework, guildSettings, trans });
|
|
35
43
|
}
|
|
36
44
|
else {
|
|
37
|
-
await commandInstance.execute({ client, interaction, args, framework, guildSettings });
|
|
45
|
+
await commandInstance.execute({ client, interaction, args, framework, guildSettings, trans });
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
else if (interaction.isButton()) {
|
|
41
49
|
}
|
|
42
50
|
else if (interaction.isSelectMenu()) {
|
|
43
51
|
let path = interaction.customId.split('.');
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
|
|
52
|
+
const commandInstance = framework.commands.get(path[0]);
|
|
53
|
+
if (!commandInstance)
|
|
54
|
+
throw new Error(`Command ${path[0]} not found or select menu id bad formatted`);
|
|
55
|
+
const trans = (key, params) => {
|
|
56
|
+
if (key.startsWith('$')) {
|
|
57
|
+
return framework.translations.get(key.replace('$', ''), guildSettings.lang, params);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return framework.translations.get('command.' + commandInstance.name + '.' + key, guildSettings.lang, params);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
if (commandInstance.selectMenu) {
|
|
64
|
+
commandInstance.selectMenu({ path, interaction, client, framework, guildSettings, trans });
|
|
47
65
|
}
|
|
48
66
|
}
|
|
49
67
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import * as url from 'url';
|
|
1
2
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, PermissionsBitField } from "discord.js";
|
|
3
|
+
import ErrorStackParser from 'error-stack-parser';
|
|
2
4
|
import { FrameworkEvent } from "../../../types/FrameworkEvent.js";
|
|
3
5
|
import { ZumitoFramework } from "../../../ZumitoFramework.js";
|
|
4
6
|
import leven from 'leven';
|
|
5
|
-
import ErrorStackParser from 'error-stack-parser';
|
|
6
|
-
import * as url from 'url';
|
|
7
7
|
import path from "path";
|
|
8
8
|
export class MessageCreate extends FrameworkEvent {
|
|
9
9
|
once = false;
|
|
@@ -99,6 +99,14 @@ export class MessageCreate extends FrameworkEvent {
|
|
|
99
99
|
client: framework.client,
|
|
100
100
|
framework: framework,
|
|
101
101
|
guildSettings: guildSettings,
|
|
102
|
+
trans: (key, params) => {
|
|
103
|
+
if (key.startsWith('$')) {
|
|
104
|
+
return framework.translations.get(key.replace('$', ''), guildSettings.lang, params);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return framework.translations.get('command.' + commandInstance.name + '.' + key, guildSettings.lang, params);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
102
110
|
});
|
|
103
111
|
if (!message.channel.isDMBased && !message.deletable && (false)) { // false = settings.deleteCommands
|
|
104
112
|
try {
|
package/dist/types/Command.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare abstract class Command {
|
|
|
18
18
|
type: string;
|
|
19
19
|
constructor();
|
|
20
20
|
abstract execute({ message, interaction, args, client, framework }: CommandParameters): void;
|
|
21
|
-
executePrefixCommand({ message, interaction, args, client, framework }: CommandParameters): void;
|
|
22
|
-
executeSlashCommand({ message, interaction, args, client, framework }: CommandParameters): void;
|
|
23
|
-
abstract selectMenu({ path, interaction, client, framework }: SelectMenuParameters): void;
|
|
21
|
+
executePrefixCommand({ message, interaction, args, client, framework, trans }: CommandParameters): void;
|
|
22
|
+
executeSlashCommand({ message, interaction, args, client, framework, trans }: CommandParameters): void;
|
|
23
|
+
abstract selectMenu({ path, interaction, client, framework, trans }: SelectMenuParameters): void;
|
|
24
24
|
}
|
package/dist/types/Command.js
CHANGED
|
@@ -16,10 +16,10 @@ export class Command {
|
|
|
16
16
|
type = CommandType.prefix;
|
|
17
17
|
constructor() {
|
|
18
18
|
}
|
|
19
|
-
executePrefixCommand({ message, interaction, args, client, framework }) {
|
|
20
|
-
this.execute({ message, interaction, args, client, framework });
|
|
19
|
+
executePrefixCommand({ message, interaction, args, client, framework, trans }) {
|
|
20
|
+
this.execute({ message, interaction, args, client, framework, trans });
|
|
21
21
|
}
|
|
22
|
-
executeSlashCommand({ message, interaction, args, client, framework }) {
|
|
23
|
-
this.execute({ message, interaction, args, client, framework });
|
|
22
|
+
executeSlashCommand({ message, interaction, args, client, framework, trans }) {
|
|
23
|
+
this.execute({ message, interaction, args, client, framework, trans });
|
|
24
24
|
}
|
|
25
25
|
}
|