Feature/49 ignore channel lists when logging (#168)

* Add entity

* Create ignore command

* Update message events to ignore channels set
This commit is contained in:
Vylpes 2022-07-16 16:12:55 +01:00 committed by GitHub
parent 4621cec9d5
commit a01a43788e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 3 deletions

37
src/commands/ignore.ts Normal file
View file

@ -0,0 +1,37 @@
import { ICommandContext } from "../contracts/ICommandContext";
import IgnoredChannel from "../entity/IgnoredChannel";
import PublicEmbed from "../helpers/embeds/PublicEmbed";
import { Command } from "../type/command";
export default class Ignore extends Command {
constructor() {
super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
}
public override async execute(context: ICommandContext) {
if (!context.message.guild) return;
const isChannelIgnored = await IgnoredChannel.IsChannelIgnored(context.message.channel.id);
if (isChannelIgnored) {
const entity = await IgnoredChannel.FetchOneById(IgnoredChannel, context.message.channel.id);
await IgnoredChannel.Remove(IgnoredChannel, entity);
const embed = new PublicEmbed(context, "Success", "This channel will start being logged again.");
await embed.SendToCurrentChannel();
} else {
const entity = new IgnoredChannel(context.message.channel.id);
await entity.Save(IgnoredChannel, entity);
const embed = new PublicEmbed(context, "Success", "This channel will now be ignored from logging.");
await embed.SendToCurrentChannel();
}
}
}