2026-02-14 11:37:24 -05:00
|
|
|
import {messageHelper} from "./helpers/messageHelper.js";
|
|
|
|
|
import {enums} from "./enums.js";
|
|
|
|
|
import {memberHelper} from "./helpers/memberHelper.js";
|
|
|
|
|
import {EmbedBuilder} from "@fluxerjs/core";
|
2026-02-19 21:45:10 -05:00
|
|
|
import {importHelper} from "./helpers/importHelper.js";
|
2026-02-14 11:37:24 -05:00
|
|
|
|
|
|
|
|
const cmds = new Map();
|
|
|
|
|
|
|
|
|
|
cmds.set('member', {
|
|
|
|
|
description: enums.help.SHORT_DESC_MEMBER,
|
|
|
|
|
async execute(message, client, args) {
|
2026-02-14 21:02:08 -05:00
|
|
|
const authorFull = `${message.author.username}#${message.author.discriminator}`
|
2026-02-14 22:11:28 -05:00
|
|
|
const attachmentUrl = message.attachments.size > 0 ? message.attachments.first().url : null;
|
|
|
|
|
const attachmentExpires = message.attachments.size > 0 ? message.attachments.first().expires_at : null;
|
2026-02-19 21:45:10 -05:00
|
|
|
const reply = await memberHelper.parseMemberCommand(message.author.id, authorFull, args, attachmentUrl, attachmentExpires).catch(async (e) =>{await message.reply(e.message);});
|
2026-02-14 14:29:21 -05:00
|
|
|
if (typeof reply === 'string') {
|
2026-02-14 21:02:08 -05:00
|
|
|
return await message.reply(reply);
|
2026-02-14 14:29:21 -05:00
|
|
|
}
|
2026-02-15 16:48:51 -05:00
|
|
|
else if (reply instanceof EmbedBuilder) {
|
|
|
|
|
await message.reply({embeds: [reply.toJSON()]})
|
|
|
|
|
}
|
2026-02-19 21:45:10 -05:00
|
|
|
else if (typeof reply === 'object') {
|
|
|
|
|
const errorsText = reply.errors.length > 0 ? reply.errors.join('\n- ') : null;
|
|
|
|
|
return await message.reply({content: `${reply.success} ${errorsText ? "\nThese errors occurred:\n" + errorsText : ""}`, embeds: [reply.embed.toJSON()]})
|
|
|
|
|
}
|
2026-02-15 16:48:51 -05:00
|
|
|
|
2026-02-14 11:37:24 -05:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
cmds.set('help', {
|
|
|
|
|
description: enums.help.SHORT_DESC_HELP,
|
|
|
|
|
async execute(message) {
|
|
|
|
|
const fields = [...cmds.entries()].map(([name, cmd]) => ({
|
|
|
|
|
name: `${messageHelper.prefix}${name}`,
|
|
|
|
|
value: cmd.description,
|
|
|
|
|
inline: true,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
|
.setTitle('Commands')
|
|
|
|
|
.setDescription(enums.help.PLURALFLUX)
|
|
|
|
|
.addFields(...fields)
|
|
|
|
|
.setFooter({ text: `Prefix: ${messageHelper.prefix}` })
|
|
|
|
|
.setTimestamp();
|
|
|
|
|
|
|
|
|
|
await message.reply({ embeds: [embed.toJSON()] });
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
2026-02-15 00:23:30 -05:00
|
|
|
cmds.set('import', {
|
2026-02-15 01:42:12 -05:00
|
|
|
description: enums.help.SHORT_DESC_IMPORT,
|
2026-02-19 21:45:10 -05:00
|
|
|
async execute(message, client, args) {
|
|
|
|
|
const attachmentUrl = message.attachments.size > 0 ? message.attachments.first().url : null;
|
|
|
|
|
if ((message.content.includes('--help') || (args[0] === '' && args.length === 1)) && !attachmentUrl ) {
|
2026-02-16 12:50:46 -05:00
|
|
|
return await message.reply(enums.help.IMPORT);
|
|
|
|
|
}
|
2026-02-15 01:29:56 -05:00
|
|
|
return await importHelper.pluralKitImport(message.author.id, attachmentUrl).then(async (successfullyAdded) => {
|
2026-02-15 00:23:30 -05:00
|
|
|
await message.reply(successfullyAdded);
|
2026-02-15 01:29:56 -05:00
|
|
|
}).catch(async (error) => {
|
2026-02-15 00:23:30 -05:00
|
|
|
if (error instanceof AggregateError) {
|
|
|
|
|
// errors.message can be a list of successfully added members, or say that none were successful.
|
2026-02-15 01:29:56 -05:00
|
|
|
let errorsText = `${error.message}.\nThese errors occurred:\n${error.errors.join('\n')}`;
|
2026-02-15 16:19:59 -05:00
|
|
|
|
|
|
|
|
await message.reply(errorsText).catch(async () => {
|
2026-02-19 21:45:10 -05:00
|
|
|
const returnedBuffer = messageHelper.returnBufferFromText(errorsText);
|
|
|
|
|
await message.reply({content: returnedBuffer.text, files: [{ name: 'text.pdf', data: returnedBuffer.file }]
|
|
|
|
|
})
|
2026-02-15 16:19:59 -05:00
|
|
|
});
|
2026-02-15 00:23:30 -05:00
|
|
|
}
|
|
|
|
|
// If just one error was returned.
|
|
|
|
|
else {
|
|
|
|
|
return await message.reply(error.message);
|
|
|
|
|
}
|
2026-02-15 01:29:56 -05:00
|
|
|
})
|
|
|
|
|
}
|
2026-02-15 00:23:30 -05:00
|
|
|
})
|
|
|
|
|
|
2026-02-14 11:37:24 -05:00
|
|
|
export const commands = cmds;
|