botblock / discordlists.py

A simple API wrapper for botblock.org providing server count posting to all bot lists and fetching bot information from all. [Python - maintained by @MattIPv4]
https://botblock.org/api/docs
MIT License
8 stars 2 forks source link

Code is outdated. #2

Closed anishanne closed 5 years ago

anishanne commented 5 years ago

The code doesn't align up with the latest d.py docs.

https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html

MattIPv4 commented 5 years ago

@anishanne Just to confirm, the only issue is that the example doesn't subclass from commands.Cog?

MattIPv4 commented 5 years ago

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.

anishanne commented 5 years ago

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))
MattIPv4 commented 5 years ago

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.