penguin-band/commands/clear.js

25 lines
676 B
JavaScript

import { SlashCommandBuilder } from "discord.js";
import { client } from "..";
import { RUNNER_ROLE_ID } from "../config.json";
const data = new SlashCommandBuilder()
.setName("clear")
.setDescription("Clears bot messages in this channel");
const permissions = [RUNNER_ROLE_ID];
const execute = async (interaction) => {
await interaction.reply("Clearing messages...");
interaction.channel.messages
.fetch({ limit: 250 })
.then((messages) => {
messages.forEach((message) => {
if (message.author.id === client.user.id) {
message.delete();
}
});
})
.catch(console.error);
};
export { data, permissions, execute };