Discord bot仅读取字符串的第一个单词,而不读取整个字符串

时间:2018-07-16 22:40:33

标签: python arguments discord.py

所以我有以下python代码:

@bot.command(pass_context=True, no_pm=True)
async def charts(ctx,arg):

    url = 'https://api.steampowered.com/ISteamApps/GetAppList/v2/'
    url_total = 'https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/?appid='
    response = requests.get(url)
    data_url = response.text
    parsed = json.loads(data_url)

    for game in parsed['applist']['apps']:
        if game['name'] == arg:
            url_total = 'https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/?appid='+str(game['appid'])
            response_playing = requests.get(url_total)
            data_playing = response_playing.text
            parsed_playing = json.loads(data_playing)
            url_steamcharts = 'https://steamcharts.com/app/' +str(game['appid'])
    await bot.reply('Aantal spelers: '+ str(parsed_playing['response']['player_count']) + ' Voor meer info: ' + url_steamcharts )    

我使用此代码从Discord机器人获取有关特定时刻正在玩游戏的玩家总数的信息。所以这段代码可以工作一半。我会给你两个例子,以及我从机器人那里得到的结果:

示例:

$ charts反恐精英 命令的结果不一致: Aantal spelers:15723等级信息:https://steamcharts.com/app/10

$ chart反恐精英全球攻势 命令的结果不一致: Aantal spelers:15723等级信息:https://steamcharts.com/app/10

因此,您可以看到结果保持不变,因此漫游器仅读取第一个单词,而不读取整个字符串。我尝试了一些方法,但到目前为止我仍无法解决。如何获得我在Discord中输入的整个字符串?

0 个答案:

没有答案