【发布时间】:2020-06-01 18:56:34
【问题描述】:
我收到此错误:discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'Bot' 对象没有属性'message'--尝试执行await self.client.message.add_reaction(emoji) 时。
我尝试将其更改为 await ctx.message.add_reaction(emoji),我意识到它是对用户发送的命令而不是机器人的新消息做出反应。
import discord
from discord.ext import commands
class MovieNight(commands.Cog):
"""Polls for Movie Night."""
def __init__(self, client):
self.client = client
@commands.command(aliases=['m'])
async def movie(self, ctx, year, *movie):
movie_title = ' '.join(movie[:-1])
await ctx.send(f"`{year}` - `{movie_title}` | **{movie[-1]}**")
emoji = '????'
await self.client.message.add_reaction(emoji)
def setup(client):
client.add_cog(MovieNight(client))
【问题讨论】:
标签: python-3.x discord.py