【问题标题】:Need assistance with discord bot需要不和谐机器人的帮助
【发布时间】:2018-11-29 16:16:39
【问题描述】:

我想要实现的是当用户输入命令 !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)

【问题讨论】:

标签: python discord discord.py


【解决方案1】:

您可以使用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")

【讨论】:

    猜你喜欢
    • 2021-01-16
    • 2021-07-20
    • 1970-01-01
    • 2021-07-03
    • 2018-04-29
    • 1970-01-01
    • 2021-07-26
    • 2018-03-20
    • 2017-06-18
    相关资源
    最近更新 更多