例如。

用户发送命令/findsomething [某种:]其中"something"是强制性的

然后,"something"变量中的值存储在变量中,并在HTTP请求的链接中使用

响应在嵌入式中迭代,并将嵌入发送给发送请求的用户,并附有所有信息

我该如何实现?哪些模块以及如何解决这个问题?

香港专业教育学院在互联网上看,找不到有助于解决这个问题的任何东西

谢谢

分析解答

您可以使用aiohttp模块来实现这一目标。

假设您已经创建了基本机器人和命令函数,则首先需要deferInteraction.response.defer的互动,使用aiohttp模块制作请求,然后使用Interaction.followup.send响应用户。

这是您可以制作命令的方式:

from discord import app_commands
import aiohttp

tree = app_commands.CommandTree(client)

@tree.command(name="yourcommandname")
async def the_command(interaction, something):
    await interaction.response.defer()

    async with aiohttp.ClientSession() as session:
        async with session.get("https://yourwebsite.com/" + something) as response: # change that to how your website works
            html = await response.text()
    
    await interaction.followup.send(content=discord.Embed(description=html))