如何使用discord.py删除DM中的反应

时间:2018-11-28 17:37:42

标签: python python-3.x discord.py

我想从我的机器人发送的私人消息中删除响应。当我尝试这个:

    embed = discord.Embed(title="Choose the word difficulty.",description="**1.** Easy\n**2.** Medium\n**3.** Hard\n**4.** Ridiculous",color=0x7a17bb)
    msg = await client.send_message(MAYOR_TAKEN[0],embed=embed)
    await client.add_reaction(message=msg,emoji='\u0031\u20E3')
    await client.add_reaction(message=msg,emoji='\u0032\u20E3')
    await client.add_reaction(message=msg,emoji='\u0033\u20E3')
    await client.add_reaction(message=msg,emoji='\u0034\u20E3')
    while True:
        react = await client.wait_for_reaction(emoji=None,message=msg,check=check)
        if react.reaction.emoji == '\u0031\u20E3':
            await client.delete_message(message=msg)
            await choosewords(1)
        elif react.reaction.emoji == '\u0032\u20E3':
            await client.delete_message(message=msg)
            await choosewords(2)
        elif react.reaction.emoji == '\u0033\u20E3':
            await client.delete_message(message=msg)
            await choosewords(3)
        elif react.reaction.emoji == '\u0034\u20E3':
            await client.delete_message(message=msg)
            await choosewords(4)
        else:
            await client.remove_reaction(message=msg,emoji=react.reaction.emoji,member=react.user)

我被禁止(状态代码:403):无法在await client.remove_reaction(message=msg,emoji=react.reaction.emoji,member=react.user)的DM通道上执行操作。如何删除该反应?

编辑:

  Traceback (most recent call last)
  File "C:\Users\samue\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "Spacebotv2.py", line 466, in Werewords
    await choosedifficulty(MAYOR_TAKEN)
  File "Spacebotv2.py", line 443, in choosedifficulty
    await client.remove_reaction(message=msg,emoji=react.reaction.emoji,member=react.user)
  File "C:\Users\samue\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 1002, in remove_reaction
    yield from self.http.remove_reaction(message.id, message.channel.id, emoji, member_id)
  File "C:\Users\samue\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 196, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: FORBIDDEN (status code: 403): Cannot execute action on a DM channel

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\samue\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\samue\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\samue\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: FORBIDDEN (status code: 403): Cannot execute action on a DM channel

0 个答案:

没有答案