initial commit

This commit is contained in:
2024-04-26 16:33:00 +02:00
commit 929d8abc87
7 changed files with 94 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
node_modules/
package-lock.json
package.json
.env

10
commands/utils/ping.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = {
name: "ping",
description: "Get the bot latency ",
async run(client, message) {
message.reply(`Ping : \`${client.ws.ping}ms\`.`);
}
};

12
events/bot/ready.js Normal file
View File

@ -0,0 +1,12 @@
const { Events, ActivityType } = require("discord.js");
module.exports = {
name: Events.ClientReady,
run(client) {
client.user.setActivity("Fortnite", {type: ActivityType.Playing})
console.log(`${client.user.username} is online`);
}
};

View File

@ -0,0 +1,15 @@
const { Events } = require ("discord.js");
module.exports = {
name: Events.MessageCreate,
run(client, message) {
const prefix = "!";
if(!message.content.startsWith(prefix)) return;
const arrayMessage = message.content.split(" ");
const name = arrayMessage[0].slice(prefix.length, arrayMessage[0].length);
const command = client.commands.get(name);
command.run(client, message);
}
};

18
loaders/loadCommands.js Normal file
View File

@ -0,0 +1,18 @@
const { readdirSync } = require("fs");
module.exports = client => {
let count = 0;
const dirsCommands = readdirSync("./commands/");
for(const dirs of dirsCommands) {
const filesDirs = readdirSync(`./commands/${dirs}/`).filter(f => f.endsWith(".js"));
for(const files of filesDirs) {
const command = require(`../commands/${dirs}/${files}`);
client.commands.set(command.name, command);
count ++;
};
};
console.log(`[Commands] => ${count} logged commands`);
}

18
loaders/loadEvents.js Normal file
View File

@ -0,0 +1,18 @@
const { readdirSync} = require("fs");
module.exports = client => {
let count = 0;
const dirsEvents = readdirSync("./events/");
for(const dirs of dirsEvents) {
const filesDirs = readdirSync(`./events/${dirs}/`).filter(f => f.endsWith(".js"));
for(const files of filesDirs) {
const event = require(`../events/${dirs}/${files}`);
client.on(event.name, (...args) => event.run(client, ...args));
count++;
};
};
console.log(`[Events] => ${count} logged events`)
}

14
main.js Normal file
View File

@ -0,0 +1,14 @@
const { Client, IntentsBitField, Collection } = require("discord.js");
const client = new Client({intents: new IntentsBitField(3276799)});
const loadCommands = require("./loaders/loadCommands");
const loadEvents = require("./loaders/loadEvents");
const dotenv = require("dotenv");
dotenv.config();
client.commands = new Collection();
loadCommands(client);
loadEvents(client);
client.login(process.env.TOKEN);