Advertisement
Guest User

Untitled

a guest
Jun 12th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. const games = JSON.parse(fs.readFileSync('./points.json', "utf8"));
  2.  
  3. const db = mysql.createConnection({
  4. host: 'localhost',
  5. user: 'root',
  6. password: 'root',
  7. database: 'l3b'
  8. })
  9.  
  10. db.connect();
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. client.on('ready', () => {
  18. console.log(`Login as [ ${client.user.username} ]`)
  19. client.user.setGame('صيانة', "https://twitch.tv/ghost99xking")
  20. })
  21. client.on("message", message => {
  22. if (message.author.bot) return;
  23. if (!message.content.startsWith(prefix)) return;
  24. let command = message.content.split(" ")[0];
  25. command = command.slice(prefix.length);
  26. let args = message.content.split(" ").slice(1);
  27. let user = message.mentions.users.first();
  28.  
  29.  
  30. var mentionned = message.mentions.users.first();
  31. var getvalueof;
  32. var bot;
  33. if(mentionned) {
  34. getvalueof = mentionned;
  35. } else {
  36. getvalueof = message.author;
  37. }
  38.  
  39.  
  40. if (!games[getvalueof.id]) games[getvalueof.id] = {
  41. wins: 0,
  42. loses: 0,
  43. points: 0,
  44. games: 0
  45. };
  46. if (message.author.bot) return;
  47.  
  48. if (!message.channel.guild) return;
  49. let game = games[message.author.id];
  50.  
  51. if (message.content.startsWith(prefix + 'نقاطي')) {
  52. let points = games.points
  53. try {
  54. points = shortNumber(points);
  55. } catch (error) {
  56. points = 0;
  57. }
  58. let wins = game.wins
  59. try {
  60. wins = shortNumber(wins);
  61. } catch (error) {
  62. wins = 0;
  63. }
  64. let loses = game.loses
  65. try {
  66. loses = shortNumber(loses);
  67. } catch (error) {
  68. loses = 0;
  69. }
  70. let games = game.game
  71. try {
  72. games = shortNumber(games);
  73. } catch (error) {
  74. games = 0;
  75. }
  76. let embed = new Discord.RichEmbed()
  77. .setAuthor(`${message.author.tag}`, message.author.avatarURL)
  78. .setColor('#000000')
  79. .setDescription(`**نقاطي
  80.  
  81. :white_check_mark: Wins : ${wins}
  82. :x: Loses: ${loses}
  83. :label: Points: ${points}
  84. :video_game: Games Played: ${games}**`);
  85. message.channel.sendEmbed(embed)
  86. }
  87. if (message.author.bot) return;
  88.  
  89. if (!message.channel.guild) return;
  90.  
  91. if (!games[message.author.id]) games[message.author.id] = {
  92. points: 0,
  93. wins: 0,
  94. loses: 0,
  95. game: 0,
  96. };
  97.  
  98. fs.writeFile("./points.json", JSON.stringify(games), function(err) {
  99. if (err) console.log(err);
  100. })
  101. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement