无法在Discord.py中发送嵌入

时间:2020-09-09 01:51:06

标签: python discord discord.py

这是我的代码:

   

@client.event
async def on_message(message):
    if message.content.startswith('.announce'):
        first_embed = discord.Embed(title="Enter announcement", color=0x2bff00)
        msgg = await message.channel.send(embed=first_embed)
        def check(m):
            return m.channel == message.channel
          
        msg = await client.wait_for('message', check=check)
        ann = msg.content
        print(ann)
        time.sleep(10)
        new_embed = discord.Embed(title='Enter Colour(Red, Green, Yellow)', color=0x2bff00)         
  

        await msgg.edit(embed=new_embed)
        def check(m):
            return m.channel == message.channel
          
        msg = await client.wait_for('message', check=check)
        colo = msg.content
        print(colo)


        channel = client.get_channel(733344357884756018)
        if(colo=='Red'):
            coloo = discord.Colour(0xFF0000)
        if(colo == 'Green'):
            coloo = discord.Colour(0x2bff00)
        if(colo == 'Yellow'):
            coloo = discord.Colour(0xFFFF00)

        await channel.send(discord.Embed(title=ann, color=coloo))


client.run('TOKEN')

不幸的是,当我运行该程序时,它会正确获取输入和所有内容,但输出结果是:

我要实现的目标:

基本上,在我的服务器上发送嵌入的通知看起来很花哨。

任何有助于解决该问题的方法,或者对我代码的改进将不胜感激:)

图片:

My Input in Discord

Output

1 个答案:

答案 0 :(得分:0)

您需要使用.map指定要发送嵌入内容 这是更新的代码-

const updatedTemplateArr = Object.entries(template).map(([key, value]) => {
  if (typeof value === 'function') {
    return {
      [key]: {
        filePath: `${projectPath}/${key}`,
        template: value(param),
      },
    }
  }
})