Compare commits
2 commits
1ac5c20aea
...
ea193ceddd
Author | SHA1 | Date | |
---|---|---|---|
ea193ceddd | |||
e7a49f7828 |
3 changed files with 22 additions and 4 deletions
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
||||||
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
"brace-style": ["error", { "allowSingleLine": true }],
|
||||||
"comma-dangle": ["error", "always-multiline"],
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
"comma-spacing": "error",
|
"comma-spacing": "error",
|
||||||
"comma-style": "error",
|
"comma-style": "error",
|
||||||
|
|
7
src/events/ready.js
Normal file
7
src/events/ready.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
name: 'ready',
|
||||||
|
once: true,
|
||||||
|
execute() {
|
||||||
|
console.log('Prêt !');
|
||||||
|
},
|
||||||
|
};
|
17
src/index.js
17
src/index.js
|
@ -1,10 +1,21 @@
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
const { Client, Intents } = require('discord.js');
|
const { Client, Intents } = require('discord.js');
|
||||||
const { token } = require('../config/config.json');
|
const { token } = require('../config/config.json');
|
||||||
|
|
||||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
||||||
|
|
||||||
client.once('ready', () => {
|
const eventsPath = path.join(__dirname, 'events');
|
||||||
console.log('Prêt !');
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
||||||
|
|
Loading…
Reference in a new issue