mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-11-14 12:27:28 +03:00
feat(Guild): add unban() method
This commit is contained in:
parent
a229593d8e
commit
64e7b7740e
2 changed files with 71 additions and 1 deletions
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from typing import List, Any, Optional, overload, Dict, TYPE_CHECKING
|
from typing import List, Any, Optional, overload, Dict, TYPE_CHECKING, Union
|
||||||
|
|
||||||
from .channel import (
|
from .channel import (
|
||||||
ThreadsList,
|
ThreadsList,
|
||||||
|
@ -575,6 +575,38 @@ class Guild(APIModelBase):
|
||||||
await self._http.get(f"/guilds/{self.id}/threads/active")
|
await self._http.get(f"/guilds/{self.id}/threads/active")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def unban(
|
||||||
|
self,
|
||||||
|
user_id: Union[Snowflake, str, int],
|
||||||
|
*,
|
||||||
|
reason: Optional[str] = None,
|
||||||
|
):
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
Remove the ban for a user.
|
||||||
|
|
||||||
|
**Required permissions:** ``BAN_MEMBERS``
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
user_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
|
||||||
|
Id of user to operate with.
|
||||||
|
reason: Optional[:class:`str`]
|
||||||
|
The reason of the action.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
-------
|
||||||
|
HTTPException
|
||||||
|
The request to perform the action failed with other http exception.
|
||||||
|
ForbiddenError
|
||||||
|
You do not have proper permissions to do the actions required.
|
||||||
|
BadRequestError
|
||||||
|
You provided a wrong guild, user or something else
|
||||||
|
Or if the user is not banned
|
||||||
|
"""
|
||||||
|
|
||||||
|
await self._client.rest.remove_guild_ban(self.id, user_id, reason=reason)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(repr=False)
|
@dataclass(repr=False)
|
||||||
class UnavailableGuild(APIModelBase):
|
class UnavailableGuild(APIModelBase):
|
||||||
|
|
|
@ -535,6 +535,44 @@ class RESTApp:
|
||||||
headers={"X-Audit-Log-Reason": reason},
|
headers={"X-Audit-Log-Reason": reason},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def remove_guild_ban(
|
||||||
|
self,
|
||||||
|
guild_id: Union[Snowflake, str, int],
|
||||||
|
user_id: Union[Snowflake, str, int],
|
||||||
|
*,
|
||||||
|
reason: Optional[str] = None,
|
||||||
|
):
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
[**REST API**] Remove the ban for a user.
|
||||||
|
|
||||||
|
**Required permissions:** ``BAN_MEMBERS``
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
|
||||||
|
Id of guild where we will remove ban for member
|
||||||
|
user_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
|
||||||
|
Id of user to operate with.
|
||||||
|
reason: Optional[:class:`str`]
|
||||||
|
The reason of the action.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
-------
|
||||||
|
HTTPException
|
||||||
|
The request to perform the action failed with other http exception.
|
||||||
|
ForbiddenError
|
||||||
|
You do not have proper permissions to do the actions required.
|
||||||
|
BadRequestError
|
||||||
|
You provided a wrong guild, user or something else
|
||||||
|
Or if the user is not banned
|
||||||
|
"""
|
||||||
|
|
||||||
|
await self._http.delete(
|
||||||
|
f"guilds/{guild_id}/bans/{user_id}",
|
||||||
|
headers={"X-Audit-Log-Reason": reason},
|
||||||
|
)
|
||||||
|
|
||||||
async def add_guild_member_role(
|
async def add_guild_member_role(
|
||||||
self,
|
self,
|
||||||
guild_id: Union[Snowflake, str, int],
|
guild_id: Union[Snowflake, str, int],
|
||||||
|
|
Loading…
Reference in a new issue