summaryrefslogtreecommitdiff
path: root/src/bot/commands/util/ping.ts
blob: 99e7fec9a3b07be18220bcbf58e1a1276fa04430 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';

export default class PingCommand extends Command {
	public constructor() {
		super('ping', {
			aliases: ['ping', 'latency', 'test'],
			clientPermissions: ['SEND_MESSAGES'],
			description: {
				content: "Checks the bot's ping to Discord.",
			},
			category: 'Utilities',
		});
	}

	public async exec(msg: Message): Promise<Message | Message[]> {
		const message = await msg.util!.send('Ping?');
		const ping = Math.round(message.createdTimestamp - msg.createdTimestamp);
		return message.edit(`Pong! \`${ping}ms\``);
	}
}