0
小さなコミュニティのためにdiscordボットを使用し、特定のゲームにオンラインプレーヤーの数を表示しようとしています。私にここで使っているコードは大丈夫だと思われますが、これは私が初めて掻き集めることです。間違ったキーワードを探すよう求めているかもしれません。モジュールはエラーなしで正常にロードされますが、トリガを入力して情報を表示すると何も起こりません。誰も私に私が見逃しているかもしれ小麦や間違った入力自分自身ここでこのページから削り取ろうとしたときに出力がありません
を指摘することができ、コードです:
import discord
from discord.ext import commands
try: # check if BeautifulSoup4 is installed
from bs4 import BeautifulSoup
soupAvailable = True
except:
soupAvailable = False
import aiohttp
class bf1online:
"""My custom cog that does stuff!"""
def __init__(self, bot):
self.bot = bot
"""This does stuff!"""
#Your code will go here
@commands.command()
async def bf1(self):
"""How many players are online atm?"""
#Your code will go here
url = "http://bf1stats.com/" #build the web adress
async with aiohttp.get(url) as response:
soupObject = BeautifulSoup(await response.text(), "html.parser")
try:
online = soupObject.find(id_='online_section').find('h2').find('p').find('b').get_text()
await self.bot.say(online + ' players are playing this game at the moment')
except:
await self.bot.say("Couldn't load amount of players. No one is playing this game anymore or there's an error.")
def setup(bot):
bot.add_cog(bf1online(bot))
画像をポストする代わりにテキストにテキストをコピーして貼り付けてください。 – jwodder
完了しましたが、それはいくつかのそれを壊しました。 –