otherstuff.py 文件源码

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

项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码
def ping(self, ctx):
        """Your average ping command."""
        # Set the embed for the pre-ping
        clock = random.randint(0x1F550, 0x1F567)  # pick a random clock
        embed = discord.Embed(colour=0xFFC107)
        embed.set_author(name=random.choice(PRE_PING_REMARKS), icon_url=emoji_url(chr(clock)))

        # Do the classic ping
        start = time.perf_counter()     # fuck time.monotonic()
        message = await ctx.send(embed=embed)
        end = time.perf_counter()       # fuck time.monotonic()
        ms = (end - start) * 1000

        # Edit the embed to show the actual ping
        embed.colour = 0x4CAF50
        embed.set_author(name='Poing!', icon_url=emoji_url('\U0001f3d3'))
        embed.add_field(name='Latency', value=f'{ctx.bot.latency * 1000 :.0f} ms')
        embed.add_field(name='Classic', value=f'{ms :.0f} ms', inline=False)

        await message.edit(embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号