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