xernerx 4.5.8 → 4.5.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/utils/ClientUtil.d.ts +1 -0
- package/dist/utils/ClientUtil.d.ts.map +1 -1
- package/dist/utils/ClientUtil.js +2 -0
- package/dist/utils/ClientUtil.js.map +1 -1
- package/dist/utils/InteractionUtil.d.ts +1 -1
- package/dist/utils/InteractionUtil.d.ts.map +1 -1
- package/dist/utils/InteractionUtil.js +1 -0
- package/dist/utils/InteractionUtil.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export default class ClientUtil extends Util {
|
|
|
8
8
|
hasVoted: Function;
|
|
9
9
|
constructor(client: XernerxClient);
|
|
10
10
|
setPresence(options: PresenceOptions): import('discord.js').ClientPresence | undefined;
|
|
11
|
+
private resolveCooldown;
|
|
11
12
|
resolveCommand(
|
|
12
13
|
options: ResolveCommandOptions
|
|
13
14
|
): XernerxMessageCommand | XernerxSlashCommand | XernerxContextCommand | Collection<string, XernerxMessageCommand | XernerxSlashCommand | XernerxContextCommand>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAGd,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE/F,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IAC5B,QAAQ,EAAE,QAAQ,CAAC;gBAEtB,MAAM,EAAE,aAAa;IAI1B,WAAW,CAAC,OAAO,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"ClientUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAGd,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE/F,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IAC5B,QAAQ,EAAE,QAAQ,CAAC;gBAEtB,MAAM,EAAE,aAAa;IAI1B,WAAW,CAAC,OAAO,EAAE,eAAe;IAK3C,OAAO,CAAC,eAAe;IAEhB,cAAc,CAAC,OAAO,EAAE,qBAAqB;IAiBvC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAiBrD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAczD,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;CAkBvC"}
|
package/dist/utils/ClientUtil.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientUtil.js","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAGtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IAG3C,YAAY,MAAqB;QAChC,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAEM,WAAW,CAAC,OAAwB;QAC1C,O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AE,OAAO,GAAG,OAAO,KAAK,OAAO,GAAG,CAAC;;YACnD,OAAO,GAAG,OAAO,GAAG,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/** @format */\n\nimport setPresence from '../functions/setPresence.js';\nimport XernerxClient from '../client/XernerxClient.js';\nimport { PresenceOptions, ResolveCommandOptions } from '../types/interfaces.js';\nimport Util from './Util.js';\nimport { Collection } from 'discord.js';\nimport { XernerxContextCommand, XernerxMessageCommand, XernerxSlashCommand } from '../main.js';\n\nexport default class ClientUtil extends Util {\n\tpublic declare hasVoted: Function;\n\n\tconstructor(client: XernerxClient) {\n\t\tsuper(client);\n\t}\n\n\tpublic setPresence(options: PresenceOptions) {\n\t\treturn setPresence(this.client, options);\n\t}\n\n\t// @ts-ignore\n\tprivate resolveCooldown() {}\n\n\tpublic resolveCommand(options: ResolveCommandOptions) {\n\t\tconst commands = [],\n\t\t\tcollection = new Collection();\n\n\t\tif (options?.type == 'MessageCommand' || !options?.type) commands.push(...this.client.commands.message);\n\n\t\tif (options?.type == 'Interaction' || options?.type == 'SlashCommand' || !options?.type) commands.push(...this.client.commands.slash);\n\n\t\tif (options?.type == 'Interaction' || options?.type == 'ContextCommand' || !options?.type) commands.push(...this.client.commands.context);\n\n\t\tcommands.map(([name, command]) => collection.set(name, command));\n\n\t\tif (options?.name) {\n\t\t\treturn (collection.get(options.name) as XernerxMessageCommand | XernerxSlashCommand | XernerxContextCommand) || null;\n\t\t} else return collection as Collection<string, XernerxMessageCommand | XernerxSlashCommand | XernerxContextCommand>;\n\t}\n\n\tpublic async resolveChannel(query: string | Record<string, string>) {\n\t\tif (typeof query == 'object') query = query.id;\n\n\t\ttry {\n\t\t\tlet channel =\n\t\t\t\tthis.client.channels.cache.find(<T>(channel: T) =>\n\t\t\t\t\t(channel as Record<string, string>).name == (query as string).toLowerCase() || (channel as Record<string, string>).id == (query as string).toLowerCase() ? channel : null\n\t\t\t\t) || null;\n\n\t\t\tif (!channel) channel = (await this.client.channels.fetch(query)) || null;\n\n\t\t\treturn channel;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic async resolveGuild(query: string | Record<string, string>) {\n\t\tif (typeof query == 'object') query = query.id;\n\n\t\ttry {\n\t\t\tlet guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == (query as string).toLowerCase()) || null;\n\n\t\t\tif (!guild) guild = (await this.client.guilds.fetch(query)) || null;\n\n\t\t\treturn guild;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic uptime(timestamp?: number | null) {\n\t\tif (!timestamp) timestamp = this.client.uptime || 0;\n\t\tlet totalSeconds = timestamp / 1000;\n\t\tlet years = Math.floor(totalSeconds / 31536000);\n\t\ttotalSeconds %= 31536000;\n\t\tlet days = Math.floor(totalSeconds / 86400);\n\t\ttotalSeconds %= 86400;\n\t\tlet hours = Math.floor(totalSeconds / 3600);\n\t\ttotalSeconds %= 3600;\n\t\tlet minutes = Math.floor(totalSeconds / 60);\n\t\tlet seconds = Math.floor(totalSeconds % 60);\n\n\t\tif (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;\n\t\telse if (days >= 1) return `${days}d ${hours}h ${minutes}m`;\n\t\telse if (hours >= 1) return `${hours}h ${minutes}m`;\n\t\telse if (minutes >= 1) return `${minutes}m ${seconds}s`;\n\t\telse return `${seconds}s`;\n\t}\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export default class InteractionUtil extends Util {
|
|
|
10
10
|
constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
|
|
11
11
|
send(content: any): Promise<import('discord.js').Message<false> | import('discord.js').Message<true> | undefined>;
|
|
12
12
|
reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import('discord.js').InteractionResponse<boolean> | import('discord.js').Message<boolean>>;
|
|
13
|
-
commandName
|
|
13
|
+
private commandName;
|
|
14
14
|
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import('discord.js').Message<false> | import('discord.js').Message<true>>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=InteractionUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionUtil.d.ts","sourceRoot":"","sources":["../../src/utils/InteractionUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,EAAgD,YAAY,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,cAAc,EAA2B,MAAM,YAAY,CAAC;AAEvL,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEjI,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,IAAI;IAChD,OAAO,CAAC,WAAW,CAAC;gBAER,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,CAAC,uBAAuB,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;IAMjJ,IAAI,CAAC,OAAO,EAAE,GAAG;IAMjB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,uBAAuB,GAAG,2BAA2B;
|
|
1
|
+
{"version":3,"file":"InteractionUtil.d.ts","sourceRoot":"","sources":["../../src/utils/InteractionUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,EAAgD,YAAY,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,cAAc,EAA2B,MAAM,YAAY,CAAC;AAEvL,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEjI,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,IAAI;IAChD,OAAO,CAAC,WAAW,CAAC;gBAER,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,CAAC,uBAAuB,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;IAMjJ,IAAI,CAAC,OAAO,EAAE,GAAG;IAMjB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,uBAAuB,GAAG,2BAA2B;IAO3G,OAAO,CAAC,WAAW;IAEN,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,GAAE,gBAAqB;CA4FlF"}
|
|
@@ -16,6 +16,7 @@ export default class InteractionUtil extends Util {
|
|
|
16
16
|
if (!content) throw new XernerxError(`Can't send a message without content.`);
|
|
17
17
|
return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
|
|
18
18
|
}
|
|
19
|
+
// @ts-ignore
|
|
19
20
|
commandName() {}
|
|
20
21
|
async paginator(embeds, options = {}) {
|
|
21
22
|
let buttonRow, menuRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionUtil.js","sourceRoot":"","sources":["../../src/utils/InteractionUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAsF,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAKvL,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,YAAY,MAAM,0BAA0B,CAAC;AAGpD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,IAAI;IACxC,WAAW,CAAC;IAEpB,YAAY,MAAqB,EAAE,WAA2H;QAC7J,KAAK,CAAC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,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;4BACnC,SAAS,EAAE,IAAI,EAAE,CAAC;yBAClB;wBACD,IAAI,MAAM,IAAI,CAAC,EAAE;4BAChB,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;4BAClG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;4BACtB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;yBACpC;wBACD,IAAI,MAAM,IAAI,CAAC,EAAE;4BAChB,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;4BAC1B,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;4BACtB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;yBACpC;qBACD;gBACF,CAAC,CAAC;qBACD,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;oBACrB,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;gBAChD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;IACP,CAAC;CACD","sourcesContent":["/** @format */\n\nimport { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload, StringSelectMenuBuilder } from 'discord.js';\n\nimport XernerxClient from '../client/XernerxClient.js';\nimport { PaginatorOptions } from '../types/interfaces.js';\nimport { XernerxInteraction } from '../types/types.js';\nimport Util from './Util.js';\nimport XernerxError from '../tools/XernerxError.js';\nimport { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';\n\nexport default class InteractionUtil extends Util {\n\tprivate interaction;\n\n\tconstructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>) {\n\t\tsuper(client);\n\n\t\tthis.interaction = interaction;\n\t}\n\n\tpublic async send(content: any) {\n\t\tif (!content) throw new XernerxError(`Can't send a message without content.`);\n\n\t\treturn await this.interaction.channel?.send(content);\n\t}\n\n\tpublic async reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions) {\n\t\tif (!content) throw new XernerxError(`Can't send a message without content.`);\n\n\t\treturn await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content as InteractionReplyOptions));\n\t}\n\n\tpublic commandName() {}\n\n\tpublic async paginator(embeds: Array<EmbedBuilder>, options: PaginatorOptions = {}) {\n\t\tlet buttonRow, menuRow;\n\n\t\tif (embeds.length <= 0) throw new XernerxError(`Can't make a paginator without embeds`);\n\n\t\toptions = {\n\t\t\ttype: options.type ?? 'combined',\n\t\t\tbuttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],\n\t\t\tdescription: options.description ?? false,\n\t\t\tplaceholder: options.placeholder ?? 'Change page',\n\t\t\tindex: options.index ?? 0,\n\t\t\tsend: options.send ?? false,\n\t\t\tfilter: options.filter ?? (() => true),\n\t\t\ttime: options.time ?? 300000,\n\t\t};\n\n\t\tif (options.type == 'button' || options.type == 'combined') {\n\t\t\tif (!options.buttons) throw new XernerxError(`¯\\\\_(ツ)_/¯ Somehow there are no buttons? ¯\\\\_(ツ)_/¯`);\n\n\t\t\tbuttonRow = new ActionRowBuilder().addComponents(\n\t\t\t\t...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary))\n\t\t\t);\n\t\t}\n\n\t\tif (options.type == 'select-menu' || options.type == 'combined') {\n\t\t\tmenuRow = new ActionRowBuilder().addComponents(\n\t\t\t\tnew StringSelectMenuBuilder()\n\t\t\t\t\t.setCustomId(`${this.interaction.id}-select-menu`)\n\t\t\t\t\t.setPlaceholder(options.placeholder as string)\n\t\t\t\t\t.addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` })))\n\t\t\t);\n\t\t}\n\n\t\tlet index = options.index || 0;\n\n\t\treturn options.send\n\t\t\t? await this.interaction.util.send({\n\t\t\t\t\tembeds: [embeds[index]],\n\t\t\t\t\tcomponents: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),\n\t\t\t } as never)\n\t\t\t: await this.interaction.util\n\t\t\t\t\t.reply({\n\t\t\t\t\t\tembeds: [embeds[index]],\n\t\t\t\t\t\tcomponents: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),\n\t\t\t\t\t} as never)\n\t\t\t\t\t.then(async (msg) => {\n\t\t\t\t\t\tconst collector = this.interaction.channel\n\t\t\t\t\t\t\t?.createMessageComponentCollector({ time: options.time })\n\n\t\t\t\t\t\t\t.on('collect', (collect) => {\n\t\t\t\t\t\t\t\tif (!collect.customId.startsWith(this.interaction.id)) return;\n\n\t\t\t\t\t\t\t\tif (collect.customId.endsWith('select-menu')) {\n\t\t\t\t\t\t\t\t\tindex = Number((collect as unknown as Record<string, Array<string>>).values[0]);\n\n\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embeds[index]] });\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst option = Number(collect.customId.split(/-/)[1]);\n\n\t\t\t\t\t\t\t\t\tlet embed = embeds[index];\n\n\t\t\t\t\t\t\t\t\tif (option == 0) {\n\t\t\t\t\t\t\t\t\t\tindex = 0;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 1) {\n\t\t\t\t\t\t\t\t\t\tindex = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 2) {\n\t\t\t\t\t\t\t\t\t\tcollect.update({ components: [] });\n\t\t\t\t\t\t\t\t\t\tcollector?.stop();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 3) {\n\t\t\t\t\t\t\t\t\t\tindex = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 4) {\n\t\t\t\t\t\t\t\t\t\tindex = embeds.length - 1;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.on('end', async () => {\n\t\t\t\t\t\t\t\tthis.interaction.editReply({ components: [] });\n\t\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InteractionUtil.js","sourceRoot":"","sources":["../../src/utils/InteractionUtil.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAsF,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAKvL,OAAO,IAAI,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ractionReplyOptions, MessagePayload, StringSelectMenuBuilder } from 'discord.js';\n\nimport XernerxClient from '../client/XernerxClient.js';\nimport { PaginatorOptions } from '../types/interfaces.js';\nimport { XernerxInteraction } from '../types/types.js';\nimport Util from './Util.js';\nimport XernerxError from '../tools/XernerxError.js';\nimport { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';\n\nexport default class InteractionUtil extends Util {\n\tprivate interaction;\n\n\tconstructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>) {\n\t\tsuper(client);\n\n\t\tthis.interaction = interaction;\n\t}\n\n\tpublic async send(content: any) {\n\t\tif (!content) throw new XernerxError(`Can't send a message without content.`);\n\n\t\treturn await this.interaction.channel?.send(content);\n\t}\n\n\tpublic async reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions) {\n\t\tif (!content) throw new XernerxError(`Can't send a message without content.`);\n\n\t\treturn await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content as InteractionReplyOptions));\n\t}\n\n\t// @ts-ignore\n\tprivate commandName() {}\n\n\tpublic async paginator(embeds: Array<EmbedBuilder>, options: PaginatorOptions = {}) {\n\t\tlet buttonRow, menuRow;\n\n\t\tif (embeds.length <= 0) throw new XernerxError(`Can't make a paginator without embeds`);\n\n\t\toptions = {\n\t\t\ttype: options.type ?? 'combined',\n\t\t\tbuttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],\n\t\t\tdescription: options.description ?? false,\n\t\t\tplaceholder: options.placeholder ?? 'Change page',\n\t\t\tindex: options.index ?? 0,\n\t\t\tsend: options.send ?? false,\n\t\t\tfilter: options.filter ?? (() => true),\n\t\t\ttime: options.time ?? 300000,\n\t\t};\n\n\t\tif (options.type == 'button' || options.type == 'combined') {\n\t\t\tif (!options.buttons) throw new XernerxError(`¯\\\\_(ツ)_/¯ Somehow there are no buttons? ¯\\\\_(ツ)_/¯`);\n\n\t\t\tbuttonRow = new ActionRowBuilder().addComponents(\n\t\t\t\t...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary))\n\t\t\t);\n\t\t}\n\n\t\tif (options.type == 'select-menu' || options.type == 'combined') {\n\t\t\tmenuRow = new ActionRowBuilder().addComponents(\n\t\t\t\tnew StringSelectMenuBuilder()\n\t\t\t\t\t.setCustomId(`${this.interaction.id}-select-menu`)\n\t\t\t\t\t.setPlaceholder(options.placeholder as string)\n\t\t\t\t\t.addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` })))\n\t\t\t);\n\t\t}\n\n\t\tlet index = options.index || 0;\n\n\t\treturn options.send\n\t\t\t? await this.interaction.util.send({\n\t\t\t\t\tembeds: [embeds[index]],\n\t\t\t\t\tcomponents: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),\n\t\t\t } as never)\n\t\t\t: await this.interaction.util\n\t\t\t\t\t.reply({\n\t\t\t\t\t\tembeds: [embeds[index]],\n\t\t\t\t\t\tcomponents: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),\n\t\t\t\t\t} as never)\n\t\t\t\t\t.then(async (msg) => {\n\t\t\t\t\t\tconst collector = this.interaction.channel\n\t\t\t\t\t\t\t?.createMessageComponentCollector({ time: options.time })\n\n\t\t\t\t\t\t\t.on('collect', (collect) => {\n\t\t\t\t\t\t\t\tif (!collect.customId.startsWith(this.interaction.id)) return;\n\n\t\t\t\t\t\t\t\tif (collect.customId.endsWith('select-menu')) {\n\t\t\t\t\t\t\t\t\tindex = Number((collect as unknown as Record<string, Array<string>>).values[0]);\n\n\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embeds[index]] });\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst option = Number(collect.customId.split(/-/)[1]);\n\n\t\t\t\t\t\t\t\t\tlet embed = embeds[index];\n\n\t\t\t\t\t\t\t\t\tif (option == 0) {\n\t\t\t\t\t\t\t\t\t\tindex = 0;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 1) {\n\t\t\t\t\t\t\t\t\t\tindex = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 2) {\n\t\t\t\t\t\t\t\t\t\tcollect.update({ components: [] });\n\t\t\t\t\t\t\t\t\t\tcollector?.stop();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 3) {\n\t\t\t\t\t\t\t\t\t\tindex = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (option == 4) {\n\t\t\t\t\t\t\t\t\t\tindex = embeds.length - 1;\n\t\t\t\t\t\t\t\t\t\tembed = embeds[index];\n\t\t\t\t\t\t\t\t\t\tcollect.update({ embeds: [embed] });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.on('end', async () => {\n\t\t\t\t\t\t\t\tthis.interaction.editReply({ components: [] });\n\t\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t}\n}\n"]}
|