2022-04-24 14:46:37 +01:00
|
|
|
import { Event } from "../type/event";
|
|
|
|
import { Message } from "discord.js";
|
|
|
|
import EventEmbed from "../helpers/embeds/EventEmbed";
|
|
|
|
import SettingsHelper from "../helpers/SettingsHelper";
|
|
|
|
import OnMessage from "./MessageEvents/OnMessage";
|
|
|
|
|
|
|
|
export default class MessageEvents extends Event {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2022-04-24 15:32:29 +01:00
|
|
|
public override async messageDelete(message: Message) {
|
|
|
|
if (!message.guild) return;
|
|
|
|
if (message.author.bot) return;
|
2022-04-24 14:46:37 +01:00
|
|
|
|
2022-04-24 15:32:29 +01:00
|
|
|
const enabled = await SettingsHelper.GetSetting("event.message.delete.enabled", message.guild.id);
|
|
|
|
if (!enabled || enabled.toLowerCase() != "true") return;
|
2022-04-24 14:46:37 +01:00
|
|
|
|
2022-06-05 14:11:01 +01:00
|
|
|
const embed = new EventEmbed(message.client, message.guild, "Message Deleted");
|
2022-04-24 14:46:37 +01:00
|
|
|
embed.AddUser("User", message.author, true);
|
|
|
|
embed.addField("Channel", message.channel.toString(), true);
|
|
|
|
embed.addField("Content", `\`\`\`${message.content || "*none*"}\`\`\``);
|
|
|
|
|
|
|
|
if (message.attachments.size > 0) {
|
|
|
|
embed.addField("Attachments", `\`\`\`${message.attachments.map(x => x.url).join("\n")}\`\`\``);
|
|
|
|
}
|
|
|
|
|
2022-04-24 15:32:29 +01:00
|
|
|
const channel = await SettingsHelper.GetSetting("event.message.delete.channel", message.guild.id);
|
|
|
|
if (!channel || !message.guild.channels.cache.find(x => x.name == channel)) return;
|
2022-04-24 14:46:37 +01:00
|
|
|
|
2022-06-05 14:11:01 +01:00
|
|
|
await embed.SendToChannel(channel);
|
2022-04-24 14:46:37 +01:00
|
|
|
}
|
|
|
|
|
2022-04-24 15:32:29 +01:00
|
|
|
public override async messageUpdate(oldMessage: Message, newMessage: Message) {
|
|
|
|
if (!newMessage.guild) return;
|
|
|
|
if (newMessage.author.bot) return;
|
|
|
|
if (oldMessage.content == newMessage.content) return;
|
2022-04-24 14:46:37 +01:00
|
|
|
|
2022-04-24 15:32:29 +01:00
|
|
|
const enabled = await SettingsHelper.GetSetting("event.message.update.enabled", newMessage.guild.id);
|
|
|
|
if (!enabled || enabled.toLowerCase() != "true") return;
|
2022-04-24 14:46:37 +01:00
|
|
|
|
2022-06-05 14:11:01 +01:00
|
|
|
const embed = new EventEmbed(newMessage.client, newMessage.guild, "Message Edited");
|
2022-04-24 14:46:37 +01:00
|
|
|
embed.AddUser("User", newMessage.author, true);
|
|
|
|
embed.addField("Channel", newMessage.channel.toString(), true);
|
|
|
|
embed.addField("Before", `\`\`\`${oldMessage.content || "*none*"}\`\`\``);
|
|
|
|
embed.addField("After", `\`\`\`${newMessage.content || "*none*"}\`\`\``);
|
|
|
|
|
2022-04-24 15:32:29 +01:00
|
|
|
const channel = await SettingsHelper.GetSetting("event.message.update.channel", newMessage.guild.id);
|
|
|
|
if (!channel || !newMessage.guild.channels.cache.find(x => x.name == channel)) return;
|
2022-04-24 14:46:37 +01:00
|
|
|
|
2022-06-05 14:11:01 +01:00
|
|
|
await embed.SendToChannel(channel);
|
2022-04-24 14:46:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async messageCreate(message: Message) {
|
|
|
|
if (!message.guild) return;
|
|
|
|
if (message.author.bot) return;
|
|
|
|
|
|
|
|
const isVerificationEnabled = await SettingsHelper.GetSetting("verification.enabled", message.guild.id);
|
|
|
|
|
|
|
|
if (isVerificationEnabled && isVerificationEnabled.toLocaleLowerCase() == "true") {
|
|
|
|
await OnMessage.VerificationCheck(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|