【问题标题】:discord.py send embed message from source codediscord.py 从源代码发送嵌入消息
【发布时间】:2021-07-10 13:04:57
【问题描述】:

所以我试图制作嵌入命令。代码:

@client.command()
@commands.has_permissions(administrator=True)
async def embed(ctx):
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    await ctx.send('Send me your source code.')
    source = await client.wait_for('message', check=check)
    src = source.content
  
    await ctx.send(embed=src)

是的,我想知道有没有办法将此字符串转换为discord.Embed。我真的很想使用源代码发送嵌入。

【问题讨论】:

    标签: python python-3.x discord.py


    【解决方案1】:

    你得到的是一个字符串,你不能像这样作为嵌入发送。

    如您所说,您必须将其放入embed

    @client.command()
    @commands.has_permissions(administrator=True)
    async def embed(ctx):
        def check(message):
            return message.author == ctx.author and message.channel == ctx.channel
    
        await ctx.send('Send me your source code.')
        source = await client.wait_for('message', check=check)
    
        embed = discord.Embed(title="Custom Embed", description=source.content, colour=discord.Colour.red())
        # You can put the colour to whatever you want with 0xHEXCODE (e.g. 0x30F90)
      
        await ctx.send(embed=embed)
    

    【讨论】:

      猜你喜欢
      • 2021-02-13
      • 2021-09-07
      • 2021-07-08
      • 2021-04-26
      • 2021-12-25
      • 1970-01-01
      • 2020-04-21
      • 2019-01-12
      • 2021-08-31
      相关资源
      最近更新 更多