簡體   English   中英

斜線命令上的嵌入問題 discord.py

[英]Trouble with Embeds on slash commands discord.py

我想在鏈接上嵌入一張圖片以使其失控,但它給出了一個錯誤,我該怎么辦?

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()

錯誤:

payload = await super().send(content, **kwargs)
TypeError: _Context.send() got an unexpected keyword argument 'embed'

我該如何解決?

對於嵌入,您必須遵循以下格式:embedVar = discord.Embed(title="Title", description="Desc", color=0x00ff00)。 此外,discord_components 已停用,您應該使用 interaction.py。 這是他們提供的示例代碼的 url。 它與 discord_components 基本相同: https ://github.com/interactions-py/library/blob/stable/examples/bot.py

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM