交互.响应.通道.发送问题

问题描述 投票:0回答:1
async def callback(self, interaction: discord.Interaction):
    embed = discord.Embed(title="Modal Results")
    embed.add_field(name="test", value=self.children[0].value)
    embed.add_field(name="test", value=self.children[1].value)
    channel = client.get_channel(1201684034531368994)
    await interaction.response.channel.send(embed)

    await interaction.response.channel.send(embed)

我不知道如何修复这条线 可以帮助我

discord discord.py pycord
1个回答
0
投票

这是代码的修订版本:

async def callback(self, interaction: discord.Interaction):
    embed = discord.Embed(title="Modal Results")
    embed.add_field(name="test", value=self.children[0].value)
    embed.add_field(name="test", value=self.children[1].value)
    channel = await client.fetch_channel(1201684034531368994) # Changed get_channel to fetch_channel and added 'await' (I personally prefer fetch)channel
    await channel.send(embed = embed) #channel already has attribute "send"

    await channel.send(embed = embed) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

说明:

您已经获得了通道对象,因此现在您可以通过通道对象发送消息。

© www.soinside.com 2019 - 2024. All rights reserved.