mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-23 01:05:56 +00:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
|
const { SlashCommandBuilder } = require("discord.js");
|
||
|
const Leaderboard = require("../../models/Leaderboard");
|
||
|
|
||
|
module.exports = {
|
||
|
data: new SlashCommandBuilder()
|
||
|
.setName("clearleaderboard")
|
||
|
.setDescription("Clears all entries in the trivia leaderboard"),
|
||
|
isModOnly: true,
|
||
|
|
||
|
async execute(interaction) {
|
||
|
try {
|
||
|
const requiredRoleId = process.env.MOD_ROLE_ID;
|
||
|
if (!interaction.member.roles.cache.has(requiredRoleId)) {
|
||
|
await interaction.reply({
|
||
|
content: "You do not have the required role to use this command!",
|
||
|
ephemeral: true,
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Clear the leaderboard
|
||
|
await Leaderboard.deleteMany({});
|
||
|
|
||
|
// Notify the mod who executed the command
|
||
|
await interaction.reply({
|
||
|
content: "The leaderboard has been cleared successfully.",
|
||
|
ephemeral: true,
|
||
|
});
|
||
|
} catch (error) {
|
||
|
console.error("Error executing clearleaderboard command:", error);
|
||
|
await interaction.reply({
|
||
|
content: "There was an error while executing this command!",
|
||
|
ephemeral: true,
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
};
|