Проблема с получением входных данных от пользователя в Discord.py

#python #discord.py #discord.py-rewrite

#питон #discord.py #python

Вопрос:

Привет, как я должен вводить строку от пользователя в Discord.py . Я получаю ошибки при попытке получить входные данные от пользователя. Было бы здорово, если бы кто-нибудь мог мне помочь 🙂

 import discord
from discord import embeds
from discord.ext.commands import Bot
from discord.ext import commands
import time

client = discord.Client()
embed = discord.Embed()
bot = commands.Bot(command_prefix='.')




@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('.gdrive'):
        first_embed = discord.Embed(title="Unlimited Google Drive Storage", color=0x2bff00)
        new_embed = discord.Embed(title='Made by zSupremeSniper0 amp; toxicXvoid', color=0x2bff00)
        new_embed2 = discord.Embed(title='Please Enter your gmail', color=0x2bff00)
       

# send a first message with an embed
        msg = await message.channel.send(embed=first_embed)

# edit the embed of the message
        time.sleep(5)
        await msg.edit(embed=new_embed)
        time.sleep(5)
        await msg.edit(embed=new_embed2)  

Ответ №1:

Вы можете использовать Client.wait_for для ожидания пользовательского ввода:

 # edit the embed of the message
        time.sleep(5)
        await msg.edit(embed=new_embed)
        time.sleep(5)
        await msg.edit(embed=new_embed2)

        def check(m):
          return m.channel == message.channel

        msg = await client.wait_for('message', check=check)
        await message.channel.send("OK")