一个相对简单的命令,它有3个参数(reportedTag、reporterTag和reasons),目的很简单,就是从#report中删除消息并发送一个到#reported
我的问题是它看不到原始命令,因此不发送报告的消息
我试过使用频道ID,频道名称,但是没有用
#---Report Command---#
@bot.command(pass_context=True)
async def report(ctx, reportedTag, reporterTag, *reasons):
if int(ctx.message.channel.id) == 416164062901305345:
reason = ' '.join(reasons)
await bot.delete_message(ctx.message)
mesg = "Report by "+ reporterTag + " for " + reportedTag + "Reason is: " + reason
return await bot.say("Report recieved. Staff have been notified :)\nEnjoy your day and we'll take care of this")
return await bot.send_message(bot.get_channel("534496148149370900"), mesg)
else:
print ("Something went wrong")
预期结果:命令行从#报告中删除,消息发送到#报告
实际结果:“出事了”
有两件事不对:
在代码中使用的
return
语句中有一个问题return
退出子例程,因此bot.send_message(bot.get_channel("534496148149370900"), mesg)
行实际上从未被调用。所以你的代码应该改成这样:除此之外,如果“出事了”实际上是输出的,那就意味着
int(ctx.message.channel.id) == 416164062901305345
是假的。请检查你的身份证和你正在写的频道相关问题 更多 >
编程相关推荐