Skip to content

Instantly share code, notes, and snippets.

@tt024
Created April 1, 2018 18:07
Show Gist options
  • Save tt024/a23579351d83d7bc1d2f2d94ce91a485 to your computer and use it in GitHub Desktop.
Save tt024/a23579351d83d7bc1d2f2d94ce91a485 to your computer and use it in GitHub Desktop.
const Discord = require('discord.js')
const bot = new Discord.Client()
const TOKEN = "votre_token"
// Bot prêt
bot.on('ready', () => {
bot.user.setStatus("online"); //dnd , online , ldle
console.log("Le bot est en ligne ! \nVersion de Node: " + process.version + "\nVersion de Discord.js: " + Discord.version + "\n");
});
bot.on("message", message => {
var prefix = ">";
var userData = JSON.parse(fs.readFileSync('points.json', 'utf-8'));
// Savoir le nombre de message envoyé avec >stats
// Les points sont enregistrés dans points.json
if (message.content.startsWith(prefix + "stats")) {
message.channel.send('Vous avez envoyé **' + userData[sender.id].messagesSent + '** messages !' )
console.log("Commande executé: >stats")
}
if (!userData[sender.id]) userData[sender.id] = {
messageSent: 0
}
userData[sender.id].messagesSent++;
fs.writeFile('points.json', JSON.stringify(userData), (err) => {
if (err) console.error(err);
});
});
client.login(TOKEN);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment