trivious 1.5.4 → 1.5.6
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/core/client/trivious.client.d.cts +1 -1
- package/dist/core/client/trivious.client.d.ts +1 -1
- package/dist/core/commands/command.base.d.cts +1 -1
- package/dist/core/commands/command.base.d.ts +1 -1
- package/dist/core/commands/subcommand.base.d.cts +1 -1
- package/dist/core/commands/subcommand.base.d.ts +1 -1
- package/dist/core/components/component.base.cjs +0 -106
- package/dist/core/components/component.base.cjs.map +1 -1
- package/dist/core/components/component.base.d.cts +2 -4
- package/dist/core/components/component.base.d.ts +2 -4
- package/dist/core/components/component.base.js +0 -102
- package/dist/core/components/component.base.js.map +1 -1
- package/dist/core/events/clientReady.d.cts +1 -1
- package/dist/core/events/clientReady.d.ts +1 -1
- package/dist/core/events/interactionCreate.cjs +18 -10
- package/dist/core/events/interactionCreate.cjs.map +1 -1
- package/dist/core/events/interactionCreate.d.cts +1 -1
- package/dist/core/events/interactionCreate.d.ts +1 -1
- package/dist/core/events/interactionCreate.js +18 -10
- package/dist/core/events/interactionCreate.js.map +1 -1
- package/dist/core/registry/command.registry.d.cts +1 -1
- package/dist/core/registry/command.registry.d.ts +1 -1
- package/dist/core/registry/component.registry.cjs +15 -14
- package/dist/core/registry/component.registry.cjs.map +1 -1
- package/dist/core/registry/component.registry.d.cts +1 -1
- package/dist/core/registry/component.registry.d.ts +1 -1
- package/dist/core/registry/component.registry.js +16 -15
- package/dist/core/registry/component.registry.js.map +1 -1
- package/dist/core/registry/event.registry.d.cts +1 -1
- package/dist/core/registry/event.registry.d.ts +1 -1
- package/dist/core/registry/index.d.cts +1 -1
- package/dist/core/registry/index.d.ts +1 -1
- package/dist/core/registry/module.registry.d.cts +1 -1
- package/dist/core/registry/module.registry.d.ts +1 -1
- package/dist/{index-Do60I3dv.d.cts → index-BBuxUTy6.d.cts} +23 -124
- package/dist/{index-JgBW-tT-.d.ts → index-BLUmi3ui.d.ts} +23 -124
- package/dist/index.cjs +0 -10
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/shared/typings/client.d.cts +1 -1
- package/dist/shared/typings/client.d.ts +1 -1
- package/dist/shared/typings/commands.d.cts +1 -1
- package/dist/shared/typings/commands.d.ts +1 -1
- package/dist/shared/typings/components.cjs +3 -3
- package/dist/shared/typings/components.cjs.map +1 -1
- package/dist/shared/typings/components.d.cts +1 -1
- package/dist/shared/typings/components.d.ts +1 -1
- package/dist/shared/typings/components.js +3 -3
- package/dist/shared/typings/components.js.map +1 -1
- package/dist/shared/typings/events.d.cts +1 -1
- package/dist/shared/typings/events.d.ts +1 -1
- package/dist/shared/typings/index.d.cts +1 -1
- package/dist/shared/typings/index.d.ts +1 -1
- package/dist/shared/typings/module.d.cts +1 -1
- package/dist/shared/typings/module.d.ts +1 -1
- package/dist/shared/typings/permissions.d.cts +1 -1
- package/dist/shared/typings/permissions.d.ts +1 -1
- package/dist/shared/utility/functions.d.cts +1 -1
- package/dist/shared/utility/functions.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { l as CommandBuilder, n as ContextMenuBuilder, m as ContextMenuCommand, S as SlashCommand, k as default } from '../../index-
|
|
2
|
+
export { l as CommandBuilder, n as ContextMenuBuilder, m as ContextMenuCommand, S as SlashCommand, k as default } from '../../index-BBuxUTy6.cjs';
|
|
3
3
|
import '../../shared/typings/registry.cjs';
|
|
4
4
|
import '../builders/util.builders.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { l as CommandBuilder, n as ContextMenuBuilder, m as ContextMenuCommand, S as SlashCommand, k as default } from '../../index-
|
|
2
|
+
export { l as CommandBuilder, n as ContextMenuBuilder, m as ContextMenuCommand, S as SlashCommand, k as default } from '../../index-BLUmi3ui.js';
|
|
3
3
|
import '../../shared/typings/registry.js';
|
|
4
4
|
import '../builders/util.builders.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { p as SubcommandBuilder, o as default } from '../../index-
|
|
2
|
+
export { p as SubcommandBuilder, o as default } from '../../index-BBuxUTy6.cjs';
|
|
3
3
|
import '../../shared/typings/registry.cjs';
|
|
4
4
|
import '../builders/util.builders.cjs';
|
|
@@ -1,110 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index_js = require('../../shared/typings/index.js');
|
|
6
|
-
var functions_js = require('../../shared/utility/functions.js');
|
|
7
|
-
|
|
8
|
-
class ComponentBuilder {
|
|
9
|
-
_customId = "";
|
|
10
|
-
_permission = index_js.PermissionLevel.USER;
|
|
11
|
-
_ephemeralReply = false;
|
|
12
|
-
/**
|
|
13
|
-
* Set the customId for the component.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
* @param {{
|
|
17
|
-
* type: ComponentType;
|
|
18
|
-
* data: string;
|
|
19
|
-
* tags?: ComponentCustomIdTag[];
|
|
20
|
-
* }} options
|
|
21
|
-
* @returns {this}
|
|
22
|
-
*/
|
|
23
|
-
setCustomId(options) {
|
|
24
|
-
this._customId = index_js.constructCustomId(options);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Set the permission required to use the component.
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
* @param {PermissionLevel} permission
|
|
32
|
-
* @returns {this}
|
|
33
|
-
*/
|
|
34
|
-
setPermission(permission) {
|
|
35
|
-
this._permission = permission;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Set the interaction as ephemeral.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
* @returns {this}
|
|
43
|
-
*/
|
|
44
|
-
setEphemeralReply() {
|
|
45
|
-
this._ephemeralReply = true;
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Builder the builder.
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
52
|
-
* @returns {{ metadata: ComponentMetadata; }}
|
|
53
|
-
*/
|
|
54
|
-
build() {
|
|
55
|
-
return {
|
|
56
|
-
metadata: {
|
|
57
|
-
customId: this._customId,
|
|
58
|
-
permission: this._permission,
|
|
59
|
-
ephemeralReply: this._ephemeralReply
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
class Component {
|
|
65
|
-
/**
|
|
66
|
-
* Validate permissions for a user/member in a guild.
|
|
67
|
-
*
|
|
68
|
-
* @async
|
|
69
|
-
* @param {ComponentInteraction} interaction
|
|
70
|
-
* @param {PermissionLevel} permission
|
|
71
|
-
* @param {boolean} [doReply=true] Defaults to `true`
|
|
72
|
-
* @returns {unknown}
|
|
73
|
-
*/
|
|
74
|
-
async validateGuildPermission(client, interaction, permission, doReply = true) {
|
|
75
|
-
if (interaction.guild) {
|
|
76
|
-
const member = interaction.member;
|
|
77
|
-
const memberHasPermission = functions_js.hasPermission(client, { permission, member });
|
|
78
|
-
if (!memberHasPermission) {
|
|
79
|
-
if (doReply)
|
|
80
|
-
await this.reply(interaction, {
|
|
81
|
-
content: `You do not have permission to run this command, required permission: \`${index_js.PermissionLevel[permission]}\``
|
|
82
|
-
});
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Reply to the interaction respecting command metadata and if the interaction has already been replied to.
|
|
90
|
-
*
|
|
91
|
-
* @async
|
|
92
|
-
* @param {ComponentInteraction} interaction
|
|
93
|
-
* @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
|
|
94
|
-
* @returns {*}
|
|
95
|
-
*/
|
|
96
|
-
async reply(interaction, options) {
|
|
97
|
-
if (interaction.replied) {
|
|
98
|
-
await interaction.editReply(options);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const newOptions = { ...options };
|
|
102
|
-
if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
|
|
103
|
-
await interaction.reply(newOptions);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
exports.ComponentBuilder = ComponentBuilder;
|
|
108
|
-
exports.default = Component;
|
|
109
3
|
//# sourceMappingURL=component.base.cjs.map
|
|
110
4
|
//# sourceMappingURL=component.base.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"component.base.cjs"}
|
|
@@ -1,105 +1,3 @@
|
|
|
1
|
-
import { PermissionLevel, constructCustomId } from '../../shared/typings/index.js';
|
|
2
|
-
import { hasPermission } from '../../shared/utility/functions.js';
|
|
3
1
|
|
|
4
|
-
class ComponentBuilder {
|
|
5
|
-
_customId = "";
|
|
6
|
-
_permission = PermissionLevel.USER;
|
|
7
|
-
_ephemeralReply = false;
|
|
8
|
-
/**
|
|
9
|
-
* Set the customId for the component.
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
12
|
-
* @param {{
|
|
13
|
-
* type: ComponentType;
|
|
14
|
-
* data: string;
|
|
15
|
-
* tags?: ComponentCustomIdTag[];
|
|
16
|
-
* }} options
|
|
17
|
-
* @returns {this}
|
|
18
|
-
*/
|
|
19
|
-
setCustomId(options) {
|
|
20
|
-
this._customId = constructCustomId(options);
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Set the permission required to use the component.
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
* @param {PermissionLevel} permission
|
|
28
|
-
* @returns {this}
|
|
29
|
-
*/
|
|
30
|
-
setPermission(permission) {
|
|
31
|
-
this._permission = permission;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Set the interaction as ephemeral.
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
* @returns {this}
|
|
39
|
-
*/
|
|
40
|
-
setEphemeralReply() {
|
|
41
|
-
this._ephemeralReply = true;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Builder the builder.
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
* @returns {{ metadata: ComponentMetadata; }}
|
|
49
|
-
*/
|
|
50
|
-
build() {
|
|
51
|
-
return {
|
|
52
|
-
metadata: {
|
|
53
|
-
customId: this._customId,
|
|
54
|
-
permission: this._permission,
|
|
55
|
-
ephemeralReply: this._ephemeralReply
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class Component {
|
|
61
|
-
/**
|
|
62
|
-
* Validate permissions for a user/member in a guild.
|
|
63
|
-
*
|
|
64
|
-
* @async
|
|
65
|
-
* @param {ComponentInteraction} interaction
|
|
66
|
-
* @param {PermissionLevel} permission
|
|
67
|
-
* @param {boolean} [doReply=true] Defaults to `true`
|
|
68
|
-
* @returns {unknown}
|
|
69
|
-
*/
|
|
70
|
-
async validateGuildPermission(client, interaction, permission, doReply = true) {
|
|
71
|
-
if (interaction.guild) {
|
|
72
|
-
const member = interaction.member;
|
|
73
|
-
const memberHasPermission = hasPermission(client, { permission, member });
|
|
74
|
-
if (!memberHasPermission) {
|
|
75
|
-
if (doReply)
|
|
76
|
-
await this.reply(interaction, {
|
|
77
|
-
content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
|
|
78
|
-
});
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Reply to the interaction respecting command metadata and if the interaction has already been replied to.
|
|
86
|
-
*
|
|
87
|
-
* @async
|
|
88
|
-
* @param {ComponentInteraction} interaction
|
|
89
|
-
* @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
|
|
90
|
-
* @returns {*}
|
|
91
|
-
*/
|
|
92
|
-
async reply(interaction, options) {
|
|
93
|
-
if (interaction.replied) {
|
|
94
|
-
await interaction.editReply(options);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const newOptions = { ...options };
|
|
98
|
-
if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
|
|
99
|
-
await interaction.reply(newOptions);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export { ComponentBuilder, Component as default };
|
|
104
2
|
//# sourceMappingURL=component.base.js.map
|
|
105
3
|
//# sourceMappingURL=component.base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"component.base.js"}
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var discord_js = require('discord.js');
|
|
4
4
|
var index_js = require('../../shared/typings/index.js');
|
|
5
|
+
var functions_js = require('../../shared/utility/functions.js');
|
|
5
6
|
|
|
7
|
+
async function validateComponentGuildPermission(client, interaction, permission) {
|
|
8
|
+
if (interaction.guild) {
|
|
9
|
+
const member = interaction.member;
|
|
10
|
+
const memberHasPermission = functions_js.hasPermission(client, { permission, member });
|
|
11
|
+
return memberHasPermission;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
6
15
|
var interactionCreate_default = {
|
|
7
16
|
name: "interactionCreate",
|
|
8
17
|
execute: async (client, interaction) => {
|
|
@@ -18,12 +27,12 @@ var interactionCreate_default = {
|
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
20
29
|
const requiredPermission = command.metadata.permission;
|
|
21
|
-
const
|
|
30
|
+
const hasPermission2 = await command.validateGuildPermission(
|
|
22
31
|
client,
|
|
23
32
|
interaction,
|
|
24
33
|
requiredPermission
|
|
25
34
|
);
|
|
26
|
-
if (!
|
|
35
|
+
if (!hasPermission2) return;
|
|
27
36
|
if (!("execute" in command)) {
|
|
28
37
|
await command.reply(interaction, {
|
|
29
38
|
content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!"
|
|
@@ -37,12 +46,11 @@ var interactionCreate_default = {
|
|
|
37
46
|
await command.execute(client, interaction);
|
|
38
47
|
}
|
|
39
48
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
40
|
-
const {
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
if (componentType === index_js.ComponentType.Modal && !(interaction instanceof discord_js.ModalSubmitInteraction))
|
|
49
|
+
const { compType, tags, data } = index_js.deconstructCustomId(interaction.customId);
|
|
50
|
+
if (compType === index_js.ComponentType.Button && !(interaction instanceof discord_js.ButtonInteraction)) return;
|
|
51
|
+
if (compType === index_js.ComponentType.Modal && !(interaction instanceof discord_js.ModalSubmitInteraction))
|
|
44
52
|
return;
|
|
45
|
-
if (tags.includes("awaited")) return;
|
|
53
|
+
if (tags && tags.includes("awaited")) return;
|
|
46
54
|
const registeredComponents = client.registries.components.get();
|
|
47
55
|
const component = registeredComponents.get(data);
|
|
48
56
|
if (!component) {
|
|
@@ -52,13 +60,13 @@ var interactionCreate_default = {
|
|
|
52
60
|
});
|
|
53
61
|
return;
|
|
54
62
|
}
|
|
55
|
-
const requiredPermission = component.
|
|
56
|
-
const
|
|
63
|
+
const requiredPermission = component.permission;
|
|
64
|
+
const hasPermission2 = await validateComponentGuildPermission(
|
|
57
65
|
client,
|
|
58
66
|
interaction,
|
|
59
67
|
requiredPermission
|
|
60
68
|
);
|
|
61
|
-
if (!
|
|
69
|
+
if (!hasPermission2) return;
|
|
62
70
|
if (!interaction.isModalSubmit()) await interaction.deferUpdate();
|
|
63
71
|
await component.execute(client, interaction);
|
|
64
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":["deconstructCustomId","ComponentType","ButtonInteraction","ModalSubmitInteraction"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":["hasPermission","deconstructCustomId","ComponentType","ButtonInteraction","ModalSubmitInteraction"],"mappings":"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","file":"interactionCreate.cjs","sourcesContent":["import { ButtonInteraction, GuildMember, ModalSubmitInteraction } from \"discord.js\";\nimport {\n\tComponentInteraction,\n\tComponentType,\n\tdeconstructCustomId,\n\tEvent,\n\tPermissionLevel,\n} from \"src/shared/typings/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport Command from \"../commands/command.base.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\nasync function validateComponentGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ComponentInteraction,\n\tpermission: PermissionLevel\n) {\n\tif (interaction.guild) {\n\t\tconst member = interaction.member as GuildMember;\n\t\tconst memberHasPermission = hasPermission(client, { permission, member });\n\t\treturn memberHasPermission;\n\t}\n\n\treturn false;\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\texecute: async (client, interaction) => {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst registeredCommands = client.registries.commands.get();\n\t\t\tconst command = registeredCommands.get(commandName);\n\t\t\tif (!command) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = command.metadata.permission;\n\t\t\tconst hasPermission = await command.validateGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!(\"execute\" in command)) {\n\t\t\t\tawait (command as Command).reply(interaction, {\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t\"Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait command.reply(interaction, { content: \"Processing command...\" });\n\n\t\t\tif (interaction.isChatInputCommand() && command.isSlashCommand()) {\n\t\t\t\tawait command.execute(client, interaction);\n\t\t\t} else if (interaction.isContextMenuCommand() && command.isContextMenuCommand()) {\n\t\t\t\tawait command.execute(client, interaction);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { compType, tags, data } = deconstructCustomId(interaction.customId);\n\n\t\t\tif (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;\n\t\t\tif (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst registeredComponents = client.registries.components.get();\n\t\t\tconst component = registeredComponents.get(data);\n\t\t\tif (!component) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = component.permission;\n\t\t\tconst hasPermission = await validateComponentGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!interaction.isModalSubmit()) await interaction.deferUpdate();\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
|
|
2
2
|
import { deconstructCustomId, ComponentType } from '../../shared/typings/index.js';
|
|
3
|
+
import { hasPermission } from '../../shared/utility/functions.js';
|
|
3
4
|
|
|
5
|
+
async function validateComponentGuildPermission(client, interaction, permission) {
|
|
6
|
+
if (interaction.guild) {
|
|
7
|
+
const member = interaction.member;
|
|
8
|
+
const memberHasPermission = hasPermission(client, { permission, member });
|
|
9
|
+
return memberHasPermission;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
4
13
|
var interactionCreate_default = {
|
|
5
14
|
name: "interactionCreate",
|
|
6
15
|
execute: async (client, interaction) => {
|
|
@@ -16,12 +25,12 @@ var interactionCreate_default = {
|
|
|
16
25
|
return;
|
|
17
26
|
}
|
|
18
27
|
const requiredPermission = command.metadata.permission;
|
|
19
|
-
const
|
|
28
|
+
const hasPermission2 = await command.validateGuildPermission(
|
|
20
29
|
client,
|
|
21
30
|
interaction,
|
|
22
31
|
requiredPermission
|
|
23
32
|
);
|
|
24
|
-
if (!
|
|
33
|
+
if (!hasPermission2) return;
|
|
25
34
|
if (!("execute" in command)) {
|
|
26
35
|
await command.reply(interaction, {
|
|
27
36
|
content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!"
|
|
@@ -35,12 +44,11 @@ var interactionCreate_default = {
|
|
|
35
44
|
await command.execute(client, interaction);
|
|
36
45
|
}
|
|
37
46
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
38
|
-
const {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
if (componentType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))
|
|
47
|
+
const { compType, tags, data } = deconstructCustomId(interaction.customId);
|
|
48
|
+
if (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;
|
|
49
|
+
if (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))
|
|
42
50
|
return;
|
|
43
|
-
if (tags.includes("awaited")) return;
|
|
51
|
+
if (tags && tags.includes("awaited")) return;
|
|
44
52
|
const registeredComponents = client.registries.components.get();
|
|
45
53
|
const component = registeredComponents.get(data);
|
|
46
54
|
if (!component) {
|
|
@@ -50,13 +58,13 @@ var interactionCreate_default = {
|
|
|
50
58
|
});
|
|
51
59
|
return;
|
|
52
60
|
}
|
|
53
|
-
const requiredPermission = component.
|
|
54
|
-
const
|
|
61
|
+
const requiredPermission = component.permission;
|
|
62
|
+
const hasPermission2 = await validateComponentGuildPermission(
|
|
55
63
|
client,
|
|
56
64
|
interaction,
|
|
57
65
|
requiredPermission
|
|
58
66
|
);
|
|
59
|
-
if (!
|
|
67
|
+
if (!hasPermission2) return;
|
|
60
68
|
if (!interaction.isModalSubmit()) await interaction.deferUpdate();
|
|
61
69
|
await component.execute(client, interaction);
|
|
62
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":["hasPermission"],"mappings":"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","file":"interactionCreate.js","sourcesContent":["import { ButtonInteraction, GuildMember, ModalSubmitInteraction } from \"discord.js\";\nimport {\n\tComponentInteraction,\n\tComponentType,\n\tdeconstructCustomId,\n\tEvent,\n\tPermissionLevel,\n} from \"src/shared/typings/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport Command from \"../commands/command.base.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\nasync function validateComponentGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ComponentInteraction,\n\tpermission: PermissionLevel\n) {\n\tif (interaction.guild) {\n\t\tconst member = interaction.member as GuildMember;\n\t\tconst memberHasPermission = hasPermission(client, { permission, member });\n\t\treturn memberHasPermission;\n\t}\n\n\treturn false;\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\texecute: async (client, interaction) => {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst registeredCommands = client.registries.commands.get();\n\t\t\tconst command = registeredCommands.get(commandName);\n\t\t\tif (!command) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = command.metadata.permission;\n\t\t\tconst hasPermission = await command.validateGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!(\"execute\" in command)) {\n\t\t\t\tawait (command as Command).reply(interaction, {\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t\"Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait command.reply(interaction, { content: \"Processing command...\" });\n\n\t\t\tif (interaction.isChatInputCommand() && command.isSlashCommand()) {\n\t\t\t\tawait command.execute(client, interaction);\n\t\t\t} else if (interaction.isContextMenuCommand() && command.isContextMenuCommand()) {\n\t\t\t\tawait command.execute(client, interaction);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { compType, tags, data } = deconstructCustomId(interaction.customId);\n\n\t\t\tif (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;\n\t\t\tif (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst registeredComponents = client.registries.components.get();\n\t\t\tconst component = registeredComponents.get(data);\n\t\t\tif (!component) {\n\t\t\t\tawait interaction.reply({\n\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\tflags: [\"Ephemeral\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = component.permission;\n\t\t\tconst hasPermission = await validateComponentGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (!interaction.isModalSubmit()) await interaction.deferUpdate();\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
|
|
@@ -16,25 +16,26 @@ class ComponentRegistry extends index_js.BaseRegistry {
|
|
|
16
16
|
* Load all components.
|
|
17
17
|
*
|
|
18
18
|
* @async
|
|
19
|
-
* @param {string} [directory=getCorePath({ coreDirectory: "
|
|
19
|
+
* @param {string} [directory=getCorePath({ coreDirectory: "events" })]
|
|
20
20
|
* @returns {Promise<this>}
|
|
21
21
|
*/
|
|
22
|
-
async load(directory = functions_js.resolveUserPath(path__default.default.join("src", "
|
|
23
|
-
if (!await functions_js.exists(directory))
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
22
|
+
async load(directory = functions_js.resolveUserPath(path__default.default.join("src", "events"))) {
|
|
23
|
+
if (!await functions_js.exists(directory)) return this;
|
|
26
24
|
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
27
25
|
for (const entry of entries) {
|
|
28
26
|
const fullPath = path.join(directory, entry.name);
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
if (entry.isDirectory()) {
|
|
28
|
+
await this.load(fullPath);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (entry.isFile() && entry.name.endsWith(".js")) {
|
|
32
|
+
const event = await this.importFile(fullPath);
|
|
33
|
+
if (!event) continue;
|
|
34
|
+
if (!event.customId || !event.customIdData) {
|
|
35
|
+
console.error(`Component from ${entry.name} does not return customId nor customIdData!`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
this.items.set(event.customId || event.customIdData, event);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/component.registry.ts"],"names":["BaseRegistry","Collection","resolveUserPath","path","exists","fs","join"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/component.registry.ts"],"names":["BaseRegistry","Collection","resolveUserPath","path","exists","fs","join"],"mappings":";;;;;;;;;;;;AAcA,MAAO,0BAAwCA,qBAAA,CAAwB;AAAA,EAC5D,KAAA,GAAQ,IAAIC,qBAAA,EAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpD,MAAM,KAAK,SAAA,GAAoBC,4BAAA,CAAgBC,sBAAK,IAAA,CAAK,KAAA,EAAO,QAAQ,CAAC,CAAA,EAAkB;AAC1F,IAAA,IAAI,CAAE,MAAMC,mBAAA,CAAO,SAAS,GAAI,OAAO,IAAA;AAEvC,IAAA,MAAM,OAAA,GAAU,MAAMC,WAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AACnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAWC,SAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAE3C,MAAA,IAAI,KAAA,CAAM,aAAY,EAAG;AACxB,QAAA,MAAM,IAAA,CAAK,KAAK,QAAQ,CAAA;AACxB,QAAA;AAAA,MACD;AAEA,MAAA,IAAI,MAAM,MAAA,EAAO,IAAK,MAAM,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,EAAG;AACjD,QAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,UAAA,CAAsB,QAAQ,CAAA;AACvD,QAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,QAAA,IAAI,CAAC,KAAA,CAAM,QAAA,IAAY,CAAC,MAAM,YAAA,EAAc;AAC3C,UAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,eAAA,EAAkB,KAAA,CAAM,IAAI,CAAA,2CAAA,CAA6C,CAAA;AACvF,UAAA;AAAA,QACD;AAEA,QAAA,IAAA,CAAK,MAAM,GAAA,CAAI,KAAA,CAAM,QAAA,IAAY,KAAA,CAAM,cAAc,KAAK,CAAA;AAAA,MAC3D;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"component.registry.cjs","sourcesContent":["import { Collection } from \"discord.js\";\nimport { BaseRegistry, Component } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\n\n/**\n * Registry to load and get all components.\n *\n * @export\n * @class ComponentRegistry\n * @typedef {ComponentRegistry}\n * @extends {BaseRegistry<Component>}\n */\nexport default class ComponentRegistry extends BaseRegistry<Component> {\n\tprotected items = new Collection<string, Component>();\n\n\t/**\n\t * Load all components.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"events\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"events\"))): Promise<this> {\n\t\tif (!(await exists(directory))) return this;\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait this.load(fullPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".js\")) {\n\t\t\t\tconst event = await this.importFile<Component>(fullPath);\n\t\t\t\tif (!event) continue;\n\n\t\t\t\tif (!event.customId || !event.customIdData) {\n\t\t\t\t\tconsole.error(`Component from ${entry.name} does not return customId nor customIdData!`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.items.set(event.customId || event.customIdData, event);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|