Fix events not working
This commit is contained in:
parent
6e700df0de
commit
e9112ee00e
2 changed files with 69 additions and 20 deletions
|
@ -77,29 +77,32 @@ export class Util {
|
||||||
|
|
||||||
// Load the events
|
// Load the events
|
||||||
loadEvents(client: Client): IUtilResponse {
|
loadEvents(client: Client): IUtilResponse {
|
||||||
// Get the current folder to check
|
|
||||||
const folder = process.env.FOLDERS_EVENTS;
|
const folder = process.env.FOLDERS_EVENTS;
|
||||||
|
|
||||||
// If the folder exists
|
|
||||||
if (existsSync(`${process.cwd()}/${folder}/`)) {
|
if (existsSync(`${process.cwd()}/${folder}/`)) {
|
||||||
// Get the files inside of this folder
|
|
||||||
const eventFiles = readdirSync(`${process.cwd()}/${folder}/`);
|
const eventFiles = readdirSync(`${process.cwd()}/${folder}/`);
|
||||||
|
|
||||||
// Loop through all the files in the folder
|
|
||||||
for (let i = 0; i < eventFiles.length; i++) {
|
for (let i = 0; i < eventFiles.length; i++) {
|
||||||
// Ignore non-javascript files
|
|
||||||
if (eventFiles[i].includes('.ts')) {
|
if (eventFiles[i].includes('.ts')) {
|
||||||
// Get the event name, by taking the command file and removing the ".ts" from the end
|
|
||||||
const eventName = eventFiles[i].split('.')[0];
|
const eventName = eventFiles[i].split('.')[0];
|
||||||
|
|
||||||
// Get the file of the event
|
|
||||||
const file = require(`${process.cwd()}/${folder}/${eventName}.ts`);
|
const file = require(`${process.cwd()}/${folder}/${eventName}.ts`);
|
||||||
|
|
||||||
// Initialise the event class
|
const event = new file[eventName]() as Event;
|
||||||
const event = new file() as Event;
|
|
||||||
|
|
||||||
// Set the client to emit to this event
|
// Load events
|
||||||
client.on(eventName, event.execute);
|
client.on('channelCreate', event.channelCreate);
|
||||||
|
client.on('channelDelete', event.channelDelete);
|
||||||
|
client.on('channelUpdate', event.channelUpdate);
|
||||||
|
client.on('guildBanAdd', event.guildBanAdd);
|
||||||
|
client.on('guildBanRemove', event.guildBanRemove);
|
||||||
|
client.on('guildCreate', event.guildCreate);
|
||||||
|
client.on('guildMemberAdd', event.guildMemberAdd);
|
||||||
|
client.on('guildMemberRemove', event.guildMemberRemove);
|
||||||
|
client.on('guildMemberUpdate', event.guildMemberUpdate);
|
||||||
|
client.on('message', event.message);
|
||||||
|
client.on('messageDelete', event.messageDelete);
|
||||||
|
client.on('messageUpdate', event.messageUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,51 @@
|
||||||
|
import { Channel, Guild, User, GuildMember, Message, PartialDMChannel, PartialGuildMember, PartialMessage } from "discord.js";
|
||||||
|
|
||||||
export class Event {
|
export class Event {
|
||||||
public execute() {
|
public channelCreate(channel: Channel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public channelDelete(channel: Channel | PartialDMChannel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public channelUpdate(oldChannel: Channel, newChannel: Channel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public guildBanAdd(guild: Guild, user: User) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public guildBanRemove(guild: Guild, user: User) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public guildCreate(guild: Guild) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public guildMemberAdd(member: GuildMember) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public guildMemberRemove(member: GuildMember | PartialGuildMember) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public guildMemberUpdate(oldMember: GuildMember | PartialGuildMember, newMember: GuildMember) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public message(message: Message) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public messageDelete(message: Message | PartialMessage) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public messageUpdate(oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue