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.js CHANGED
@@ -204,7 +204,6 @@ var BaseCommandBuilder = class {
204
204
  async run(client, ...args) {
205
205
  const config = this.resolveConfig(client);
206
206
  const ctx = this.extractContext(args);
207
- let cancel = false;
208
207
  try {
209
208
  if (!config.enabled) {
210
209
  return await config.onUsedWhenDisabled?.(...args);
@@ -219,16 +218,11 @@ var BaseCommandBuilder = class {
219
218
  if (!await this.checkConditions(config, ...args)) {
220
219
  return await config.onConditionsNotMet?.(...args);
221
220
  }
222
- await config.beforeExecute?.({ cancel: () => cancel = true }, ...args);
223
- if (cancel) return;
221
+ await config.beforeExecute?.(...args);
224
222
  if (config.logExecution !== false) {
225
- const optionsWithName = this.options;
226
- const builderWithName = this;
227
- const cmdName = optionsWithName.name ?? builderWithName.builder?.name ?? "Unknown";
223
+ const cmdName = this.options.name || this.builder?.name || "Unknown";
228
224
  const location = ctx.guild ? `${ctx.guild.name} (${ctx.guild.id})` : "Direct Messages";
229
- if (client.logger) {
230
- client.logger.commandExecuted(cmdName, ctx.user.username, location);
231
- }
225
+ client.logger.commandExecuted(cmdName, ctx.user.username, location);
232
226
  }
233
227
  const result = await config.execute?.(...args);
234
228
  await config.afterExecute?.(result, ...args);
@@ -456,7 +450,9 @@ var Logger = class {
456
450
  extend(extras) {
457
451
  for (const [key, fn] of Object.entries(extras)) {
458
452
  if (typeof fn === "function") {
459
- this[key] = (...args) => fn.call(this, ...args);
453
+ this[key] = function(...args) {
454
+ return fn.call(this, ...args);
455
+ };
460
456
  }
461
457
  }
462
458
  return this;
@@ -826,14 +822,12 @@ var contextCommandHandler = new EventBuilder({
826
822
  if (!command) {
827
823
  const content = `**${interaction.commandName}** is not a registered context command.`;
828
824
  if (interaction.replied || interaction.deferred) {
829
- await interaction.followUp({ content, flags: "Ephemeral" });
830
- } else {
831
- await interaction.reply({ content, flags: "Ephemeral" });
825
+ return interaction.followUp({ content, flags: "Ephemeral" });
832
826
  }
833
- return;
827
+ return interaction.reply({ content, flags: "Ephemeral" });
834
828
  }
835
829
  try {
836
- await command.run(client, client, interaction);
830
+ return await command.run(client, client, interaction);
837
831
  } catch (err) {
838
832
  await client.error.handleCommandError(err, interaction.guild, interaction);
839
833
  }
@@ -892,14 +886,12 @@ var slashCommandHandler = new EventBuilder({
892
886
  if (!command) {
893
887
  const content = `**/\`${interaction.commandName}\`** is not a registered command.`;
894
888
  if (interaction.replied || interaction.deferred) {
895
- await interaction.followUp({ content, flags: "Ephemeral" });
896
- } else {
897
- await interaction.reply({ content, flags: "Ephemeral" });
889
+ return interaction.followUp({ content, flags: "Ephemeral" });
898
890
  }
899
- return;
891
+ return interaction.reply({ content, flags: "Ephemeral" });
900
892
  }
901
893
  try {
902
- await command.run(client, client, interaction);
894
+ return await command.run(client, client, interaction);
903
895
  } catch (err) {
904
896
  await client.error.handleCommandError(err, interaction.guild, interaction);
905
897
  }
@@ -1701,7 +1693,7 @@ var VimcordErrorHandler = class {
1701
1693
  import chalk2 from "chalk";
1702
1694
 
1703
1695
  // package.json
1704
- var version = "1.0.51";
1696
+ var version = "1.0.54";
1705
1697
 
1706
1698
  // src/client/vimcord.logger.ts
1707
1699
  var clientLoggerFactory = (client) => new Logger({ prefixEmoji: "\u26A1", prefix: `vimcord (i${client.clientId})` }).extend({
@@ -1777,11 +1769,9 @@ function getDevMode() {
1777
1769
  }
1778
1770
 
1779
1771
  // src/configs/app.config.ts
1780
- var packageJson = getPackageJson();
1781
- var version2 = typeof packageJson.version === "string" ? packageJson.version : "1.0.0";
1782
1772
  var defaultConfig = {
1783
1773
  name: "Discord Bot",
1784
- version: version2,
1774
+ version: getPackageJson()?.version ?? "1.0.0",
1785
1775
  devMode: getDevMode(),
1786
1776
  verbose: false,
1787
1777
  enableCLI: false,
@@ -2105,16 +2095,11 @@ var CommandManager = class {
2105
2095
  slash;
2106
2096
  prefix;
2107
2097
  context;
2108
- logger;
2109
2098
  constructor(client) {
2110
2099
  this.client = client;
2111
2100
  this.slash = new SlashCommandManager(client);
2112
2101
  this.prefix = new PrefixCommandManager(client);
2113
2102
  this.context = new ContextCommandManager(client);
2114
- this.logger = new Logger({
2115
- prefixEmoji: "\u26A1",
2116
- prefix: `vimcord (i${client.clientId}) [CommandManager]`
2117
- });
2118
2103
  }
2119
2104
  getAllAppCommands(options = {}) {
2120
2105
  return [...this.slash.getAll(options), ...this.context.getAll(options)];
@@ -2122,21 +2107,23 @@ var CommandManager = class {
2122
2107
  async registerGlobal(options = {}) {
2123
2108
  const client = await Vimcord.getReadyInstance(this.client.clientId);
2124
2109
  if (!client.rest) {
2125
- this.logger.error("Failed to register app commands globally: REST is not initialized");
2110
+ console.error(`[CommandManager] \u2716 Failed to register app commands globally: REST is not initialized`);
2126
2111
  return;
2127
2112
  }
2128
2113
  const commands = this.getAllAppCommands(options).map((cmd) => cmd.builder.toJSON());
2129
2114
  if (!commands.length) {
2130
- this.logger.info("No commands to register globally");
2115
+ console.log("[CommandManager] No commands to register globally");
2131
2116
  return;
2132
2117
  }
2133
- this.logger.info(`Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} globally...`);
2118
+ console.log(
2119
+ `[CommandManager] Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} globally...`
2120
+ );
2134
2121
  try {
2135
2122
  await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands });
2136
- this.logger.success(`Registered app ${commands.length === 1 ? "command" : "commands"} globally`);
2123
+ console.log(`[CommandManager] \u2714 Registered app ${commands.length === 1 ? "command" : "commands"} globally`);
2137
2124
  } catch (err) {
2138
- this.logger.error(
2139
- `Failed to register app ${commands.length === 1 ? "command" : "commands"} globally`,
2125
+ console.error(
2126
+ `[CommandManager] \u2716 Failed to register app ${commands.length === 1 ? "command" : "commands"} globally`,
2140
2127
  err
2141
2128
  );
2142
2129
  }
@@ -2144,66 +2131,60 @@ var CommandManager = class {
2144
2131
  async unregisterGlobal() {
2145
2132
  const client = await Vimcord.getReadyInstance(this.client.clientId);
2146
2133
  if (!client.rest) {
2147
- this.logger.error("Failed to remove app commands globally: REST is not initialized");
2134
+ console.error(`[CommandManager] \u2716 Failed to remove app commands globally: REST is not initialized`);
2148
2135
  return;
2149
2136
  }
2150
2137
  try {
2151
2138
  await client.rest.put(Routes.applicationCommands(client.user.id), { body: [] });
2152
- this.logger.success("Removed app commands globally");
2139
+ console.log(`[CommandManager] \u2714 Removed app commands globally`);
2153
2140
  } catch (err) {
2154
- this.logger.error("Failed to remove app commands globally", err);
2141
+ console.error(`[CommandManager] \u2716 Failed to remove app commands globally`, err);
2155
2142
  }
2156
2143
  }
2157
2144
  async registerGuild(options = {}) {
2158
2145
  const client = await Vimcord.getReadyInstance(this.client.clientId);
2159
2146
  if (!client.rest) {
2160
- this.logger.error("Failed to register app commands by guild: REST is not initialized");
2147
+ console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
2161
2148
  return;
2162
2149
  }
2163
2150
  const commands = this.getAllAppCommands(options).map((cmd) => cmd.builder.toJSON());
2164
2151
  if (!commands.length) {
2165
- this.logger.info("No commands to register by guild");
2152
+ console.log("[CommandManager] No commands to register by guild");
2166
2153
  return;
2167
2154
  }
2168
2155
  const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
2169
- this.logger.info(
2170
- `Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} for ${guildIds.length} guilds...`
2156
+ console.log(
2157
+ `[CommandManager] Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} for ${guildIds.length} guilds...`
2171
2158
  );
2172
2159
  await Promise.all(
2173
- guildIds.map(async (guildId) => {
2174
- try {
2175
- await client.rest.put(Routes.applicationGuildCommands(client.user.id, guildId), { body: commands });
2160
+ guildIds.map(
2161
+ (guildId) => client.rest.put(Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
2176
2162
  const gName = client.guilds.cache.get(guildId)?.name || "n/a";
2177
- this.logger.success(
2178
- `Set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`
2163
+ console.log(
2164
+ `[CommandManager] \u2714 Set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`
2179
2165
  );
2180
- } catch (err) {
2166
+ }).catch((err) => {
2181
2167
  const gName = client.guilds.cache.get(guildId)?.name || "n/a";
2182
- this.logger.error(
2183
- `Failed to set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`,
2168
+ console.log(
2169
+ `[CommandManager] \u2716 Failed to set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`,
2184
2170
  err
2185
2171
  );
2186
- }
2187
- })
2172
+ })
2173
+ )
2188
2174
  );
2189
2175
  }
2190
2176
  async unregisterGuild(options = {}) {
2191
2177
  const client = await Vimcord.getReadyInstance(this.client.clientId);
2192
2178
  if (!client.rest) {
2193
- this.logger.error("Failed to unregister app commands by guild: REST is not initialized");
2179
+ console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
2194
2180
  return;
2195
2181
  }
2196
2182
  const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
2197
- this.logger.info(`Unregistering commands from ${guildIds.length} guilds...`);
2183
+ console.log(`[CommandManager] Unregistering commands from ${guildIds.length} guilds...`);
2198
2184
  await Promise.all(
2199
- guildIds.map(async (guildId) => {
2200
- try {
2201
- await client.rest.put(Routes.applicationGuildCommands(client.user.id, guildId), { body: [] });
2202
- this.logger.success(`Removed app commands in guild: ${guildId}`);
2203
- } catch (err) {
2204
- this.logger.error(`Failed to remove app commands in guild: ${guildId}`, err);
2205
- }
2206
- })
2185
+ guildIds.map(
2186
+ (guildId) => client.rest.put(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))
2187
+ )
2207
2188
  );
2208
2189
  }
2209
2190
  };
@@ -2711,8 +2692,8 @@ var Vimcord = class _Vimcord extends Client2 {
2711
2692
  return this.config.app.version;
2712
2693
  }
2713
2694
  // prettier-ignore
2714
- set $version(version3) {
2715
- this.config.app.version = version3;
2695
+ set $version(version2) {
2696
+ this.config.app.version = version2;
2716
2697
  }
2717
2698
  /** Current dev mode state */
2718
2699
  // prettier-ignore
@@ -3501,6 +3482,7 @@ import {
3501
3482
  RoleSelectMenuBuilder,
3502
3483
  StringSelectMenuBuilder,
3503
3484
  TextInputBuilder,
3485
+ TextInputStyle,
3504
3486
  UserSelectMenuBuilder
3505
3487
  } from "discord.js";
3506
3488
  var DEFAULT_CONFIG = {
@@ -3593,7 +3575,8 @@ var BetterModal = class _BetterModal {
3593
3575
  addTextInput(data) {
3594
3576
  this.validateComponentLength();
3595
3577
  const customId = data.customId ?? this.createComponentId();
3596
- const textInput = new TextInputBuilder({ ...data, customId });
3578
+ const { label: _, ...textInputData } = data;
3579
+ const textInput = new TextInputBuilder({ style: TextInputStyle.Short, required: false, ...textInputData, customId });
3597
3580
  const label = this.createLabelComponent(data);
3598
3581
  label.setTextInputComponent(textInput);
3599
3582
  this.components.set(customId, { textInput: data });
@@ -3988,7 +3971,7 @@ var Paginator = class {
3988
3971
  if (disabledNavRow.components.length > 0) {
3989
3972
  newComponents.push(disabledNavRow);
3990
3973
  }
3991
- await this.data.message.edit({ components: newComponents });
3974
+ await this.data.message.edit({ components: newComponents }).catch(Boolean);
3992
3975
  if (this.options.useReactions) {
3993
3976
  await this.nav_removeFromMessage();
3994
3977
  }
@@ -3999,7 +3982,7 @@ var Paginator = class {
3999
3982
  }
4000
3983
  break;
4001
3984
  case 2 /* DeleteMessage */:
4002
- await this.data.message.delete();
3985
+ await this.data.message.delete().catch(Boolean);
4003
3986
  break;
4004
3987
  case 3 /* DoNothing */:
4005
3988
  break;
@@ -4009,16 +3992,16 @@ var Paginator = class {
4009
3992
  async nav_removeFromMessage() {
4010
3993
  if (!this.data.message?.editable) return;
4011
3994
  if (this.options.useReactions) {
4012
- await this.data.message.reactions.removeAll();
3995
+ await this.data.message.reactions.removeAll().catch(Boolean);
4013
3996
  } else {
4014
3997
  const newComponents = this.data.message.components.filter((c) => c.type !== ComponentType2.Container);
4015
- await this.data.message.edit({ components: newComponents });
3998
+ await this.data.message.edit({ components: newComponents }).catch(Boolean);
4016
3999
  }
4017
4000
  }
4018
4001
  async nav_addReactions() {
4019
4002
  if (!this.data.message || !this.options.useReactions || !this.data.navigation.reactions.length) return;
4020
4003
  for (const r of this.data.navigation.reactions) {
4021
- await this.data.message.react(r.id);
4004
+ await this.data.message.react(r.id).catch(Boolean);
4022
4005
  }
4023
4006
  }
4024
4007
  async collect_components() {
@@ -4053,7 +4036,7 @@ var Paginator = class {
4053
4036
  }
4054
4037
  switch (i.customId) {
4055
4038
  case "ssm_chapterSelect":
4056
- await i.deferUpdate();
4039
+ await i.deferUpdate().catch(Boolean);
4057
4040
  const chapterIndex = this.chapters.findIndex(
4058
4041
  (c) => c.id === i.values[0]
4059
4042
  );
@@ -4061,25 +4044,25 @@ var Paginator = class {
4061
4044
  await this.refresh();
4062
4045
  break;
4063
4046
  case "btn_first":
4064
- await i.deferUpdate();
4047
+ await i.deferUpdate().catch(Boolean);
4065
4048
  this.callEventStack("first", this.data.page.current, this.data.page.index);
4066
4049
  await this.setPage(this.data.page.index.chapter, 0);
4067
4050
  await this.refresh();
4068
4051
  break;
4069
4052
  case "btn_back":
4070
- await i.deferUpdate();
4053
+ await i.deferUpdate().catch(Boolean);
4071
4054
  this.callEventStack("back", this.data.page.current, this.data.page.index);
4072
4055
  await this.setPage(this.data.page.index.chapter, this.data.page.index.nested - 1);
4073
4056
  await this.refresh();
4074
4057
  break;
4075
4058
  case "btn_next":
4076
- await i.deferUpdate();
4059
+ await i.deferUpdate().catch(Boolean);
4077
4060
  this.callEventStack("next", this.data.page.current, this.data.page.index);
4078
4061
  await this.setPage(this.data.page.index.chapter, this.data.page.index.nested + 1);
4079
4062
  await this.refresh();
4080
4063
  break;
4081
4064
  case "btn_last":
4082
- await i.deferUpdate();
4065
+ await i.deferUpdate().catch(Boolean);
4083
4066
  this.callEventStack("last", this.data.page.current, this.data.page.index);
4084
4067
  await this.setPage(
4085
4068
  this.data.page.index.chapter,