【问题标题】:Not able to send Embeds in Discord.py无法在 Discord.py 中发送嵌入
【发布时间】:2020-09-09 10:10:35
【问题描述】:

这是我的代码:

   

@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

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您需要使用.send(embed=discord.Embed) 指定您正在发送嵌入 这是更新的代码-

    @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(embed=discord.Embed(title=ann, color=coloo))
    
    
    client.run('TOKEN')
    

    【讨论】:

      猜你喜欢
      • 2021-02-05
      • 1970-01-01
      • 2023-03-09
      • 2020-05-31
      • 2021-02-13
      • 2021-01-25
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多