【发布时间】:2020-09-08 03:00:09
【问题描述】:
我有 say 命令可以正常工作,并回复我在其中提供的消息。但是,我想更改代码以支持 自定义嵌入正文消息。
基本上,我的问题是:如何让我的say 命令回复消息或自定义嵌入正文消息?
我的say 命令
@commands.command(name='say', aliases=['repeat', 'talk'])
@commands.has_permissions(manage_messages=True)
async def _say(self, ctx, *, message):
await ctx.send(message, ctx)
我希望我的命令能够做的是......
示例:
-say {embed=discord.Embed(title="Test", description="Embed Example")
embed.set_author(name="Author", url="https://authorlink.com", icon_url="https://authoricon.com")
embed.set_thumbnail(url="https://thumbnail.png")
embed.add_field(name="Field 1", value="Field test 1", inline=True)
embed.add_field(name="Field 2", value="Field test 2", inline=False)
embed.set_footer(text=ctx.guild.name)
await ctx.send(embed=embed)}
有谁知道如何使代码也发送自定义嵌入正文消息?我了解嵌入以及如何形成它。现在,我只希望我的命令能够同时说出自定义嵌入和自定义消息。我希望我的想法是有意义的。
- 编辑: 这就是我得到的嵌入(作为单独的命令)
(这样我不能自定义整个嵌入,而只能自定义代码中提供的字段的值。如果可能的话,我正在寻找一种使其完全自定义的方法,并将其与一个命令合并仅用于嵌入和普通消息)_
@commands.command(name="sayembed")
@commands.has_permissions(manage_messages=True)
async def _saye(self, ctx, *, message):
embedsay = discord.Embed(color=ctx.author.color, timestamp=ctx.message.created_at)
embedsay.set_author(name="Message from:", icon_url=ctx.author.avatar_url)
embedsay.add_field(name=ctx.message.author, value=str(message))
embedsay.set_thumbnail(url=ctx.author.avatar_url)
embedsay.set_footer(text=ctx.guild.name)
await ctx.send(embed=embedsay)
【问题讨论】:
-
您能否提供一些示例,说明如何调用命令来发送嵌入?如果您正在编写一个刚刚发送嵌入的命令,那会是什么样子?
-
就像我说的,它是同一个命令,我只是在寻找一种
-say命令可以发送两种消息的方式。如果不可能,我想我会对单独的嵌入命令感到满意,可能是-sayembed或其他东西。 -
现在我确实有一个发送嵌入的示例命令,但问题是,它只能发送自定义字段值,而不是整个自定义嵌入消息(如自定义页脚、字段、嵌入信息等.)。我将在我的帖子中添加一个嵌入消息的示例。
标签: python-3.x discord discord.py-rewrite