Added support for message events

This commit is contained in:
2023-04-20 19:23:59 +02:00
parent 7bb523e886
commit d5bf3a1125

View File

@@ -166,6 +166,22 @@ client.on(Events.ClientReady, () => {
console.log("Logged in as " + client.user.tag + "!");
});
// message events
const msgPath = path.join(__dirname, 'events', 'messages');
const msgFiles = fs.readdirSync(msgPath).filter(file => file.endsWith('.js'));
for (const file of msgFiles) {
const filePath = path.join(msgPath, file);
const msg = require(filePath);
if ('name' in msg && 'execute' in msg && msg.type === 'message') {
client.on(Events.MessageCreate, msg.execute);
} else {
console.log(`[WARNING] The message at ${filePath} is missing a required "name", "execute" or "type" property.`);
}
}
client.on(Events.ClientReady, () => {
client.user.setActivity({ name: "over the Illegitimate Server", type: ActivityType.Watching });