Star-Board discord.py 个问题
Star-Board discord.py issues
我正在使用 json 文件来存储公会的星级频道。这是我的代码:
@client.event
async def on_raw_reaction_add(payload):
star = await get_star_channels()
if str(payload.message.guild.id) not in star:
return
starchannel = client.get_channel(star[str(payload.message.guild.id)])
if payload.emoji == '⭐':
if str(payload.message.guild.id) not in star:
return
if not payload.member.guild_permissions.manage_messages:
await payload.message.channel.send("You don't have the permissions to star a message")
return
if len(payload.message.attachments) > 0:
embed.set_image(url = payload.message.attachments[0].url)
embed = discord.Embed(description = f"{payload.message.author}:\n\n{payload.message.content}\n\n**[Jump to message]({payload.message.jump_url})**", color = random.choice(colors_for_embeds1), timestamp = datetime.now())
embed.set_author(name = f"{payload.member.name} starred a message", icon_url = payload.member.avatar_url)
embed.set_footer(text = f"<#{payload.channel.id}>")
await starchannel.send(embed = embed)
我面临的问题是 'RawReactionActionEvent'
对象没有属性 'message'
或 'guild'
所以我无法获得 guild ID where the reaction was added
(似乎方法)。如果不访问公会 ID,我无法获得 star channel ID stored in the JSON file
因为 key of all the star-channel IDs is the guild ID
.
你应该使用 guild_id
和 message_id
以下是 RawReactionActionEvent 的所有属性:
message_id
user_id
channel_id
guild_id
emoji
member
仅适用于 on_raw_reaction_add
event_type
我正在使用 json 文件来存储公会的星级频道。这是我的代码:
@client.event
async def on_raw_reaction_add(payload):
star = await get_star_channels()
if str(payload.message.guild.id) not in star:
return
starchannel = client.get_channel(star[str(payload.message.guild.id)])
if payload.emoji == '⭐':
if str(payload.message.guild.id) not in star:
return
if not payload.member.guild_permissions.manage_messages:
await payload.message.channel.send("You don't have the permissions to star a message")
return
if len(payload.message.attachments) > 0:
embed.set_image(url = payload.message.attachments[0].url)
embed = discord.Embed(description = f"{payload.message.author}:\n\n{payload.message.content}\n\n**[Jump to message]({payload.message.jump_url})**", color = random.choice(colors_for_embeds1), timestamp = datetime.now())
embed.set_author(name = f"{payload.member.name} starred a message", icon_url = payload.member.avatar_url)
embed.set_footer(text = f"<#{payload.channel.id}>")
await starchannel.send(embed = embed)
我面临的问题是 'RawReactionActionEvent'
对象没有属性 'message'
或 'guild'
所以我无法获得 guild ID where the reaction was added
(似乎方法)。如果不访问公会 ID,我无法获得 star channel ID stored in the JSON file
因为 key of all the star-channel IDs is the guild ID
.
你应该使用 guild_id
和 message_id
以下是 RawReactionActionEvent 的所有属性:
message_id
user_id
channel_id
guild_id
emoji
member
仅适用于 on_raw_reaction_add
event_type