[英]Trouble with Embeds on slash commands discord.py
I want an embed with a picture on the link to come out of command, but it gives an error, what can I do about it?我想在链接上嵌入一张图片以使其失控,但它给出了一个错误,我该怎么办?
import discord, asyncio, json, requests, time, datetime, files, random,os
from discord.ext import commands, tasks
from discord_components import Button, ButtonStyle, DiscordComponents, SelectOption, Select
import interactions
bot = interactions.Client("")
@bot.event
async def on_ready():
print("Ready!")
@bot.command(name="example",description="example description",)
async def example(ctx: interactions.CommandContext):
response = requests.get('some url')
json_data = response.json()
url = json_data['url']
embed = discord.Embed(color = 0xff9900, title = '')
embed.set_image(url='url')
await ctx.send(embed = embed)
bot.start()
Error:错误:
payload = await super().send(content, **kwargs)
TypeError: _Context.send() got an unexpected keyword argument 'embed'
how i can fix that?我该如何解决?
for embeds, you have to follow the format: embedVar = discord.Embed(title="Title", description="Desc", color=0x00ff00).对于嵌入,您必须遵循以下格式:embedVar = discord.Embed(title="Title", description="Desc", color=0x00ff00)。 Also, discord_components is discontinued, you should use interactions.py.此外,discord_components 已停用,您应该使用 interaction.py。 Here is the url for the sample code they provide.这是他们提供的示例代码的 url。 Its essentially the same as discord_components: https://github.com/interactions-py/library/blob/stable/examples/bot.py它与 discord_components 基本相同: https ://github.com/interactions-py/library/blob/stable/examples/bot.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.