【问题标题】:AttributeError: 'Message' object has no attribute 'send' when trying to send embeds using discord.pyAttributeError:尝试使用 discord.py 发送嵌入时,\'Message\' 对象没有属性 \'send\'
【发布时间】:2022-12-21 21:15:19
【问题描述】:

尝试使用 discord.py 并学习机器人开发的开始,但是当我尝试发送嵌入时,它给了我错误。

我试过:

import discord

intents = discord.Intents.default()
intents.message_content = True

client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'Logged in as {client.user}')

@client.event
async def on_message(message):
    if message.content.startswith('!test'):
        embed=discord.Embed(title="title", color=0x13fa07)
        embed.add_field(name="name1", value="value1", inline=True)
        embed.add_field(name="name2", value="value2", inline=True)
        embed.set_footer(text="bot test 0.1")
        await message.send(embed=embed)
        
client.run('token here')

(已审查的代币)

但随后它返回

AttributeError: 'Message' object has no attribute 'send'

【问题讨论】:

    标签: discord discord.py


    【解决方案1】:

    欢迎使用 discord.py,正如错误所说的'Message' object has no attribute 'send' 但它确实具有属性 channel 具有您正在寻找的属性 send docs

    ...
    await message.channel.send(embed=embed)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-15
      • 2021-08-19
      • 1970-01-01
      • 2021-07-27
      • 2021-08-01
      • 2017-12-02
      • 2023-01-23
      • 2021-02-03
      相关资源
      最近更新 更多