2024-09-25 23:07:02 +01:00
|
|
|
const {
|
|
|
|
SlashCommandBuilder,
|
|
|
|
EmbedBuilder,
|
|
|
|
PermissionsBitField,
|
|
|
|
} = require("discord.js");
|
2024-09-05 03:50:51 +01:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName("help")
|
|
|
|
.setDescription("Lists all available commands"),
|
|
|
|
|
|
|
|
async execute(interaction, client) {
|
|
|
|
try {
|
2024-09-25 23:07:02 +01:00
|
|
|
// Check if the user has the Manage Roles permission
|
|
|
|
const isMod = interaction.member.permissions.has(
|
|
|
|
PermissionsBitField.Flags.ManageRoles
|
|
|
|
);
|
2024-09-05 03:50:51 +01:00
|
|
|
|
|
|
|
const serverName = interaction.guild.name;
|
|
|
|
|
|
|
|
const helpEmbed = new EmbedBuilder()
|
|
|
|
.setColor("#0099ff")
|
|
|
|
.setTitle("Available Commands")
|
|
|
|
.setDescription("Here are all the available commands:")
|
|
|
|
.setTimestamp()
|
|
|
|
.setFooter({
|
|
|
|
text: `${serverName}`,
|
|
|
|
iconURL: client.user.displayAvatarURL(),
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add general commands
|
|
|
|
client.commands.forEach((command) => {
|
|
|
|
if (!command.isModOnly) {
|
|
|
|
helpEmbed.addFields({
|
|
|
|
name: `/${command.data.name}`,
|
|
|
|
value: command.data.description,
|
|
|
|
inline: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add mod-only commands if the user is a mod
|
|
|
|
if (isMod) {
|
|
|
|
client.commands.forEach((command) => {
|
|
|
|
if (command.isModOnly) {
|
|
|
|
helpEmbed.addFields({
|
|
|
|
name: `/${command.data.name}`,
|
|
|
|
value: command.data.description + " (Mods only)",
|
|
|
|
inline: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
await interaction.reply({
|
|
|
|
embeds: [helpEmbed],
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Error executing the help command:", error);
|
|
|
|
await interaction.reply({
|
|
|
|
content: "There was an error while executing this command!",
|
|
|
|
ephemeral: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|