Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. const Command = require('../base/Command.js');
  2. const Discord = require('discord.js');
  3. class Ping extends Command {
  4. constructor(client) {
  5. super(client, {
  6. name: 'ping',
  7. description: 'Latency and API response times.',
  8. usage: 'ping',
  9. extended: 'This command is a response test, it helps gauge if there is any latency (lag) in either the bots connection, or the API.',
  10. aliases: ['pong']
  11. });
  12. }
  13.  
  14. async run(message, args, level) { // eslint-disable-line no-unused-vars
  15. try {
  16. const msg = await message.channel.send('Pinging ...');
  17. const mss = Math.round(this.client.ping);
  18. const ms = msg.createdTimestamp - message.createdTimestamp;
  19. const embed = new Discord.RichEmbed()
  20. .setAuthor(`${this.client.user.username}`, `${this.client.user.avatarURL}`)
  21. .setColor(`${[Math.floor(Math.random() * 16777215).toString(16)]}`)
  22. .setTitle('Speed of bot connection.')
  23. .setDescription(`
  24. • 🏓 | \`Ping:\` ${ms}ms
  25. • 💙 | \`API:\` ${mss}ms
  26. `)
  27. .setFooter(`${this.client.user.tag} (ID Client: ${this.client.user.id})`, `${this.client.user.avatarURL}`);
  28. msg.edit({embed});
  29.  
  30. } catch (e) {
  31. console.log(e);
  32. }
  33. }
  34. }
  35.  
  36. module.exports = Ping;
  37.  
  38.  
  39. function editPong(message, secondMessage) {
  40. const mss = Math.round(this.client.ping);
  41. const ms = secondMessage.createdTimestamp - message.createdTimestamp;
  42. let statuss = '';
  43. if (mss < 50) {
  44. statuss = '(`ممتاز`)';
  45. } else if (mss < 100) {
  46. statuss = '(`جيد جداً`)';
  47. } else if (mss < 300) {
  48. statuss = '(`جيد`)';
  49. } else if (mss < 1000) {
  50. statuss = '(`متوسط`)';
  51. } else {
  52. statuss = '(`سيء`)';
  53. }
  54. let status = '';
  55. if (ms < 50) {
  56. status = '(`ممتاز`)';
  57. } else if (ms < 100) {
  58. status = '(`جيد جداً`)';
  59. } else if (ms < 300) {
  60. status = '(`جيد`)';
  61. } else if (ms < 1000) {
  62. status = '(`متوسط`)';
  63. } else {
  64. status = '(`سيء`)';
  65. }
  66. const embed = new Discord.RichEmbed()
  67. .setAuthor(`${this.client.user.username}`, `${this.client.user.avatarURL}`)
  68. .setColor(`${[Math.floor(Math.random() * 16777215).toString(16)]}`)
  69. .setTitle('سرعة أتصال البوت')
  70. .setDescription(`
  71. • 🏓 | \`Ping:\` ${ms}ms | ${status}
  72. • 💙 | \`Websocket:\` ${mss}ms | ${statuss}
  73. `)
  74. .setFooter(`${this.client.user.tag} (ID Client: ${this.client.user.id})`, `${this.client.user.avatarURL}`);
  75. secondMessage.edit({embed});
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement