Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // index.js :
- const Discord = require('discord.js'),
- client = new Discord.Client({
- fetchAllMembers: true
- }),
- config = require('./config.json'),
- fs = require('fs')
- client.login(config.token)
- client.commands = new Discord.Collection()
- fs.readdir('./commands', (err, files) => {
- if (err) throw err
- files.forEach(file => {
- if (!file.endsWith('.js')) return
- const command = require(`./commands/${file}`)
- client.commands.set(command.name, command)
- })
- })
- client.on('message', message => {
- if (message.type !== 'DEFAULT' || message.author.bot) return
- const args = message.content.trim().split(/ +/g)
- const commandName = args.shift().toLowerCase()
- if (!commandName.startsWith(config.prefix)) return
- const command = client.commands.get(commandName.slice(config.prefix.length))
- if (!command) return
- command.run(message, args, client)
- })
- // config.json
- {
- "token": "votre token",
- "prefix": "!"
- }
- // bonjour.js
- module.exports = {
- run: message => message.channel.send('bonjour à toi'),
- name: 'bjr'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement