kyb3r / dhooks

A simple python Discord webhook API wrapper

Home Page:https://discord.gg/etJNHCQ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: 'Webhook' object has no attribute 'bytes_to_base64_data'

lyricalpaws opened this issue · comments

The code:

    async def on_guild_remove(self, guild):
        if guild.icon_url is "":
            guildicon = "https://cdn.discordapp.com/attachments/443347566231289856/513380120451350541/2mt196.jpg"
        else:
            guildicon = guild.icon_url
        findbots = sum(1 for member in guild.members if member.bot)
        findusers = sum(1 for member in guild.members if not member.bot)
        webhook = Webhook(self.config.guildleavewebhook, is_async=True)
        embed = dhooks.Embed(description=f'I\'ve left {guild.name}...', color=5810826, timestamp=True)
        embed.set_author(name=f'{guild.name}', url='https://discordapp.com/oauth2/authorize?client_id=460383314973556756&scope=bot&permissions=469888118', icon_url=guildicon)
        embed.set_thumbnail(url=guildicon)
        embed.add_field(name='Info', value=f'New guild count: **{len(self.bot.guilds)}**\nOwner: **{guild.owner}**\nUsers/Bot Ratio: **{findusers}/{findbots}**')
        await webhook.modify(name=guild.name, avatar=guildicon)
        await webhook.execute(embeds=embed)
        await webhook.close()

The full error:

Traceback (most recent call last):
  File "C:\Users\Paws\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 225, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Paws\Desktop\Pawbot\cogs\events.py", line 84, in on_guild_join
    await webhook.modify(name=guild.name, avatar=guildicon)
  File "C:\Users\Paws\AppData\Local\Programs\Python\Python37-32\lib\site-packages\dhooks\client.py", line 153, in modify
    payload['avatar'] = self.bytes_to_base64_data(avatar)
AttributeError: 'Webhook' object has no attribute 'bytes_to_base64_data'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0497DAF0>

This was a bug in the library, its fixed now! pip3 install -U dhooks