trivious 2.2.3 → 2.2.5

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.
@@ -15,12 +15,11 @@ async function registerComponents(client, directory) {
15
15
  const component = await importFile(file);
16
16
  if (!component || !("component" in component && "identifier" in component && "execute" in component))
17
17
  continue;
18
- const contextIdentifier = component.context.toString() + component.identifier;
19
- if (client.stores.components.get(contextIdentifier))
18
+ if (client.stores.components.get(component.identifier))
20
19
  console.warn(
21
20
  `[Trivious] Component identifier '${component.identifier}' with the context '${ComponentContext[component.context]}' has a duplicate and has been overridden`
22
21
  );
23
- client.stores.components.set(contextIdentifier, component);
22
+ client.stores.components.set(component.identifier, component);
24
23
  }
25
24
  }
26
25
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/components/registry.components.ts"],"names":["fs"],"mappings":";;;;;;AAMA,eAAO,kBAAA,CAA0C,QAAwB,SAAA,EAAmB;AAC3F,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,oDAAoD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC7D;AAAA,KACD;AAED,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,SAAA,GAAY,MAAM,UAAA,CAAsB,IAAI,CAAA;AAClD,IAAA,IACC,CAAC,SAAA,IACD,EAAE,eAAe,SAAA,IAAa,YAAA,IAAgB,aAAa,SAAA,IAAa,SAAA,CAAA;AAExE,MAAA;AAED,IAAA,MAAM,iBAAA,GAAoB,SAAA,CAAU,OAAA,CAAQ,QAAA,KAAa,SAAA,CAAU,UAAA;AACnE,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,iBAAiB,CAAA;AACjD,MAAA,OAAA,CAAQ,IAAA;AAAA,QACP,oCAAoC,SAAA,CAAU,UAAU,uBAAuB,gBAAA,CAAiB,SAAA,CAAU,OAAO,CAAC,CAAA,yCAAA;AAAA,OACnH;AAED,IAAA,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,iBAAA,EAAmB,SAAS,CAAA;AAAA,EAC1D;AACD","file":"registry.components.js","sourcesContent":["import { Component, ComponentContext, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport default async function registerComponents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register components; passed directory '${directory} does not exist!'`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst component = await importFile<Component>(file);\n\t\tif (\n\t\t\t!component ||\n\t\t\t!(\"component\" in component && \"identifier\" in component && \"execute\" in component)\n\t\t)\n\t\t\tcontinue;\n\n\t\tconst contextIdentifier = component.context.toString() + component.identifier;\n\t\tif (client.stores.components.get(contextIdentifier))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Component identifier '${component.identifier}' with the context '${ComponentContext[component.context]}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.components.set(contextIdentifier, component);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/components/registry.components.ts"],"names":["fs"],"mappings":";;;;;;AAMA,eAAO,kBAAA,CAA0C,QAAwB,SAAA,EAAmB;AAC3F,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,oDAAoD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC7D;AAAA,KACD;AAED,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,SAAA,GAAY,MAAM,UAAA,CAAsB,IAAI,CAAA;AAClD,IAAA,IACC,CAAC,SAAA,IACD,EAAE,eAAe,SAAA,IAAa,YAAA,IAAgB,aAAa,SAAA,IAAa,SAAA,CAAA;AAExE,MAAA;AAED,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,UAAU,UAAU,CAAA;AACpD,MAAA,OAAA,CAAQ,IAAA;AAAA,QACP,oCAAoC,SAAA,CAAU,UAAU,uBAAuB,gBAAA,CAAiB,SAAA,CAAU,OAAO,CAAC,CAAA,yCAAA;AAAA,OACnH;AAED,IAAA,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,SAAA,CAAU,YAAY,SAAS,CAAA;AAAA,EAC7D;AACD","file":"registry.components.js","sourcesContent":["import { Component, ComponentContext, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport default async function registerComponents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register components; passed directory '${directory} does not exist!'`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst component = await importFile<Component>(file);\n\t\tif (\n\t\t\t!component ||\n\t\t\t!(\"component\" in component && \"identifier\" in component && \"execute\" in component)\n\t\t)\n\t\t\tcontinue;\n\n\t\tif (client.stores.components.get(component.identifier))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Component identifier '${component.identifier}' with the context '${ComponentContext[component.context]}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.components.set(component.identifier, component);\n\t}\n}\n"]}
@@ -57,8 +57,6 @@ var interactionCreate_default = {
57
57
  }
58
58
  } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
59
59
  const { context, identifier, tags } = customId.decode(interaction.customId);
60
- const identContext = identifier.slice(0, 1);
61
- if (context !== Number(identContext)) return;
62
60
  if (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))
63
61
  return;
64
62
  if (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"names":["subcommand"],"mappings":";;;;;;AAuBA,SAAS,sCAAA,CACR,MAAA,EACA,OAAA,EACA,WAAA,EAIoB;AACpB,EAAA,IAAI,EAAE,aAAA,IAAiB,OAAA,CAAA,EAAU,OAAO,CAAC,OAAO,wCAAwC,CAAA;AACxF,EAAA,IAAI,CAAC,WAAA,CAAY,kBAAA,IAAsB,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAE9F,EAAA,MAAM,EAAE,SAAQ,GAAI,WAAA;AAEpB,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,aAAA,CAAc,KAAK,CAAA;AAClD,EAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,kBAAA,CAAmB,KAAK,CAAA;AAClD,EAAA,IAAI,CAAC,cAAA,EAAgB,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAE5E,EAAA,IAAI,SAAA,EAAW;AACd,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,gBAAA,EAAkB,GAAA,CAAI,SAAS,CAAA;AACrD,IAAA,IAAI,CAAC,KAAA,EAAO,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAEnE,IAAA,MAAMA,WAAAA,GAAa,KAAA,CAAM,WAAA,CAAY,GAAA,CAAI,cAAc,CAAA;AACvD,IAAA,IAAI,CAACA,WAAAA,EAAY,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAExE,IAAA,OAAO,mBAAA,CAAoB,MAAA,EAAQA,WAAAA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A,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,4DAAA,EAA6D;AAAA,UACtF,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,aAAA,GAAgB,mBAAA;AAAA,QACrB,MAAA;AAAA,QACA,SAAA;AAAA,QACA,WAAA,CAAY;AAAA,OACb;AACA,MAAA,IAAI,CAAC,aAAA,EAAe;AACnB,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,kDAAA,EAAmD;AAAA,UAC5E,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AACA,MAAA,MAAM,SAAA,CAAU,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import {\n\tComponentContext,\n\tSlashCommandData,\n\tTriviousClient,\n\ttype ContextCommandData,\n\ttype Event,\n} from \"#typings\";\nimport {\n\tApplicationCommandType,\n\tButtonInteraction,\n\tChatInputCommandInteraction,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport { handleSlashCommand, interactionReply } from \"src/features/commands/methods.commands.js\";\nimport customId from \"src/features/customId/methods.customid.js\";\nimport { canMemberRunCommand } from \"src/features/permissions/methods.permissions.js\";\n\n/**\n * Check if the command is a subcommand and validate whether the member can run the command based on subcommand permissions\n */\nfunction validateMemberPermissionsForSubcommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData | ContextCommandData,\n\tinteraction:\n\t\t| ChatInputCommandInteraction\n\t\t| MessageContextMenuCommandInteraction\n\t\t| UserContextMenuCommandInteraction\n): [boolean, string] {\n\tif (!(\"subcommands\" in command)) return [false, \"Cannot validate subcommand permissions\"];\n\tif (!interaction.isChatInputCommand()) return [false, \"Cannot validate subcommand permissions\"];\n\n\tconst { options } = interaction;\n\n\tconst subcommandName = options.getSubcommand(false);\n\tconst groupName = options.getSubcommandGroup(false);\n\tif (!subcommandName) return [false, \"Cannot validate subcommand permissions\"];\n\n\tif (groupName) {\n\t\tconst group = command.subcommandGroups?.get(groupName);\n\t\tif (!group) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\tconst subcommand = group.subcommands.get(subcommandName);\n\t\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n\t}\n\n\tconst subcommand = command.subcommands?.get(subcommandName);\n\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\tasync execute(client, interaction) {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst storeToCheck = interaction.isChatInputCommand()\n\t\t\t\t? client.stores.commands.chatInput\n\t\t\t\t: client.stores.commands.context;\n\t\t\tconst command = storeToCheck.get(commandName);\n\n\t\t\tif (!command) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst subcommandPerms = validateMemberPermissionsForSubcommand(client, command, interaction);\n\t\t\tconst commandPerms = canMemberRunCommand(client, command, interaction.member as GuildMember);\n\t\t\tconst hasPermission = subcommandPerms[0] && commandPerms[0] ? true : false;\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: {\n\t\t\t\t\t\tcontent: `You do not have permission to run this command`,\n\t\t\t\t\t},\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tcommand.commandType === ApplicationCommandType.ChatInput &&\n\t\t\t\tinteraction.isChatInputCommand()\n\t\t\t) {\n\t\t\t\tawait handleSlashCommand(client, command, interaction);\n\t\t\t} else {\n\t\t\t\tawait (command as ContextCommandData).execute(client, interaction as never);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { context, identifier, tags } = customId.decode(interaction.customId);\n\t\t\tconst identContext = identifier.slice(0, 1);\n\t\t\tif (context !== Number(identContext)) return;\n\n\t\t\tif (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))\n\t\t\t\treturn;\n\t\t\tif (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst component = client.stores.components.get(identifier);\n\n\t\t\tif (!component) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hasPermission = canMemberRunCommand(\n\t\t\t\tclient,\n\t\t\t\tcomponent,\n\t\t\t\tinteraction.member as GuildMember\n\t\t\t);\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"You do not have permission to use this component\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
1
+ {"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"names":["subcommand"],"mappings":";;;;;;AAu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AA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import {\n\tComponentContext,\n\tSlashCommandData,\n\tTriviousClient,\n\ttype ContextCommandData,\n\ttype Event,\n} from \"#typings\";\nimport {\n\tApplicationCommandType,\n\tButtonInteraction,\n\tChatInputCommandInteraction,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport { handleSlashCommand, interactionReply } from \"src/features/commands/methods.commands.js\";\nimport customId from \"src/features/customId/methods.customid.js\";\nimport { canMemberRunCommand } from \"src/features/permissions/methods.permissions.js\";\n\n/**\n * Check if the command is a subcommand and validate whether the member can run the command based on subcommand permissions\n */\nfunction validateMemberPermissionsForSubcommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData | ContextCommandData,\n\tinteraction:\n\t\t| ChatInputCommandInteraction\n\t\t| MessageContextMenuCommandInteraction\n\t\t| UserContextMenuCommandInteraction\n): [boolean, string] {\n\tif (!(\"subcommands\" in command)) return [false, \"Cannot validate subcommand permissions\"];\n\tif (!interaction.isChatInputCommand()) return [false, \"Cannot validate subcommand permissions\"];\n\n\tconst { options } = interaction;\n\n\tconst subcommandName = options.getSubcommand(false);\n\tconst groupName = options.getSubcommandGroup(false);\n\tif (!subcommandName) return [false, \"Cannot validate subcommand permissions\"];\n\n\tif (groupName) {\n\t\tconst group = command.subcommandGroups?.get(groupName);\n\t\tif (!group) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\tconst subcommand = group.subcommands.get(subcommandName);\n\t\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n\t}\n\n\tconst subcommand = command.subcommands?.get(subcommandName);\n\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\tasync execute(client, interaction) {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst storeToCheck = interaction.isChatInputCommand()\n\t\t\t\t? client.stores.commands.chatInput\n\t\t\t\t: client.stores.commands.context;\n\t\t\tconst command = storeToCheck.get(commandName);\n\n\t\t\tif (!command) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst subcommandPerms = validateMemberPermissionsForSubcommand(client, command, interaction);\n\t\t\tconst commandPerms = canMemberRunCommand(client, command, interaction.member as GuildMember);\n\t\t\tconst hasPermission = subcommandPerms[0] && commandPerms[0] ? true : false;\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: {\n\t\t\t\t\t\tcontent: `You do not have permission to run this command`,\n\t\t\t\t\t},\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tcommand.commandType === ApplicationCommandType.ChatInput &&\n\t\t\t\tinteraction.isChatInputCommand()\n\t\t\t) {\n\t\t\t\tawait handleSlashCommand(client, command, interaction);\n\t\t\t} else {\n\t\t\t\tawait (command as ContextCommandData).execute(client, interaction as never);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { context, identifier, tags } = customId.decode(interaction.customId);\n\t\t\tif (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))\n\t\t\t\treturn;\n\t\t\tif (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst component = client.stores.components.get(identifier);\n\n\t\t\tif (!component) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hasPermission = canMemberRunCommand(\n\t\t\t\tclient,\n\t\t\t\tcomponent,\n\t\t\t\tinteraction.member as GuildMember\n\t\t\t);\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"You do not have permission to use this component\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
@@ -1,8 +1,6 @@
1
- import { PermissionsBitField } from 'discord.js';
2
-
3
1
  interface CommandPermissionValues {
4
2
  requiredRoleIds?: string[];
5
- requiredMemberPermissions?: PermissionsBitField[];
3
+ requiredMemberPermissions?: bigint[];
6
4
  userIds?: string[];
7
5
  }
8
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trivious",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "discord-bot",