Added support for message events
This commit is contained in:
16
index.js
16
index.js
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user