trivious 1.3.23 → 1.3.24
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 +26 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +27 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -752,6 +752,14 @@ declare class ModuleRegistry extends BaseRegistry<Module> {
|
|
|
752
752
|
*/
|
|
753
753
|
declare class EventRegistry extends BaseRegistry<Event> {
|
|
754
754
|
protected items: Collection<string, Event<keyof ClientEvents>>;
|
|
755
|
+
/**
|
|
756
|
+
* Load all preset events, can be overridden by user-provided events.
|
|
757
|
+
*
|
|
758
|
+
* @async
|
|
759
|
+
* @protected
|
|
760
|
+
* @returns {Promise<this>}
|
|
761
|
+
*/
|
|
762
|
+
protected loadPresetEvents(): Promise<this>;
|
|
755
763
|
/**
|
|
756
764
|
* Load all events.
|
|
757
765
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -752,6 +752,14 @@ declare class ModuleRegistry extends BaseRegistry<Module> {
|
|
|
752
752
|
*/
|
|
753
753
|
declare class EventRegistry extends BaseRegistry<Event> {
|
|
754
754
|
protected items: Collection<string, Event<keyof ClientEvents>>;
|
|
755
|
+
/**
|
|
756
|
+
* Load all preset events, can be overridden by user-provided events.
|
|
757
|
+
*
|
|
758
|
+
* @async
|
|
759
|
+
* @protected
|
|
760
|
+
* @returns {Promise<this>}
|
|
761
|
+
*/
|
|
762
|
+
protected loadPresetEvents(): Promise<this>;
|
|
755
763
|
/**
|
|
756
764
|
* Load all events.
|
|
757
765
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'util';
|
|
2
|
-
import { Collection, SlashCommandSubcommandBuilder, Client, REST, Routes, SlashCommandBuilder, ContextMenuCommandBuilder, InteractionContextType
|
|
2
|
+
import { Collection, SlashCommandSubcommandBuilder, Client, REST, Routes, SlashCommandBuilder, ContextMenuCommandBuilder, InteractionContextType } from 'discord.js';
|
|
3
3
|
import { existsSync, promises } from 'fs';
|
|
4
4
|
import path, { dirname, join, resolve } from 'path';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
@@ -488,16 +488,16 @@ var getPermissionLevel = (client, member) => {
|
|
|
488
488
|
|
|
489
489
|
// src/shared/utility/functions.ts
|
|
490
490
|
var __filename$1 = fileURLToPath(import.meta.url);
|
|
491
|
-
var
|
|
491
|
+
var __dirname2 = dirname(__filename$1);
|
|
492
492
|
var getPackageRoot = () => {
|
|
493
|
-
let dir =
|
|
493
|
+
let dir = __dirname2;
|
|
494
494
|
while (dir !== dirname(dir)) {
|
|
495
495
|
if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
|
|
496
496
|
return dir;
|
|
497
497
|
}
|
|
498
498
|
dir = dirname(dir);
|
|
499
499
|
}
|
|
500
|
-
return
|
|
500
|
+
return __dirname2;
|
|
501
501
|
};
|
|
502
502
|
var FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
|
|
503
503
|
function getCorePath(options) {
|
|
@@ -541,7 +541,8 @@ async function exists(path2) {
|
|
|
541
541
|
}
|
|
542
542
|
function hasPermission(client, options) {
|
|
543
543
|
const { permission, user, member } = options;
|
|
544
|
-
if (permission === 5 /* BOT_OWNER */ && client._options.botOwnerIds)
|
|
544
|
+
if (permission === 5 /* BOT_OWNER */ && client._options.botOwnerIds)
|
|
545
|
+
return user ? client._options.botOwnerIds.includes(user.id) : member ? client._options.botOwnerIds.includes(member.id) : false;
|
|
545
546
|
if (user) return true;
|
|
546
547
|
if (member) {
|
|
547
548
|
const memberPermission = getPermissionLevel(client, member);
|
|
@@ -695,69 +696,28 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
695
696
|
return this;
|
|
696
697
|
}
|
|
697
698
|
};
|
|
698
|
-
var interactionCreate_default = {
|
|
699
|
-
name: "interactionCreate",
|
|
700
|
-
execute: async (client, interaction) => {
|
|
701
|
-
if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
|
|
702
|
-
const { commandName } = interaction;
|
|
703
|
-
const registeredCommands = client.registries.commands.get();
|
|
704
|
-
const command = registeredCommands.get(commandName);
|
|
705
|
-
if (!command) {
|
|
706
|
-
await interaction.reply({
|
|
707
|
-
content: `Command is outdated, inactive or does not have a handler!`,
|
|
708
|
-
flags: ["Ephemeral"]
|
|
709
|
-
});
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
const requiredPermission = command.metadata.permission;
|
|
713
|
-
const hasPermission2 = await command.validateGuildPermission(
|
|
714
|
-
client,
|
|
715
|
-
interaction,
|
|
716
|
-
requiredPermission
|
|
717
|
-
);
|
|
718
|
-
if (!hasPermission2) return;
|
|
719
|
-
if (!("execute" in command)) {
|
|
720
|
-
await command.reply(interaction, { content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!" });
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
await command.reply(interaction, { content: "Processing command..." });
|
|
724
|
-
if (interaction.isChatInputCommand() && command.isSlashCommand()) {
|
|
725
|
-
await command.execute(client, interaction);
|
|
726
|
-
} else if (interaction.isContextMenuCommand() && command.isContextMenuCommand()) {
|
|
727
|
-
await command.execute(client, interaction);
|
|
728
|
-
}
|
|
729
|
-
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
730
|
-
const { componentType, tags, data } = deconstructCustomId(interaction.customId);
|
|
731
|
-
if (componentType === "button" /* Button */ && !(interaction instanceof ButtonInteraction))
|
|
732
|
-
return;
|
|
733
|
-
if (componentType === "modal" /* Modal */ && !(interaction instanceof ModalSubmitInteraction))
|
|
734
|
-
return;
|
|
735
|
-
if (tags.includes("awaited")) return;
|
|
736
|
-
const registeredComponents = client.registries.components.get();
|
|
737
|
-
const component = registeredComponents.get(data);
|
|
738
|
-
if (!component) {
|
|
739
|
-
await interaction.reply({
|
|
740
|
-
content: `Command is outdated, inactive or does not have a handler!`,
|
|
741
|
-
flags: ["Ephemeral"]
|
|
742
|
-
});
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
const requiredPermission = component.metadata.permission;
|
|
746
|
-
const hasPermission2 = await component.validateGuildPermission(
|
|
747
|
-
client,
|
|
748
|
-
interaction,
|
|
749
|
-
requiredPermission
|
|
750
|
-
);
|
|
751
|
-
if (!hasPermission2) return;
|
|
752
|
-
if (!interaction.isModalSubmit()) await interaction.deferUpdate();
|
|
753
|
-
await component.execute(client, interaction);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
// src/core/registry/event.registry.ts
|
|
759
699
|
var EventRegistry = class extends BaseRegistry {
|
|
760
700
|
items = new Collection();
|
|
701
|
+
/**
|
|
702
|
+
* Load all preset events, can be overridden by user-provided events.
|
|
703
|
+
*
|
|
704
|
+
* @async
|
|
705
|
+
* @protected
|
|
706
|
+
* @returns {Promise<this>}
|
|
707
|
+
*/
|
|
708
|
+
async loadPresetEvents() {
|
|
709
|
+
const directory = join(__dirname, "../events");
|
|
710
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
711
|
+
for (const entry of entries) {
|
|
712
|
+
const fullPath = join(directory, entry.name);
|
|
713
|
+
if (!entry.isFile() || !entry.name.endsWith(".js")) continue;
|
|
714
|
+
const event = await this.importFile(fullPath);
|
|
715
|
+
if (!event) continue;
|
|
716
|
+
if (this.items.has(event.name)) continue;
|
|
717
|
+
this.items.set(event.name, event);
|
|
718
|
+
}
|
|
719
|
+
return this;
|
|
720
|
+
}
|
|
761
721
|
/**
|
|
762
722
|
* Load all events.
|
|
763
723
|
*
|
|
@@ -780,7 +740,7 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
780
740
|
this.items.set(event.name, event);
|
|
781
741
|
}
|
|
782
742
|
}
|
|
783
|
-
this.
|
|
743
|
+
await this.loadPresetEvents();
|
|
784
744
|
return this;
|
|
785
745
|
}
|
|
786
746
|
/**
|