messing with events

This commit is contained in:
alwayscompiling
2022-06-22 21:06:46 -04:00
parent 59d9115eb5
commit 6faeb366a5
4 changed files with 37 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
name: 'interactionCreate',
execute(interaction) {
console.log(`${interaction.user.tag} in #${interaction.channel.name} triggered an interaction.`);
},
};
+7
View File
@@ -0,0 +1,7 @@
module.exports = {
name: 'ready',
once: true,
execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
},
};
+10
View File
@@ -0,0 +1,10 @@
module.exports = {
name: 'messageCreate',
execute(client) {
console.log('user has sent a message');
if (client.messageCreate.content.includes('reee')) {
const channel = client.channels.cache.get('id');
channel.send('reee');
}
},
};
+14
View File
@@ -41,5 +41,19 @@ client.on('interactionCreate', async interaction => {
}
});
const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
}
else {
client.on(event.name, (...args) => event.execute(...args));
}
}
// Login to Discord with your client's token
client.login(token);