cog_info.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:Godavaru 作者: Godavaru 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号