diff --git a/index.js b/index.js index 2e2b3f4..6456949 100644 --- a/index.js +++ b/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 });