Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // index.js
- const Discord = require('discord.js')
- const intents = new Discord.IntentsBitField(3276799)
- const bot = new Discord.Client({intents})
- const loadCommands = require('./loader/LoadCommands.js')
- const loadEvents = require('./loader/LoadEvent.js')
- bot.commands = new Discord.Collection()
- loadCommands(bot)
- loadEvents(bot)
- bot.login("le token")
- // Commandes
- // ping.js
- const Discord = require('discord.js');
- module.exports = {
- name: "ping",
- async run(bot, message) {
- await message.reply(`Ping : \`${bot.ws.ping}\``)
- }
- }
- // Events
- // messageCreate.js
- const Discord = require('discord.js')
- module.exports = async (bot, message) => {
- let prefix = "?";
- let messageArray = message.content.split(" ")
- let commandname = messageArray[0].slice(prefix.length)
- let args = messageArray.slice(1)
- if (!message.content.startsWith(prefix)) return;
- let command = require(`../commandes/${commandname}`)
- if (!command) return message.reply("Cette commande n'existe pas.")
- command.run(bot, message, args)
- }
- // ready.js
- const Discord = require('discord.js');
- module.exports = async bot => {
- console.log(`${bot.user.tag} est en ligne !`);
- }
- // Loader
- // LoadCommands.js
- const fs = require('fs');
- module.exports = async bot => {
- fs.readdirSync("./commandes").filter(f => f.endsWith(".js")).forEach(async file => {
- let command = require(`../commandes/${file}`);
- if(!command.name || typeof command.name !== "string") throw new TypeError(`La Commande ${file.slice(0, file.lengh - 3)} n'a pas de nom !`)
- bot.commands.set(command.name, command);
- console.log(`Commande ${command.name} chargée`)
- })
- }
- // LoadEvent.js
- const fs = require('fs');
- module.exports = async bot => {
- fs.readdirSync("./Events").filter(f => f.endsWith(".js")).forEach(async file => {
- let Events = require(`../Events/${file}`);
- bot.on(file.split(".js").join(""), Events.bind(null, bot))
- console.log(`Evènement ${file} Chargé avec succès !`)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment