首页 文章

Discord Bot响应短语(Discord.py Rewrite)

提问于
浏览
0

现在,我正在尝试为Discord Bot(使用Discord.py Rewrite包)编写一个事件,该事件将在聊天中发送某个短语时发送图像 .

基于我一直有的错误消息,看起来它没有传递Message参数,因为我可能在某处遗漏了某些东西 . 听众似乎正在按照应有的方式工作(它触发了某人在聊天中说话的那一刻) .

以下是我收到的错误消息以供参考:

忽略消息中的异常Traceback(最近一次调用最后一次):文件“C:\ Program Files(x86)\ Python36-32 \ lib \ site-> packages \ discord \ client.py”,第221行,在_run_event等待coro( * args,** kwargs)TypeError:dealwithit()缺少1个必需>位置参数:'message'

以下是供参考的代码段

@bot.event
async def dealwithit(ctx,message):
    msg = message.content
    msg = msg.lower()
    msg = "".join(msg.split())
    if ctx.user.id != message.author.id:
        if msg == "dealwithit":
            dealwithit= discord.File('swag.jpg', filename='swag.jpg')
            await client.send_message(content=None,file=dealwithit)

bot.add_listener(dealwithit,'on_message')

任何有关我可能遗失的帮助,如果没有通过论证,或者设置不正确,我们将不胜感激 .

1 回答

  • 0

    这是使用discord命令重写的

    bot = commands.Bot(command_prefix='!')
        @bot.command(pass_context=True)
        async def dealwithit(ctx):
            sendfile = open("swag.jpg", "rb")
            await bot.send_file(ctx.author.channel, sendfile)
            sendfile.close()
    

相关问题