spacecommands 3.5.1 → 3.5.2
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/CommandHandler.js
CHANGED
|
@@ -291,7 +291,9 @@ class CommandHandler {
|
|
|
291
291
|
}
|
|
292
292
|
if (autocomplete) {
|
|
293
293
|
const slashCommands = instance.slashCommands;
|
|
294
|
-
slashCommands.registerAutocomplete(names[0],
|
|
294
|
+
slashCommands.registerAutocomplete(names[0], async (interaction) => {
|
|
295
|
+
await autocomplete(interaction, instance);
|
|
296
|
+
});
|
|
295
297
|
}
|
|
296
298
|
}
|
|
297
299
|
if (callback) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const discord_js_1 = require("discord.js");
|
|
3
|
+
let instance;
|
|
4
|
+
module.exports = {
|
|
5
|
+
init: (client, inst) => {
|
|
6
|
+
instance = inst;
|
|
7
|
+
},
|
|
8
|
+
category: 'Configuration',
|
|
9
|
+
description: 'Set your personal language preference for the bot.',
|
|
10
|
+
slash: true,
|
|
11
|
+
testOnly: false,
|
|
12
|
+
options: [
|
|
13
|
+
{
|
|
14
|
+
name: 'language',
|
|
15
|
+
description: 'The language code (e.g., english, spanish)',
|
|
16
|
+
type: 3, // STRING
|
|
17
|
+
required: true,
|
|
18
|
+
autocomplete: true,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
autocomplete: (interaction) => {
|
|
22
|
+
const focusedValue = interaction.options.getFocused().toLowerCase();
|
|
23
|
+
const choices = instance.messageHandler.languages();
|
|
24
|
+
const filtered = choices.filter((choice) => choice.startsWith(focusedValue)).slice(0, 25);
|
|
25
|
+
interaction.respond(filtered.map((choice) => ({ name: choice, value: choice })));
|
|
26
|
+
},
|
|
27
|
+
callback: async (options) => {
|
|
28
|
+
const { interaction, instance, text, guild, user } = options;
|
|
29
|
+
if (!interaction || !interaction.isChatInputCommand()) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const lang = text.toLowerCase();
|
|
33
|
+
if (!instance.messageHandler.languages().includes(lang)) {
|
|
34
|
+
return interaction.reply({
|
|
35
|
+
content: instance.messageHandler.get(guild, 'LANGUAGE_NOT_SUPPORTED', { LANGUAGE: lang }),
|
|
36
|
+
flags: discord_js_1.MessageFlags.Ephemeral,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
await instance.messageHandler.setUserLanguage(user, lang);
|
|
40
|
+
return interaction.reply({
|
|
41
|
+
content: instance.messageHandler.get(guild, 'NEW_LANGUAGE', { LANGUAGE: lang }, user),
|
|
42
|
+
flags: discord_js_1.MessageFlags.Ephemeral,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
package/package.json
CHANGED