我在下面的代码中得到"This Interaction Failure":
class SimpleView(discord.ui.View):
@discord.ui.button(label="✔️", style=discord.ButtonStyle.success)
async def approve(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message(content="Approved!", ephemeral=True)
@discord.ui.button(label="❌", style=discord.ButtonStyle.red)
async def deny(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message(content="Denied!")
@bot.event
async def on_member_join(member: discord.Member):
view = SimpleView()
role_name = discord.utils.get(member.guild.roles, name="Test")
approve_channel_id = 1158716789103013898
approve = member.guild.get_channel(approve_channel_id)
if approve is not None:
await member.add_roles(role_name)
await approve.send(f"{member} joined the server! Do you Approve?", view=view)
await view.wait()
else:
print(f"Channel with ID {approve_channel_id} not found!")
我试图做的是,当某人加入服务器时,他将获得一个特定的角色,并在仅限管理员的通道中使用两个按钮发送消息,一个按钮接受用户在服务器中,另一个按钮拒绝.但是,当我按下一个按钮时,我得到"This Interaction Failure",并且控制台中没有任何错误.