Python 如何在我的discord.py机器人中创建一个有效的介绍功能?

Python 如何在我的discord.py机器人中创建一个有效的介绍功能?,python,discord,bots,discord.py,discord.py-rewrite,Python,Discord,Bots,Discord.py,Discord.py Rewrite,我正在尝试向我的discord.py机器人添加一个介绍功能。这就是我希望它工作的方式: 有人发送“.intro”,机器人开始向用户询问一大堆个人问题。一旦他们回答了所有的问题,机器人就会制作一个嵌入程序,将所有答案存储在其中,并将嵌入程序发送到一个名为“intro”的频道。然后,当有人想要找到某个特定用户的介绍时,他们会执行“.whois@user”,这会告诉bot找到由所述用户创建的介绍,以便bot可以将其发回。当有人已经做了介绍并想要编辑它时,他们会再次做“.intro”,然后输入所需的答案

我正在尝试向我的discord.py机器人添加一个介绍功能。这就是我希望它工作的方式:

有人发送“.intro”,机器人开始向用户询问一大堆个人问题。一旦他们回答了所有的问题,机器人就会制作一个嵌入程序,将所有答案存储在其中,并将嵌入程序发送到一个名为“intro”的频道。然后,当有人想要找到某个特定用户的介绍时,他们会执行“.whois@user”,这会告诉bot找到由所述用户创建的介绍,以便bot可以将其发回。当有人已经做了介绍并想要编辑它时,他们会再次做“.intro”,然后输入所需的答案,机器人会在“intro”频道中编辑他们的介绍

我对编码非常陌生,我不知道如何实现这一点。我已经编写了制作所需简介嵌入的代码,但是我不知道如何在不同的嵌入中存储不同的人的答案。任何帮助都将不胜感激!多谢各位

这是我的简介:

import discord
from discord.ext import commands
import asyncio


class IntroSystem(commands.Cog):

    def __init__(self, client):
        self.client = client

    @commands.command()
    async def intro(self, ctx):
        global name, location, age, gender, hobbies
        await ctx.send("What's your name?")

        try:
            name = await self.client.wait_for(
                "message",
                timeout=20,
                check=lambda message: message.author == ctx.author
                                      and message.channel == ctx.channel
            )
        except asyncio.TimeoutError:
            await ctx.send('Timeout! Restart by saying `.intro`')
            return

        await ctx.send("Where do you live?")

        try:
            location = await self.client.wait_for(
                "message",
                timeout=20,
                check=lambda message: message.author == ctx.author
                                      and message.channel == ctx.channel
            )
        except asyncio.TimeoutError:
            await ctx.send('Timeout! Restart by saying `.intro`')
            return

        await ctx.send("How old are you?")

        try:
            age = await self.client.wait_for(
                "message",
                timeout=20,
                check=lambda message: message.author == ctx.author
                                      and message.channel == ctx.channel
            )
        except asyncio.TimeoutError:
            await ctx.send('Timeout! Restart by saying `.intro`')
            return

        await ctx.send("What's your gender? `Male, Female or Non Binary`")

        try:
            gender = await self.client.wait_for(
                "message",
                timeout=20,
                check=lambda message: message.author == ctx.author
                                      and message.channel == ctx.channel
            )
        except asyncio.TimeoutError:
            await ctx.send('Timeout! Restart by saying `.intro`')
            return

        await ctx.send("What are your hobbies or interests?")

        try:
            hobbies = await self.client.wait_for(
                "message",
                timeout=60,
                check=lambda message: message.author == ctx.author
                                      and message.channel == ctx.channel
            )
        except asyncio.TimeoutError:
            await ctx.send('Timeout! Restart by saying `.intro`')
            return

        embed = discord.Embed(
            title='',
            description='',
            colour=discord.Color.blue()
        )
        embed.set_thumbnail(url=ctx.message.author.avatar_url)
        embed.set_author(name=ctx.message.author, url=ctx.message.author.avatar_url)
        embed.add_field(name="Name", value=name.content, inline=True)
        embed.add_field(name="Location", value=location.content, inline=True)
        embed.add_field(name="Age", value=age.content, inline=True)
        embed.add_field(name="Gender", value=gender.content, inline=False)
        embed.add_field(name="Hobbies", value=hobbies.content, inline=False)

        await ctx.send(embed=embed)


def setup(client):
    client.add_cog(IntroSystem(client))
Messageable.send()
返回它发送的消息的
discord.Message
实例,因此您可以使用该实例将消息与消息所属的一起存储在
数据库中

这样,您可以轻松地检查某人是否在那里(->检查用户的
id
是否在数据库中),获取他们的消息(使用,在数据库中查找属于给定用户id的消息),并允许用户在获取消息后使用编辑消息

当有人使用
.whois
时,您只需向他们发送,将他们带到相应的消息


这应该是一个足够的解释,让你去。我不只是给你做这件事的代码。

我也很新,但我认为你可以用用户的名字创建一个文件,把信息放在那里,然后每次有人这样做。whois@user”它会在你的文件中插入用户并说出信息。
你可以试试看,我想这样行得通

对不起,我该如何创建数据库呢?介绍频道可以是数据库吗,还是我必须学习MySQL或其他东西才能制作?抱歉问了太多问题。频道不是数据库。。。是的,我指的是SQL数据库。可以使用SQL,也可以使用JSON文件,但要注意JSON并不是专门用于此目的的。你可以在互联网上找到这两个网站的基本例子。