2022-09-18 11:57:22 +01:00
|
|
|
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
2022-07-16 16:12:55 +01:00
|
|
|
import IgnoredChannel from "../entity/IgnoredChannel";
|
|
|
|
import { Command } from "../type/command";
|
|
|
|
|
|
|
|
export default class Ignore extends Command {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
2022-09-18 11:57:22 +01:00
|
|
|
super.CommandBuilder = new SlashCommandBuilder()
|
|
|
|
.setName('ignore')
|
|
|
|
.setDescription('Ignore events in this channel')
|
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
2022-07-16 16:12:55 +01:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:57:22 +01:00
|
|
|
public override async execute(interaction: CommandInteraction) {
|
|
|
|
if (!interaction.guildId) return;
|
2022-07-16 16:12:55 +01:00
|
|
|
|
2022-09-18 11:57:22 +01:00
|
|
|
const isChannelIgnored = await IgnoredChannel.IsChannelIgnored(interaction.guildId);
|
2022-07-16 16:12:55 +01:00
|
|
|
|
|
|
|
if (isChannelIgnored) {
|
2022-09-18 11:57:22 +01:00
|
|
|
const entity = await IgnoredChannel.FetchOneById(IgnoredChannel, interaction.guildId);
|
2022-07-16 16:12:55 +01:00
|
|
|
|
|
|
|
await IgnoredChannel.Remove(IgnoredChannel, entity);
|
|
|
|
|
2022-09-18 11:57:22 +01:00
|
|
|
await interaction.reply('This channel will start being logged again.');
|
2022-07-16 16:12:55 +01:00
|
|
|
} else {
|
2022-09-18 11:57:22 +01:00
|
|
|
const entity = new IgnoredChannel(interaction.guildId);
|
2022-07-16 16:12:55 +01:00
|
|
|
|
|
|
|
await entity.Save(IgnoredChannel, entity);
|
|
|
|
|
2022-09-18 11:57:22 +01:00
|
|
|
await interaction.reply('This channel will now be ignored from logging.');
|
2022-07-16 16:12:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|