Estoy intentando añadir una función de introducción a mi bot discord.py. Así es como quiero que funcione:
Alguien envía ".intro", y el bot comienza a hacer un montón de preguntas personales al usuario. Una vez que éste responde a todas las preguntas, el bot crea un embed que almacena todas esas respuestas, y envía el embed a un canal llamado "intro". Y entonces, cuando alguien quiere encontrar la intro de un usuario en particular, hace ".whois @usuario", lo que le dice al bot que encuentre la intro creada por el usuario mencionado, para que el bot pueda enviarla de vuelta. Cuando alguien ya ha hecho su introducción y quiere editarla, hace ".intro" una vez más, e introduce las respuestas requeridas, y el bot edita su introducción en el canal "intro".
Soy muy nuevo en la codificación, y no tengo ni idea de cómo implementar esto. He escrito el código para hacer la incrustación de la introducción requerida, pero no tengo ni idea de cómo almacenar las respuestas de diferentes personas en diferentes incrustaciones. Cualquier ayuda será muy apreciada. Gracias.
Este es mi engranaje de introducción:
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))