-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
base: V3/develop
Are you sure you want to change the base?
[Admin] add a simple [p]editrole icon
command
#6177
Conversation
[p]role icon
command[p]editrole icon
command
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 |
There was a problem hiding this comment.
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.
Red-DiscordBot/redbot/core/core_commands.py
Lines 2867 to 2878 in ca84cc9
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.")) |
Description of the changes
Adds a simple
[p]role icon
command as suggested in the #feature-ideas channelThe 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