【问题标题】:Discord.py Bot make op.ggDiscord.py 机器人制作 op.gg
【发布时间】:2022-01-16 02:04:12
【问题描述】:

所以我试图制作一个机器人,当我输入 !opgg 时,它会询问“请给我 5 个召唤师姓名 :)”,然后当有人输入 5 个名字时,它会将它们拆分并添加到末尾https://oce.op.gg/multi/query= 在末尾添加“,”,我想要它,所以我必须输入一个名称然后发送,然后它会要求另一个名称。

这是我目前的代码

import discord
import config

from discord.ext import commands

bot = commands.Bot(command_prefix=config.PREFIX)

@bot.event
async def on_ready():
    print("-----")
    print("Bot is online!")
    print("-----")

@bot.command()
async def opgg(ctx):
    await ctx.send("Please Give me 5 summoner names :)")


    

bot.run(config.TOKEN)

【问题讨论】:

标签: python discord discord.py bots


【解决方案1】:

就像@MattDMo 说的那样,您应该提供到目前为止您已经尝试过的内容并重写您的问题。你可以试试这样的

@bot.command()
async def opgg(ctx,*summonerNames):
    names = ', '.join(summonerNames)
    url = f'https://oce.op.gg/multi/query={names}'
    return await ctx.send(url)

现在你可以做!opgg "Hide on Bush" "PawN" "Uzi" "Trick2g" 如果您希望用户能够在名称中使用空格,则需要使用引号。

2021 年没有太空的世界冠军

!opgg Meiko Viper Scout Jiejie Flandre

请考虑自己学习如何为League of Legends 使用 Riot Games API,因为抓取 op.gg 并不可靠。您还可以使用其他库,例如 Riot-Watcher 或 cassiopeia

【讨论】:

    猜你喜欢
    • 2021-04-28
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    • 2021-10-07
    • 2021-03-29
    相关资源
    最近更新 更多