Files
quarksBot/commands/help.js
T
2022-08-28 17:41:34 -07:00

180 lines
6.0 KiB
JavaScript

const { EmbedBuilder, ActionRowBuilder, SelectMenuBuilder } = require("discord.js");
const settings = require('../config/settingsHelp');
module.exports = {
name: "help",
debug: false,
description: "Get information on a specific command",
usage: "[option]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [
{
name: "commands",
description: "List all commands",
value: "commands",
type: 1,
options: [{
name: "command",
description: "Get information on a specific command",
value: "command",
type: 3,
required: false,
}]
},
{
name: "settings",
description: "How to configure the settings",
value: "settings",
type: 1,
},
{
name: "support",
description: "Get support for QuarksBot",
value: "support",
type: 1,
},
{
name: "credits",
description: "QuarksBot Credits",
value: "credits",
type: 1,
}
],
SlashCommand: {
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (args[0].name == 'commands') {
let Commands = client.commands.filter((cmd) => {
return !cmd.debug
}).map((cmd) =>
`\`/${cmd.name}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}`
);
let Embed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`${Commands.join("\n")}
QuarksBot Version: v${client.config.Version}`);
if (!args[0].options[0]) return interaction.send(Embed);
else {
let cmd =
client.commands.get(args[0].options[0].value) ||
client.commands.find(
(x) => x.aliases && x.aliases.includes(args[0].options[0].value)
);
if (!cmd)
return client.sendTime(
interaction,
`❌ | Unable to find that command.`
);
let embed = new EmbedBuilder()
.setDescription(cmd.description)
.setColor(client.config.Colors.Green)
.setTitle(`How to use /${cmd.name} command`)
if (cmd.SlashCommand.options && cmd.SlashCommand.options[0].type == 1) {
let description = `${cmd.description}\n\n**Usage**\n`;
for (let i = 0; i < cmd.SlashCommand.options.length; i++) {
if (cmd.SlashCommand.options[i].type == 1) {
let param = '';
if (cmd.SlashCommand.options[i].options) {
param = cmd.SlashCommand.options[i].options.length > 0 ? ' ' : '';
for (let j = 0; j < cmd.SlashCommand.options[i].options.length; j++) {
if (cmd.SlashCommand.options[i].options[j].required) param += `[${cmd.SlashCommand.options[i].options[j].name}] `
}
}
description += `\`/${cmd.name} ${cmd.SlashCommand.options[i].name}${param}\`\n${cmd.SlashCommand.options[i].description}\n\n`
}
}
embed.setDescription(description);
} else {
embed.addField(
"Usage",
`\`/${cmd.name}\`${cmd.usage ? " " + cmd.usage : ""}`,
true
)
}
return interaction.send(embed);
}
} else if (args[0].name == 'settings') {
let settingsMenu = new SelectMenuBuilder()
.setCustomId(`settingSelect-${interaction.member.user.id}`)
.setPlaceholder('Select Setting you require help with')
settings.settings.map((setting) => {
settingsMenu.addOptions({
label: setting.name,
description: 'Get help with this setting',
value: setting.name,
})
})
const SelectSettings = new ActionRowBuilder().addComponents(settingsMenu);
interaction.send({ components: [SelectSettings], flags: (1 << 6) });
client.on("interactionCreate", MenuInteraction => {
if(!MenuInteraction.isSelectMenu()) return;
if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) {
return MenuInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
const setting = settings.settings.find(setting => setting.name === MenuInteraction.values[0]);
const settingEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle(setting.name)
.setDescription(setting.description)
return MenuInteraction.update({ embeds: [settingEmbed], components: [] });
});
} else if (args[0].name == 'support') {
const supportEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`**__QuarksBot Support__**
Are you experiencing troubles with QuarksBot?
Do you have questions or concerns?
Do you require help to use the bot?
Do you have a feature you'd like to see?
Join the support server to have all your needs fulfilled.
╚➤ ${client.config.SupportServer}
`)
return interaction.send({ embeds: [supportEmbed] });
} else if (args[0].name == 'credits') {
const creditsEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('QuarksBot Credits')
.setDescription(`
**Bot Author:** McDazzzled#5307
Special thanks to Mav#1518 for the introduction to the project idea,
as well as providing feedback/ideas for features.
${client.config.SupportServer}
`);
return interaction.send({ embeds: [creditsEmbed] })
}
},
},
};