mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-09-22 19:22:01 +03:00
fix: something with emojis ya
This commit is contained in:
parent
17c16279b1
commit
db4de62b4c
6 changed files with 230 additions and 229 deletions
|
@ -21,39 +21,36 @@ import sys
|
|||
import os
|
||||
|
||||
sys.path.append(os.path.abspath("../.."))
|
||||
sys.path.append(os.path.abspath('extensions'))
|
||||
sys.path.append(os.path.abspath("extensions"))
|
||||
|
||||
|
||||
project = 'Melisa'
|
||||
copyright = '2022, MelisaDev'
|
||||
author = 'MelisaDev'
|
||||
project = "Melisa"
|
||||
copyright = "2022, MelisaDev"
|
||||
author = "MelisaDev"
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.0.1a'
|
||||
release = "0.0.1a"
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
extensions = [
|
||||
'sphinx_design',
|
||||
"sphinx_design",
|
||||
"sphinx.ext.napoleon",
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.viewcode",
|
||||
"sphinx.ext.autosectionlabel",
|
||||
"sphinx.ext.extlinks",
|
||||
"sphinxcontrib_trio",
|
||||
"attributable"
|
||||
"attributable",
|
||||
]
|
||||
|
||||
autodoc_default_options = {
|
||||
'members': True,
|
||||
'show-inheritance': True
|
||||
}
|
||||
autodoc_default_options = {"members": True, "show-inheritance": True}
|
||||
|
||||
autodoc_typehints = 'none'
|
||||
autodoc_typehints = "none"
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
add_module_names = False
|
||||
|
||||
|
@ -67,13 +64,13 @@ intersphinx_mapping = {
|
|||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
html_theme = 'furo'
|
||||
html_theme = "furo"
|
||||
html_theme_options = {
|
||||
"sidebar_hide_name": True,
|
||||
}
|
||||
pygments_style = 'monokai'
|
||||
pygments_style = "monokai"
|
||||
default_dark_mode = True
|
||||
html_static_path = ['_static']
|
||||
html_static_path = ["_static"]
|
||||
html_css_files = ["custom.css"]
|
||||
|
||||
rst_prolog = """
|
||||
|
|
|
@ -40,56 +40,50 @@ class attributetable_item(nodes.Part, nodes.Element):
|
|||
|
||||
def visit_attributetable_node(self, node):
|
||||
class_ = node["python-class"]
|
||||
self.body.append(
|
||||
f'<div class="py-attribute-table" data-move-to-id="{class_}">'
|
||||
)
|
||||
self.body.append(f'<div class="py-attribute-table" data-move-to-id="{class_}">')
|
||||
|
||||
|
||||
def visit_attributetablecolumn_node(self, node):
|
||||
self.body.append(self.starttag(
|
||||
node, 'div', CLASS='py-attribute-table-column')
|
||||
)
|
||||
self.body.append(self.starttag(node, "div", CLASS="py-attribute-table-column"))
|
||||
|
||||
|
||||
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):
|
||||
attributes = {
|
||||
'class': 'py-attribute-table-badge',
|
||||
'title': node['badge-type'],
|
||||
"class": "py-attribute-table-badge",
|
||||
"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):
|
||||
self.body.append(self.starttag(
|
||||
node, 'li', CLASS='py-attribute-table-entry')
|
||||
)
|
||||
self.body.append(self.starttag(node, "li", CLASS="py-attribute-table-entry"))
|
||||
|
||||
|
||||
def depart_attributetable_node(self, node):
|
||||
self.body.append('</div>')
|
||||
self.body.append("</div>")
|
||||
|
||||
|
||||
def depart_attributetablecolumn_node(self, node):
|
||||
self.body.append('</div>')
|
||||
self.body.append("</div>")
|
||||
|
||||
|
||||
def depart_attributetabletitle_node(self, node):
|
||||
self.body.append('</span>')
|
||||
self.body.append("</span>")
|
||||
|
||||
|
||||
def depart_attributetablebadge_node(self, node):
|
||||
self.body.append('</span>')
|
||||
self.body.append("</span>")
|
||||
|
||||
|
||||
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):
|
||||
|
@ -102,14 +96,15 @@ class PyAttributeTable(SphinxDirective):
|
|||
def parse_name(self, content):
|
||||
path, name = _name_parser_regex.match(content).groups()
|
||||
if path:
|
||||
modulename = path.rstrip('.')
|
||||
modulename = path.rstrip(".")
|
||||
else:
|
||||
modulename = self.env.temp_data.get('autodoc:module')
|
||||
modulename = self.env.temp_data.get("autodoc:module")
|
||||
if not modulename:
|
||||
modulename = self.env.ref_context.get('py:module')
|
||||
modulename = self.env.ref_context.get("py:module")
|
||||
if modulename is None:
|
||||
raise RuntimeError('modulename somehow None for %s in %s.' % (
|
||||
content, self.env.docname))
|
||||
raise RuntimeError(
|
||||
"modulename somehow None for %s in %s." % (content, self.env.docname)
|
||||
)
|
||||
|
||||
return modulename, name
|
||||
|
||||
|
@ -139,12 +134,12 @@ class PyAttributeTable(SphinxDirective):
|
|||
replaced.
|
||||
"""
|
||||
content = self.arguments[0].strip()
|
||||
node = attributetableplaceholder('')
|
||||
node = attributetableplaceholder("")
|
||||
modulename, name = self.parse_name(content)
|
||||
node['python-doc'] = self.env.docname
|
||||
node['python-module'] = modulename
|
||||
node['python-class'] = name
|
||||
node['python-full-name'] = f'{modulename}.{name}'
|
||||
node["python-doc"] = self.env.docname
|
||||
node["python-module"] = modulename
|
||||
node["python-class"] = name
|
||||
node["python-full-name"] = f"{modulename}.{name}"
|
||||
return [node]
|
||||
|
||||
|
||||
|
@ -152,17 +147,20 @@ def build_lookup_table(env):
|
|||
# Given an environment, load up a lookup table of
|
||||
# full-class-name: objects
|
||||
result = {}
|
||||
domain = env.domains['py']
|
||||
domain = env.domains["py"]
|
||||
|
||||
ignored = {
|
||||
'data', 'exception', 'module', 'class',
|
||||
"data",
|
||||
"exception",
|
||||
"module",
|
||||
"class",
|
||||
}
|
||||
|
||||
for (fullname, _, objtype, docname, _, _) in domain.get_objects():
|
||||
if objtype in ignored:
|
||||
continue
|
||||
|
||||
classname, _, child = fullname.rpartition('.')
|
||||
classname, _, child = fullname.rpartition(".")
|
||||
try:
|
||||
result[classname].append(child)
|
||||
except KeyError:
|
||||
|
@ -171,7 +169,7 @@ def build_lookup_table(env):
|
|||
return result
|
||||
|
||||
|
||||
TableElement = namedtuple('TableElement', 'fullname label badge')
|
||||
TableElement = namedtuple("TableElement", "fullname label badge")
|
||||
|
||||
|
||||
def process_attributetable(app, doctree, fromdocname):
|
||||
|
@ -179,16 +177,21 @@ def process_attributetable(app, doctree, fromdocname):
|
|||
|
||||
lookup = build_lookup_table(env)
|
||||
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)
|
||||
table = attributetable('')
|
||||
table = attributetable("")
|
||||
for label, subitems in groups.items():
|
||||
if not subitems:
|
||||
continue
|
||||
table.append(class_results_to_node(
|
||||
label, sorted(subitems, key=lambda c: c.label)))
|
||||
table.append(
|
||||
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 [])
|
||||
|
||||
|
@ -197,10 +200,12 @@ def get_class_results(lookup, modulename, name, fullname):
|
|||
module = importlib.import_module(modulename)
|
||||
cls = getattr(module, name)
|
||||
|
||||
groups = OrderedDict([
|
||||
(_('Attributes'), []),
|
||||
(_('Methods'), []),
|
||||
])
|
||||
groups = OrderedDict(
|
||||
[
|
||||
(_("Attributes"), []),
|
||||
(_("Methods"), []),
|
||||
]
|
||||
)
|
||||
|
||||
try:
|
||||
members = lookup[fullname]
|
||||
|
@ -208,8 +213,8 @@ def get_class_results(lookup, modulename, name, fullname):
|
|||
return groups
|
||||
|
||||
for attr in members:
|
||||
attrlookup = f'{fullname}.{attr}'
|
||||
key = _('Attributes')
|
||||
attrlookup = f"{fullname}.{attr}"
|
||||
key = _("Attributes")
|
||||
badge = None
|
||||
label = attr
|
||||
value = None
|
||||
|
@ -220,67 +225,76 @@ def get_class_results(lookup, modulename, name, fullname):
|
|||
break
|
||||
|
||||
if value is not None:
|
||||
doc = value.__doc__ or ''
|
||||
if inspect.iscoroutinefunction(value) or doc.startswith('|coro|'):
|
||||
key = _('Methods')
|
||||
badge = attributetablebadge('async', 'async')
|
||||
badge['badge-type'] = _('coroutine')
|
||||
doc = value.__doc__ or ""
|
||||
if inspect.iscoroutinefunction(value) or doc.startswith("|coro|"):
|
||||
key = _("Methods")
|
||||
badge = attributetablebadge("async", "async")
|
||||
badge["badge-type"] = _("coroutine")
|
||||
elif isinstance(value, classmethod):
|
||||
key = _('Methods')
|
||||
label = f'{name}.{attr}'
|
||||
badge = attributetablebadge('cls', 'cls')
|
||||
badge['badge-type'] = _('classmethod')
|
||||
elif (
|
||||
inspect.isfunction(value)
|
||||
or isinstance(value, staticmethod)
|
||||
):
|
||||
if (
|
||||
doc.startswith(('A decorator', 'A shortcut decorator'))
|
||||
or label in ("event", "loop")
|
||||
key = _("Methods")
|
||||
label = f"{name}.{attr}"
|
||||
badge = attributetablebadge("cls", "cls")
|
||||
badge["badge-type"] = _("classmethod")
|
||||
elif inspect.isfunction(value) or isinstance(value, staticmethod):
|
||||
if doc.startswith(("A decorator", "A shortcut decorator")) or label in (
|
||||
"event",
|
||||
"loop",
|
||||
):
|
||||
# finicky but surprisingly consistent
|
||||
badge = attributetablebadge('@', '@')
|
||||
badge['badge-type'] = _('decorator')
|
||||
key = _('Methods')
|
||||
badge = attributetablebadge("@", "@")
|
||||
badge["badge-type"] = _("decorator")
|
||||
key = _("Methods")
|
||||
else:
|
||||
key = _('Methods')
|
||||
badge = attributetablebadge('def', 'def')
|
||||
badge['badge-type'] = _('method')
|
||||
key = _("Methods")
|
||||
badge = attributetablebadge("def", "def")
|
||||
badge["badge-type"] = _("method")
|
||||
|
||||
groups[key].append(TableElement(
|
||||
fullname=attrlookup, label=label, badge=badge))
|
||||
groups[key].append(TableElement(fullname=attrlookup, label=label, badge=badge))
|
||||
|
||||
return groups
|
||||
|
||||
|
||||
def class_results_to_node(key, elements):
|
||||
title = attributetabletitle(key, key)
|
||||
ul = nodes.bullet_list('')
|
||||
ul = nodes.bullet_list("")
|
||||
for element in elements:
|
||||
ref = nodes.reference('', '', internal=True,
|
||||
refuri='#' + element.fullname,
|
||||
anchorname='',
|
||||
*[nodes.Text(element.label)])
|
||||
para = addnodes.compact_paragraph('', '', ref)
|
||||
ref = nodes.reference(
|
||||
"",
|
||||
"",
|
||||
internal=True,
|
||||
refuri="#" + element.fullname,
|
||||
anchorname="",
|
||||
*[nodes.Text(element.label)],
|
||||
)
|
||||
para = addnodes.compact_paragraph("", "", ref)
|
||||
if element.badge is not None:
|
||||
ul.append(attributetable_item('', element.badge, para))
|
||||
ul.append(attributetable_item("", element.badge, para))
|
||||
else:
|
||||
ul.append(attributetable_item('', para))
|
||||
ul.append(attributetable_item("", para))
|
||||
|
||||
return attributetablecolumn('', title, ul)
|
||||
return attributetablecolumn("", title, ul)
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('attributetable', PyAttributeTable)
|
||||
app.add_node(attributetable, html=(
|
||||
visit_attributetable_node, depart_attributetable_node))
|
||||
app.add_node(attributetablecolumn, html=(
|
||||
visit_attributetablecolumn_node, depart_attributetablecolumn_node))
|
||||
app.add_node(attributetabletitle, 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_directive("attributetable", PyAttributeTable)
|
||||
app.add_node(
|
||||
attributetable, html=(visit_attributetable_node, depart_attributetable_node)
|
||||
)
|
||||
app.add_node(
|
||||
attributetablecolumn,
|
||||
html=(visit_attributetablecolumn_node, depart_attributetablecolumn_node),
|
||||
)
|
||||
app.add_node(
|
||||
attributetabletitle,
|
||||
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.connect('doctree-resolved', process_attributetable)
|
||||
app.connect("doctree-resolved", process_attributetable)
|
||||
|
|
|
@ -231,7 +231,12 @@ class HTTPClient:
|
|||
return await self.__send("DELETE", route, headers=headers)
|
||||
|
||||
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]:
|
||||
"""|coro|
|
||||
Sends a PATCH request to a Discord REST API endpoint.
|
||||
|
|
|
@ -13,8 +13,7 @@ from .channel import (
|
|||
Thread,
|
||||
_choose_channel_type,
|
||||
)
|
||||
|
||||
|
||||
from .emoji import Emoji
|
||||
from .member import GuildMember
|
||||
from .role import Role
|
||||
from ...utils import Snowflake, Timestamp
|
||||
|
@ -24,7 +23,6 @@ from ...utils.types import APINullable
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from .channel import ChannelType, Channel
|
||||
from .emoji import Emoji
|
||||
|
||||
|
||||
class DefaultMessageNotificationLevel(IntEnum):
|
||||
|
@ -226,9 +224,9 @@ class Guild(APIModelBase):
|
|||
Explicit content filter level
|
||||
features: APINullable[List[:class:`str`]]
|
||||
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
|
||||
emojis: APINullable[:class:`typing.Any`]
|
||||
emojis: Dict[:class:`~melisa.utils.snowflake.Snowflake`, :class:`~melisa.models.guild.emoji.Emoji`]
|
||||
Custom guild emojis
|
||||
mfa_level: :class:`int`
|
||||
Required MFA level for the guild
|
||||
|
@ -327,8 +325,7 @@ class Guild(APIModelBase):
|
|||
default_message_notifications: APINullable[int] = None
|
||||
explicit_content_filter: APINullable[int] = None
|
||||
features: APINullable[List[str]] = None
|
||||
emojis: APINullable[Emoji] = None
|
||||
# TODO: Make a structures of emoji and role
|
||||
emojis: APINullable[Dict[str, Emoji]] = None
|
||||
|
||||
mfa_level: APINullable[MFALevel] = None
|
||||
application_id: APINullable[Snowflake] = None
|
||||
|
@ -461,6 +458,7 @@ class Guild(APIModelBase):
|
|||
self.channels = {}
|
||||
self.members = {}
|
||||
self.roles = {}
|
||||
self.emojis = {}
|
||||
|
||||
for member in data.get("members", []):
|
||||
member = GuildMember.from_dict(member)
|
||||
|
@ -477,6 +475,10 @@ class Guild(APIModelBase):
|
|||
role["guild_id"] = self.id
|
||||
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
|
||||
|
||||
@property
|
||||
|
@ -621,9 +623,7 @@ class Guild(APIModelBase):
|
|||
|
||||
await self._client.rest.remove_guild_ban(self.id, user_id, reason=reason)
|
||||
|
||||
async def fetch_emojis(
|
||||
self
|
||||
):
|
||||
async def fetch_emojis(self) -> List[Emoji]:
|
||||
"""|coro|
|
||||
|
||||
Getting all emojis from guild
|
||||
|
@ -638,12 +638,9 @@ class Guild(APIModelBase):
|
|||
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(
|
||||
self,
|
||||
emoji_id: Union[Snowflake, str, int]
|
||||
):
|
||||
async def fetch_emoji(self, emoji_id: Union[Snowflake, str, int]) -> Emoji:
|
||||
"""|coro|
|
||||
|
||||
Get emoji from guild
|
||||
|
@ -663,16 +660,17 @@ class Guild(APIModelBase):
|
|||
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(
|
||||
self,
|
||||
emoji_name: Optional[str],
|
||||
emoji_image: Optional[str],
|
||||
emoji_name: str,
|
||||
emoji_image: Any,
|
||||
*,
|
||||
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|
|
||||
|
||||
Create a new emoji for the guild.
|
||||
|
@ -687,7 +685,7 @@ class Guild(APIModelBase):
|
|||
The 128x128 emoji image
|
||||
reason: Optional[:class:`str`]
|
||||
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
|
||||
|
||||
Raises
|
||||
|
@ -700,7 +698,9 @@ class Guild(APIModelBase):
|
|||
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(
|
||||
self,
|
||||
|
@ -708,18 +708,16 @@ class Guild(APIModelBase):
|
|||
emoji_name: Optional[str],
|
||||
*,
|
||||
reason: Optional[str] = None,
|
||||
role_id: Union[Snowflake, str, int] = None
|
||||
role_id: List[Union[Snowflake, str, int]] = None,
|
||||
):
|
||||
"""|coro|
|
||||
|
||||
Modify the given emoji.
|
||||
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
|
||||
----------
|
||||
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`]
|
||||
The ID of the emoji that we will modify
|
||||
emoji_name: Optional[:class:`str`]
|
||||
|
@ -739,14 +737,13 @@ class Guild(APIModelBase):
|
|||
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(
|
||||
self,
|
||||
emoji_id: Union[Snowflake, str, int],
|
||||
*,
|
||||
reason: Optional[str] = None
|
||||
):
|
||||
self, emoji_id: Union[Snowflake, str, int], *, reason: Optional[str] = None
|
||||
) -> None:
|
||||
"""|coro|
|
||||
|
||||
Delete the given emoji.
|
||||
|
@ -755,8 +752,6 @@ class Guild(APIModelBase):
|
|||
|
||||
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`]
|
||||
The ID of the emoji that we will delete
|
||||
reason: Optional[:class:`str`]
|
||||
|
|
|
@ -15,6 +15,7 @@ from .utils import json, UNDEFINED
|
|||
from .utils.snowflake import Snowflake
|
||||
from .models.guild.guild import Guild
|
||||
from .models.user.user import User
|
||||
from .models.guild.emoji import Emoji
|
||||
from .models.guild.channel import _choose_channel_type, Channel
|
||||
|
||||
|
||||
|
@ -677,7 +678,7 @@ class RESTApp:
|
|||
Parameters
|
||||
----------
|
||||
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
|
||||
-------
|
||||
|
@ -688,15 +689,13 @@ class RESTApp:
|
|||
BadRequestError
|
||||
You provided a wrong guild
|
||||
"""
|
||||
|
||||
await self._http.get(
|
||||
f"/guilds/{guild_id}/emojis"
|
||||
)
|
||||
return [
|
||||
Emoji.from_dict(emoji)
|
||||
for emoji in await self._http.get(f"/guilds/{guild_id}/emojis")
|
||||
]
|
||||
|
||||
async def get_guild_emoji(
|
||||
self,
|
||||
guild_id: Union[Snowflake, str, int],
|
||||
emoji_id: Union[Snowflake, str, int]
|
||||
self, guild_id: Union[Snowflake, str, int], emoji_id: Union[Snowflake, str, int]
|
||||
):
|
||||
"""|coro|
|
||||
|
||||
|
@ -719,19 +718,18 @@ class RESTApp:
|
|||
You provided a wrong guild and emoji
|
||||
"""
|
||||
|
||||
await self._http.get(
|
||||
f"/guilds/{guild_id}/emojis/{emoji_id}"
|
||||
)
|
||||
await self._http.get(f"/guilds/{guild_id}/emojis/{emoji_id}")
|
||||
|
||||
async def create_guild_emoji(
|
||||
self,
|
||||
guild_id: Union[int, str, Snowflake],
|
||||
emoji_name: Optional[str],
|
||||
emoji_image: Optional[str],
|
||||
emoji_name: str,
|
||||
emoji_image: Any,
|
||||
*,
|
||||
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|
|
||||
|
||||
[**REST API**] Create a new emoji for the guild.
|
||||
|
@ -760,16 +758,14 @@ class RESTApp:
|
|||
You provided a wrong guild
|
||||
"""
|
||||
|
||||
data = {
|
||||
"name": emoji_name,
|
||||
"image": emoji_image,
|
||||
"roles": role_id
|
||||
}
|
||||
data = {"name": emoji_name, "image": emoji_image, "roles": role_id}
|
||||
|
||||
return Emoji.from_dict(
|
||||
await self._http.post(
|
||||
f"/guilds/{guild_id}/emojis",
|
||||
json = data,
|
||||
headers={"X-Audit-Log-Reason": reason}
|
||||
json=data,
|
||||
headers={"X-Audit-Log-Reason": reason},
|
||||
)
|
||||
)
|
||||
|
||||
async def modify_guild_emoji(
|
||||
|
@ -779,7 +775,7 @@ class RESTApp:
|
|||
emoji_name: Optional[str],
|
||||
*,
|
||||
reason: Optional[str] = None,
|
||||
role_id: Union[int, str, Snowflake] = None
|
||||
role_id: Union[int, str, Snowflake] = None,
|
||||
):
|
||||
"""|coro|
|
||||
|
||||
|
@ -809,15 +805,14 @@ class RESTApp:
|
|||
You provided a wrong guild and emoji
|
||||
"""
|
||||
|
||||
data = {
|
||||
"name": emoji_name,
|
||||
"roles": role_id
|
||||
}
|
||||
data = {"name": emoji_name, "roles": role_id}
|
||||
|
||||
return Emoji.from_dict(
|
||||
await self._http.patch(
|
||||
f"/guilds/{guild_id}/emojis/{emoji_id}",
|
||||
json = data,
|
||||
headers={"X-Audit-Log-Reason": reason}
|
||||
json=data,
|
||||
headers={"X-Audit-Log-Reason": reason},
|
||||
)
|
||||
)
|
||||
|
||||
async def delete_guild_emoji(
|
||||
|
@ -825,7 +820,7 @@ class RESTApp:
|
|||
guild_id: Union[int, str, Snowflake],
|
||||
emoji_id: Union[int, str, Snowflake],
|
||||
*,
|
||||
reason: Optional[str] = None
|
||||
reason: Optional[str] = None,
|
||||
):
|
||||
"""|coro|
|
||||
|
||||
|
@ -853,7 +848,7 @@ class RESTApp:
|
|||
|
||||
await self._http.delete(
|
||||
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(
|
||||
|
@ -1101,7 +1096,9 @@ class RESTApp:
|
|||
data["default_permission"] = default_permission
|
||||
|
||||
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(
|
||||
|
@ -1130,9 +1127,7 @@ class RESTApp:
|
|||
You provided a wrong arguments
|
||||
"""
|
||||
|
||||
await self._http.delete(
|
||||
f"/applications/{application_id}/commands/{command_id}"
|
||||
)
|
||||
await self._http.delete(f"/applications/{application_id}/commands/{command_id}")
|
||||
|
||||
return None
|
||||
|
||||
|
|
27
setup.py
27
setup.py
|
@ -8,29 +8,24 @@ README = (HERE / "README.md").read_text(encoding="utf8")
|
|||
|
||||
with open(HERE / "melisa/__init__.py") as file:
|
||||
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(
|
||||
name='melisa',
|
||||
author='MelisaDev',
|
||||
url='https://github.com/MelisaDev/melisa',
|
||||
name="melisa",
|
||||
author="MelisaDev",
|
||||
url="https://github.com/MelisaDev/melisa",
|
||||
version=version,
|
||||
packages=setuptools.find_packages(),
|
||||
license='MIT',
|
||||
description='Cache-optimized Discord microframework for Python 3',
|
||||
license="MIT",
|
||||
description="Cache-optimized Discord microframework for Python 3",
|
||||
long_description=README,
|
||||
long_description_content_type="text/markdown",
|
||||
include_package_data=True,
|
||||
python_requires='>=3.8,<3.11',
|
||||
python_requires=">=3.8,<3.11",
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
"aiohttp", "typing_extensions"
|
||||
],
|
||||
extras_require={
|
||||
"speedup": [
|
||||
"orjson==3.7.3"
|
||||
]
|
||||
},
|
||||
install_requires=["aiohttp", "typing_extensions"],
|
||||
extras_require={"speedup": ["orjson==3.7.3"]},
|
||||
test_suite="tests",
|
||||
project_urls={
|
||||
"Documentation": "https://docs.melisapy.site/",
|
||||
|
@ -54,5 +49,5 @@ setuptools.setup(
|
|||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
"Topic :: Utilities",
|
||||
"Typing :: Typed",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue