Files
SupportBot/Commands/help.js
T

98 lines
2.9 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");
async function asyncForEach(array, callback) {
2021-10-24 22:41:46 +01:00
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
2021-10-21 19:28:23 +01:00
}
2021-10-24 22:41:46 +01:00
}
2021-10-21 19:28:23 +01:00
module.exports = new Command({
2021-10-24 22:41:46 +01:00
name: cmdconfig.HelpCommand,
description: cmdconfig.HelpCommandDesc,
slashCommandOptions: [],
permission: "SEND_MESSAGES",
2021-10-21 19:28:23 +01:00
2021-10-24 22:41:46 +01:00
async run(interaction) {
2021-11-25 01:51:56 +01:00
let SupportStaff = interaction.guild.roles.cache.find(
(SupportTeam) =>
2021-12-04 20:58:19 -06:00
SupportTeam.name === supportbot.Staff ||
SupportTeam.id === supportbot.Staff
2021-11-25 01:51:56 +01:00
);
let Admins = interaction.guild.roles.cache.find(
(AdminUser) =>
AdminUser.name === supportbot.Admin || AdminUser.id === supportbot.Admin
);
if (!SupportStaff || !Admins)
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 = "";
botCommands += `**/${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
botCommands += `**/${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
botCommands += `**/${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n`;
2021-10-21 19:28:23 +01:00
2021-11-25 01:51:56 +01:00
let ticketCommands = "";
ticketCommands += `**/${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`;
ticketCommands += `**/${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n`;
2021-10-24 22:41:46 +01:00
2021-11-25 01:51:56 +01:00
let staffCommands = "";
staffCommands += `**/${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n`;
staffCommands += `**/${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n`;
2021-10-24 22:41:46 +01:00
2021-11-25 01:51:56 +01:00
const HelpEmbed1 = new Discord.MessageEmbed()
.setTitle(supportbot.Name + " Commands")
.setThumbnail(interaction.user.displayAvatarURL())
2021-10-24 22:41:46 +01:00
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
2021-11-25 01:51:56 +01:00
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter, 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(Admins.id)
) {
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
if (supportbot.SendHelpPage === "dm") {
interaction.user.reply({
embeds: [HelpEmbed1],
});
}
2021-10-24 22:41:46 +01:00
2021-11-25 01:51:56 +01:00
if (supportbot.SendHelpPage === "channel") {
interaction.reply({
embeds: [HelpEmbed1],
});
2021-10-24 22:41:46 +01:00
}
},
2021-12-04 20:58:19 -06:00
});