为了账号安全,请及时绑定邮箱和手机立即绑定

在命令discord.py中调用命令

在命令discord.py中调用命令

月关宝盒 2024-01-04 10:11:40
好的,所以我需要两个命令来复制,默认代码是这样写的(我知道它很难重复,因为它充满了引用,但这并不重要,这里只是为了上下文):@bot.command(name='Bot', help="Dane nt. zakażenia w danym miejscu")async def cv_local(ctx, country=""):    translator = Translator()    translation = translator.translate(country, 'en')    country = translation.text    now = datetime.datetime.now()    startTime = time.time()    if country == "":        country = "world"        print("At " + str(now.hour) + ":" + str(now.minute) + " user " + str(ctx.message.author.name) + "(Id: " + str(            ctx.message.author.id) + ")" +              " didn't mention any country, sent data for world")    else:        print("At " + str(now.hour) + ":" + str(now.minute) + " user " + str(ctx.message.author.name) + "(Id: " + str(            ctx.message.author.id) + ")" + " searched for: " +              str(Library.exceptionCheck(country)[1]))    if str(country).lower() == "world" or str(country).lower() == "kw" or str(country).lower() == "za":        url = 'https://www.worldometers.info/coronavirus/'        code = Library.HttpsRead(url, "świata", translation.src)    else:        temp1 = Library.exceptionCheck(country)[0]        url = 'https://www.worldometers.info/coronavirus/country/' + temp1        code = Library.HttpsRead(url, country, config[ctx.guild.name]['country'])    await ctx.send(embed=code)    print("execution took %s seconds \n" % (time.time() - startTime))我没有可以发布给你的错误痕迹,这很令人沮丧
查看完整描述

1 回答

?
江户川乱折腾

TA贡献1851条经验 获得超5个赞

最后我制作了该命令的又一个版本并且它可以工作:


@bot.command(name='cv', help="Dane nt. zakażenia w danym miejscu")

async def cv_local2(ctx, leng=""):

    print("Invoking...")

    temp1 = bot.commands

    temp = bot.get_command(name='Bot')

    await temp.callback(ctx, leng)


查看完整回答
反对 回复 2024-01-04
  • 1 回答
  • 0 关注
  • 103 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信