fix: something with emojis ya

This commit is contained in:
grey-cat-1908 2022-06-30 22:29:10 +03:00
parent 17c16279b1
commit db4de62b4c
6 changed files with 230 additions and 229 deletions

View file

@ -21,39 +21,36 @@ import sys
import os import os
sys.path.append(os.path.abspath("../..")) sys.path.append(os.path.abspath("../.."))
sys.path.append(os.path.abspath('extensions')) sys.path.append(os.path.abspath("extensions"))
project = 'Melisa' project = "Melisa"
copyright = '2022, MelisaDev' copyright = "2022, MelisaDev"
author = 'MelisaDev' author = "MelisaDev"
# The full version, including alpha/beta/rc tags # The full version, including alpha/beta/rc tags
release = '0.0.1a' release = "0.0.1a"
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
extensions = [ extensions = [
'sphinx_design', "sphinx_design",
"sphinx.ext.napoleon", "sphinx.ext.napoleon",
"sphinx.ext.autodoc", "sphinx.ext.autodoc",
"sphinx.ext.viewcode", "sphinx.ext.viewcode",
"sphinx.ext.autosectionlabel", "sphinx.ext.autosectionlabel",
"sphinx.ext.extlinks", "sphinx.ext.extlinks",
"sphinxcontrib_trio", "sphinxcontrib_trio",
"attributable" "attributable",
] ]
autodoc_default_options = { autodoc_default_options = {"members": True, "show-inheritance": True}
'members': True,
'show-inheritance': True
}
autodoc_typehints = 'none' autodoc_typehints = "none"
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ["_templates"]
add_module_names = False add_module_names = False
@ -67,13 +64,13 @@ intersphinx_mapping = {
# -- Options for HTML output ------------------------------------------------- # -- Options for HTML output -------------------------------------------------
html_theme = 'furo' html_theme = "furo"
html_theme_options = { html_theme_options = {
"sidebar_hide_name": True, "sidebar_hide_name": True,
} }
pygments_style = 'monokai' pygments_style = "monokai"
default_dark_mode = True default_dark_mode = True
html_static_path = ['_static'] html_static_path = ["_static"]
html_css_files = ["custom.css"] html_css_files = ["custom.css"]
rst_prolog = """ rst_prolog = """

View file

@ -40,56 +40,50 @@ class attributetable_item(nodes.Part, nodes.Element):
def visit_attributetable_node(self, node): def visit_attributetable_node(self, node):
class_ = node["python-class"] class_ = node["python-class"]
self.body.append( self.body.append(f'<div class="py-attribute-table" data-move-to-id="{class_}">')
f'<div class="py-attribute-table" data-move-to-id="{class_}">'
)
def visit_attributetablecolumn_node(self, node): def visit_attributetablecolumn_node(self, node):
self.body.append(self.starttag( self.body.append(self.starttag(node, "div", CLASS="py-attribute-table-column"))
node, 'div', CLASS='py-attribute-table-column')
)
def visit_attributetabletitle_node(self, node): def visit_attributetabletitle_node(self, node):
self.body.append(self.starttag(node, 'span')) self.body.append(self.starttag(node, "span"))
def visit_attributetablebadge_node(self, node): def visit_attributetablebadge_node(self, node):
attributes = { attributes = {
'class': 'py-attribute-table-badge', "class": "py-attribute-table-badge",
'title': node['badge-type'], "title": node["badge-type"],
} }
self.body.append(self.starttag(node, 'span', **attributes)) self.body.append(self.starttag(node, "span", **attributes))
def visit_attributetable_item_node(self, node): def visit_attributetable_item_node(self, node):
self.body.append(self.starttag( self.body.append(self.starttag(node, "li", CLASS="py-attribute-table-entry"))
node, 'li', CLASS='py-attribute-table-entry')
)
def depart_attributetable_node(self, node): def depart_attributetable_node(self, node):
self.body.append('</div>') self.body.append("</div>")
def depart_attributetablecolumn_node(self, node): def depart_attributetablecolumn_node(self, node):
self.body.append('</div>') self.body.append("</div>")
def depart_attributetabletitle_node(self, node): def depart_attributetabletitle_node(self, node):
self.body.append('</span>') self.body.append("</span>")
def depart_attributetablebadge_node(self, node): def depart_attributetablebadge_node(self, node):
self.body.append('</span>') self.body.append("</span>")
def depart_attributetable_item_node(self, node): def depart_attributetable_item_node(self, node):
self.body.append('</li>') self.body.append("</li>")
_name_parser_regex = re.compile(r'(?P<module>[\w.]+\.)?(?P<name>\w+)') _name_parser_regex = re.compile(r"(?P<module>[\w.]+\.)?(?P<name>\w+)")
class PyAttributeTable(SphinxDirective): class PyAttributeTable(SphinxDirective):
@ -102,14 +96,15 @@ class PyAttributeTable(SphinxDirective):
def parse_name(self, content): def parse_name(self, content):
path, name = _name_parser_regex.match(content).groups() path, name = _name_parser_regex.match(content).groups()
if path: if path:
modulename = path.rstrip('.') modulename = path.rstrip(".")
else: else:
modulename = self.env.temp_data.get('autodoc:module') modulename = self.env.temp_data.get("autodoc:module")
if not modulename: if not modulename:
modulename = self.env.ref_context.get('py:module') modulename = self.env.ref_context.get("py:module")
if modulename is None: if modulename is None:
raise RuntimeError('modulename somehow None for %s in %s.' % ( raise RuntimeError(
content, self.env.docname)) "modulename somehow None for %s in %s." % (content, self.env.docname)
)
return modulename, name return modulename, name
@ -139,12 +134,12 @@ class PyAttributeTable(SphinxDirective):
replaced. replaced.
""" """
content = self.arguments[0].strip() content = self.arguments[0].strip()
node = attributetableplaceholder('') node = attributetableplaceholder("")
modulename, name = self.parse_name(content) modulename, name = self.parse_name(content)
node['python-doc'] = self.env.docname node["python-doc"] = self.env.docname
node['python-module'] = modulename node["python-module"] = modulename
node['python-class'] = name node["python-class"] = name
node['python-full-name'] = f'{modulename}.{name}' node["python-full-name"] = f"{modulename}.{name}"
return [node] return [node]
@ -152,17 +147,20 @@ def build_lookup_table(env):
# Given an environment, load up a lookup table of # Given an environment, load up a lookup table of
# full-class-name: objects # full-class-name: objects
result = {} result = {}
domain = env.domains['py'] domain = env.domains["py"]
ignored = { ignored = {
'data', 'exception', 'module', 'class', "data",
"exception",
"module",
"class",
} }
for (fullname, _, objtype, docname, _, _) in domain.get_objects(): for (fullname, _, objtype, docname, _, _) in domain.get_objects():
if objtype in ignored: if objtype in ignored:
continue continue
classname, _, child = fullname.rpartition('.') classname, _, child = fullname.rpartition(".")
try: try:
result[classname].append(child) result[classname].append(child)
except KeyError: except KeyError:
@ -171,7 +169,7 @@ def build_lookup_table(env):
return result return result
TableElement = namedtuple('TableElement', 'fullname label badge') TableElement = namedtuple("TableElement", "fullname label badge")
def process_attributetable(app, doctree, fromdocname): def process_attributetable(app, doctree, fromdocname):
@ -179,16 +177,21 @@ def process_attributetable(app, doctree, fromdocname):
lookup = build_lookup_table(env) lookup = build_lookup_table(env)
for node in doctree.traverse(attributetableplaceholder): for node in doctree.traverse(attributetableplaceholder):
modulename, classname, fullname = node['python-module'], node['python-class'], node['python-full-name'] modulename, classname, fullname = (
node["python-module"],
node["python-class"],
node["python-full-name"],
)
groups = get_class_results(lookup, modulename, classname, fullname) groups = get_class_results(lookup, modulename, classname, fullname)
table = attributetable('') table = attributetable("")
for label, subitems in groups.items(): for label, subitems in groups.items():
if not subitems: if not subitems:
continue continue
table.append(class_results_to_node( table.append(
label, sorted(subitems, key=lambda c: c.label))) class_results_to_node(label, sorted(subitems, key=lambda c: c.label))
)
table['python-class'] = fullname table["python-class"] = fullname
node.replace_self([table] if table else []) node.replace_self([table] if table else [])
@ -197,10 +200,12 @@ def get_class_results(lookup, modulename, name, fullname):
module = importlib.import_module(modulename) module = importlib.import_module(modulename)
cls = getattr(module, name) cls = getattr(module, name)
groups = OrderedDict([ groups = OrderedDict(
(_('Attributes'), []), [
(_('Methods'), []), (_("Attributes"), []),
]) (_("Methods"), []),
]
)
try: try:
members = lookup[fullname] members = lookup[fullname]
@ -208,8 +213,8 @@ def get_class_results(lookup, modulename, name, fullname):
return groups return groups
for attr in members: for attr in members:
attrlookup = f'{fullname}.{attr}' attrlookup = f"{fullname}.{attr}"
key = _('Attributes') key = _("Attributes")
badge = None badge = None
label = attr label = attr
value = None value = None
@ -220,67 +225,76 @@ def get_class_results(lookup, modulename, name, fullname):
break break
if value is not None: if value is not None:
doc = value.__doc__ or '' doc = value.__doc__ or ""
if inspect.iscoroutinefunction(value) or doc.startswith('|coro|'): if inspect.iscoroutinefunction(value) or doc.startswith("|coro|"):
key = _('Methods') key = _("Methods")
badge = attributetablebadge('async', 'async') badge = attributetablebadge("async", "async")
badge['badge-type'] = _('coroutine') badge["badge-type"] = _("coroutine")
elif isinstance(value, classmethod): elif isinstance(value, classmethod):
key = _('Methods') key = _("Methods")
label = f'{name}.{attr}' label = f"{name}.{attr}"
badge = attributetablebadge('cls', 'cls') badge = attributetablebadge("cls", "cls")
badge['badge-type'] = _('classmethod') badge["badge-type"] = _("classmethod")
elif ( elif inspect.isfunction(value) or isinstance(value, staticmethod):
inspect.isfunction(value) if doc.startswith(("A decorator", "A shortcut decorator")) or label in (
or isinstance(value, staticmethod) "event",
): "loop",
if (
doc.startswith(('A decorator', 'A shortcut decorator'))
or label in ("event", "loop")
): ):
# finicky but surprisingly consistent # finicky but surprisingly consistent
badge = attributetablebadge('@', '@') badge = attributetablebadge("@", "@")
badge['badge-type'] = _('decorator') badge["badge-type"] = _("decorator")
key = _('Methods') key = _("Methods")
else: else:
key = _('Methods') key = _("Methods")
badge = attributetablebadge('def', 'def') badge = attributetablebadge("def", "def")
badge['badge-type'] = _('method') badge["badge-type"] = _("method")
groups[key].append(TableElement( groups[key].append(TableElement(fullname=attrlookup, label=label, badge=badge))
fullname=attrlookup, label=label, badge=badge))
return groups return groups
def class_results_to_node(key, elements): def class_results_to_node(key, elements):
title = attributetabletitle(key, key) title = attributetabletitle(key, key)
ul = nodes.bullet_list('') ul = nodes.bullet_list("")
for element in elements: for element in elements:
ref = nodes.reference('', '', internal=True, ref = nodes.reference(
refuri='#' + element.fullname, "",
anchorname='', "",
*[nodes.Text(element.label)]) internal=True,
para = addnodes.compact_paragraph('', '', ref) refuri="#" + element.fullname,
anchorname="",
*[nodes.Text(element.label)],
)
para = addnodes.compact_paragraph("", "", ref)
if element.badge is not None: if element.badge is not None:
ul.append(attributetable_item('', element.badge, para)) ul.append(attributetable_item("", element.badge, para))
else: else:
ul.append(attributetable_item('', para)) ul.append(attributetable_item("", para))
return attributetablecolumn('', title, ul) return attributetablecolumn("", title, ul)
def setup(app): def setup(app):
app.add_directive('attributetable', PyAttributeTable) app.add_directive("attributetable", PyAttributeTable)
app.add_node(attributetable, html=( app.add_node(
visit_attributetable_node, depart_attributetable_node)) attributetable, html=(visit_attributetable_node, depart_attributetable_node)
app.add_node(attributetablecolumn, html=( )
visit_attributetablecolumn_node, depart_attributetablecolumn_node)) app.add_node(
app.add_node(attributetabletitle, html=( attributetablecolumn,
visit_attributetabletitle_node, depart_attributetabletitle_node)) html=(visit_attributetablecolumn_node, depart_attributetablecolumn_node),
app.add_node(attributetablebadge, html=( )
visit_attributetablebadge_node, depart_attributetablebadge_node)) app.add_node(
app.add_node(attributetable_item, html=( attributetabletitle,
visit_attributetable_item_node, depart_attributetable_item_node)) html=(visit_attributetabletitle_node, depart_attributetabletitle_node),
)
app.add_node(
attributetablebadge,
html=(visit_attributetablebadge_node, depart_attributetablebadge_node),
)
app.add_node(
attributetable_item,
html=(visit_attributetable_item_node, depart_attributetable_item_node),
)
app.add_node(attributetableplaceholder) app.add_node(attributetableplaceholder)
app.connect('doctree-resolved', process_attributetable) app.connect("doctree-resolved", process_attributetable)

View file

@ -231,7 +231,12 @@ class HTTPClient:
return await self.__send("DELETE", route, headers=headers) return await self.__send("DELETE", route, headers=headers)
async def patch( async def patch(
self, route: str, *, headers: dict = None, json: Optional[Dict] = None, data=None self,
route: str,
*,
headers: dict = None,
json: Optional[Dict] = None,
data=None,
) -> Optional[Dict]: ) -> Optional[Dict]:
"""|coro| """|coro|
Sends a PATCH request to a Discord REST API endpoint. Sends a PATCH request to a Discord REST API endpoint.

View file

@ -13,8 +13,7 @@ from .channel import (
Thread, Thread,
_choose_channel_type, _choose_channel_type,
) )
from .emoji import Emoji
from .member import GuildMember from .member import GuildMember
from .role import Role from .role import Role
from ...utils import Snowflake, Timestamp from ...utils import Snowflake, Timestamp
@ -24,7 +23,6 @@ from ...utils.types import APINullable
if TYPE_CHECKING: if TYPE_CHECKING:
from .channel import ChannelType, Channel from .channel import ChannelType, Channel
from .emoji import Emoji
class DefaultMessageNotificationLevel(IntEnum): class DefaultMessageNotificationLevel(IntEnum):
@ -226,9 +224,9 @@ class Guild(APIModelBase):
Explicit content filter level Explicit content filter level
features: APINullable[List[:class:`str`]] features: APINullable[List[:class:`str`]]
Enabled guild features Enabled guild features
roles: APINullable[:class:`typing.Any`] roles: Dict[:class:`~melisa.utils.snowflake.Snowflake`, :class:`~melisa.models.guild.role.Role`]
Roles in the guild Roles in the guild
emojis: APINullable[:class:`typing.Any`] emojis: Dict[:class:`~melisa.utils.snowflake.Snowflake`, :class:`~melisa.models.guild.emoji.Emoji`]
Custom guild emojis Custom guild emojis
mfa_level: :class:`int` mfa_level: :class:`int`
Required MFA level for the guild Required MFA level for the guild
@ -327,8 +325,7 @@ class Guild(APIModelBase):
default_message_notifications: APINullable[int] = None default_message_notifications: APINullable[int] = None
explicit_content_filter: APINullable[int] = None explicit_content_filter: APINullable[int] = None
features: APINullable[List[str]] = None features: APINullable[List[str]] = None
emojis: APINullable[Emoji] = None emojis: APINullable[Dict[str, Emoji]] = None
# TODO: Make a structures of emoji and role
mfa_level: APINullable[MFALevel] = None mfa_level: APINullable[MFALevel] = None
application_id: APINullable[Snowflake] = None application_id: APINullable[Snowflake] = None
@ -461,6 +458,7 @@ class Guild(APIModelBase):
self.channels = {} self.channels = {}
self.members = {} self.members = {}
self.roles = {} self.roles = {}
self.emojis = {}
for member in data.get("members", []): for member in data.get("members", []):
member = GuildMember.from_dict(member) member = GuildMember.from_dict(member)
@ -477,6 +475,10 @@ class Guild(APIModelBase):
role["guild_id"] = self.id role["guild_id"] = self.id
self.roles[Snowflake(int(role["id"]))] = Role.from_dict(role) self.roles[Snowflake(int(role["id"]))] = Role.from_dict(role)
for emoji in data.get("emojis", []):
emoji["guild_id"] = self.id
self.emojis[Snowflake(emoji["id"])] = Emoji.from_dict(emoji)
return self return self
@property @property
@ -621,9 +623,7 @@ class Guild(APIModelBase):
await self._client.rest.remove_guild_ban(self.id, user_id, reason=reason) await self._client.rest.remove_guild_ban(self.id, user_id, reason=reason)
async def fetch_emojis( async def fetch_emojis(self) -> List[Emoji]:
self
):
"""|coro| """|coro|
Getting all emojis from guild Getting all emojis from guild
@ -638,12 +638,9 @@ class Guild(APIModelBase):
You provided a wrong guild You provided a wrong guild
""" """
await self._client.rest.list_guild_emojis(self.id) return await self._client.rest.list_guild_emojis(self.id)
async def fetch_emoji( async def fetch_emoji(self, emoji_id: Union[Snowflake, str, int]) -> Emoji:
self,
emoji_id: Union[Snowflake, str, int]
):
"""|coro| """|coro|
Get emoji from guild Get emoji from guild
@ -663,16 +660,17 @@ class Guild(APIModelBase):
You provided a wrong guild and emoji You provided a wrong guild and emoji
""" """
await self._client.rest.get_guild_emoji(self.id, emoji_id) return await self._client.rest.get_guild_emoji(self.id, emoji_id)
async def create_emoji( async def create_emoji(
self, self,
emoji_name: Optional[str], emoji_name: str,
emoji_image: Optional[str], emoji_image: Any,
*, *,
reason: Optional[str] = None, reason: Optional[str] = None,
role_id: Union[Snowflake, str, int] = None role_id: List[Union[Snowflake, str, int]] = None,
): ) -> Emoji:
# FIXME: emoji_image != str, it works another way
"""|coro| """|coro|
Create a new emoji for the guild. Create a new emoji for the guild.
@ -687,7 +685,7 @@ class Guild(APIModelBase):
The 128x128 emoji image The 128x128 emoji image
reason: Optional[:class:`str`] reason: Optional[:class:`str`]
The reason of the action The reason of the action
role_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`] role_id: List[Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]]
Roles allowed to use this emoji Roles allowed to use this emoji
Raises Raises
@ -700,7 +698,9 @@ class Guild(APIModelBase):
You provided a wrong guild You provided a wrong guild
""" """
await self._client.rest.create_guild_emoji(self.id, emoji_name, emoji_image, reason=reason, role_id=role_id) return await self._client.rest.create_guild_emoji(
self.id, emoji_name, emoji_image, reason=reason, role_id=role_id
)
async def edit_emoji( async def edit_emoji(
self, self,
@ -708,18 +708,16 @@ class Guild(APIModelBase):
emoji_name: Optional[str], emoji_name: Optional[str],
*, *,
reason: Optional[str] = None, reason: Optional[str] = None,
role_id: Union[Snowflake, str, int] = None role_id: List[Union[Snowflake, str, int]] = None,
): ):
"""|coro| """|coro|
Modify the given emoji. Modify the given emoji.
Requires the `MANAGE_EMOJIS_AND_STICKERS` permission. Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
Returns the updated emoji object on success. Fires a Guild Emojis Update Gateway event. Returns the updated emoji object on success.
Parameters Parameters
---------- ----------
guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
ID of the guild in which we will modify emoji
emoji_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`] emoji_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
The ID of the emoji that we will modify The ID of the emoji that we will modify
emoji_name: Optional[:class:`str`] emoji_name: Optional[:class:`str`]
@ -739,14 +737,13 @@ class Guild(APIModelBase):
You provided a wrong guild and emoji You provided a wrong guild and emoji
""" """
await self._client.rest.modify_guild_emoji(self.id, emoji_id, emoji_name, reason=reason, role_id=role_id) return await self._client.rest.modify_guild_emoji(
self.id, emoji_id, emoji_name, reason=reason, role_id=role_id
)
async def delete_emoji( async def delete_emoji(
self, self, emoji_id: Union[Snowflake, str, int], *, reason: Optional[str] = None
emoji_id: Union[Snowflake, str, int], ) -> None:
*,
reason: Optional[str] = None
):
"""|coro| """|coro|
Delete the given emoji. Delete the given emoji.
@ -755,8 +752,6 @@ class Guild(APIModelBase):
Parameters Parameters
---------- ----------
guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
ID of the guild in which we will delete emoji
emoji_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`] emoji_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
The ID of the emoji that we will delete The ID of the emoji that we will delete
reason: Optional[:class:`str`] reason: Optional[:class:`str`]

View file

@ -15,6 +15,7 @@ from .utils import json, UNDEFINED
from .utils.snowflake import Snowflake from .utils.snowflake import Snowflake
from .models.guild.guild import Guild from .models.guild.guild import Guild
from .models.user.user import User from .models.user.user import User
from .models.guild.emoji import Emoji
from .models.guild.channel import _choose_channel_type, Channel from .models.guild.channel import _choose_channel_type, Channel
@ -677,7 +678,7 @@ class RESTApp:
Parameters Parameters
---------- ----------
guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`] guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
ID of the guild in which we will get the list emojis ID of the guild in which we will get the list of emojis
Raises Raises
------- -------
@ -688,15 +689,13 @@ class RESTApp:
BadRequestError BadRequestError
You provided a wrong guild You provided a wrong guild
""" """
return [
await self._http.get( Emoji.from_dict(emoji)
f"/guilds/{guild_id}/emojis" for emoji in await self._http.get(f"/guilds/{guild_id}/emojis")
) ]
async def get_guild_emoji( async def get_guild_emoji(
self, self, guild_id: Union[Snowflake, str, int], emoji_id: Union[Snowflake, str, int]
guild_id: Union[Snowflake, str, int],
emoji_id: Union[Snowflake, str, int]
): ):
"""|coro| """|coro|
@ -719,19 +718,18 @@ class RESTApp:
You provided a wrong guild and emoji You provided a wrong guild and emoji
""" """
await self._http.get( await self._http.get(f"/guilds/{guild_id}/emojis/{emoji_id}")
f"/guilds/{guild_id}/emojis/{emoji_id}"
)
async def create_guild_emoji( async def create_guild_emoji(
self, self,
guild_id: Union[int, str, Snowflake], guild_id: Union[int, str, Snowflake],
emoji_name: Optional[str], emoji_name: str,
emoji_image: Optional[str], emoji_image: Any,
*, *,
reason: Optional[str] = None, reason: Optional[str] = None,
role_id: Union[int, str, Snowflake] = None role_id: Union[int, str, Snowflake] = None,
): ):
# FIXME: emoji_image != str, it works another way
"""|coro| """|coro|
[**REST API**] Create a new emoji for the guild. [**REST API**] Create a new emoji for the guild.
@ -760,16 +758,14 @@ class RESTApp:
You provided a wrong guild You provided a wrong guild
""" """
data = { data = {"name": emoji_name, "image": emoji_image, "roles": role_id}
"name": emoji_name,
"image": emoji_image,
"roles": role_id
}
await self._http.post( return Emoji.from_dict(
f"/guilds/{guild_id}/emojis", await self._http.post(
json = data, f"/guilds/{guild_id}/emojis",
headers={"X-Audit-Log-Reason": reason} json=data,
headers={"X-Audit-Log-Reason": reason},
)
) )
async def modify_guild_emoji( async def modify_guild_emoji(
@ -779,7 +775,7 @@ class RESTApp:
emoji_name: Optional[str], emoji_name: Optional[str],
*, *,
reason: Optional[str] = None, reason: Optional[str] = None,
role_id: Union[int, str, Snowflake] = None role_id: Union[int, str, Snowflake] = None,
): ):
"""|coro| """|coro|
@ -809,15 +805,14 @@ class RESTApp:
You provided a wrong guild and emoji You provided a wrong guild and emoji
""" """
data = { data = {"name": emoji_name, "roles": role_id}
"name": emoji_name,
"roles": role_id
}
await self._http.patch( return Emoji.from_dict(
f"/guilds/{guild_id}/emojis/{emoji_id}", await self._http.patch(
json = data, f"/guilds/{guild_id}/emojis/{emoji_id}",
headers={"X-Audit-Log-Reason": reason} json=data,
headers={"X-Audit-Log-Reason": reason},
)
) )
async def delete_guild_emoji( async def delete_guild_emoji(
@ -825,7 +820,7 @@ class RESTApp:
guild_id: Union[int, str, Snowflake], guild_id: Union[int, str, Snowflake],
emoji_id: Union[int, str, Snowflake], emoji_id: Union[int, str, Snowflake],
*, *,
reason: Optional[str] = None reason: Optional[str] = None,
): ):
"""|coro| """|coro|
@ -853,7 +848,7 @@ class RESTApp:
await self._http.delete( await self._http.delete(
f"/guilds/{guild_id}/emojis/{emoji_id}", f"/guilds/{guild_id}/emojis/{emoji_id}",
headers={"X-Audit-Log-Reason": reason} headers={"X-Audit-Log-Reason": reason},
) )
async def get_global_application_commands( async def get_global_application_commands(
@ -1101,7 +1096,9 @@ class RESTApp:
data["default_permission"] = default_permission data["default_permission"] = default_permission
return ApplicationCommand.from_dict( return ApplicationCommand.from_dict(
await self._http.patch(f"/applications/{application_id}/commands/{command_id}", json=data) await self._http.patch(
f"/applications/{application_id}/commands/{command_id}", json=data
)
) )
async def delete_global_application_command( async def delete_global_application_command(
@ -1130,9 +1127,7 @@ class RESTApp:
You provided a wrong arguments You provided a wrong arguments
""" """
await self._http.delete( await self._http.delete(f"/applications/{application_id}/commands/{command_id}")
f"/applications/{application_id}/commands/{command_id}"
)
return None return None

View file

@ -8,29 +8,24 @@ README = (HERE / "README.md").read_text(encoding="utf8")
with open(HERE / "melisa/__init__.py") as file: with open(HERE / "melisa/__init__.py") as file:
version = re.search( version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', file.read(), re.MULTILINE).group(1) r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', file.read(), re.MULTILINE
).group(1)
setuptools.setup( setuptools.setup(
name='melisa', name="melisa",
author='MelisaDev', author="MelisaDev",
url='https://github.com/MelisaDev/melisa', url="https://github.com/MelisaDev/melisa",
version=version, version=version,
packages=setuptools.find_packages(), packages=setuptools.find_packages(),
license='MIT', license="MIT",
description='Cache-optimized Discord microframework for Python 3', description="Cache-optimized Discord microframework for Python 3",
long_description=README, long_description=README,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
include_package_data=True, include_package_data=True,
python_requires='>=3.8,<3.11', python_requires=">=3.8,<3.11",
zip_safe=False, zip_safe=False,
install_requires=[ install_requires=["aiohttp", "typing_extensions"],
"aiohttp", "typing_extensions" extras_require={"speedup": ["orjson==3.7.3"]},
],
extras_require={
"speedup": [
"orjson==3.7.3"
]
},
test_suite="tests", test_suite="tests",
project_urls={ project_urls={
"Documentation": "https://docs.melisapy.site/", "Documentation": "https://docs.melisapy.site/",
@ -54,5 +49,5 @@ setuptools.setup(
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities", "Topic :: Utilities",
"Typing :: Typed", "Typing :: Typed",
] ],
) )