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

Add new cog: Croissants screengrab #5

Merged
merged 3 commits into from
Feb 9, 2022
Merged

Add new cog: Croissants screengrab #5

merged 3 commits into from
Feb 9, 2022

Conversation

leo-chartier
Copy link
Contributor

Add a cog to automatically save a message by creating a "screenshot" of it if it matches a certain regex.

@PaulMarisOUMary
Copy link
Owner

Tested with :
python: 3.10.0
discord.py: 2.0.0a

Please update your PR with the following changes, using discord 2.0.0a (install the devellopement version here) and with python 3.10.0 or higher.

Errors :

- 2.0.0a Member attribute error

Ignoring exception in on_message
Traceback (most recent call last):
  File "\Python\Python310\lib\site-packages\discord\client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "\Desktop\Algosup-Discord\cogs\croissants.py", line 32, in on_receive_message
    file=self.__get_screenshot(author, message)
  File "\Desktop\Algosup-Discord\cogs\croissants.py", line 55, in __get_screenshot
    pfp = Image.open(BytesIO(requests.get(author.avatar_url).content))
AttributeError: 'Member' object has no attribute 'avatar_url'

changes : Solved
\cogs\croissants.py line 55

pfp = Image.open(io.BytesIO(requests.get(author.display_avatar.url).content)) # Since version 2 of discord.py avatar_url is deprecated, use display_avatar.url instead

- Message type is not iterable

Ignoring exception in on_message
Traceback (most recent call last):
  File "\Python\Python310\lib\site-packages\discord\client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "\Desktop\Algosup-Discord\cogs\croissants.py", line 32, in on_receive_message
    file=self.__get_screenshot(author, message)
  File "\Desktop\Algosup-Discord\cogs\croissants.py", line 66, in __get_screenshot
    draw.text((99, 48), content, content_color, content_font)
  File "\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 393, in text
    if self._multiline_check(text):
  File "\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 368, in _multiline_check
    return split_character in text
TypeError: argument of type 'Message' is not iterable

changes : Solved
\cogs\croissants.py line 66

draw.text((99, 48), str(content), content_color, content_font) # Cast Message in string

- Image File is empty

image
Unsolved

@PaulMarisOUMary PaulMarisOUMary added feature request A feature request invalid This doesn't seem right request change Some change are required to proceed and removed invalid This doesn't seem right labels Jan 31, 2022
leo-chartier and others added 2 commits February 3, 2022 18:40
Fixed all three errors

Improvements:
- Replying to the original message
- Using the username color
- Resizing profile picture later for better resolution
Need to fix : Emojis in image
@PaulMarisOUMary PaulMarisOUMary removed the request change Some change are required to proceed label Feb 9, 2022
@PaulMarisOUMary PaulMarisOUMary merged commit 51e863c into PaulMarisOUMary:main Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants