Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG IN SETAVATAR #1678

Closed
5 of 8 tasks
OzzyHelix opened this issue Aug 1, 2018 · 23 comments
Closed
5 of 8 tasks

BUG IN SETAVATAR #1678

OzzyHelix opened this issue Aug 1, 2018 · 23 comments

Comments

@OzzyHelix
Copy link

OzzyHelix commented Aug 1, 2018

Please tick all applicable boxes.

  • I am using Python 3.5 or higher (run python --version on the command line)
  • I have followed the official guides to install the bot for my system
  • I have updated my dependencies to the latest version using the appropriate update script

Which version are you using?

  • The latest master version (1.9.7)
  • The latest review version

What type of issue are you creating?

  • Bug
  • Feature request
  • Question

Description of issue

a bug in the setavatar command
there was someone who's case was not reproducible
in particular module 'aiohttp' has no attribute 'Timeout'
in the setavatar command changing
this

        try:
            with aiohttp.Timeout(10):
                async with self.aiosession.get(thing) as res:
                    await self.user.edit(avatar=await res.read())

to this

        try:
            with async_timeout.timeout(10):
                async with self.aiosession.get(thing) as res:
                    await self.user.edit(avatar=await res.read())

will fix the problem
however it might not be a long term solution however it does make the link uploading work at the very least

Steps to reproduce

  1. attempting to change the avatar from a link
    note: uploading images as an avatar doesn't work because of this bug

Log file

Please attach your MusicBot log file (located at logs/musicbot.log) to this issue. You can do so by dragging and dropping the file here. If you do not include your log file, you WILL be asked to provide one.
musicbot.log

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

I didn't test your solution, however 5 seconds in the aiohttp documentation, I found this, and made

    try:  
        timeout = aiohttp.ClientTimeout(total=10)  
        async with aiohttp.ClientSession(timeout=timeout):  
            async with self.aiosession.get(thing) as res:  
                await self.user.edit(avatar=await res.read())

Although this works, it led to

168118999337402368/Aleana#2643: !setavatar
[ERROR:bot] Exception in on_message
Traceback (most recent call last):
File "/mnt/secondary/aleana/test/MusicBot/musicbot/bot.py", line 2726, in on_message
response = await handler(**handler_kwargs)
File "/mnt/secondary/aleana/test/MusicBot/musicbot/bot.py", line 137, in wrapper
return await func(self, *args, **kwargs)
File "/mnt/secondary/aleana/test/MusicBot/musicbot/bot.py", line 2445, in cmd_setavatar
thing = message.attachments[0]['url']
TypeError: 'Attachment' object is not subscriptable

Once I work out the kinks with set avatar here, I'll make a PR to solve this issue.

edit: formatting is hard pepehands

@AutumnClove
Copy link
Member

See the above PR @OzoneHelix

@OzzyHelix
Copy link
Author

@AutumnClove thank you

@OzzyHelix
Copy link
Author

what I discover was a partial fix it fixed links but not uploading an image

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

I tested your solution and got this result in VSC before even starting the bot

Undefined variable 'async_timeout'

@OzzyHelix
Copy link
Author

OzzyHelix commented Aug 1, 2018

its odd because when I tried your solution it was looking in init.py for it which makes no sense

@OzzyHelix
Copy link
Author

darn github's formatting

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

Error given when trying my solution?

@OzzyHelix
Copy link
Author

Unable to change avatar: module 'aiohttp' has no attribute 'ClientTimeout'

@OzzyHelix
Copy link
Author

its really weird

@OzzyHelix
Copy link
Author

I should probably say I'm using Pycham and not VSC

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

If you update your dependencies for review, you'll most likely solve that error. The current requirements.txt for d.py rewrite requires aiohttp>=3.3.0,<3.4.0 which has ClientTimeout

@OzzyHelix
Copy link
Author

so I should add aiohttp to requirements.txt

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

No, d.py rewrite already requires it, and as such, doesn't need to be added to the requirements file.

@OzzyHelix
Copy link
Author

No matching distribution found for aiohttp<3.4.0,>=3.3.0 (from -r requirements.txt)
this happens when trying to update

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

This is a current issue that will eventually be fixed. I've found that using Python 3.6 solves this issue, however it should be noted that 3.6 can cause issues on Windows.

@OzzyHelix
Copy link
Author

its odd because I'm trying to update on python 3.5 but I have python3.6 and python3.5 installed on my windows machine

@OzzyHelix
Copy link
Author

wait correction I have python 3.5.2 installed

@OzzyHelix
Copy link
Author

ok after installing python 3.6.6 your solution works completely my solution half worked so this is much better

@OzzyHelix
Copy link
Author

I removed python 3.5.2 and now using python 3.6.6 the setavatar command works completely

@OzzyHelix
Copy link
Author

travis also seemed to have failed when trying to use python3.5

@AleanaA
Copy link
Member

AleanaA commented Aug 1, 2018

That's a known issue.

@OzzyHelix
Copy link
Author

well lets hope it will be resolved in the future

@MattBSG MattBSG closed this as completed Aug 2, 2018
@Just-Some-Bots Just-Some-Bots locked and limited conversation to collaborators Feb 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants