Discord.py中的延迟命令 [英] Latency command in Discord.py

查看:60
本文介绍了Discord.py中的延迟命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多地方,但找不到使用 discord.py 进行ping(延迟)命令的方法,如下所示:

I've looked in a lot of places and I can't find a way to make a ping (latency) command using discord.py, something like this:

@client.command(pass_context=True)
async def pong(ctx):
    # Somehow find 'pingtime'
    await client.say(pingtime)

推荐答案

在这一点上,您确实应该使用重写discord.py的分支

Really at this point you should be using the rewrite branch of discord.py

这是我使用命令扩展名的解决方案.

This would be my solution using the commands extension.

@bot.command()
async def ping(ctx):
    await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))

这篇关于Discord.py中的延迟命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆