Top-gg-Community / python-sdk

A simple API wrapper for top.gg written in Python
https://docs.top.gg/docs/Libraries/python
MIT License
90 stars 54 forks source link

Event functions not working #37

Closed Samarth-Nasnodkar closed 3 years ago

Samarth-Nasnodkar commented 3 years ago

I tried using the events in dblpy like on_dbl_vote() but they do not seem to work. I am using python 3.8.5, which is supported according to the documentation. The posting of the guild count works without any issue. Please look into this. `class TopGG(commands.Cog):

def __init__(self, bot):
    self.bot = bot
    self.token = os.environ.get('dbl_token')
    self.dblpy = dbl.DBLClient(self.bot, self.token)
    self.update_stats.start()

def cog_unload(self):
    self.update_stats.cancel()

@tasks.loop(minutes=30)
async def update_stats(self):
    await self.bot.wait_until_ready()
    try:
        server_count = len(self.bot.guilds)
        await self.dblpy.post_guild_count(server_count)
        print('Posted server count ({})'.format(server_count))
    except Exception as e:
        print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

@commands.Cog.listener()
async def on_dbl_vote(self , data):
            print("Bot received a vote!")
    user_id = int(data['user'])
    user = self.client.get_user(user_id)
    channel = self.client.get_channel(785782444594036747)
    await channel.send(f'{user.name} Just voted Among Us bot.')

def setup(bot): bot.add_cog(TopGG(bot))`

Esmeray6 commented 3 years ago

Make sure you are entering correct URL to your webserver on top.gg website with the authorization key. The appropriate URL format is http://serverip:webhook_port/webhook_path, where serverip is your server's IP.

Also make sure that your machine does not have any firewall that happens to be blocking top.gg requests on specified port. Port forwarding may be necessary if you are attempting to receive votes on your local machine.

Esmeray6 commented 3 years ago

Closing this issue, as I assume that the issue has been resolved.