Files
SupportBot/Commands/help.js
T

73 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2021-10-21 19:28:23 +01:00
// SupportBot | Emerald Services
2021-10-24 22:41:46 +01:00
// Help Command
2021-10-21 19:28:23 +01:00
const fs = require("fs");
const Discord = require("discord.js");
2021-10-24 22:41:46 +01:00
const yaml = require("js-yaml");
2022-08-12 01:35:36 +01:00
2021-10-27 19:30:10 -05:00
const supportbot = yaml.load(
fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
2022-08-12 01:35:36 +01:00
const cmdconfig = yaml.load(
fs.readFileSync("./Configs/commands.yml", "utf8")
);
2021-10-21 19:28:23 +01:00
const Command = require("../Structures/Command.js");
module.exports = new Command({
2022-07-23 07:50:12 +01:00
name: cmdconfig.Help.Command,
description: cmdconfig.Help.Description,
2022-07-22 13:19:05 +01:00
type: Discord.ApplicationCommandType.ChatInput,
options: [],
2022-07-23 07:50:12 +01:00
permissions: cmdconfig.Help.Permission,
2021-10-21 19:28:23 +01:00
2021-10-24 22:41:46 +01:00
async run(interaction) {
2022-01-30 00:07:04 -06:00
const { getRole } = interaction.client;
2022-08-12 01:35:36 +01:00
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
2024-06-12 12:54:31 +01:00
if (!SupportStaff || !Admin) {
2021-11-25 01:51:56 +01:00
return interaction.reply(
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
2021-10-24 22:41:46 +01:00
);
2022-06-21 01:38:22 +01:00
}
2021-10-21 19:28:23 +01:00
2024-06-12 12:54:31 +01:00
// Fetch all commands from the client's commands collection
let botCommands = "";
interaction.client.commands.forEach((command) => {
if (command.permissions) {
botCommands += `\`${command.name}\` `;
}
});
2021-10-24 22:41:46 +01:00
2024-06-12 12:54:31 +01:00
// Create embed
2022-07-22 13:19:05 +01:00
const HelpEmbed1 = new Discord.EmbedBuilder()
.setTitle(supportbot.General.Name + " Commands")
2021-11-25 01:51:56 +01:00
.setThumbnail(interaction.user.displayAvatarURL())
2022-08-11 19:19:29 +01:00
.setColor(supportbot.Embed.Colours.General)
2024-06-12 12:54:31 +01:00
.addFields({
name: "🖥️ Commands\n",
value: botCommands || "No commands available.",
inline: false,
2022-02-25 21:55:33 -06:00
});
2021-10-24 22:41:46 +01:00
2024-06-12 12:54:31 +01:00
// Conditionally add Addons section
if (supportbot.General.Addons.Enabled) {
HelpEmbed1.addFields({
name: "🛠️ Addons\n",
value: "No addons available.",
inline: false,
2021-11-25 01:51:56 +01:00
});
2024-06-12 12:54:31 +01:00
}
HelpEmbed1.setFooter({
text: supportbot.Embed.Footer,
iconURL: interaction.user.displayAvatarURL(),
});
interaction.reply({
ephemeral: true,
embeds: [HelpEmbed1],
});
2021-10-24 22:41:46 +01:00
},
2021-12-04 20:58:19 -06:00
});