需要Discord机器人的帮助

时间:2018-06-20 13:44:10

标签: python discord discord.py

我要实现的是,当用户输入命令!finduser和用户名时,例如,“!finduser user3”,我希望机器人发布网站网址,并在结尾添加“ / user3” https://ogusers.com/user3。我知道它令人困惑,但我真的不知道如何解释它。 这是当前代码。

if message.content.startswith('!finduser'):
    user = message.content.startswith ('')
    msg = 'https://ogusers.com' + '/' + user
    await client.send_message(message.channel, msg)

1 个答案:

答案 0 :(得分:0)

您可以使用discord.ext.commands扩展名来为您处理大部分命令解析。

from discord.ext import commands

bot = commands.Bot("!")

@bot.command(pass_context=True)
async def finduser(ctx, name):
    await bot.say("https://ogusers.com/{}".format(name))

bot.run("TOKEN")
相关问题