From ad982c6533eea51fb35e27ba0326bda1cd0e9342 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 28 May 2017 13:55:48 +0000 Subject: [PATCH] Custom Ping Command --- XiaoBot.js | 2 +- commands/util/ping.js | 24 ++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 commands/util/ping.js diff --git a/XiaoBot.js b/XiaoBot.js index 204dc025..8a526bce 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -32,7 +32,7 @@ client.registry ['roleplay', 'Roleplay'] ]) .registerDefaultGroups() - .registerDefaultCommands({ help: false }) + .registerDefaultCommands({ help: false, ping: false }) .registerCommandsIn(path.join(__dirname, 'commands')); client.on('ready', () => { diff --git a/commands/util/ping.js b/commands/util/ping.js new file mode 100644 index 00000000..43154618 --- /dev/null +++ b/commands/util/ping.js @@ -0,0 +1,24 @@ +const { Command } = require('discord.js-commando'); +const { stripIndents } = require('common-tags'); + +module.exports = class PingCommand extends Command { + constructor(client) { + super(client, { + name: 'ping', + aliases: ['pong', 'ping-pong'], + group: 'util', + memberName: 'ping', + description: 'Checks the bot\'s ping to the Discord server.', + guarded: true + }); + } + + async run(msg) { + const message = await msg.say('Pinging...'); + return message.edit(stripIndents` + :ping_pong: Pong! + **Message Ping:** ${Math.round(msg.createdTimestamp - message.createdTimestamp)}ms + **Heartbeat Ping:** ${Math.round(this.client.ping)}ms + `); + } +}; diff --git a/package.json b/package.json index 7cd2b329..150389d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "21.4.2", + "version": "21.4.3", "description": "A Discord Bot", "main": "Shard.js", "scripts": {