v3.0 (#145)
* Change rules.txt to rules.json (#31) * Migrate to yarn * Add role configs to config template * Install packges and setup typescript * Migrate entry point * Migrate about command * Migrate ban command * Migrate clear command * Migrate kick command * Migrate mute command * Migrate poll command * Migrate bunny command * Update required roles checker * Migrate role command * Migrate unmute command * Migrate warn command * Migrate eval command * Migrate help command * Migrate rules command * Migrate events to typescript * Update about command to use the PublicEmbed class * Update ErrorMessage to ChannelNotFound * Update messageDelete event to ignore bots * Feature/74 merge vylbot core (#80) * Merge VylBot-Core * Update commands to new system * Fix issue where events would not load * Feature/12 create tests (#102) * Fix tests * Update coverage * Remove unrequired mock files * Add about command test * Update about tests * Ban command tests * eval command tests * Start help command tests * Add help command tests * Add kick command tests * Mute command tests * Poll command tests * Add role command tests Signed-off-by: Ethan Lane <ethan@vylpes.com> * Add rules command tests * Add unmute command tests * Add warn command tests * Add MemberEvents tests * Add GuildMemberUpdate tests Signed-off-by: Ethan Lane <ethan@vylpes.com> * Add MessageEvents tests * Add StringTools test Signed-off-by: Ethan Lane <ethan@vylpes.com> * Add embed tests Signed-off-by: Ethan Lane <ethan@vylpes.com> * Add GitHub Actions Signed-off-by: Ethan Lane <ethan@vylpes.com> * Move to tslint Signed-off-by: Ethan Lane <ethan@vylpes.com> * Remove tslint Signed-off-by: Ethan Lane <ethan@vylpes.com> * Remove linting script Signed-off-by: Ethan Lane <ethan@vylpes.com> * Update rules with blog website and event spoilers rule" (#106) Signed-off-by: Ethan Lane <ethan@vylpes.com> * Containerise bot (#107) * Add moderator names to audit reason (#108) * Feature/48 database (#114) * Add database and default values * Add ability to save a setting to the database * Get commands and events to use database * Setup and config command * Update commands to check roles per server * Different rules per server Signed-off-by: Ethan Lane <ethan@vylpes.com> * Different prefix per server Signed-off-by: Ethan Lane <ethan@vylpes.com> * Add verification system Signed-off-by: Ethan Lane <ethan@vylpes.com> * Disabled commands per server * Add devmode for default prefix * Update embeds * Fix broken tests * Feature/66 add different commands per server (#122) * Add ability for server exclusive commands * Add MankBot server-exclusive commands * Add lobby entity to database * Add documentation * Add setup command for lobby (#123) * Update bot to discord.js v13 (#125) * Update bot to discord.js v13 * Remove debug code * 110 commandshelp about command errors which causes command to not run (#126) * Change onMessage to onMessageCreate * Fix help command * Add override for bot owner and server owner (#135) * Change help command so exclusive commands can only be seen for the server they're assigned to (#136) * Change parsing to not crash if invalid (#142) * 137 role command cannot read properties of undefined (#141) * Fix issue with bot crashing * Fix server prefix not showing * Add easy way to configure role command * Move help text to its own directory * Make role config command to use role id * Get lobby command to use IDs instead of names (#144) Co-authored-by: Vylpes <getgravitysoftware@gmail.com>
This commit is contained in:
parent
1168898e57
commit
04a4a6204c
118 changed files with 13966 additions and 4027 deletions
49
src/events/MemberEvents.ts
Normal file
49
src/events/MemberEvents.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { Event } from "../type/event";
|
||||
import { GuildMember } from "discord.js";
|
||||
import EventEmbed from "../helpers/embeds/EventEmbed";
|
||||
import GuildMemberUpdate from "./MemberEvents/GuildMemberUpdate";
|
||||
import IEventReturnContext from "../contracts/IEventReturnContext";
|
||||
|
||||
export default class MemberEvents extends Event {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public override async guildMemberAdd(member: GuildMember): Promise<IEventReturnContext> {
|
||||
const embed = new EventEmbed(member.guild, "Member Joined");
|
||||
embed.AddUser("User", member.user, true);
|
||||
embed.addField("Created", member.user.createdAt.toISOString());
|
||||
embed.setFooter({ text: `Id: ${member.user.id}` });
|
||||
|
||||
await embed.SendToMemberLogsChannel();
|
||||
|
||||
return {
|
||||
embeds: [embed]
|
||||
};
|
||||
}
|
||||
|
||||
public override async guildMemberRemove(member: GuildMember): Promise<IEventReturnContext> {
|
||||
const embed = new EventEmbed(member.guild, "Member Left");
|
||||
embed.AddUser("User", member.user, true);
|
||||
embed.addField("Joined", member.joinedAt?.toISOString() || "n/a");
|
||||
embed.setFooter({ text: `Id: ${member.user.id}` });
|
||||
|
||||
await embed.SendToMemberLogsChannel();
|
||||
|
||||
return {
|
||||
embeds: [embed]
|
||||
};
|
||||
}
|
||||
|
||||
public override async guildMemberUpdate(oldMember: GuildMember, newMember: GuildMember): Promise<IEventReturnContext> {
|
||||
const handler = new GuildMemberUpdate(oldMember, newMember);
|
||||
|
||||
if (oldMember.nickname != newMember.nickname) { // Nickname change
|
||||
await handler.NicknameChanged();
|
||||
}
|
||||
|
||||
return {
|
||||
embeds: []
|
||||
};
|
||||
}
|
||||
}
|
30
src/events/MemberEvents/GuildMemberUpdate.ts
Normal file
30
src/events/MemberEvents/GuildMemberUpdate.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import IEventReturnContext from "../../contracts/IEventReturnContext";
|
||||
import EventEmbed from "../../helpers/embeds/EventEmbed";
|
||||
|
||||
export default class GuildMemberUpdate {
|
||||
public oldMember: GuildMember;
|
||||
public newMember: GuildMember;
|
||||
|
||||
constructor(oldMember: GuildMember, newMember: GuildMember) {
|
||||
this.oldMember = oldMember;
|
||||
this.newMember = newMember;
|
||||
}
|
||||
|
||||
public async NicknameChanged(): Promise<IEventReturnContext> {
|
||||
const oldNickname = this.oldMember.nickname || "*none*";
|
||||
const newNickname = this.newMember.nickname || "*none*";
|
||||
|
||||
const embed = new EventEmbed(this.newMember.guild, "Nickname Changed");
|
||||
embed.AddUser("User", this.newMember.user, true);
|
||||
embed.addField("Before", oldNickname, true);
|
||||
embed.addField("After", newNickname, true);
|
||||
embed.setFooter({ text: `Id: ${this.newMember.user.id}` });
|
||||
|
||||
await embed.SendToMemberLogsChannel();
|
||||
|
||||
return {
|
||||
embeds: [embed]
|
||||
};
|
||||
}
|
||||
}
|
84
src/events/MessageEvents.ts
Normal file
84
src/events/MessageEvents.ts
Normal file
|
@ -0,0 +1,84 @@
|
|||
import { Event } from "../type/event";
|
||||
import { Message } from "discord.js";
|
||||
import EventEmbed from "../helpers/embeds/EventEmbed";
|
||||
import IEventReturnContext from "../contracts/IEventReturnContext";
|
||||
import SettingsHelper from "../helpers/SettingsHelper";
|
||||
import OnMessage from "./MessageEvents/OnMessage";
|
||||
|
||||
export default class MessageEvents extends Event {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public override async messageDelete(message: Message): Promise<IEventReturnContext> {
|
||||
if (!message.guild) {
|
||||
return {
|
||||
embeds: []
|
||||
};
|
||||
}
|
||||
|
||||
if (message.author.bot) {
|
||||
return {
|
||||
embeds: []
|
||||
};
|
||||
}
|
||||
|
||||
const embed = new EventEmbed(message.guild, "Message Deleted");
|
||||
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")}\`\`\``);
|
||||
}
|
||||
|
||||
await embed.SendToMessageLogsChannel();
|
||||
|
||||
return {
|
||||
embeds: [embed]
|
||||
};
|
||||
}
|
||||
|
||||
public override async messageUpdate(oldMessage: Message, newMessage: Message): Promise<IEventReturnContext> {
|
||||
if (!newMessage.guild){
|
||||
return {
|
||||
embeds: []
|
||||
};
|
||||
}
|
||||
|
||||
if (newMessage.author.bot) {
|
||||
return {
|
||||
embeds: []
|
||||
};
|
||||
}
|
||||
|
||||
if (oldMessage.content == newMessage.content) {
|
||||
return {
|
||||
embeds: []
|
||||
};
|
||||
}
|
||||
|
||||
const embed = new EventEmbed(newMessage.guild, "Message Edited");
|
||||
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*"}\`\`\``);
|
||||
|
||||
await embed.SendToMessageLogsChannel();
|
||||
|
||||
return {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
59
src/events/MessageEvents/OnMessage.ts
Normal file
59
src/events/MessageEvents/OnMessage.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue