Added guildCreate event

This commit is contained in:
2021-09-18 05:19:53 -07:00
parent 35e2dba4e9
commit 59b2e8aaf5
+15 -1
View File
@@ -1,4 +1,4 @@
import {Client, GuildMember, Intents, Interaction, Message, TextChannel} from "discord.js";
import {Client, Guild, GuildMember, Intents, Interaction, Message, TextChannel} from "discord.js";
import Logger from "../libs/Logger";
import Environment from "./Environment";
@@ -46,6 +46,7 @@ class Discord {
thisModule.init();
}
// On bot logged in
this.client.on("ready", () => {
for(const module in this.loaded_module) {
let thisModule = this.loaded_module[module];
@@ -55,6 +56,7 @@ class Discord {
}
});
// Member join guild event to modules
this.client.on("guildMemberAdd", (member: GuildMember) => {
for(const module in this.loaded_module) {
let thisModule = this.loaded_module[module];
@@ -64,6 +66,7 @@ class Discord {
}
});
// Interaction create event to modules
this.client.on("interactionCreate", (interaction: Interaction) => {
for(const module in this.loaded_module) {
let thisModule = this.loaded_module[module];
@@ -73,6 +76,7 @@ class Discord {
}
});
// Message create event to modules
this.client.on("messageCreate", (message: Message) => {
for(const module in this.loaded_module) {
let thisModule = this.loaded_module[module];
@@ -82,6 +86,16 @@ class Discord {
}
});
// Joined guild event to modules
this.client.on("guildCreate", (guild : Guild) => {
for(const module in this.loaded_module) {
let thisModule = this.loaded_module[module];
if (typeof thisModule.guildCreate === "function")
thisModule.guildCreate(guild);
}
});
// Handling commands
this.client.on("messageCreate", async (message: Message) => {