From b903b30dd971f41e8f5c6ac42f45a189d54c880e Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Thu, 3 May 2018 17:21:47 -0700 Subject: [PATCH] Add pingtime --- pingtime/pingtime.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pingtime/pingtime.py diff --git a/pingtime/pingtime.py b/pingtime/pingtime.py new file mode 100644 index 0000000..a88181a --- /dev/null +++ b/pingtime/pingtime.py @@ -0,0 +1,17 @@ +from discord.ext import commands +import time + + +class Pingtime: + + def __init__(self, bot): + self.bot = bot + + @commands.command(pass_context=True) + async def pingtime(self, ctx): + """Ping pong.""" + channel = ctx.message.channel + t1 = time.perf_counter() + await channel.trigger_typing() + t2 = time.perf_counter() + await ctx.send("Pong: {}ms".format(round((t2-t1)*1000)))