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

[Admin] add a simple [p]editrole icon command #6177

Open
wants to merge 3 commits into
base: V3/develop
Choose a base branch
from

Conversation

japandotorg
Copy link
Contributor

Description of the changes

Adds a simple [p]role icon command as suggested in the #feature-ideas channel

The approach might not be well thought right now, but I'm open to suggestions on how to improve it, etc etc.

Have the changes in this PR been tested?

No

@github-actions github-actions bot added the Category: Cogs - Admin This is related to the Admin cog. label May 25, 2023
@Flame442 Flame442 changed the title [Admin] add a simple [p]role icon command [Admin] add a simple [p]editrole icon command Nov 6, 2023
Comment on lines +367 to +374
elif isinstance(icon, str) and icon.startswith("http"):
try:
async with aiohttp.ClientSession() as session:
async with session.get(url=icon, raise_for_status=True) as response:
image = await response.read()
except aiohttp.ClientResponseError as error:
await ctx.send(_("Invalid url provided: {}").format(error.message))
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should follow similar logic as [p]set bot avatar follows for processing the str link input, namely filtering out <link> syntax and being slightly more verbose as to what exception the get raised.

elif url is not None:
if url.startswith("<") and url.endswith(">"):
url = url[1:-1]
async with aiohttp.ClientSession() as session:
try:
async with session.get(url) as r:
data = await r.read()
except aiohttp.InvalidURL:
return await ctx.send(_("That URL is invalid."))
except aiohttp.ClientError:
return await ctx.send(_("Something went wrong while trying to get the image."))

@Flame442 Flame442 self-assigned this Nov 6, 2023
@Flame442 Flame442 added Type: Feature New feature or request. QA: Changes Requested Used by few QA members. Awaiting changes requested by maintainers or QA. labels Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Cogs - Admin This is related to the Admin cog. QA: Changes Requested Used by few QA members. Awaiting changes requested by maintainers or QA. Type: Feature New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants