def ping(self, ctx):
"""Check my response time and my websocket ping
**Usage:** `g_ping`
**Permission:** User"""
console = self.bot.get_channel(316688736089800715)
before = datetime.datetime.utcnow()
ping_msg = await console.send(":mega: **Pinging...**")
ping = (datetime.datetime.utcnow() - before) * 1000
before2 = time.monotonic()
await (await self.bot.ws.ping())
after = time.monotonic()
ping2 = (after - before2) * 1000
var = int(random.random() * 5)
v = ["a", "e", "i", "o", "u"]
await ping_msg.edit(content=':warning: [`'+str(datetime.datetime.now().strftime("%d/%m/%y %H:%M:%S"))+'`] `' + ctx.message.author.name + '#' + ctx.message.author.discriminator + '` checked my ping in the channel `' + ctx.message.channel.name + '` in the server `' + ctx.message.guild.name + '`. The result was {:.2f}ms'.format(ping.total_seconds())+" with a websocket ping of {0:.0f}ms".format(ping2))
await ctx.send(":mega: P"+v[var]+"ng! The message took **{:.0f}ms**!".format(ping.total_seconds())+" `Websocket: {0:.0f}ms` :thinking:".format(ping2))
评论列表
文章目录