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

feat: allow editing for guild role icons #1558

Merged
merged 13 commits into from
Oct 5, 2023
Merged
Empty file modified interactions/client/utils/misc_utils.py
100644 → 100755
Empty file.
15 changes: 13 additions & 2 deletions interactions/models/discord/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from typing import Any, TYPE_CHECKING

import attrs

from interactions.client.const import MISSING, T, Missing
from interactions.client.utils import nulled_boolean_get
from interactions.client.utils.attr_converters import optional as optional_c
from interactions.client.utils.serializer import dict_filter
from interactions.client.utils.serializer import dict_filter, to_image_data
from interactions.models.discord.asset import Asset
from interactions.models.discord.file import UPLOADABLE_TYPE
from interactions.models.discord.color import COLOR_TYPES, Color, process_color
from interactions.models.discord.emoji import PartialEmoji
from interactions.models.discord.enums import Permissions
Expand Down Expand Up @@ -187,6 +187,8 @@ async def edit(
color: Color | COLOR_TYPES | None = None,
hoist: bool | None = None,
mentionable: bool | None = None,
icon: bytes | UPLOADABLE_TYPE | None = None,
unicode_emoji: str | None = None,
) -> "Role":
"""
Edit this role, all arguments are optional.
Expand All @@ -197,20 +199,29 @@ async def edit(
color: The color of the role
hoist: whether the role should be displayed separately in the sidebar
mentionable: whether the role should be mentionable
icon: (Guild Level 2+) Bytes-like object representing the icon; supports PNG, JPEG and WebP
unicode_emoji: (Guild Level 2+) Unicode emoji for the role; can't be used with icon

Returns:
Role with updated information

"""
color = process_color(color)

if icon and unicode_emoji:
raise ValueError("Cannot pass both icon and unicode_emoji")
if icon:
icon = to_image_data(icon)

payload = dict_filter(
{
"name": name,
"permissions": permissions,
"color": color,
"hoist": hoist,
"mentionable": mentionable,
"icon": icon,
"unicode_emoji": unicode_emoji,
}
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "interactions.py"
version = "5.9.2"
version = "5.10.0"
description = "Easy, simple, scalable and modular: a Python API wrapper for interactions."
authors = [
"LordOfPolls <dev@lordofpolls.com>",
Expand Down