v3.1.0 #317
5 changed files with 83 additions and 3 deletions
37
src/commands/ignore.ts
Normal file
37
src/commands/ignore.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
src/entity/IgnoredChannel.ts
Normal file
21
src/entity/IgnoredChannel.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { Entity, getConnection } from "typeorm";
|
||||||
|
import BaseEntity from "../contracts/BaseEntity";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export default class IgnoredChannel extends BaseEntity {
|
||||||
|
constructor(channelId: string) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.Id = channelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async IsChannelIgnored(channelId: string): Promise<boolean> {
|
||||||
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(IgnoredChannel);
|
||||||
|
|
||||||
|
const single = await repository.findOne(channelId);
|
||||||
|
|
||||||
|
return single != undefined;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { Message } from "discord.js";
|
||||||
import EventEmbed from "../helpers/embeds/EventEmbed";
|
import EventEmbed from "../helpers/embeds/EventEmbed";
|
||||||
import SettingsHelper from "../helpers/SettingsHelper";
|
import SettingsHelper from "../helpers/SettingsHelper";
|
||||||
import OnMessage from "./MessageEvents/OnMessage";
|
import OnMessage from "./MessageEvents/OnMessage";
|
||||||
|
import IgnoredChannel from "../entity/IgnoredChannel";
|
||||||
|
|
||||||
export default class MessageEvents extends Event {
|
export default class MessageEvents extends Event {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -16,6 +17,9 @@ export default class MessageEvents extends Event {
|
||||||
const enabled = await SettingsHelper.GetSetting("event.message.delete.enabled", message.guild.id);
|
const enabled = await SettingsHelper.GetSetting("event.message.delete.enabled", message.guild.id);
|
||||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||||
|
|
||||||
|
const ignored = await IgnoredChannel.IsChannelIgnored(message.channel.id);
|
||||||
|
if (ignored) return;
|
||||||
|
|
||||||
const embed = new EventEmbed(message.client, message.guild, "Message Deleted");
|
const embed = new EventEmbed(message.client, message.guild, "Message Deleted");
|
||||||
embed.AddUser("User", message.author, true);
|
embed.AddUser("User", message.author, true);
|
||||||
embed.addField("Channel", message.channel.toString(), true);
|
embed.addField("Channel", message.channel.toString(), true);
|
||||||
|
@ -39,6 +43,9 @@ export default class MessageEvents extends Event {
|
||||||
const enabled = await SettingsHelper.GetSetting("event.message.update.enabled", newMessage.guild.id);
|
const enabled = await SettingsHelper.GetSetting("event.message.update.enabled", newMessage.guild.id);
|
||||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||||
|
|
||||||
|
const ignored = await IgnoredChannel.IsChannelIgnored(newMessage.channel.id);
|
||||||
|
if (ignored) return;
|
||||||
|
|
||||||
const embed = new EventEmbed(newMessage.client, newMessage.guild, "Message Edited");
|
const embed = new EventEmbed(newMessage.client, newMessage.guild, "Message Edited");
|
||||||
embed.AddUser("User", newMessage.author, true);
|
embed.AddUser("User", newMessage.author, true);
|
||||||
embed.addField("Channel", newMessage.channel.toString(), true);
|
embed.addField("Channel", newMessage.channel.toString(), true);
|
||||||
|
|
13
src/migration/1657647026816-CreateIgnoredChannel.ts
Normal file
13
src/migration/1657647026816-CreateIgnoredChannel.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
|
export class migration1657647026816 implements MigrationInterface {
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
queryRunner.query(`CREATE TABLE ignored_channel (Id varchar(255), PRIMARY KEY (Id))`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
queryRunner.query(`DROP TABLE ignored_channel`)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import Code from "./commands/code";
|
||||||
import Config from "./commands/config";
|
import Config from "./commands/config";
|
||||||
import Disable from "./commands/disable";
|
import Disable from "./commands/disable";
|
||||||
import Help from "./commands/help";
|
import Help from "./commands/help";
|
||||||
|
import Ignore from "./commands/ignore";
|
||||||
import Kick from "./commands/kick";
|
import Kick from "./commands/kick";
|
||||||
import Mute from "./commands/mute";
|
import Mute from "./commands/mute";
|
||||||
import Poll from "./commands/poll";
|
import Poll from "./commands/poll";
|
||||||
|
@ -32,7 +33,11 @@ export default class Registry {
|
||||||
CoreClient.RegisterCommand("ban", new Ban());
|
CoreClient.RegisterCommand("ban", new Ban());
|
||||||
CoreClient.RegisterCommand("bunny", new Bunny());
|
CoreClient.RegisterCommand("bunny", new Bunny());
|
||||||
CoreClient.RegisterCommand("clear", new Clear());
|
CoreClient.RegisterCommand("clear", new Clear());
|
||||||
|
CoreClient.RegisterCommand("code", new Code());
|
||||||
|
CoreClient.RegisterCommand("config", new Config());
|
||||||
|
CoreClient.RegisterCommand("disable", new Disable());
|
||||||
CoreClient.RegisterCommand("help", new Help());
|
CoreClient.RegisterCommand("help", new Help());
|
||||||
|
CoreClient.RegisterCommand("ignore", new Ignore());
|
||||||
CoreClient.RegisterCommand("kick", new Kick());
|
CoreClient.RegisterCommand("kick", new Kick());
|
||||||
CoreClient.RegisterCommand("mute", new Mute());
|
CoreClient.RegisterCommand("mute", new Mute());
|
||||||
CoreClient.RegisterCommand("poll", new Poll());
|
CoreClient.RegisterCommand("poll", new Poll());
|
||||||
|
@ -41,9 +46,6 @@ export default class Registry {
|
||||||
CoreClient.RegisterCommand("unmute", new Unmute());
|
CoreClient.RegisterCommand("unmute", new Unmute());
|
||||||
CoreClient.RegisterCommand("warn", new Warn());
|
CoreClient.RegisterCommand("warn", new Warn());
|
||||||
CoreClient.RegisterCommand("setup", new Setup());
|
CoreClient.RegisterCommand("setup", new Setup());
|
||||||
CoreClient.RegisterCommand("config", new Config());
|
|
||||||
CoreClient.RegisterCommand("code", new Code());
|
|
||||||
CoreClient.RegisterCommand("disable", new Disable());
|
|
||||||
|
|
||||||
// Exclusive Commands: MankBot
|
// Exclusive Commands: MankBot
|
||||||
CoreClient.RegisterCommand("lobby", new Lobby(), "501231711271780357");
|
CoreClient.RegisterCommand("lobby", new Lobby(), "501231711271780357");
|
||||||
|
|
Loading…
Reference in a new issue