This repository has been archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pixeldeee
committed
Aug 3, 2023
1 parent
d311101
commit 7e52211
Showing
6 changed files
with
104 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from pytecord.client import Client | ||
from pytecord.guild import Guild, GuildChannel, Message, MessageDeleteEvent | ||
from .client import Client | ||
from .guild import Guild, GuildChannel, Message, MessageDeleteEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from .interfaces import Object | ||
from typing import Any | ||
|
||
class User(Object): | ||
def __init__(self, data: dict[str, Any], token: str) -> None: | ||
self.__token = token | ||
self.__data = data | ||
|
||
def eval(self) -> dict[str, Any]: | ||
""" | ||
Returns a dict representation of user | ||
``` | ||
>>> user = User() | ||
>>> user.eval() | ||
``` | ||
""" | ||
return self.__data | ||
|
||
def __int__(self) -> int: | ||
""" | ||
Returns an object id | ||
``` | ||
>>> obj = Object() | ||
>>> int(obj) | ||
``` | ||
""" | ||
print('Is under developerment!') | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
from requests import get, post | ||
from aiohttp import ClientSession | ||
|
||
from typing import Literal, Any | ||
|
||
from pytecord.config import API_VERSION | ||
from .config import API_VERSION | ||
|
||
class MessagePayload: | ||
def __init__(self, content: str) -> None: | ||
self.json = { | ||
'content': content | ||
} | ||
def eval(self) -> dict[str, Any]: | ||
return self.json | ||
|
||
def get_headers(token: str): | ||
return {'Authorization': f'Bot {token}'} | ||
|
||
def rget(what_to_get: Literal['channel', 'guild', 'user'], id: int, token: str = None, headers: dict[str, Any] = None): | ||
def rget(endpoint: str, token: str = None, headers: dict[str, Any] = None): | ||
if token: | ||
headers = get_headers(token) | ||
return get(f'https://discord.com/api/v{API_VERSION}/{what_to_get}s/{id}', headers=headers) | ||
return get(f'https://discord.com/api/v{API_VERSION}{endpoint}', headers=headers) | ||
|
||
def rfetch(where_get: Literal['channel'], what_to_fetch: Literal['message'], first_id: int, second_id: int, token: str = None, headers: dict[str, Any] = None): | ||
async def apost(endpoint: str, token: str = None, headers: dict[str, Any] = None, data: dict[str, Any] = None): | ||
if token: | ||
headers = get_headers(token) | ||
return get(f'https://discord.com/api/v{API_VERSION}/{where_get}s/{first_id}/{what_to_fetch}s/{second_id}', headers=headers) | ||
async with ClientSession(headers=headers) as s: | ||
async with s.post(f'https://discord.com/api/v{API_VERSION}{endpoint}', data=data) as r: | ||
if r.status == 200: | ||
return await r.json() | ||
raise Exception(await r.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters