在 Discord.py 中从用户获取输入时出现问题
Problem Getting an input from user in Discord.py
嘿嘿
我应该如何在 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)
您可以使用 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")
嘿嘿 我应该如何在 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)
您可以使用 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")