Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const games = JSON.parse(fs.readFileSync('./points.json', "utf8"));
- const db = mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: 'root',
- database: 'l3b'
- })
- db.connect();
- client.on('ready', () => {
- console.log(`Login as [ ${client.user.username} ]`)
- client.user.setGame('صيانة', "https://twitch.tv/ghost99xking")
- })
- client.on("message", message => {
- if (message.author.bot) return;
- if (!message.content.startsWith(prefix)) return;
- let command = message.content.split(" ")[0];
- command = command.slice(prefix.length);
- let args = message.content.split(" ").slice(1);
- let user = message.mentions.users.first();
- var mentionned = message.mentions.users.first();
- var getvalueof;
- var bot;
- if(mentionned) {
- getvalueof = mentionned;
- } else {
- getvalueof = message.author;
- }
- if (!games[getvalueof.id]) games[getvalueof.id] = {
- wins: 0,
- loses: 0,
- points: 0,
- games: 0
- };
- if (message.author.bot) return;
- if (!message.channel.guild) return;
- let game = games[message.author.id];
- if (message.content.startsWith(prefix + 'نقاطي')) {
- let points = games.points
- try {
- points = shortNumber(points);
- } catch (error) {
- points = 0;
- }
- let wins = game.wins
- try {
- wins = shortNumber(wins);
- } catch (error) {
- wins = 0;
- }
- let loses = game.loses
- try {
- loses = shortNumber(loses);
- } catch (error) {
- loses = 0;
- }
- let games = game.game
- try {
- games = shortNumber(games);
- } catch (error) {
- games = 0;
- }
- let embed = new Discord.RichEmbed()
- .setAuthor(`${message.author.tag}`, message.author.avatarURL)
- .setColor('#000000')
- .setDescription(`**نقاطي
- :white_check_mark: Wins : ${wins}
- :x: Loses: ${loses}
- :label: Points: ${points}
- :video_game: Games Played: ${games}**`);
- message.channel.sendEmbed(embed)
- }
- if (message.author.bot) return;
- if (!message.channel.guild) return;
- if (!games[message.author.id]) games[message.author.id] = {
- points: 0,
- wins: 0,
- loses: 0,
- game: 0,
- };
- fs.writeFile("./points.json", JSON.stringify(games), function(err) {
- if (err) console.log(err);
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement