Closed anishanne closed 5 years ago
@anishanne Just to confirm, the only issue is that the example doesn't subclass from commands.Cog?
1.1.0 has some minor fixes for non-breaking stuff that changes in d.py and also has updated cog examples in the README and tests.
I fixed that myself and the code still didn't update stuff for discordbots.group
...
This code however did work.
from discord.ext import commands
from discord.ext.commands import Context
import requests
import json
import asyncio
class DiscordGroup(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.auth="token"
self.bg_task = self.bot.loop.create_task(self.post_guild_count())
async def post_guild_count(self):
while True:
url = F"https://api.discordbots.group/v1/bot/{self.bot.user.id}"
payload = {"server_count":len(self.bot.guilds)}
headers = {"Authorization":self.auth,
"Content-Type":'application/json'}
r = requests.post(url, data=json.dumps(payload), headers=headers)
await asyncio.sleep(1800)
def setup(bot):
bot.add_cog(DiscordGroup(bot))
Your code has some really bad practices within it. I cannot reproduce your issue with DBG, I suggest checking the return data from manually posting your count with discordlists as this will reveal any issue you are having.
The code doesn't align up with the latest d.py docs.
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html