Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. const commando = require('discord.js-commando');
  2. const mysql = require("mysql");
  3. const { RichEmbed } = require('discord.js');
  4.  
  5. var con = mysql.createConnection({
  6. host: "localhost",
  7. user: "root",
  8. password: "-",
  9. database: "-"
  10. });
  11.  
  12. con.connect(err => {
  13. if(err) throw err;
  14. con.query("SHOW TABLES");
  15. });
  16.  
  17.  
  18. class ShowXPCommand extends commando.Command {
  19. constructor(client) {
  20. super(client, {
  21. name: 'showxp',
  22. group: 'xp',
  23. memberName: 'showxp',
  24. description: 'Shows the XP of mentioned user or you.'
  25. });
  26. }
  27.  
  28. async run(message, args) {
  29. let target = message.mentions.users.first() || message.guild.members.get(args[1]) || message.author;
  30.  
  31. con.query(`SELECT * FROM xp WHERE id = '${target.id}'`, (err, rows) => {
  32. if(err) throw err;
  33.  
  34. if(!rows[0]) return message.channel.send("This user has no XP on record. :c ~")
  35.  
  36. let xp = rows[0].xp;
  37. message.channel.send(xp);
  38.  
  39. let embed = new RichEmbed()
  40. .setDescription("User's XP")
  41. .setcolor("#15f153")
  42. .addField("User's Name", message.target.username);
  43. return message.embed(embed);
  44. })
  45. }
  46. }
  47.  
  48. module.exports = ShowXPCommand
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement