From 6faeb366a5a15d3e57029bc082985424c69e7869 Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Wed, 22 Jun 2022 21:06:46 -0400 Subject: [PATCH] messing with events --- events/interactionCreate.js | 6 ++++++ events/ready.js | 7 +++++++ events/reee.js | 10 ++++++++++ index.js | 14 ++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 events/interactionCreate.js create mode 100644 events/ready.js create mode 100644 events/reee.js diff --git a/events/interactionCreate.js b/events/interactionCreate.js new file mode 100644 index 0000000..6959079 --- /dev/null +++ b/events/interactionCreate.js @@ -0,0 +1,6 @@ +module.exports = { + name: 'interactionCreate', + execute(interaction) { + console.log(`${interaction.user.tag} in #${interaction.channel.name} triggered an interaction.`); + }, +}; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js new file mode 100644 index 0000000..4fc1ce2 --- /dev/null +++ b/events/ready.js @@ -0,0 +1,7 @@ +module.exports = { + name: 'ready', + once: true, + execute(client) { + console.log(`Ready! Logged in as ${client.user.tag}`); + }, +}; \ No newline at end of file diff --git a/events/reee.js b/events/reee.js new file mode 100644 index 0000000..2bc3fd5 --- /dev/null +++ b/events/reee.js @@ -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'); + } + }, +}; \ No newline at end of file diff --git a/index.js b/index.js index 20953a7..ae7bb85 100644 --- a/index.js +++ b/index.js @@ -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); \ No newline at end of file