vimcord 1.0.52 → 1.0.54
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/index.cjs +57 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +514 -518
- package/dist/index.d.ts +514 -518
- package/dist/index.js +58 -75
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -316,7 +316,6 @@ var BaseCommandBuilder = class {
|
|
|
316
316
|
async run(client, ...args) {
|
|
317
317
|
const config = this.resolveConfig(client);
|
|
318
318
|
const ctx = this.extractContext(args);
|
|
319
|
-
let cancel = false;
|
|
320
319
|
try {
|
|
321
320
|
if (!config.enabled) {
|
|
322
321
|
return await config.onUsedWhenDisabled?.(...args);
|
|
@@ -331,16 +330,11 @@ var BaseCommandBuilder = class {
|
|
|
331
330
|
if (!await this.checkConditions(config, ...args)) {
|
|
332
331
|
return await config.onConditionsNotMet?.(...args);
|
|
333
332
|
}
|
|
334
|
-
await config.beforeExecute?.(
|
|
335
|
-
if (cancel) return;
|
|
333
|
+
await config.beforeExecute?.(...args);
|
|
336
334
|
if (config.logExecution !== false) {
|
|
337
|
-
const
|
|
338
|
-
const builderWithName = this;
|
|
339
|
-
const cmdName = optionsWithName.name ?? builderWithName.builder?.name ?? "Unknown";
|
|
335
|
+
const cmdName = this.options.name || this.builder?.name || "Unknown";
|
|
340
336
|
const location = ctx.guild ? `${ctx.guild.name} (${ctx.guild.id})` : "Direct Messages";
|
|
341
|
-
|
|
342
|
-
client.logger.commandExecuted(cmdName, ctx.user.username, location);
|
|
343
|
-
}
|
|
337
|
+
client.logger.commandExecuted(cmdName, ctx.user.username, location);
|
|
344
338
|
}
|
|
345
339
|
const result = await config.execute?.(...args);
|
|
346
340
|
await config.afterExecute?.(result, ...args);
|
|
@@ -568,7 +562,9 @@ var Logger = class {
|
|
|
568
562
|
extend(extras) {
|
|
569
563
|
for (const [key, fn] of Object.entries(extras)) {
|
|
570
564
|
if (typeof fn === "function") {
|
|
571
|
-
this[key] = (...args)
|
|
565
|
+
this[key] = function(...args) {
|
|
566
|
+
return fn.call(this, ...args);
|
|
567
|
+
};
|
|
572
568
|
}
|
|
573
569
|
}
|
|
574
570
|
return this;
|
|
@@ -938,14 +934,12 @@ var contextCommandHandler = new EventBuilder({
|
|
|
938
934
|
if (!command) {
|
|
939
935
|
const content = `**${interaction.commandName}** is not a registered context command.`;
|
|
940
936
|
if (interaction.replied || interaction.deferred) {
|
|
941
|
-
|
|
942
|
-
} else {
|
|
943
|
-
await interaction.reply({ content, flags: "Ephemeral" });
|
|
937
|
+
return interaction.followUp({ content, flags: "Ephemeral" });
|
|
944
938
|
}
|
|
945
|
-
return;
|
|
939
|
+
return interaction.reply({ content, flags: "Ephemeral" });
|
|
946
940
|
}
|
|
947
941
|
try {
|
|
948
|
-
await command.run(client, client, interaction);
|
|
942
|
+
return await command.run(client, client, interaction);
|
|
949
943
|
} catch (err) {
|
|
950
944
|
await client.error.handleCommandError(err, interaction.guild, interaction);
|
|
951
945
|
}
|
|
@@ -1004,14 +998,12 @@ var slashCommandHandler = new EventBuilder({
|
|
|
1004
998
|
if (!command) {
|
|
1005
999
|
const content = `**/\`${interaction.commandName}\`** is not a registered command.`;
|
|
1006
1000
|
if (interaction.replied || interaction.deferred) {
|
|
1007
|
-
|
|
1008
|
-
} else {
|
|
1009
|
-
await interaction.reply({ content, flags: "Ephemeral" });
|
|
1001
|
+
return interaction.followUp({ content, flags: "Ephemeral" });
|
|
1010
1002
|
}
|
|
1011
|
-
return;
|
|
1003
|
+
return interaction.reply({ content, flags: "Ephemeral" });
|
|
1012
1004
|
}
|
|
1013
1005
|
try {
|
|
1014
|
-
await command.run(client, client, interaction);
|
|
1006
|
+
return await command.run(client, client, interaction);
|
|
1015
1007
|
} catch (err) {
|
|
1016
1008
|
await client.error.handleCommandError(err, interaction.guild, interaction);
|
|
1017
1009
|
}
|
|
@@ -1795,7 +1787,7 @@ var VimcordErrorHandler = class {
|
|
|
1795
1787
|
var import_chalk2 = __toESM(require("chalk"));
|
|
1796
1788
|
|
|
1797
1789
|
// package.json
|
|
1798
|
-
var version = "1.0.
|
|
1790
|
+
var version = "1.0.54";
|
|
1799
1791
|
|
|
1800
1792
|
// src/client/vimcord.logger.ts
|
|
1801
1793
|
var clientLoggerFactory = (client) => new Logger({ prefixEmoji: "\u26A1", prefix: `vimcord (i${client.clientId})` }).extend({
|
|
@@ -1871,11 +1863,9 @@ function getDevMode() {
|
|
|
1871
1863
|
}
|
|
1872
1864
|
|
|
1873
1865
|
// src/configs/app.config.ts
|
|
1874
|
-
var packageJson = getPackageJson();
|
|
1875
|
-
var version2 = typeof packageJson.version === "string" ? packageJson.version : "1.0.0";
|
|
1876
1866
|
var defaultConfig = {
|
|
1877
1867
|
name: "Discord Bot",
|
|
1878
|
-
version:
|
|
1868
|
+
version: getPackageJson()?.version ?? "1.0.0",
|
|
1879
1869
|
devMode: getDevMode(),
|
|
1880
1870
|
verbose: false,
|
|
1881
1871
|
enableCLI: false,
|
|
@@ -2199,16 +2189,11 @@ var CommandManager = class {
|
|
|
2199
2189
|
slash;
|
|
2200
2190
|
prefix;
|
|
2201
2191
|
context;
|
|
2202
|
-
logger;
|
|
2203
2192
|
constructor(client) {
|
|
2204
2193
|
this.client = client;
|
|
2205
2194
|
this.slash = new SlashCommandManager(client);
|
|
2206
2195
|
this.prefix = new PrefixCommandManager(client);
|
|
2207
2196
|
this.context = new ContextCommandManager(client);
|
|
2208
|
-
this.logger = new Logger({
|
|
2209
|
-
prefixEmoji: "\u26A1",
|
|
2210
|
-
prefix: `vimcord (i${client.clientId}) [CommandManager]`
|
|
2211
|
-
});
|
|
2212
2197
|
}
|
|
2213
2198
|
getAllAppCommands(options = {}) {
|
|
2214
2199
|
return [...this.slash.getAll(options), ...this.context.getAll(options)];
|
|
@@ -2216,21 +2201,23 @@ var CommandManager = class {
|
|
|
2216
2201
|
async registerGlobal(options = {}) {
|
|
2217
2202
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2218
2203
|
if (!client.rest) {
|
|
2219
|
-
|
|
2204
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands globally: REST is not initialized`);
|
|
2220
2205
|
return;
|
|
2221
2206
|
}
|
|
2222
2207
|
const commands = this.getAllAppCommands(options).map((cmd) => cmd.builder.toJSON());
|
|
2223
2208
|
if (!commands.length) {
|
|
2224
|
-
|
|
2209
|
+
console.log("[CommandManager] No commands to register globally");
|
|
2225
2210
|
return;
|
|
2226
2211
|
}
|
|
2227
|
-
|
|
2212
|
+
console.log(
|
|
2213
|
+
`[CommandManager] Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} globally...`
|
|
2214
|
+
);
|
|
2228
2215
|
try {
|
|
2229
2216
|
await client.rest.put(import_discord8.Routes.applicationCommands(client.user.id), { body: commands });
|
|
2230
|
-
|
|
2217
|
+
console.log(`[CommandManager] \u2714 Registered app ${commands.length === 1 ? "command" : "commands"} globally`);
|
|
2231
2218
|
} catch (err) {
|
|
2232
|
-
|
|
2233
|
-
`Failed to register app ${commands.length === 1 ? "command" : "commands"} globally`,
|
|
2219
|
+
console.error(
|
|
2220
|
+
`[CommandManager] \u2716 Failed to register app ${commands.length === 1 ? "command" : "commands"} globally`,
|
|
2234
2221
|
err
|
|
2235
2222
|
);
|
|
2236
2223
|
}
|
|
@@ -2238,66 +2225,60 @@ var CommandManager = class {
|
|
|
2238
2225
|
async unregisterGlobal() {
|
|
2239
2226
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2240
2227
|
if (!client.rest) {
|
|
2241
|
-
|
|
2228
|
+
console.error(`[CommandManager] \u2716 Failed to remove app commands globally: REST is not initialized`);
|
|
2242
2229
|
return;
|
|
2243
2230
|
}
|
|
2244
2231
|
try {
|
|
2245
2232
|
await client.rest.put(import_discord8.Routes.applicationCommands(client.user.id), { body: [] });
|
|
2246
|
-
|
|
2233
|
+
console.log(`[CommandManager] \u2714 Removed app commands globally`);
|
|
2247
2234
|
} catch (err) {
|
|
2248
|
-
|
|
2235
|
+
console.error(`[CommandManager] \u2716 Failed to remove app commands globally`, err);
|
|
2249
2236
|
}
|
|
2250
2237
|
}
|
|
2251
2238
|
async registerGuild(options = {}) {
|
|
2252
2239
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2253
2240
|
if (!client.rest) {
|
|
2254
|
-
|
|
2241
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
|
|
2255
2242
|
return;
|
|
2256
2243
|
}
|
|
2257
2244
|
const commands = this.getAllAppCommands(options).map((cmd) => cmd.builder.toJSON());
|
|
2258
2245
|
if (!commands.length) {
|
|
2259
|
-
|
|
2246
|
+
console.log("[CommandManager] No commands to register by guild");
|
|
2260
2247
|
return;
|
|
2261
2248
|
}
|
|
2262
2249
|
const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
|
|
2263
|
-
|
|
2264
|
-
`Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} for ${guildIds.length} guilds...`
|
|
2250
|
+
console.log(
|
|
2251
|
+
`[CommandManager] Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} for ${guildIds.length} guilds...`
|
|
2265
2252
|
);
|
|
2266
2253
|
await Promise.all(
|
|
2267
|
-
guildIds.map(
|
|
2268
|
-
|
|
2269
|
-
await client.rest.put(import_discord8.Routes.applicationGuildCommands(client.user.id, guildId), { body: commands });
|
|
2254
|
+
guildIds.map(
|
|
2255
|
+
(guildId) => client.rest.put(import_discord8.Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
|
|
2270
2256
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
2271
|
-
|
|
2272
|
-
`Set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`
|
|
2257
|
+
console.log(
|
|
2258
|
+
`[CommandManager] \u2714 Set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`
|
|
2273
2259
|
);
|
|
2274
|
-
}
|
|
2260
|
+
}).catch((err) => {
|
|
2275
2261
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
2276
|
-
|
|
2277
|
-
`Failed to set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`,
|
|
2262
|
+
console.log(
|
|
2263
|
+
`[CommandManager] \u2716 Failed to set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`,
|
|
2278
2264
|
err
|
|
2279
2265
|
);
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2266
|
+
})
|
|
2267
|
+
)
|
|
2282
2268
|
);
|
|
2283
2269
|
}
|
|
2284
2270
|
async unregisterGuild(options = {}) {
|
|
2285
2271
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2286
2272
|
if (!client.rest) {
|
|
2287
|
-
|
|
2273
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
|
|
2288
2274
|
return;
|
|
2289
2275
|
}
|
|
2290
2276
|
const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
|
|
2291
|
-
|
|
2277
|
+
console.log(`[CommandManager] Unregistering commands from ${guildIds.length} guilds...`);
|
|
2292
2278
|
await Promise.all(
|
|
2293
|
-
guildIds.map(
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
this.logger.success(`Removed app commands in guild: ${guildId}`);
|
|
2297
|
-
} catch (err) {
|
|
2298
|
-
this.logger.error(`Failed to remove app commands in guild: ${guildId}`, err);
|
|
2299
|
-
}
|
|
2300
|
-
})
|
|
2279
|
+
guildIds.map(
|
|
2280
|
+
(guildId) => client.rest.put(import_discord8.Routes.applicationGuildCommands(client.user.id, guildId), { body: [] }).then(() => console.log(`[CommandManager] \u2714 Removed app commands in guild: ${guildId}`)).catch((err) => console.log(`[CommandManager] \u2716 Failed to remove app commands in guild: ${guildId}`, err))
|
|
2281
|
+
)
|
|
2301
2282
|
);
|
|
2302
2283
|
}
|
|
2303
2284
|
};
|
|
@@ -2805,8 +2786,8 @@ var Vimcord = class _Vimcord extends import_discord11.Client {
|
|
|
2805
2786
|
return this.config.app.version;
|
|
2806
2787
|
}
|
|
2807
2788
|
// prettier-ignore
|
|
2808
|
-
set $version(
|
|
2809
|
-
this.config.app.version =
|
|
2789
|
+
set $version(version2) {
|
|
2790
|
+
this.config.app.version = version2;
|
|
2810
2791
|
}
|
|
2811
2792
|
/** Current dev mode state */
|
|
2812
2793
|
// prettier-ignore
|
|
@@ -3668,7 +3649,8 @@ var BetterModal = class _BetterModal {
|
|
|
3668
3649
|
addTextInput(data) {
|
|
3669
3650
|
this.validateComponentLength();
|
|
3670
3651
|
const customId = data.customId ?? this.createComponentId();
|
|
3671
|
-
const
|
|
3652
|
+
const { label: _, ...textInputData } = data;
|
|
3653
|
+
const textInput = new import_discord13.TextInputBuilder({ style: import_discord13.TextInputStyle.Short, required: false, ...textInputData, customId });
|
|
3672
3654
|
const label = this.createLabelComponent(data);
|
|
3673
3655
|
label.setTextInputComponent(textInput);
|
|
3674
3656
|
this.components.set(customId, { textInput: data });
|
|
@@ -4054,7 +4036,7 @@ var Paginator = class {
|
|
|
4054
4036
|
if (disabledNavRow.components.length > 0) {
|
|
4055
4037
|
newComponents.push(disabledNavRow);
|
|
4056
4038
|
}
|
|
4057
|
-
await this.data.message.edit({ components: newComponents });
|
|
4039
|
+
await this.data.message.edit({ components: newComponents }).catch(Boolean);
|
|
4058
4040
|
if (this.options.useReactions) {
|
|
4059
4041
|
await this.nav_removeFromMessage();
|
|
4060
4042
|
}
|
|
@@ -4065,7 +4047,7 @@ var Paginator = class {
|
|
|
4065
4047
|
}
|
|
4066
4048
|
break;
|
|
4067
4049
|
case 2 /* DeleteMessage */:
|
|
4068
|
-
await this.data.message.delete();
|
|
4050
|
+
await this.data.message.delete().catch(Boolean);
|
|
4069
4051
|
break;
|
|
4070
4052
|
case 3 /* DoNothing */:
|
|
4071
4053
|
break;
|
|
@@ -4075,16 +4057,16 @@ var Paginator = class {
|
|
|
4075
4057
|
async nav_removeFromMessage() {
|
|
4076
4058
|
if (!this.data.message?.editable) return;
|
|
4077
4059
|
if (this.options.useReactions) {
|
|
4078
|
-
await this.data.message.reactions.removeAll();
|
|
4060
|
+
await this.data.message.reactions.removeAll().catch(Boolean);
|
|
4079
4061
|
} else {
|
|
4080
4062
|
const newComponents = this.data.message.components.filter((c) => c.type !== import_discord14.ComponentType.Container);
|
|
4081
|
-
await this.data.message.edit({ components: newComponents });
|
|
4063
|
+
await this.data.message.edit({ components: newComponents }).catch(Boolean);
|
|
4082
4064
|
}
|
|
4083
4065
|
}
|
|
4084
4066
|
async nav_addReactions() {
|
|
4085
4067
|
if (!this.data.message || !this.options.useReactions || !this.data.navigation.reactions.length) return;
|
|
4086
4068
|
for (const r of this.data.navigation.reactions) {
|
|
4087
|
-
await this.data.message.react(r.id);
|
|
4069
|
+
await this.data.message.react(r.id).catch(Boolean);
|
|
4088
4070
|
}
|
|
4089
4071
|
}
|
|
4090
4072
|
async collect_components() {
|
|
@@ -4119,7 +4101,7 @@ var Paginator = class {
|
|
|
4119
4101
|
}
|
|
4120
4102
|
switch (i.customId) {
|
|
4121
4103
|
case "ssm_chapterSelect":
|
|
4122
|
-
await i.deferUpdate();
|
|
4104
|
+
await i.deferUpdate().catch(Boolean);
|
|
4123
4105
|
const chapterIndex = this.chapters.findIndex(
|
|
4124
4106
|
(c) => c.id === i.values[0]
|
|
4125
4107
|
);
|
|
@@ -4127,25 +4109,25 @@ var Paginator = class {
|
|
|
4127
4109
|
await this.refresh();
|
|
4128
4110
|
break;
|
|
4129
4111
|
case "btn_first":
|
|
4130
|
-
await i.deferUpdate();
|
|
4112
|
+
await i.deferUpdate().catch(Boolean);
|
|
4131
4113
|
this.callEventStack("first", this.data.page.current, this.data.page.index);
|
|
4132
4114
|
await this.setPage(this.data.page.index.chapter, 0);
|
|
4133
4115
|
await this.refresh();
|
|
4134
4116
|
break;
|
|
4135
4117
|
case "btn_back":
|
|
4136
|
-
await i.deferUpdate();
|
|
4118
|
+
await i.deferUpdate().catch(Boolean);
|
|
4137
4119
|
this.callEventStack("back", this.data.page.current, this.data.page.index);
|
|
4138
4120
|
await this.setPage(this.data.page.index.chapter, this.data.page.index.nested - 1);
|
|
4139
4121
|
await this.refresh();
|
|
4140
4122
|
break;
|
|
4141
4123
|
case "btn_next":
|
|
4142
|
-
await i.deferUpdate();
|
|
4124
|
+
await i.deferUpdate().catch(Boolean);
|
|
4143
4125
|
this.callEventStack("next", this.data.page.current, this.data.page.index);
|
|
4144
4126
|
await this.setPage(this.data.page.index.chapter, this.data.page.index.nested + 1);
|
|
4145
4127
|
await this.refresh();
|
|
4146
4128
|
break;
|
|
4147
4129
|
case "btn_last":
|
|
4148
|
-
await i.deferUpdate();
|
|
4130
|
+
await i.deferUpdate().catch(Boolean);
|
|
4149
4131
|
this.callEventStack("last", this.data.page.current, this.data.page.index);
|
|
4150
4132
|
await this.setPage(
|
|
4151
4133
|
this.data.page.index.chapter,
|