【问题标题】:Problem Getting an input from user in Discord.py在 Discord.py 中获取用户输入的问题
【发布时间】:2020-09-24 09:01:11
【问题描述】:

我应该如何在 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 & 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)

【问题讨论】:

    标签: python discord.py discord.py-rewrite


    【解决方案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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-18
      • 2019-09-10
      • 2018-06-09
      • 2020-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多