discord-bot-shared 0.14.4 → 0.15.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/dist/bot.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bot.d.ts","names":[],"sources":["../src/bot.ts"],"sourcesContent":[],"mappings":";;;;;cAMa,GAAA;;EAAA,SAAG,QAAA,EAGY,cAHZ;EAAA,SAAA,MAAA,EAIU,YAJV;aAGY,CAAA,OAAA,EAGE,UAHF;OACF,CAAA,CAAA,EAcF,OAdE,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"bot.d.ts","names":[],"sources":["../src/bot.ts"],"sourcesContent":[],"mappings":";;;;;cAMa,GAAA;;EAAA,SAAG,QAAA,EAGY,cAHZ;EAGY,SAAA,MAAA,EACF,YADE;EACF,WAAA,CAAA,OAAA,EAEI,UAFJ;EAEI,KAAA,CAAA,CAAA,EAYN,OAZM,CAAA,IAAA,CAAA"}
package/dist/bot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bot.js","names":["#discord"],"sources":["../src/bot.ts"],"sourcesContent":["import { Client, Events, REST } from \"discord.js\"\n\nimport { CommandManager } from \"@/command-manager.js\"\nimport { EventManager } from \"@/event-manager.js\"\nimport type { BotOptions, DiscordContext } from \"@/types.js\"\n\nexport class Bot {\n readonly #discord: DiscordContext\n\n public readonly commands: CommandManager\n public readonly events: EventManager\n\n public constructor(options: BotOptions) {\n this.#discord = {\n applicationId: options.applicationId,\n token: options.token,\n client: new Client(options.clientOptions),\n rest: new REST().setToken(options.token),\n }\n\n this.commands = new CommandManager(this.#discord)\n this.events = new EventManager(this.#discord)\n }\n\n public async login(): Promise<void> {\n this.#discord.client.once(Events.ClientReady, () => {\n console.log(\"Client is ready.\")\n })\n\n this.commands._listen()\n this.events._listen()\n await this.#discord.client.login(this.#discord.token)\n }\n}\n"],"mappings":";;;AAMA,IAAa,MAAb,MAAiB;CACf;CAEA;CACA;CAEA,YAAmB,SAAqB;AACtC,QAAA,UAAgB;GACd,eAAe,QAAQ;GACvB,OAAO,QAAQ;GACf,QAAQ,IAAI,OAAO,QAAQ,cAAc;GACzC,MAAM,IAAI,MAAM,CAAC,SAAS,QAAQ,MAAM;GACzC;AAED,OAAK,WAAW,IAAI,eAAe,MAAA,QAAc;AACjD,OAAK,SAAS,IAAI,aAAa,MAAA,QAAc;;CAG/C,MAAa,QAAuB;AAClC,QAAA,QAAc,OAAO,KAAK,OAAO,mBAAmB;AAClD,WAAQ,IAAI,mBAAmB;IAC/B;AAEF,OAAK,SAAS,SAAS;AACvB,OAAK,OAAO,SAAS;AACrB,QAAM,MAAA,QAAc,OAAO,MAAM,MAAA,QAAc,MAAM"}
1
+ {"version":3,"file":"bot.js","names":["#discord"],"sources":["../src/bot.ts"],"sourcesContent":["import { Client, Events, REST } from \"discord.js\"\n\nimport { CommandManager } from \"~/command-manager.ts\"\nimport { EventManager } from \"~/event-manager.ts\"\nimport type { BotOptions, DiscordContext } from \"~/types.ts\"\n\nexport class Bot {\n readonly #discord: DiscordContext\n\n public readonly commands: CommandManager\n public readonly events: EventManager\n\n public constructor(options: BotOptions) {\n this.#discord = {\n applicationId: options.applicationId,\n token: options.token,\n client: new Client(options.clientOptions),\n rest: new REST().setToken(options.token),\n }\n\n this.commands = new CommandManager(this.#discord)\n this.events = new EventManager(this.#discord)\n }\n\n public async login(): Promise<void> {\n this.#discord.client.once(Events.ClientReady, () => {\n console.log(\"Client is ready.\")\n })\n\n this.commands._listen()\n this.events._listen()\n await this.#discord.client.login(this.#discord.token)\n }\n}\n"],"mappings":";;;AAMA,IAAa,MAAb,MAAiB;CACf;CAEA;CACA;CAEA,YAAmB,SAAqB;AACtC,QAAA,UAAgB;GACd,eAAe,QAAQ;GACvB,OAAO,QAAQ;GACf,QAAQ,IAAI,OAAO,QAAQ,cAAc;GACzC,MAAM,IAAI,MAAM,CAAC,SAAS,QAAQ,MAAM;GACzC;AAED,OAAK,WAAW,IAAI,eAAe,MAAA,QAAc;AACjD,OAAK,SAAS,IAAI,aAAa,MAAA,QAAc;;CAG/C,MAAa,QAAuB;AAClC,QAAA,QAAc,OAAO,KAAK,OAAO,mBAAmB;AAClD,WAAQ,IAAI,mBAAmB;IAC/B;AAEF,OAAK,SAAS,SAAS;AACvB,OAAK,OAAO,SAAS;AACrB,QAAM,MAAA,QAAc,OAAO,MAAM,MAAA,QAAc,MAAM"}
@@ -14,9 +14,11 @@ declare class CommandManager {
14
14
  add(command: Command): void;
15
15
  setGlobalCommandHook(commandHook: CommandHook): void;
16
16
  register(): Promise<void>;
17
+ unregister(): Promise<void>;
18
+ registerGuildCommands(): Promise<void>;
19
+ private _registerGuildCommands;
17
20
  unregisterGuildCommands(): Promise<void>;
18
21
  private _unregisterGuildCommands;
19
- unregisterApplicationCommands(): Promise<void>;
20
22
  _listen(): void;
21
23
  private static checkRoles;
22
24
  private static interactionReply;
@@ -1 +1 @@
1
- {"version":3,"file":"command-manager.d.ts","names":[],"sources":["../src/command-manager.ts"],"sourcesContent":[],"mappings":";;;;UAYiB,OAAA;;EAAA,OAAA,EAEN,+CAFa;EAAA,GAAA,EAAA,CAAA,WAAA,EAGH,2BAHG,CAAA,QAAA,CAAA,EAAA,GAAA,IAAA,GAG8C,OAH9C,CAAA,IAAA,CAAA;;AAGH,KAGT,WAAA,GAHS,CAAA,WAAA,EAGmB,2BAHnB,CAAA,QAAA,CAAA,EAAA,GAAA,OAAA,GAGuE,OAHvE,CAAA,OAAA,CAAA;AAAiD,cAKzD,cAAA,CALyD;EAAO,CAAA,OAAA;EAGjE,WAAA,CAAA,OAAW,EAOO,cAPP;EAAA,GAAA,CAAA,OAAA,EAcD,OAdC,CAAA,EAAA,IAAA;sBAAiB,CAAA,WAAA,EAkBG,WAlBH,CAAA,EAAA,IAAA;UAAoD,CAAA,CAAA,EAsBjE,OAtBiE,CAAA,IAAA,CAAA;EAAO,uBAAA,CAAA,CAAA,EA8BzD,OA9ByD,CAAA,IAAA,CAAA;EAEtF,QAAA,wBAAc;EAAA,6BAAA,CAAA,CAAA,EAuDqB,OAvDrB,CAAA,IAAA,CAAA;SAKG,CAAA,CAAA,EAAA,IAAA;iBAOR,UAAA;iBAIqB,gBAAA"}
1
+ {"version":3,"file":"command-manager.d.ts","names":[],"sources":["../src/command-manager.ts"],"sourcesContent":[],"mappings":";;;;UAYiB,OAAA;;EAAA,OAAA,EAEN,+CAFa;EAEb,GAAA,EAAA,CAAA,WAAA,EACU,2BADV,CAAA,QAAA,CAAA,EAAA,GAAA,IAAA,GAC2D,OAD3D,CAAA,IAAA,CAAA;;AAC2D,KAG1D,WAAA,GAH0D,CAAA,WAAA,EAG9B,2BAH8B,CAAA,QAAA,CAAA,EAAA,GAAA,OAAA,GAGsB,OAHtB,CAAA,OAAA,CAAA;AAAO,cAKhE,cAAA,CALgE;EAGjE,CAAA,OAAA;EAEC,WAAA,CAAA,OAAc,EAKG,cALH;EAKG,GAAA,CAAA,OAAA,EAOR,OAPQ,CAAA,EAAA,IAAA;EAOR,oBAAA,CAAA,WAAA,EAIqB,WAJrB,CAAA,EAAA,IAAA;EAIqB,QAAA,CAAA,CAAA,EAIhB,OAJgB,CAAA,IAAA,CAAA;EAIhB,UAAA,CAAA,CAAA,EAQE,OARF,CAAA,IAAA,CAAA;EAQE,qBAAA,CAAA,CAAA,EAOO,OAPP,CAAA,IAAA,CAAA;EAOO,QAAA,sBAAA;EA6BM,uBAAA,CAAA,CAAA,EAAA,OAAA,CAAA,IAAA,CAAA;EAAO,QAAA,wBAAA"}
@@ -14,10 +14,39 @@ var CommandManager = class CommandManager {
14
14
  this.#globalCommandHook = commandHook;
15
15
  }
16
16
  async register() {
17
- const payload = this.#commands.map((c) => c.command);
17
+ const commandPayload = this.#commands.map((c) => c.command);
18
18
  const route = Routes.applicationCommands(this.#discord.applicationId);
19
- await this.#discord.rest.put(route, { body: payload });
20
- console.log(`Registered ${this.#commands.size.toString()} (/) commands.`);
19
+ await this.#discord.rest.put(route, { body: commandPayload });
20
+ console.log(`Globally registered ${this.#commands.size.toString()} (/) commands.`);
21
+ }
22
+ async unregister() {
23
+ const route = Routes.applicationCommands(this.#discord.applicationId);
24
+ await this.#discord.rest.put(route, { body: [] });
25
+ console.log("Unregistered global commands.");
26
+ }
27
+ async registerGuildCommands() {
28
+ if (this.#discord.client.readyAt) await this._registerGuildCommands();
29
+ else this.#discord.client.once(Events.ClientReady, () => void this._registerGuildCommands());
30
+ }
31
+ async _registerGuildCommands() {
32
+ let guilds;
33
+ try {
34
+ guilds = await this.#discord.client.guilds.fetch();
35
+ } catch (error) {
36
+ console.error("Unable to register guild commands. Failed to fetch guilds.");
37
+ throw error;
38
+ }
39
+ const commandPayload = this.#commands.map((c) => c.command);
40
+ const registerPromises = [];
41
+ for (const guild of guilds.values()) {
42
+ const route = Routes.applicationGuildCommands(this.#discord.applicationId, guild.id);
43
+ const registerCommandsInGuild = async () => {
44
+ await this.#discord.rest.put(route, { body: commandPayload });
45
+ console.log(`Registered ${this.#commands.size.toString()} (/) commands in guild: ${guild.name}`);
46
+ };
47
+ registerPromises.push(registerCommandsInGuild());
48
+ }
49
+ await Promise.all(registerPromises);
21
50
  }
22
51
  async unregisterGuildCommands() {
23
52
  if (this.#discord.client.readyAt) await this._unregisterGuildCommands();
@@ -34,19 +63,14 @@ var CommandManager = class CommandManager {
34
63
  const unregisterPromises = [];
35
64
  for (const guild of guilds.values()) {
36
65
  const route = Routes.applicationGuildCommands(this.#discord.applicationId, guild.id);
37
- const unregisterGuildCommands = async () => {
66
+ const unregister = async () => {
38
67
  await this.#discord.rest.put(route, { body: [] });
39
68
  console.log(`Unregistered commands from guild: ${guild.name}`);
40
69
  };
41
- unregisterPromises.push(unregisterGuildCommands());
70
+ unregisterPromises.push(unregister());
42
71
  }
43
72
  await Promise.all(unregisterPromises);
44
73
  }
45
- async unregisterApplicationCommands() {
46
- const route = Routes.applicationCommands(this.#discord.applicationId);
47
- await this.#discord.rest.put(route, { body: [] });
48
- console.log("Unregistered application commands.");
49
- }
50
74
  _listen() {
51
75
  const listen = async (interaction) => {
52
76
  if (!interaction.isChatInputCommand()) return;
@@ -1 +1 @@
1
- {"version":3,"file":"command-manager.js","names":["#commands","#discord","#globalCommandHook","guilds: Collection<Snowflake, OAuth2Guild>","unregisterPromises: Promise<void>[]","errorMessage: string"],"sources":["../src/command-manager.ts"],"sourcesContent":["import type {\n ChatInputCommandInteraction,\n Interaction,\n OAuth2Guild,\n RESTPostAPIChatInputApplicationCommandsJSONBody,\n Snowflake,\n} from \"discord.js\"\nimport { Collection, Events, MessageFlags, Routes } from \"discord.js\"\n\nimport type { DiscordContext } from \"@/types.js\"\nimport { throwUserError, UserError } from \"@/util.js\"\n\nexport interface Command {\n requiredRoles?: string[]\n command: RESTPostAPIChatInputApplicationCommandsJSONBody\n run: (interaction: ChatInputCommandInteraction<\"cached\">) => void | Promise<void>\n}\n\nexport type CommandHook = (interaction: ChatInputCommandInteraction<\"cached\">) => boolean | Promise<boolean>\n\nexport class CommandManager {\n readonly #commands = new Collection<string, Command>()\n #globalCommandHook?: CommandHook\n readonly #discord: DiscordContext\n\n public constructor(discord: DiscordContext) {\n this.#discord = discord\n }\n\n /*\n * Add a command\n */\n public add(command: Command): void {\n this.#commands.set(command.command.name, command)\n }\n\n public setGlobalCommandHook(commandHook: CommandHook): void {\n this.#globalCommandHook = commandHook\n }\n\n public async register(): Promise<void> {\n const payload = this.#commands.map((c) => c.command)\n const route = Routes.applicationCommands(this.#discord.applicationId)\n await this.#discord.rest.put(route, { body: payload })\n\n console.log(`Registered ${this.#commands.size.toString()} (/) commands.`)\n }\n\n public async unregisterGuildCommands(): Promise<void> {\n if (this.#discord.client.readyAt) await this._unregisterGuildCommands()\n else this.#discord.client.once(Events.ClientReady, () => void this._unregisterGuildCommands())\n }\n\n private async _unregisterGuildCommands(): Promise<void> {\n let guilds: Collection<Snowflake, OAuth2Guild>\n try {\n guilds = await this.#discord.client.guilds.fetch()\n } catch (error) {\n console.error(\"Unable to unregister guild commands. Failed to fetch guilds.\")\n throw error\n }\n\n const unregisterPromises: Promise<void>[] = []\n for (const guild of guilds.values()) {\n const route = Routes.applicationGuildCommands(this.#discord.applicationId, guild.id)\n const unregisterGuildCommands = async () => {\n await this.#discord.rest.put(route, { body: [] })\n console.log(`Unregistered commands from guild: ${guild.name}`)\n }\n unregisterPromises.push(unregisterGuildCommands())\n }\n\n await Promise.all(unregisterPromises)\n }\n\n public async unregisterApplicationCommands(): Promise<void> {\n const route = Routes.applicationCommands(this.#discord.applicationId)\n await this.#discord.rest.put(route, { body: [] })\n console.log(\"Unregistered application commands.\")\n }\n\n public _listen(): void {\n const listen = async (interaction: Interaction) => {\n if (!interaction.isChatInputCommand()) return\n if (!interaction.guildId) return\n if (!interaction.inCachedGuild()) await interaction.client.guilds.fetch(interaction.guildId).catch(console.error)\n if (!interaction.inCachedGuild()) {\n CommandManager.interactionReply(interaction, \"Guild is not cached. Try again.\")\n return\n }\n\n const command = this.#commands.get(interaction.commandName)\n if (!command) {\n CommandManager.interactionReply(interaction, `Failed to get command with name: ${interaction.commandName}`)\n return\n }\n\n if (!(await CommandManager.checkRoles(command, interaction))) {\n CommandManager.interactionReply(interaction, \"You do not have one of the required roles to run this command.\")\n return\n }\n\n try {\n const shouldContinue = this.#globalCommandHook ? await this.#globalCommandHook(interaction) : true\n if (!shouldContinue) throwUserError(\"The global command hook returned false.\")\n\n await command.run(interaction)\n } catch (error) {\n CommandManager.interactionReply(interaction, error)\n }\n }\n\n this.#discord.client.on(Events.InteractionCreate, (interaction) => void listen(interaction))\n console.log(\"Listening for commands.\")\n }\n\n private static async checkRoles(command: Command, interaction: ChatInputCommandInteraction<\"cached\">) {\n if (!command.requiredRoles) return true\n\n if (command.requiredRoles.length > 0) {\n const member = await interaction.guild.members.fetch(interaction.user).catch(console.error)\n if (!member) return false\n\n return member.roles.cache.some((role) =>\n command.requiredRoles ? command.requiredRoles.includes(role.name) : false,\n )\n }\n\n return false\n }\n\n private static interactionReply(interaction: ChatInputCommandInteraction, error: unknown) {\n let errorMessage: string\n if (error instanceof UserError) errorMessage = error.message\n else if (error instanceof Error && error.stack) errorMessage = error.stack\n else errorMessage = String(error)\n\n const message = `There was an error while running this command.\\n\\`\\`\\`${errorMessage}\\`\\`\\``\n const handleInteractionReply = async () => {\n await (interaction.deferred\n ? interaction.editReply(message).catch(console.error)\n : interaction.reply({ content: message, flags: MessageFlags.Ephemeral }).catch(console.error))\n }\n void handleInteractionReply()\n }\n}\n"],"mappings":";;AAoBA,IAAa,iBAAb,MAAa,eAAe;CAC1B,YAAqB,IAAI,YAA6B;CACtD;CACA;CAEA,YAAmB,SAAyB;AAC1C,QAAA,UAAgB;;CAMlB,IAAW,SAAwB;AACjC,QAAA,SAAe,IAAI,QAAQ,QAAQ,MAAM,QAAQ;;CAGnD,qBAA4B,aAAgC;AAC1D,QAAA,oBAA0B;;CAG5B,MAAa,WAA0B;EACrC,MAAM,UAAU,MAAA,SAAe,KAAK,MAAM,EAAE,QAAQ;EACpD,MAAM,QAAQ,OAAO,oBAAoB,MAAA,QAAc,cAAc;AACrE,QAAM,MAAA,QAAc,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAEtD,UAAQ,IAAI,cAAc,MAAA,SAAe,KAAK,UAAU,CAAC,gBAAgB;;CAG3E,MAAa,0BAAyC;AACpD,MAAI,MAAA,QAAc,OAAO,QAAS,OAAM,KAAK,0BAA0B;MAClE,OAAA,QAAc,OAAO,KAAK,OAAO,mBAAmB,KAAK,KAAK,0BAA0B,CAAC;;CAGhG,MAAc,2BAA0C;EACtD,IAAIG;AACJ,MAAI;AACF,YAAS,MAAM,MAAA,QAAc,OAAO,OAAO,OAAO;WAC3C,OAAO;AACd,WAAQ,MAAM,+DAA+D;AAC7E,SAAM;;EAGR,MAAMC,qBAAsC,EAAE;AAC9C,OAAK,MAAM,SAAS,OAAO,QAAQ,EAAE;GACnC,MAAM,QAAQ,OAAO,yBAAyB,MAAA,QAAc,eAAe,MAAM,GA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SAAkB,aAAoD;AACpG,MAAI,CAAC,QAAQ,cAAe,QAAO;AAEnC,MAAI,QAAQ,cAAc,SAAS,GAAG;GACpC,MAAM,SAAS,MAAM,YAAY,MAAM,QAAQ,MAAM,YAAY,KAAK,CAAC,MAAM,QAAQ,MAAM;AAC3F,OAAI,CAAC,OAAQ,QAAO;AAEpB,UAAO,OAAO,MAAM,MAAM,MAAM,SAC9B,QAAQ,gBAAgB,QAAQ,cAAc,SAAS,KAAK,KAAK,GAAG,MACrE;;AAGH,SAAO;;CAGT,OAAe,iBAAiB,aAA0C,OAAgB;EACxF,IAAIC;AACJ,MAAI,iBAAiB,UAAW,gBAAe,MAAM;WAC5C,iBAAiB,SAAS,MAAM,MAAO,gBAAe,MAAM;MAChE,gBAAe,OAAO,MAAM;EAEjC,MAAM,UAAU,yDAAyD,aAAa;EACtF,MAAM,yBAAyB,YAAY;AACzC,UAAO,YAAY,WACf,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM,GACnD,YAAY,MAAM;IAAE,SAAS;IAAS,OAAO,aAAa;IAAW,CAAC,CAAC,MAAM,QAAQ,MAAM;;AAE5F,0BAAwB"}
1
+ {"version":3,"file":"command-manager.js","names":["#commands","#discord","#globalCommandHook","guilds: Collection<Snowflake, OAuth2Guild>","registerPromises: Promise<void>[]","unregisterPromises: Promise<void>[]","errorMessage: string"],"sources":["../src/command-manager.ts"],"sourcesContent":["import type {\n ChatInputCommandInteraction,\n Interaction,\n OAuth2Guild,\n RESTPostAPIChatInputApplicationCommandsJSONBody,\n Snowflake,\n} from \"discord.js\"\nimport { Collection, Events, MessageFlags, Routes } from \"discord.js\"\n\nimport type { DiscordContext } from \"~/types.ts\"\nimport { throwUserError, UserError } from \"~/util.ts\"\n\nexport interface Command {\n requiredRoles?: string[]\n command: RESTPostAPIChatInputApplicationCommandsJSONBody\n run: (interaction: ChatInputCommandInteraction<\"cached\">) => void | Promise<void>\n}\n\nexport type CommandHook = (interaction: ChatInputCommandInteraction<\"cached\">) => boolean | Promise<boolean>\n\nexport class CommandManager {\n readonly #commands = new Collection<string, Command>()\n #globalCommandHook?: CommandHook\n readonly #discord: DiscordContext\n\n public constructor(discord: DiscordContext) {\n this.#discord = discord\n }\n\n /*\n * Add a command\n */\n public add(command: Command): void {\n this.#commands.set(command.command.name, command)\n }\n\n public setGlobalCommandHook(commandHook: CommandHook): void {\n this.#globalCommandHook = commandHook\n }\n\n public async register(): Promise<void> {\n const commandPayload = this.#commands.map((c) => c.command)\n const route = Routes.applicationCommands(this.#discord.applicationId)\n await this.#discord.rest.put(route, { body: commandPayload })\n\n console.log(`Globally registered ${this.#commands.size.toString()} (/) commands.`)\n }\n\n public async unregister(): Promise<void> {\n const route = Routes.applicationCommands(this.#discord.applicationId)\n await this.#discord.rest.put(route, { body: [] })\n console.log(\"Unregistered global commands.\")\n }\n\n // We can't fetch guilds before the client is ready.\n public async registerGuildCommands() {\n if (this.#discord.client.readyAt) await this._registerGuildCommands()\n else this.#discord.client.once(Events.ClientReady, () => void this._registerGuildCommands())\n }\n\n private async _registerGuildCommands(): Promise<void> {\n let guilds: Collection<Snowflake, OAuth2Guild>\n try {\n guilds = await this.#discord.client.guilds.fetch()\n } catch (error) {\n console.error(\"Unable to register guild commands. Failed to fetch guilds.\")\n throw error\n }\n\n const commandPayload = this.#commands.map((c) => c.command)\n\n const registerPromises: Promise<void>[] = []\n for (const guild of guilds.values()) {\n const route = Routes.applicationGuildCommands(this.#discord.applicationId, guild.id)\n const registerCommandsInGuild = async () => {\n await this.#discord.rest.put(route, { body: commandPayload })\n console.log(`Registered ${this.#commands.size.toString()} (/) commands in guild: ${guild.name}`)\n }\n registerPromises.push(registerCommandsInGuild())\n }\n\n await Promise.all(registerPromises)\n }\n\n public async unregisterGuildCommands(): Promise<void> {\n if (this.#discord.client.readyAt) await this._unregisterGuildCommands()\n else this.#discord.client.once(Events.ClientReady, () => void this._unregisterGuildCommands())\n }\n\n private async _unregisterGuildCommands(): Promise<void> {\n let guilds: Collection<Snowflake, OAuth2Guild>\n try {\n guilds = await this.#discord.client.guilds.fetch()\n } catch (error) {\n console.error(\"Unable to unregister guild commands. Failed to fetch guilds.\")\n throw error\n }\n\n const unregisterPromises: Promise<void>[] = []\n for (const guild of guilds.values()) {\n const route = Routes.applicationGuildCommands(this.#discord.applicationId, guild.id)\n const unregister = async () => {\n await this.#discord.rest.put(route, { body: [] })\n console.log(`Unregistered commands from guild: ${guild.name}`)\n }\n unregisterPromises.push(unregister())\n }\n\n await Promise.all(unregisterPromises)\n }\n\n public _listen(): void {\n const listen = async (interaction: Interaction) => {\n if (!interaction.isChatInputCommand()) return\n if (!interaction.guildId) return\n if (!interaction.inCachedGuild()) await interaction.client.guilds.fetch(interaction.guildId).catch(console.error)\n if (!interaction.inCachedGuild()) {\n CommandManager.interactionReply(interaction, \"Guild is not cached. Try again.\")\n return\n }\n\n const command = this.#commands.get(interaction.commandName)\n if (!command) {\n CommandManager.interactionReply(interaction, `Failed to get command with name: ${interaction.commandName}`)\n return\n }\n\n if (!(await CommandManager.checkRoles(command, interaction))) {\n CommandManager.interactionReply(interaction, \"You do not have one of the required roles to run this command.\")\n return\n }\n\n try {\n const shouldContinue = this.#globalCommandHook ? await this.#globalCommandHook(interaction) : true\n if (!shouldContinue) throwUserError(\"The global command hook returned false.\")\n\n await command.run(interaction)\n } catch (error) {\n CommandManager.interactionReply(interaction, error)\n }\n }\n\n this.#discord.client.on(Events.InteractionCreate, (interaction) => void listen(interaction))\n console.log(\"Listening for commands.\")\n }\n\n private static async checkRoles(command: Command, interaction: ChatInputCommandInteraction<\"cached\">) {\n if (!command.requiredRoles) return true\n\n if (command.requiredRoles.length > 0) {\n const member = await interaction.guild.members.fetch(interaction.user).catch(console.error)\n if (!member) return false\n\n return member.roles.cache.some((role) =>\n command.requiredRoles ? command.requiredRoles.includes(role.name) : false,\n )\n }\n\n return false\n }\n\n private static interactionReply(interaction: ChatInputCommandInteraction, error: unknown) {\n let errorMessage: string\n if (error instanceof UserError) errorMessage = error.message\n else if (error instanceof Error && error.stack) errorMessage = error.stack\n else errorMessage = String(error)\n\n const message = `There was an error while running this command.\\n\\`\\`\\`${errorMessage}\\`\\`\\``\n const handleInteractionReply = async () => {\n await (interaction.deferred\n ? interaction.editReply(message).catch(console.error)\n : interaction.reply({ content: message, flags: MessageFlags.Ephemeral }).catch(console.error))\n }\n void handleInteractionReply()\n }\n}\n"],"mappings":";;AAoBA,IAAa,iBAAb,MAAa,eAAe;CAC1B,YAAqB,IAAI,YAA6B;CACtD;CACA;CAEA,YAAmB,SAAyB;AAC1C,QAAA,UAAgB;;CAMlB,IAAW,SAAwB;AACjC,QAAA,SAAe,IAAI,QAAQ,QAAQ,MAAM,QAAQ;;CAGnD,qBAA4B,aAAgC;AAC1D,QAAA,oBAA0B;;CAG5B,MAAa,WAA0B;EACrC,MAAM,iBAAiB,MAAA,SAAe,KAAK,MAAM,EAAE,QAAQ;EAC3D,MAAM,QAAQ,OAAO,oBAAoB,MAAA,QAAc,cAAc;AACrE,QAAM,MAAA,QAAc,KAAK,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE7D,UAAQ,IAAI,uBAAuB,MAAA,SAAe,KAAK,UAAU,CAAC,gBAAgB;;CAGpF,MAAa,aAA4B;EACvC,MAAM,QAAQ,OAAO,oBAAoB,MAAA,QAAc,cAAc;AACrE,QAAM,MAAA,QAAc,KAAK,IAAI,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;AACjD,UAAQ,IAAI,gCAAgC;;CAI9C,MAAa,wBAAwB;AACnC,MAAI,MAAA,QAAc,OAAO,QAAS,OAAM,KAAK,wBAAwB;MAChE,OAAA,QAAc,OAAO,KAAK,OAAO,mBAAmB,KAAK,KAAK,wBAAwB,CAAC;;CAG9F,MAAc,yBAAwC;EACpD,IAAIG;AACJ,MAAI;AACF,YAAS,MAAM,MAAA,QAAc,OAAO,OAAO,OAAO;WAC3C,OAAO;AACd,WAAQ,MAAM,6DAA6D;AAC3E,SAAM;;EA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Y;AACzC,UAAO,YAAY,WACf,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM,GACnD,YAAY,MAAM;IAAE,SAAS;IAAS,OAAO,aAAa;IAAW,CAAC,CAAC,MAAM,QAAQ,MAAM;;AAE5F,0BAAwB"}
@@ -3,11 +3,11 @@ import { Client, ClientEvents } from "discord.js";
3
3
 
4
4
  //#region src/event-manager.d.ts
5
5
  type ValidEvents = keyof ClientEvents;
6
- type EventHandler<E extends ValidEvents = ValidEvents> = (client: Client, ...args: ClientEvents[E]) => void | Promise<void>;
6
+ type EventHandler<E$1 extends ValidEvents = ValidEvents> = (client: Client, ...args: ClientEvents[E$1]) => void | Promise<void>;
7
7
  type EventHandlerMap = { [E in ValidEvents]: EventHandler<E> };
8
- interface SingleEvent<E extends ValidEvents = ValidEvents> {
9
- event: E;
10
- handler: EventHandlerMap[E];
8
+ interface SingleEvent<E$1 extends ValidEvents = ValidEvents> {
9
+ event: E$1;
10
+ handler: EventHandlerMap[E$1];
11
11
  }
12
12
  declare class EventManager {
13
13
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"event-manager.d.ts","names":[],"sources":["../src/event-manager.ts"],"sourcesContent":[],"mappings":";;;;KAIK,WAAA,SAAoB;KAEpB,uBAAuB,cAAc,wBAChC,iBACC,aAAa,cACZ;AAPoC,KAS3C,eAAA,GAPW,QAQR,WANS,GAMK,YANL,CAMkB,CANlB,CAAA,EAAA;UASP,WATkB,CAAA,UASI,WATJ,GASkB,WATlB,CAAA,CAAA;OAAc,EAUjC,CAViC;SAChC,EAUC,eAVD,CAUiB,CAVjB,CAAA;;AACc,cAYX,YAAA,CAZW;UACZ;EAAO,WAAA,CAAA,OAAA,EAeW,cAfX;EAEd,GAAA,CAAA,UAoBkB,WApBH,CAAA,CAAA,KAAA,EAoBuB,WApBvB,CAoBmC,CApBnC,CAAA,CAAA,EAAA,IAAA;EAAA,OAAA,CAAA,CAAA,EAAA,IAAA;;AACe,KAyCvB,KAAA,GAzCuB,QA0C3B,WA1Cc,GA0CA,WA1CA,CA0CY,CA1CZ,CAAA,EAAY,CA2ChC,WA3CgC,CAAA"}
1
+ {"version":3,"file":"event-manager.d.ts","names":[],"sources":["../src/event-manager.ts"],"sourcesContent":[],"mappings":";;;;KAIK,WAAA,SAAoB;KAEpB,yBAAuB,cAAc,wBAChC,iBACC,aAAa,gBACZ;AAPoC,KAS3C,eAAA,GAPW,QAQR,WANS,GAMK,YANL,CAMkB,CANlB,CAAA,EAAW;UASlB,WATgC,CAAA,YASV,WATU,GASI,WATJ,CAAA,CAAA;EAChC,KAAA,EASD,GATC;EACC,OAAA,EASA,eATA,CASgB,GAThB,CAAA;;AACC,cAWC,YAAA,CAXD;EAAO,CAAA,OAAA;EAEd,WAAA,CAAA,OAAe,EAaU,cAbV;EACZ,GAAA,CAAA,UAmBe,WAnBf,CAAA,CAAA,KAAA,EAmBmC,WAnBnC,CAmB+C,CAnB/C,CAAA,CAAA,EAAA,IAAA;EAA2B,OAAA,CAAA,CAAA,EAAA,IAAA;;AAAD,KAuCtB,KAAA,GAvCsB,QAwC1B,WArCa,GAqCC,WArCD,CAqCa,CArCb,CAAA,EAAW,CAsC9B,WAtC8B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"event-manager.js","names":["#events","#discord"],"sources":["../src/event-manager.ts"],"sourcesContent":["import type { Client, ClientEvents } from \"discord.js\"\n\nimport type { DiscordContext } from \"@/types.js\"\n\ntype ValidEvents = keyof ClientEvents\n\ntype EventHandler<E extends ValidEvents = ValidEvents> = (\n client: Client,\n ...args: ClientEvents[E]\n) => void | Promise<void>\n\ntype EventHandlerMap = {\n [E in ValidEvents]: EventHandler<E>\n}\n\ninterface SingleEvent<E extends ValidEvents = ValidEvents> {\n event: E\n handler: EventHandlerMap[E]\n}\n\nexport class EventManager {\n readonly #events: SingleEvent[] = []\n readonly #discord: DiscordContext\n\n public constructor(discord: DiscordContext) {\n this.#discord = discord\n }\n\n /*\n * Add an event listener\n */\n public add<N extends ValidEvents>(event: SingleEvent<N>): void {\n this.#events.push(event)\n }\n\n public _listen(): void {\n for (const event of this.#events) {\n const listen = async (...args: ClientEvents[typeof event.event]) => {\n try {\n // TS Error: Expression produces a union type that is too complex to represent.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n await (event.handler as EventHandler)(this.#discord.client, ...args)\n } catch (error) {\n console.error(error)\n }\n }\n\n this.#discord.client.on(event.event, (...args) => void listen(...args))\n }\n console.log(`Listening for (${this.#events.length.toString()}) events.`)\n }\n}\n\nexport type Event = {\n [E in ValidEvents]: SingleEvent<E>\n}[ValidEvents]\n"],"mappings":"AAoBA,IAAa,eAAb,MAA0B;CACxB,UAAkC,EAAE;CACpC;CAEA,YAAmB,SAAyB;AAC1C,QAAA,UAAgB;;CAMlB,IAAkC,OAA6B;AAC7D,QAAA,OAAa,KAAK,MAAM;;CAG1B,UAAuB;AACrB,OAAK,MAAM,SAAS,MAAA,QAAc;GAChC,MAAM,SAAS,OAAO,GAAG,SAA2C;AAClE,QAAI;AAGF,WAAO,MAAM,QAAyB,MAAA,QAAc,QAAQ,GAAG,KAAK;aAC7D,OAAO;AACd,aAAQ,MAAM,MAAM;;;AAIxB,SAAA,QAAc,OAAO,GAAG,MAAM,QAAQ,GAAG,SAAS,KAAK,OAAO,GAAG,KAAK,CAAC;;AAEzE,UAAQ,IAAI,kBAAkB,MAAA,OAAa,OAAO,UAAU,CAAC,WAAW"}
1
+ {"version":3,"file":"event-manager.js","names":["#events","#discord"],"sources":["../src/event-manager.ts"],"sourcesContent":["import type { Client, ClientEvents } from \"discord.js\"\n\nimport type { DiscordContext } from \"~/types.ts\"\n\ntype ValidEvents = keyof ClientEvents\n\ntype EventHandler<E extends ValidEvents = ValidEvents> = (\n client: Client,\n ...args: ClientEvents[E]\n) => void | Promise<void>\n\ntype EventHandlerMap = {\n [E in ValidEvents]: EventHandler<E>\n}\n\ninterface SingleEvent<E extends ValidEvents = ValidEvents> {\n event: E\n handler: EventHandlerMap[E]\n}\n\nexport class EventManager {\n readonly #events: SingleEvent[] = []\n readonly #discord: DiscordContext\n\n public constructor(discord: DiscordContext) {\n this.#discord = discord\n }\n\n /*\n * Add an event listener\n */\n public add<N extends ValidEvents>(event: SingleEvent<N>): void {\n this.#events.push(event)\n }\n\n public _listen(): void {\n for (const event of this.#events) {\n const listen = async (...args: ClientEvents[typeof event.event]) => {\n try {\n await (event.handler as EventHandler)(this.#discord.client, ...args)\n } catch (error) {\n console.error(error)\n }\n }\n\n this.#discord.client.on(event.event, (...args) => void listen(...args))\n }\n console.log(`Listening for (${this.#events.length.toString()}) events.`)\n }\n}\n\nexport type Event = {\n [E in ValidEvents]: SingleEvent<E>\n}[ValidEvents]\n"],"mappings":"AAoBA,IAAa,eAAb,MAA0B;CACxB,UAAkC,EAAE;CACpC;CAEA,YAAmB,SAAyB;AAC1C,QAAA,UAAgB;;CAMlB,IAAkC,OAA6B;AAC7D,QAAA,OAAa,KAAK,MAAM;;CAG1B,UAAuB;AACrB,OAAK,MAAM,SAAS,MAAA,QAAc;GAChC,MAAM,SAAS,OAAO,GAAG,SAA2C;AAClE,QAAI;AACF,WAAO,MAAM,QAAyB,MAAA,QAAc,QAAQ,GAAG,KAAK;aAC7D,OAAO;AACd,aAAQ,MAAM,MAAM;;;AAIxB,SAAA,QAAc,OAAO,GAAG,MAAM,QAAQ,GAAG,SAAS,KAAK,OAAO,GAAG,KAAK,CAAC;;AAEzE,UAAQ,IAAI,kBAAkB,MAAA,OAAa,OAAO,UAAU,CAAC,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,UAAA;;EAAA,KAAA,EAAA,MAAU;EAMV,aAAA,EAHA,aAGc;;AAGrB,UAHO,cAAA,CAGP;eACF,EAAA,MAAA;EAAI,KAAA,EAAA,MAAA;UADF;QACF"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,UAAA;;EAAA,KAAA,EAAA,MAAU;EAMV,aAAA,EAHA,aAGc;;UAAd,cAAA;;;UAGP;QACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","names":[],"sources":["../src/util.ts"],"sourcesContent":[],"mappings":";;;UAYU,uBAAA;GACP,WAAA,CAAY,aAAA,GAAgB;EADrB,CAEP,WAAA,CAAY,iBAAA,CAFkB,EAEE,WAFF;EAAA,CAG9B,WAAA,CAAY,eAAA,CAHkB,EAGA,YAHA;GAI9B,WAAA,CAAY,SAAA,CAHgB,EAGJ,WAHI;GAI5B,WAAA,CAAY,UAAA,CAJA,EAIa,YAJb;GAKZ,WAAA,CAAY,UAAA,CAJoB,EAIP,YAJO;;;;;;;;;;;AAyBnC;;;;;;;;;AAyBgB,iBAzBM,UAyBI,CAAA,UAAA,MAzBuB,uBAyBvB,CAAA,CAAA,KAAA,EAxBjB,KAwBiB,EAAA,eAAA,EAAA,MAAA,EAAA,WAAA,EAtBX,CAsBW,CAAA,EArBvB,OAqBuB,CArBf,uBAqBe,CArBS,CAqBT,CAAA,CAAA;AAU1B;;;;;;iBAVgB,UAAA;;;;;;;iBAUA,cAAA"}
1
+ {"version":3,"file":"util.d.ts","names":[],"sources":["../src/util.ts"],"sourcesContent":[],"mappings":";;;UAYU,uBAAA;GACP,WAAA,CAAY,aAAA,GAAgB;EADrB,CAEP,WAAA,CAAY,iBAAA,CAFkB,EAEE,WAFF;EACF,CAE5B,WAAA,CAAY,eAAA,CAFgB,EAEE,YAFF;EAA5B,CAGA,WAAA,CAAY,SAAA,CAHA,EAGY,WAHZ;EACoB,CAGhC,WAAA,CAAY,UAAA,CAHoB,EAGP,YAHO;EAAhC,CAIA,WAAA,CAAY,UAAA,CAJA,EAIa,YAJb;;;;;;;;;;AAyBf;;;;;;;;AAyBA;AAUA;iBAnCsB,2BAA2B,gCACxC,6CAEM,IACZ,QAAQ,wBAAwB;;;;;;;iBAqBnB,UAAA;;;;;;;iBAUA,cAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-bot-shared",
3
- "version": "0.14.4",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "description": "Modules for creating discord bots.",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "files": ["dist/"],
27
27
  "scripts": {
28
28
  "bundle": "bun lint && tsdown",
29
- "lint": "markdown-toc -i --bullets '-' --maxdepth 3 ./README.md && tsc --noEmit && biome check --write && adamhl8-knip",
29
+ "lint": "markdown-toc -i --bullets '-' --maxdepth 3 ./README.md && ts-import-fix -w && tsc --noEmit && biome check --write && adamhl8-knip",
30
30
  "prepare": "find .githooks -type f -exec ln -srf {} .git/hooks/ \\; || true",
31
31
  "prepublishOnly": "bun bundle"
32
32
  },
@@ -34,15 +34,15 @@
34
34
  "discord.js": "^14.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@adamhl8/configs": "^0.15.23",
37
+ "@adamhl8/configs": "^0.18.0",
38
38
  "@arethetypeswrong/core": "^0.18.2",
39
- "@biomejs/biome": "^2.2.4",
40
- "@types/bun": "^1.2.22",
41
- "discord.js": "^14.22.1",
42
- "knip": "^5.63.1",
39
+ "@biomejs/biome": "^2.3.8",
40
+ "@types/bun": "^1.3.4",
41
+ "discord.js": "^14.25.1",
42
+ "knip": "^5.73.1",
43
43
  "markdown-toc": "^1.2.0",
44
- "publint": "^0.3.13",
45
- "tsdown": "^0.15.2",
46
- "typescript": "^5.9.2"
44
+ "publint": "^0.3.16",
45
+ "tsdown": "^0.17.2",
46
+ "typescript": "^5.9.3"
47
47
  }
48
48
  }