DentyMods

rep.js

May 9th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. const Discord = require("discord.js");
  2.  
  3. module.exports.run = async (client, message, args) => {
  4. const member = message.mentions.members.first() || message.guild.members.get(args[0]) || message.member;
  5.  
  6. const mySQL = require("mysql");
  7. const con = mySQL.createConnection({
  8. host: "no",
  9. port: "no",
  10. user: "no",
  11. password: "no",
  12. database: "no"
  13. });
  14.  
  15.  
  16.  
  17. let sql;
  18. con.query(`SELECT * FROM rep WHERE UserID = '${member.user.id}'`, (err, rows) => {
  19. if (err) {
  20. throw err;
  21. }
  22. if (rows.length < 1) {
  23. $sql = `INSERT INTO rep(UserID, rep) VALUES ('${member.user.id}', '1')`; // Because he got the $rep @mention command in the first place, he got 1 rep, not 0, I guess.
  24. connection.query(sql)
  25. } else {
  26.  
  27. }
  28.  
  29. let rep = rows[1].rep;
  30. let info = new Discord.RichEmbed()
  31. .addField(`You gave ${member.user.username}`, rep)
  32. .setTimestamp(new Date());
  33. });
  34. };
Add Comment
Please, Sign In to add comment