如何在没有 AttributeError 的情况下使用 add_reaction ? (使用 Hikari 和 Lightbulb)在 Discord 中
How to use add_reaction without AttributeError ? (Using Hikari and Lightbulb) In Discord
我正在尝试制作一个 discord 机器人,它将对问题做出额外的反应。该代码将使用命令 /poll 从用户那里获取消息并通过嵌入发送(已经处理),这是我的代码
#Using Hikari And Lightbulb
import hikari
import lightbulb
@lightbulb.command("message", "type your message here")
@lightbulb.implements(lightbulb.SlashCommand)
async def poll(ctx):
embed_options = (
hikari.Embed(
title="This is a test Embed",
description="I want to add a reaction to this message"
)
)
msg = await ctx.respond(embed=embed_options)
await msg.add_reaction(":one:")
这段代码只是我原代码的一个例子。每当我 运行 它并发送嵌入时,我都会收到此错误
await msg.add_reaction(":one:")
AttributeError: 'ResponseProxy' object has no attribute 'add_reaction'
请注意,我使用的是 Hikari 和 Lightbulb,而不是 Discord.py
灯泡文档 - https://hikari-lightbulb.readthedocs.io/en/latest/
Github 灯泡页面 - https://github.com/tandemdude/hikari-lightbulb
Hikari 文档 - https://www.hikari-py.dev/hikari/index.html
光 Github - https://github.com/hikari-py/hikari/
从错误判断和浏览了一些 Lightbulb 文档后,我相当确定 ctx.respond 正在返回一个 ResponseProxy,尝试制作它
#Using Hikari And Lightbulb
import hikari
import lightbulb
@lightbulb.command("message", "type your message here")
@lightbulb.implements(lightbulb.SlashCommand)
async def poll(ctx):
embed_options = (
hikari.Embed(
title="This is a test Embed",
description="I want to add a reaction to this message"
)
)
rp = await ctx.respond(embed=embed_options)
msg = await rp.message()
await msg.add_reaction(":one:")
我正在尝试制作一个 discord 机器人,它将对问题做出额外的反应。该代码将使用命令 /poll 从用户那里获取消息并通过嵌入发送(已经处理),这是我的代码
#Using Hikari And Lightbulb
import hikari
import lightbulb
@lightbulb.command("message", "type your message here")
@lightbulb.implements(lightbulb.SlashCommand)
async def poll(ctx):
embed_options = (
hikari.Embed(
title="This is a test Embed",
description="I want to add a reaction to this message"
)
)
msg = await ctx.respond(embed=embed_options)
await msg.add_reaction(":one:")
这段代码只是我原代码的一个例子。每当我 运行 它并发送嵌入时,我都会收到此错误
await msg.add_reaction(":one:")
AttributeError: 'ResponseProxy' object has no attribute 'add_reaction'
请注意,我使用的是 Hikari 和 Lightbulb,而不是 Discord.py
灯泡文档 - https://hikari-lightbulb.readthedocs.io/en/latest/
Github 灯泡页面 - https://github.com/tandemdude/hikari-lightbulb
Hikari 文档 - https://www.hikari-py.dev/hikari/index.html
光 Github - https://github.com/hikari-py/hikari/
从错误判断和浏览了一些 Lightbulb 文档后,我相当确定 ctx.respond 正在返回一个 ResponseProxy,尝试制作它
#Using Hikari And Lightbulb
import hikari
import lightbulb
@lightbulb.command("message", "type your message here")
@lightbulb.implements(lightbulb.SlashCommand)
async def poll(ctx):
embed_options = (
hikari.Embed(
title="This is a test Embed",
description="I want to add a reaction to this message"
)
)
rp = await ctx.respond(embed=embed_options)
msg = await rp.message()
await msg.add_reaction(":one:")