Files
SupportBot/Commands/help.js
T

99 lines
3.0 KiB
JavaScript
Raw 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");
2021-10-27 19:30:10 -05:00
const supportbot = yaml.load(
fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
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-07-23 07:50:12 +01:00
let disableCommand = true;
if (cmdconfig.Help.Enabled === false) {
if (interaction.type === Discord.InteractionType.ApplicationCommand && disableCommand)
return interaction.reply({
content: ":x: This command is `disabled`",
ephemeral: true,
});
}
2022-01-30 00:07:04 -06:00
const { getRole } = interaction.client;
let SupportStaff = await getRole(supportbot.Staff, interaction.guild);
let Admin = await getRole(supportbot.Admin, interaction.guild);
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
);
2021-12-04 20:58:19 -06:00
2021-11-25 01:51:56 +01:00
let botCommands = "";
2022-07-23 07:50:12 +01:00
botCommands += ` \`${cmdconfig.Help.Command}\` `;
botCommands += `\`${cmdconfig.Ping.Command}\` `;
botCommands += `\`${cmdconfig.Info.Command}\` `;
2022-06-21 01:38:22 +01:00
2022-06-21 01:41:53 +01:00
if (supportbot.DisableSuggestions === false) {
2022-07-23 07:50:12 +01:00
botCommands += `\`${cmdconfig.Suggestion.Command}\` `;
2022-06-21 01:38:22 +01:00
}
2021-10-21 19:28:23 +01:00
2021-11-25 01:51:56 +01:00
let ticketCommands = "";
2022-07-23 07:50:12 +01:00
ticketCommands += ` \`${cmdconfig.OpenTicket.Command}\` `;
ticketCommands += `\`${cmdconfig.CloseTicket.Command}\` `;
2021-10-24 22:41:46 +01:00
2021-11-25 01:51:56 +01:00
let staffCommands = "";
2022-07-23 07:50:12 +01:00
staffCommands += ` \`${cmdconfig.TicketAdd.Command}\` `;
staffCommands += `\`${cmdconfig.TicketRemove.Command}\` `;
staffCommands += `\`${cmdconfig.UserInfo.Command}\` `;
staffCommands += `\`${cmdconfig.Translate.Command}\` `;
2021-10-24 22:41:46 +01:00
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)
2021-11-25 01:51:56 +01:00
.addFields(
{
name: "🖥️ General Commands\n",
value: `${botCommands}\n`,
inline: false,
},
{
name: "🎫 Support Commands\n",
value: `${ticketCommands}\n`,
inline: false,
}
)
2021-10-24 22:41:46 +01:00
2022-08-11 19:19:29 +01:00
.setColor(supportbot.Embed.Colours.General)
2022-02-25 21:55:33 -06:00
.setFooter({
2022-08-11 19:19:29 +01:00
text: supportbot.Embed.Footer,
2022-02-25 21:55:33 -06:00
iconURL: interaction.user.displayAvatarURL(),
});
2021-10-24 22:41:46 +01:00
2021-12-04 20:58:19 -06:00
if (
interaction.member.roles.cache.has(SupportStaff.id) ||
interaction.member.roles.cache.has(Admin.id)
2021-12-04 20:58:19 -06:00
) {
2021-11-25 01:51:56 +01:00
HelpEmbed1.addFields({
name: "🔐 Staff Commands\n",
value: `${staffCommands}\n`,
inline: false,
});
}
2021-10-24 22:41:46 +01:00
2021-11-25 01:51:56 +01:00
interaction.reply({
2022-06-16 02:31:58 +01:00
ephemeral: true,
2021-11-25 01:51:56 +01:00
embeds: [HelpEmbed1],
});
2021-10-24 22:41:46 +01:00
},
2021-12-04 20:58:19 -06:00
});