discordpy:如何将用户输入存储到变量中?

discordpy:如何将用户输入存储到变量中?,discord,discord.py,Discord,Discord.py,我目前正在为我的discord服务器创建一个简单的登录系统,我试图找到一种方法将用户输入存储到变量中,并将其用于数据库。我目前需要[https://steamcommunity.com/id/]在变量中 async def on_message(message): if message.content.startswith('!login'): channel = message.channel embed = discord.Embed(color=di

我目前正在为我的discord服务器创建一个简单的登录系统,我试图找到一种方法将用户输入存储到变量中,并将其用于数据库。我目前需要[https://steamcommunity.com/id/]在变量中

async def on_message(message):
    if message.content.startswith('!login'):
        channel = message.channel
        embed = discord.Embed(color=discord.Color.red())
        embed.set_author(name='{0.user}'.format(client), icon_url='https://scontent.fsyd1-1.fna.fbcdn.net/v/t1.15752-9/119154591_373692013645493_2520568812144261390_n.png?_nc_cat=100&ccb=2&_nc_sid=ae9488&_nc_ohc=qee8e9Q3a0sAX9_z2Nj&_nc_ht=scontent.fsyd1-1.fna&oh=ffeafaaa09f2bb802afce08030c41f08&oe=60394D0B')
        embed.add_field(name='WELCOME TO LINKED.GG', value='Looking forward to seeing you in queue!', inline=False)
        embed.add_field(name='Link your STEAM account to the bot:',
                        value='Reply to this bots message: \n `!login <steam profile url>`', inline=False)
        embed.add_field(name='Please read over the rules:',
                        value='<#804911670698442815>', inline=False)
        embed.add_field(name='Join our discord server', value='[Click to join discord](https://discord.gg/2dKCUAzceN)', inline=True)
        await channel.send(embed=embed)

        def check(m):
            return m.content.startswith('https://steamcommunity.com/id/') and m.channel == channel

        msg = await client.wait_for('message', check=check)
        print(msg)
        await channel.send('Connected {.author}!'.format(msg))
    await client.process_commands(message)```
@client.command()
async def login(ctx, *, username=None):
    if username == None:
        await ctx.send(f'{ctx.author.mention}, please enter your username to log in!')
        return
    await ctx.send(f'Logged in as {username}! Welcome back.')
async def on_消息(消息):
如果message.content.startswith(“!login”):
channel=message.channel
嵌入=discord.embed(color=discord.color.red())
embed.set_author(name={0.user}.format(client),icon_url=https://scontent.fsyd1-1.fna.fbcdn.net/v/t1.15752-9/119154591_373692013645493_2520568812144261390_n.png?_nc_cat=100&ccb=2&_nc_sid=ae9488&_nc_ohc=qee8e9Q3a0sAX9_z2Nj&_nc_ht=scontent.fsyd1-1.fna&oh=FFEAAAA09F2BB802AFCE8030C41F08&oe=60394D0B')
embed.add_字段(name='WELCOME TO LINKED.GG',value='Looking TO you in queue!',inline=False)
embed.add_字段(name='Link your STEAM account to the bot:',
value='Reply to this bots message:\n`!login`',inline=False)
embed.add_字段(name=”请仔细阅读规则:',
值=“”,内联=假)
embed.add_字段(name='Join our discord server',value='[单击以加入discord](https://discord.gg/2dKCUAzceN),inline=True)
等待通道发送(嵌入=嵌入)
def检查(m):
返回m.content.startswith('https://steamcommunity.com/id/“)和m.channel==通道
msg=wait client.wait_for('message',check=check)
打印(msg)
等待channel.send('Connected{.author}!'.format(msg))
等待客户端处理命令(消息)```

最好在消息上使用命令而不是
然后您可以使用logging命令传递参数。我会让你来整理你的数据库,并搜索是否已经创建了帐户

下面是一个通过命令传递“username”参数的简单示例,用户名将存储在
username
变量中

async def on_message(message):
    if message.content.startswith('!login'):
        channel = message.channel
        embed = discord.Embed(color=discord.Color.red())
        embed.set_author(name='{0.user}'.format(client), icon_url='https://scontent.fsyd1-1.fna.fbcdn.net/v/t1.15752-9/119154591_373692013645493_2520568812144261390_n.png?_nc_cat=100&ccb=2&_nc_sid=ae9488&_nc_ohc=qee8e9Q3a0sAX9_z2Nj&_nc_ht=scontent.fsyd1-1.fna&oh=ffeafaaa09f2bb802afce08030c41f08&oe=60394D0B')
        embed.add_field(name='WELCOME TO LINKED.GG', value='Looking forward to seeing you in queue!', inline=False)
        embed.add_field(name='Link your STEAM account to the bot:',
                        value='Reply to this bots message: \n `!login <steam profile url>`', inline=False)
        embed.add_field(name='Please read over the rules:',
                        value='<#804911670698442815>', inline=False)
        embed.add_field(name='Join our discord server', value='[Click to join discord](https://discord.gg/2dKCUAzceN)', inline=True)
        await channel.send(embed=embed)

        def check(m):
            return m.content.startswith('https://steamcommunity.com/id/') and m.channel == channel

        msg = await client.wait_for('message', check=check)
        print(msg)
        await channel.send('Connected {.author}!'.format(msg))
    await client.process_commands(message)```
@client.command()
async def login(ctx, *, username=None):
    if username == None:
        await ctx.send(f'{ctx.author.mention}, please enter your username to log in!')
        return
    await ctx.send(f'Logged in as {username}! Welcome back.')

避免在函数中嵌入函数。您应该能够根据代码回答自己的问题。要为变量名赋值,
test=some\u expression