xernerx 4.17.7 → 4.17.9
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/build/XernerxContextCommand.d.ts +47 -75
- package/dist/build/XernerxContextCommand.js +115 -119
- package/dist/build/XernerxEvent.d.ts +10 -10
- package/dist/build/XernerxEvent.js +17 -17
- package/dist/build/XernerxInhibitor.d.ts +15 -39
- package/dist/build/XernerxInhibitor.js +18 -18
- package/dist/build/XernerxMessageCommand.d.ts +52 -78
- package/dist/build/XernerxMessageCommand.js +114 -118
- package/dist/build/XernerxSlashCommand.d.ts +63 -97
- package/dist/build/XernerxSlashCommand.js +173 -177
- package/dist/client/XernerxClient.d.ts +55 -61
- package/dist/client/XernerxClient.js +94 -91
- package/dist/client/XernerxShardClient.d.ts +14 -14
- package/dist/client/XernerxShardClient.js +48 -61
- package/dist/functions/deploy.js +52 -45
- package/dist/functions/load.js +29 -28
- package/dist/functions/reload.js +24 -23
- package/dist/functions/setPresence.d.ts +1 -1
- package/dist/functions/setPresence.js +16 -17
- package/dist/handlers/CommandHandler.d.ts +10 -10
- package/dist/handlers/CommandHandler.js +337 -312
- package/dist/handlers/EventHandler.d.ts +5 -3
- package/dist/handlers/EventHandler.js +76 -48
- package/dist/handlers/ExtensionHandler.d.ts +3 -3
- package/dist/handlers/ExtensionHandler.js +23 -23
- package/dist/handlers/Handler.d.ts +17 -22
- package/dist/handlers/Handler.js +57 -45
- package/dist/handlers/InhibitorHandler.d.ts +3 -3
- package/dist/handlers/InhibitorHandler.js +23 -25
- package/dist/handlers/IntegrationHandler.d.ts +6 -6
- package/dist/handlers/IntegrationHandler.js +20 -20
- package/dist/main.d.ts +22 -29
- package/dist/main.js +22 -29
- package/dist/models/Arguments.d.ts +1 -4
- package/dist/models/Arguments.js +149 -134
- package/dist/models/Cooldowns.d.ts +6 -6
- package/dist/models/Cooldowns.js +29 -25
- package/dist/models/XernerxEntitlement.d.ts +45 -0
- package/dist/models/XernerxEntitlement.js +57 -0
- package/dist/models/XernerxUser.d.ts +14 -0
- package/dist/models/XernerxUser.js +13 -0
- package/dist/tools/XernerxError.d.ts +4 -4
- package/dist/tools/XernerxError.js +8 -8
- package/dist/tools/XernerxIntents.d.ts +2 -2
- package/dist/tools/XernerxIntents.js +21 -21
- package/dist/tools/XernerxLog.d.ts +25 -25
- package/dist/tools/XernerxLog.js +131 -140
- package/dist/tools/XernerxText.d.ts +23 -23
- package/dist/tools/XernerxText.js +89 -79
- package/dist/types/extenders.d.ts +47 -55
- package/dist/types/interfaces.d.ts +190 -195
- package/dist/types/types.d.ts +5 -104
- package/dist/utils/ClientUtil.d.ts +10 -12
- package/dist/utils/ClientUtil.js +117 -96
- package/dist/utils/InteractionUtil.d.ts +13 -13
- package/dist/utils/InteractionUtil.js +147 -148
- package/dist/utils/MessageUtil.d.ts +14 -14
- package/dist/utils/MessageUtil.js +161 -162
- package/dist/utils/Util.d.ts +7 -7
- package/dist/utils/Util.js +7 -7
- package/dist/validators/commandValidation.d.ts +1 -4
- package/dist/validators/commandValidation.js +114 -157
- package/dist/validators/inhibitorValidations.d.ts +2 -21
- package/dist/validators/inhibitorValidations.js +39 -39
- package/package.json +6 -5
- package/tsup.config.ts +19 -0
- package/dist/functions/xernerxUser.d.ts +0 -4
- package/dist/functions/xernerxUser.js +0 -10
|
@@ -1,154 +1,153 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
-
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, InteractionType, StringSelectMenuBuilder } from 'discord.js';
|
|
2
|
+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, InteractionType, StringSelectMenuBuilder, } from 'discord.js';
|
|
3
3
|
import Util from './Util.js';
|
|
4
4
|
import XernerxError from '../tools/XernerxError.js';
|
|
5
5
|
import { Style } from 'dumfunctions';
|
|
6
6
|
export default class InteractionUtil extends Util {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
7
|
+
constructor(client, interaction) {
|
|
8
|
+
super(client);
|
|
9
|
+
this.interaction = interaction;
|
|
10
|
+
this.parsed = {
|
|
11
|
+
alias: null,
|
|
12
|
+
args: null,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async send(content) {
|
|
16
|
+
if (!content)
|
|
17
|
+
throw new XernerxError(`Can't send a message without content.`);
|
|
18
|
+
return await this.interaction.channel?.send(content);
|
|
19
|
+
}
|
|
20
|
+
async reply(content) {
|
|
21
|
+
if (!content)
|
|
22
|
+
throw new XernerxError(`Can't send a message without content.`);
|
|
23
|
+
return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
|
|
24
|
+
}
|
|
25
|
+
async mimic(user, interaction, options) {
|
|
26
|
+
user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
|
|
27
|
+
const webhooks = await this.interaction.channel.fetchWebhooks();
|
|
28
|
+
const webhook = webhooks.find((wh) => wh.token) ||
|
|
29
|
+
(await this.interaction.channel.createWebhook({
|
|
30
|
+
name: `${this.client.user?.username}'s mimic webhook.`,
|
|
31
|
+
avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
|
|
32
|
+
}));
|
|
33
|
+
await webhook.send({
|
|
34
|
+
content: interaction.content,
|
|
35
|
+
username: user.username,
|
|
36
|
+
avatarURL: user.displayAvatarURL(),
|
|
37
|
+
});
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
webhook.delete().catch(() => true);
|
|
40
|
+
}, options.timeout);
|
|
41
|
+
}
|
|
42
|
+
async paginator(embeds, options = {}) {
|
|
43
|
+
let buttonRow, menuRow;
|
|
44
|
+
if (embeds.length <= 0)
|
|
45
|
+
throw new XernerxError(`Can't make a paginator without embeds`);
|
|
46
|
+
options = {
|
|
47
|
+
type: options.type ?? 'combined',
|
|
48
|
+
buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
|
|
49
|
+
description: options.description ?? false,
|
|
50
|
+
placeholder: options.placeholder ?? 'Change page',
|
|
51
|
+
index: options.index ?? 0,
|
|
52
|
+
send: options.send ?? false,
|
|
53
|
+
filter: options.filter ?? (() => true),
|
|
54
|
+
time: options.time ?? 300000,
|
|
55
|
+
};
|
|
56
|
+
if (options.type == 'button' || options.type == 'combined') {
|
|
57
|
+
if (!options.buttons)
|
|
58
|
+
throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
|
|
59
|
+
buttonRow = new ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary)));
|
|
60
|
+
}
|
|
61
|
+
if (options.type == 'select-menu' || options.type == 'combined') {
|
|
62
|
+
menuRow = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder()
|
|
63
|
+
.setCustomId(`${this.interaction.id}-select-menu`)
|
|
64
|
+
.setPlaceholder(options.placeholder)
|
|
65
|
+
.addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
|
|
66
|
+
}
|
|
67
|
+
let index = options.index || 0;
|
|
68
|
+
return options.send
|
|
69
|
+
? await this.interaction.util.send({
|
|
70
|
+
embeds: [embeds[index]],
|
|
71
|
+
components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
|
|
72
|
+
})
|
|
73
|
+
: await this.interaction.util
|
|
74
|
+
.reply({
|
|
75
|
+
embeds: [embeds[index]],
|
|
76
|
+
components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
|
|
77
|
+
})
|
|
78
|
+
.then(async (msg) => {
|
|
79
|
+
const collector = this.interaction.channel
|
|
80
|
+
?.createMessageComponentCollector({ time: options.time })
|
|
81
|
+
.on('collect', (collect) => {
|
|
82
|
+
if (!collect.customId.startsWith(this.interaction.id))
|
|
83
|
+
return;
|
|
84
|
+
if (collect.customId.endsWith('select-menu')) {
|
|
85
|
+
index = Number(collect.values[0]);
|
|
86
|
+
collect.update({ embeds: [embeds[index]] });
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const option = Number(collect.customId.split(/-/)[1]);
|
|
90
|
+
let embed = embeds[index];
|
|
91
|
+
if (option == 0) {
|
|
92
|
+
index = 0;
|
|
93
|
+
embed = embeds[index];
|
|
94
|
+
collect.update({ embeds: [embed] });
|
|
95
|
+
}
|
|
96
|
+
if (option == 1) {
|
|
97
|
+
index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
|
|
98
|
+
embed = embeds[index];
|
|
99
|
+
collect.update({ embeds: [embed] });
|
|
100
|
+
}
|
|
101
|
+
if (option == 2) {
|
|
102
|
+
collect.update({ components: [] });
|
|
103
|
+
collector?.stop();
|
|
104
|
+
}
|
|
105
|
+
if (option == 3) {
|
|
106
|
+
index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
|
|
107
|
+
embed = embeds[index];
|
|
108
|
+
collect.update({ embeds: [embed] });
|
|
109
|
+
}
|
|
110
|
+
if (option == 4) {
|
|
111
|
+
index = embeds.length - 1;
|
|
112
|
+
embed = embeds[index];
|
|
113
|
+
collect.update({ embeds: [embed] });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
.on('end', async () => {
|
|
118
|
+
this.interaction.editReply({ components: [] });
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
commands() {
|
|
123
|
+
if (this.interaction.type == InteractionType.ApplicationCommand)
|
|
124
|
+
return this.client.commands.slash;
|
|
125
|
+
else
|
|
126
|
+
return this.client.commands.context;
|
|
127
|
+
}
|
|
128
|
+
permissionCheck(type, permissions, emit = true) {
|
|
129
|
+
const missing = [];
|
|
130
|
+
for (const permission of permissions) {
|
|
131
|
+
if (type == 'user') {
|
|
132
|
+
this.interaction.memberPermissions?.has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
|
|
133
|
+
}
|
|
134
|
+
if (type == 'client') {
|
|
135
|
+
this.interaction.guild?.members.me?.permissionsIn(this.interaction.channel?.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const command = this.commands().toJSON().find((cmd) => cmd.name == this.parsed.alias?.split(/ +/)[0]);
|
|
139
|
+
if (missing.length && emit) {
|
|
140
|
+
this.client.emit(`commandBlock`, this.interaction, {
|
|
141
|
+
reason: `missing${Style.pascalCase(type)}Permissions`,
|
|
142
|
+
message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
|
|
143
|
+
required: permissions,
|
|
144
|
+
missing,
|
|
145
|
+
}, command || null);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
else if (missing.length && !emit)
|
|
149
|
+
return missing;
|
|
150
|
+
else
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
154
153
|
}
|
|
@@ -6,21 +6,21 @@ import Util from './Util.js';
|
|
|
6
6
|
import { PaginatorOptions } from '../types/interfaces.js';
|
|
7
7
|
import { PermissionNames } from '../main.js';
|
|
8
8
|
type MimicOptions = {
|
|
9
|
-
|
|
9
|
+
timeout: number;
|
|
10
10
|
};
|
|
11
11
|
export default class MessageUtil extends Util {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
private readonly message;
|
|
13
|
+
parsed: {
|
|
14
|
+
alias: string | null;
|
|
15
|
+
prefix: string | null;
|
|
16
|
+
args: Record<string, unknown> | null;
|
|
17
|
+
};
|
|
18
|
+
constructor(client: XernerxClient, message: XernerxMessage);
|
|
19
|
+
send(content: any): Promise<any>;
|
|
20
|
+
reply(content: string | MessagePayload | MessageReplyOptions | MessageEditOptions): Promise<import("discord.js").Message<boolean> | null>;
|
|
21
|
+
mimic(user: XernerxUser | string, message: MessageCreateOptions, options: MimicOptions): Promise<void>;
|
|
22
|
+
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<any>;
|
|
23
|
+
commands(): import("discord.js").Collection<string, import("../main.js").XernerxMessageCommand>;
|
|
24
|
+
permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames>, emit?: boolean): boolean | string[];
|
|
25
25
|
}
|
|
26
26
|
export {};
|