Feature/103 improve events #201
14 changed files with 297 additions and 370 deletions
|
@ -5,7 +5,6 @@ import { EventType } from "../constants/EventType";
|
|||
import ICommandItem from "../contracts/ICommandItem";
|
||||
import IEventItem from "../contracts/IEventItem";
|
||||
import { Command } from "../type/command";
|
||||
import { Event } from "../type/event";
|
||||
|
||||
import { Events } from "./events";
|
||||
import { Util } from "./util";
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
import { Event } from "../type/event";
|
||||
import { EmbedBuilder, GuildMember, TextChannel } from "discord.js";
|
||||
import GuildMemberUpdate from "./MemberEvents/GuildMemberUpdate";
|
||||
import SettingsHelper from "../helpers/SettingsHelper";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
|
||||
export default class MemberEvents extends Event {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public override async guildMemberAdd(member: GuildMember) {
|
||||
if (!member.guild) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.member.add.enabled", member.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle('Member Joined')
|
||||
.setDescription(`${member.user} \`${member.user.tag}\``)
|
||||
.setFooter({ text: `Id: ${member.user.id}` })
|
||||
.addFields([
|
||||
{
|
||||
name: 'Created',
|
||||
value: member.user.createdAt.toISOString(),
|
||||
}
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.member.add.channel", member.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = member.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [embed ]});
|
||||
}
|
||||
|
||||
public override async guildMemberRemove(member: GuildMember) {
|
||||
if (!member.guild) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.member.remove.enabled", member.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle('Member Left')
|
||||
.setDescription(`${member.user} \`${member.user.tag}\``)
|
||||
.setFooter({ text: `Id: ${member.user.id}` })
|
||||
.addFields([
|
||||
{
|
||||
name: 'Joined',
|
||||
value: member.joinedAt ? member.joinedAt.toISOString() : "*none*",
|
||||
}
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.member.remove.channel", member.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = member.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [embed ]});
|
||||
}
|
||||
|
||||
public override async guildMemberUpdate(oldMember: GuildMember, newMember: GuildMember) {
|
||||
const handler = new GuildMemberUpdate(oldMember, newMember);
|
||||
|
||||
if (oldMember.nickname != newMember.nickname) { // Nickname change
|
||||
await handler.NicknameChanged();
|
||||
}
|
||||
}
|
||||
}
|
34
src/events/MemberEvents/GuildMemberAdd.ts
Normal file
34
src/events/MemberEvents/GuildMemberAdd.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { EmbedBuilder, GuildMember, TextChannel } from "discord.js";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
|
||||
export default async function GuildMemberAdd(member: GuildMember) {
|
||||
if (!member.guild) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.member.add.enabled", member.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle('Member Joined')
|
||||
.setDescription(`${member.user} \`${member.user.tag}\``)
|
||||
.setFooter({ text: `Id: ${member.user.id}` })
|
||||
.addFields([
|
||||
{
|
||||
name: 'Created',
|
||||
value: member.user.createdAt.toISOString(),
|
||||
}
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.member.add.channel", member.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = member.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [embed ]});
|
||||
}
|
34
src/events/MemberEvents/GuildMemberRemove.ts
Normal file
34
src/events/MemberEvents/GuildMemberRemove.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { EmbedBuilder, GuildMember, TextChannel } from "discord.js";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
|
||||
export default async function GuildMemberRemove(member: GuildMember) {
|
||||
if (!member.guild) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.member.remove.enabled", member.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle('Member Left')
|
||||
.setDescription(`${member.user} \`${member.user.tag}\``)
|
||||
.setFooter({ text: `Id: ${member.user.id}` })
|
||||
.addFields([
|
||||
{
|
||||
name: 'Joined',
|
||||
value: member.joinedAt ? member.joinedAt.toISOString() : "*none*",
|
||||
}
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.member.remove.channel", member.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = member.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [embed ]});
|
||||
}
|
|
@ -1,49 +1,8 @@
|
|||
import { EmbedBuilder, GuildMember, TextChannel } from "discord.js";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
import { GuildMember } from "discord.js";
|
||||
import NicknameChanged from "./GuildMemberUpdate/NicknameChanged";
|
||||
|
||||
export default class GuildMemberUpdate {
|
||||
public oldMember: GuildMember;
|
||||
public newMember: GuildMember;
|
||||
|
||||
constructor(oldMember: GuildMember, newMember: GuildMember) {
|
||||
this.oldMember = oldMember;
|
||||
this.newMember = newMember;
|
||||
}
|
||||
|
||||
public async NicknameChanged() {
|
||||
const enabled = await SettingsHelper.GetSetting("event.member.update.enabled", this.newMember.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const oldNickname = this.oldMember.nickname || "*none*";
|
||||
const newNickname = this.newMember.nickname || "*none*";
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle('Nickname Changed')
|
||||
.setDescription(`${this.newMember.user} \`${this.newMember.user.tag}\``)
|
||||
.setFooter({ text: `Id: ${this.newMember.user.id}` })
|
||||
.addFields([
|
||||
{
|
||||
name: 'Before',
|
||||
value: oldNickname,
|
||||
},
|
||||
{
|
||||
name: 'After',
|
||||
value: newNickname,
|
||||
},
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.member.update.channel", this.newMember.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = this.newMember.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [embed ]});
|
||||
export default async function GuildMemberUpdate(oldMember: GuildMember, newMember: GuildMember) {
|
||||
if (oldMember.nickname != newMember.nickname) { // Nickname change
|
||||
await NicknameChanged(oldMember, newMember);
|
||||
}
|
||||
}
|
39
src/events/MemberEvents/GuildMemberUpdate/NicknameChanged.ts
Normal file
39
src/events/MemberEvents/GuildMemberUpdate/NicknameChanged.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { EmbedBuilder, GuildMember, TextChannel } from "discord.js";
|
||||
import EmbedColours from "../../../constants/EmbedColours";
|
||||
import SettingsHelper from "../../../helpers/SettingsHelper";
|
||||
|
||||
export default async function NicknameChanged(oldMember: GuildMember, newMember: GuildMember) {
|
||||
const enabled = await SettingsHelper.GetSetting("event.member.update.enabled", newMember.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const oldNickname = oldMember.nickname || "*none*";
|
||||
const newNickname = newMember.nickname || "*none*";
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle('Nickname Changed')
|
||||
.setDescription(`${newMember.user} \`${newMember.user.tag}\``)
|
||||
.setFooter({ text: `Id: ${newMember.user.id}` })
|
||||
.addFields([
|
||||
{
|
||||
name: 'Before',
|
||||
value: oldNickname,
|
||||
},
|
||||
{
|
||||
name: 'After',
|
||||
value: newNickname,
|
||||
},
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.member.update.channel", newMember.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = newMember.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [embed ]});
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
import { Event } from "../type/event";
|
||||
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
||||
import SettingsHelper from "../helpers/SettingsHelper";
|
||||
import OnMessage from "./MessageEvents/OnMessage";
|
||||
import IgnoredChannel from "../entity/IgnoredChannel";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
|
||||
export default class MessageEvents extends Event {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public override async messageDelete(message: Message) {
|
||||
if (!message.guild) return;
|
||||
if (message.author.bot) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.message.delete.enabled", message.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const ignored = await IgnoredChannel.IsChannelIgnored(message.channel.id);
|
||||
if (ignored) return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle("Message Deleted")
|
||||
.setDescription(`${message.author} \`${message.author.tag}\``)
|
||||
.addFields([
|
||||
{
|
||||
name: "Channel",
|
||||
value: message.channel.toString(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Content",
|
||||
value: `\`\`\`${message.content || "*none*"}\`\`\``,
|
||||
}
|
||||
]);
|
||||
|
||||
if (message.attachments.size > 0) {
|
||||
embed.addFields([
|
||||
{
|
||||
name: "Attachments",
|
||||
value: `\`\`\`${message.attachments.map(x => x.url).join("\n")}\`\`\``
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.message.delete.channel", message.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = message.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [ embed ]});
|
||||
}
|
||||
|
||||
public override async messageUpdate(oldMessage: Message, newMessage: Message) {
|
||||
if (!newMessage.guild) return;
|
||||
if (newMessage.author.bot) return;
|
||||
if (oldMessage.content == newMessage.content) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.message.update.enabled", newMessage.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const ignored = await IgnoredChannel.IsChannelIgnored(newMessage.channel.id);
|
||||
if (ignored) return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle("Message Edited")
|
||||
.setDescription(`${newMessage.author} \`${newMessage.author.tag}\``)
|
||||
.addFields([
|
||||
{
|
||||
name: "Channel",
|
||||
value: newMessage.channel.toString(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Before",
|
||||
value: `\`\`\`${oldMessage.content || "*none*"}\`\`\``,
|
||||
},
|
||||
{
|
||||
name: "After",
|
||||
value: `\`\`\`${newMessage.content || "*none*"}\`\`\``,
|
||||
}
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.message.delete.channel", newMessage.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = newMessage.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [ embed ]});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
14
src/events/MessageEvents/MessageCreate.ts
Normal file
14
src/events/MessageEvents/MessageCreate.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { Message } from "discord.js";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
import VerificationCheck from "./MessageCreate/VerificationCheck";
|
||||
|
||||
export default async function 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 VerificationCheck(message);
|
||||
}
|
||||
}
|
57
src/events/MessageEvents/MessageCreate/VerificationCheck.ts
Normal file
57
src/events/MessageEvents/MessageCreate/VerificationCheck.ts
Normal file
|
@ -0,0 +1,57 @@
|
|||
import { Message } from "discord.js";
|
||||
import SettingsHelper from "../../../helpers/SettingsHelper";
|
||||
|
||||
export default async function VerificationCheck(message: Message) {
|
||||
if (!message.guild) return;
|
||||
|
||||
const verificationChannel = await SettingsHelper.GetSetting("verification.channel", message.guild.id);
|
||||
|
||||
if (!verificationChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = message.guild.channels.cache.find(x => x.name == verificationChannel);
|
||||
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentChannel = message.guild.channels.cache.find(x => x == message.channel);
|
||||
|
||||
if (!currentChannel || currentChannel.name != verificationChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const verificationCode = await SettingsHelper.GetSetting("verification.code", message.guild.id);
|
||||
|
||||
if (!verificationCode || verificationCode == "") {
|
||||
await message.reply("`verification.code` is not set inside of the server's config. Please contact the server's mod team.");
|
||||
await message.delete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const verificationRoleName = await SettingsHelper.GetSetting("verification.role", message.guild.id);
|
||||
|
||||
if (!verificationRoleName) {
|
||||
await message.reply("`verification.role` is not set inside of the server's config. Please contact the server's mod team.");
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
const role = message.guild.roles.cache.find(x => x.name == verificationRoleName);
|
||||
|
||||
if (!role) {
|
||||
await message.reply("The entry role configured for this server does not exist. Please contact the server's mod team.");
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.content.toLocaleLowerCase() != verificationCode.toLocaleLowerCase()) {
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
await message.member?.roles.add(role);
|
||||
await message.delete();
|
||||
}
|
52
src/events/MessageEvents/MessageDelete.ts
Normal file
52
src/events/MessageEvents/MessageDelete.ts
Normal file
|
@ -0,0 +1,52 @@
|
|||
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
import IgnoredChannel from "../../entity/IgnoredChannel";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
|
||||
export default async function MessageDelete(message: Message) {
|
||||
if (!message.guild) return;
|
||||
if (message.author.bot) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.message.delete.enabled", message.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const ignored = await IgnoredChannel.IsChannelIgnored(message.channel.id);
|
||||
if (ignored) return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle("Message Deleted")
|
||||
.setDescription(`${message.author} \`${message.author.tag}\``)
|
||||
.addFields([
|
||||
{
|
||||
name: "Channel",
|
||||
value: message.channel.toString(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Content",
|
||||
value: `\`\`\`${message.content || "*none*"}\`\`\``,
|
||||
}
|
||||
]);
|
||||
|
||||
if (message.attachments.size > 0) {
|
||||
embed.addFields([
|
||||
{
|
||||
name: "Attachments",
|
||||
value: `\`\`\`${message.attachments.map(x => x.url).join("\n")}\`\`\``
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.message.delete.channel", message.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = message.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [ embed ]});
|
||||
}
|
48
src/events/MessageEvents/MessageUpdate.ts
Normal file
48
src/events/MessageEvents/MessageUpdate.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
import IgnoredChannel from "../../entity/IgnoredChannel";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
|
||||
export default async function MessageUpdate(oldMessage: Message, newMessage: Message) {
|
||||
if (!newMessage.guild) return;
|
||||
if (newMessage.author.bot) return;
|
||||
if (oldMessage.content == newMessage.content) return;
|
||||
|
||||
const enabled = await SettingsHelper.GetSetting("event.message.update.enabled", newMessage.guild.id);
|
||||
if (!enabled || enabled.toLowerCase() != "true") return;
|
||||
|
||||
const ignored = await IgnoredChannel.IsChannelIgnored(newMessage.channel.id);
|
||||
if (ignored) return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setTitle("Message Edited")
|
||||
.setDescription(`${newMessage.author} \`${newMessage.author.tag}\``)
|
||||
.addFields([
|
||||
{
|
||||
name: "Channel",
|
||||
value: newMessage.channel.toString(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: "Before",
|
||||
value: `\`\`\`${oldMessage.content || "*none*"}\`\`\``,
|
||||
},
|
||||
{
|
||||
name: "After",
|
||||
value: `\`\`\`${newMessage.content || "*none*"}\`\`\``,
|
||||
}
|
||||
]);
|
||||
|
||||
const channelSetting = await SettingsHelper.GetSetting("event.message.delete.channel", newMessage.guild.id);
|
||||
|
||||
if (!channelSetting) return;
|
||||
|
||||
const channel = newMessage.guild.channels.cache.find(x => x.name == channelSetting);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
const guildChannel = channel as TextChannel;
|
||||
|
||||
await guildChannel.send({ embeds: [ embed ]});
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
import { Message as Message } from "discord.js";
|
||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||
|
||||
export default class OnMessage {
|
||||
public static async VerificationCheck(message: Message) {
|
||||
if (!message.guild) return;
|
||||
|
||||
const verificationChannel = await SettingsHelper.GetSetting("verification.channel", message.guild.id);
|
||||
|
||||
if (!verificationChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = message.guild.channels.cache.find(x => x.name == verificationChannel);
|
||||
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentChannel = message.guild.channels.cache.find(x => x == message.channel);
|
||||
|
||||
if (!currentChannel || currentChannel.name != verificationChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const verificationCode = await SettingsHelper.GetSetting("verification.code", message.guild.id);
|
||||
|
||||
if (!verificationCode || verificationCode == "") {
|
||||
await message.reply("`verification.code` is not set inside of the server's config. Please contact the server's mod team.");
|
||||
await message.delete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const verificationRoleName = await SettingsHelper.GetSetting("verification.role", message.guild.id);
|
||||
|
||||
if (!verificationRoleName) {
|
||||
await message.reply("`verification.role` is not set inside of the server's config. Please contact the server's mod team.");
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
const role = message.guild.roles.cache.find(x => x.name == verificationRoleName);
|
||||
|
||||
if (!role) {
|
||||
await message.reply("The entry role configured for this server does not exist. Please contact the server's mod team.");
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.content.toLocaleLowerCase() != verificationCode.toLocaleLowerCase()) {
|
||||
await message.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
await message.member?.roles.add(role);
|
||||
await message.delete();
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
import { CoreClient } from "./client/client";
|
||||
import { EventType } from "./constants/EventType";
|
||||
|
||||
// Command Imports
|
||||
import About from "./commands/about";
|
||||
import Audits from "./commands/audits";
|
||||
import Ban from "./commands/ban";
|
||||
import Bunny from "./commands/bunny";
|
||||
import Clear from "./commands/clear";
|
||||
import Code from "./commands/code";
|
||||
import Config from "./commands/config";
|
||||
|
@ -25,10 +27,12 @@ import AddLobby from "./commands/501231711271780357/Lobby/add";
|
|||
import RemoveLobby from "./commands/501231711271780357/Lobby/remove";
|
||||
|
||||
// Event Imports
|
||||
import MemberEvents from "./events/MemberEvents";
|
||||
import MessageEvents from "./events/MessageEvents";
|
||||
import Bunny from "./commands/bunny";
|
||||
import { EventType } from "./constants/EventType";
|
||||
import GuildMemberAdd from "./events/MemberEvents/GuildMemberAdd";
|
||||
import GuildMemberRemove from "./events/MemberEvents/GuildMemberRemove";
|
||||
import GuildMemberUpdate from "./events/MemberEvents/GuildMemberUpdate";
|
||||
import MessageDelete from "./events/MessageEvents/MessageDelete";
|
||||
import MessageUpdate from "./events/MessageEvents/MessageUpdate";
|
||||
import MessageCreate from "./events/MessageEvents/MessageCreate";
|
||||
|
||||
export default class Registry {
|
||||
public static RegisterCommands() {
|
||||
|
@ -65,15 +69,12 @@ export default class Registry {
|
|||
}
|
||||
|
||||
public static RegisterEvents() {
|
||||
const memberEvents = new MemberEvents();
|
||||
const messageEvents = new MessageEvents();
|
||||
CoreClient.RegisterEvent(EventType.GuildMemberAdd, GuildMemberAdd);
|
||||
CoreClient.RegisterEvent(EventType.GuildMemberRemove, GuildMemberRemove);
|
||||
CoreClient.RegisterEvent(EventType.GuildMemberUpdate, GuildMemberUpdate);
|
||||
|
||||
CoreClient.RegisterEvent(EventType.GuildMemberAdd, memberEvents.guildMemberAdd);
|
||||
CoreClient.RegisterEvent(EventType.GuildMemberRemove, memberEvents.guildMemberRemove);
|
||||
CoreClient.RegisterEvent(EventType.GuildMemberUpdate, memberEvents.guildMemberUpdate);
|
||||
|
||||
CoreClient.RegisterEvent(EventType.MessageDelete, messageEvents.messageDelete);
|
||||
CoreClient.RegisterEvent(EventType.MessageUpdate, messageEvents.messageUpdate);
|
||||
CoreClient.RegisterEvent(EventType.MessageCreate, messageEvents.messageCreate);
|
||||
CoreClient.RegisterEvent(EventType.MessageDelete, MessageDelete);
|
||||
CoreClient.RegisterEvent(EventType.MessageUpdate, MessageUpdate);
|
||||
CoreClient.RegisterEvent(EventType.MessageCreate, MessageCreate);
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
import { Channel, Guild, GuildMember, Message, PartialDMChannel, PartialGuildMember, PartialMessage, GuildBan } from "discord.js";
|
||||
|
||||
export class Event {
|
||||
public channelCreate(channel: Channel) {
|
||||
|
||||
}
|
||||
|
||||
public channelDelete(channel: Channel | PartialDMChannel) {
|
||||
|
||||
}
|
||||
|
||||
public channelUpdate(oldChannel: Channel, newChannel: Channel) {
|
||||
|
||||
}
|
||||
|
||||
public guildBanAdd(ban: GuildBan) {
|
||||
|
||||
}
|
||||
|
||||
public guildBanRemove(ban: GuildBan) {
|
||||
|
||||
}
|
||||
|
||||
public guildCreate(guild: Guild) {
|
||||
|
||||
}
|
||||
|
||||
public guildMemberAdd(member: GuildMember) {
|
||||
|
||||
}
|
||||
|
||||
public guildMemberRemove(member: GuildMember | PartialGuildMember) {
|
||||
|
||||
}
|
||||
|
||||
public guildMemberUpdate(oldMember: GuildMember | PartialGuildMember, newMember: GuildMember) {
|
||||
|
||||
}
|
||||
|
||||
public messageCreate(message: Message) {
|
||||
|
||||
}
|
||||
|
||||
public messageDelete(message: Message | PartialMessage) {
|
||||
|
||||
}
|
||||
|
||||
public messageUpdate(oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage) {
|
||||
|
||||
}
|
||||
|
||||
public ready() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue