penguin-band/commands/clear.js
2024-03-26 23:56:43 -05:00

25 lines
676 B
JavaScript

import { SlashCommandBuilder } from "discord.js";
import { client } from "..";
import { ROLE_ID_RUNNER } from "../config.json";
const data = new SlashCommandBuilder()
.setName("clear")
.setDescription("Clears bot messages in this channel");
const permissions = [ROLE_ID_RUNNER];
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 };