Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

disunity

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disunity - npm Package Compare versions

Comparing version
0.1.8
to
0.1.9
+0
-0
LICENSE

@@ -0,0 +0,0 @@ MIT License

+1
-1
Metadata-Version: 2.1
Name: disunity
Version: 0.1.8
Version: 0.1.9
Summary: Python framework for Discord interactions using a web server

@@ -5,0 +5,0 @@ Author: Tadeo Murillo,

@@ -13,3 +13,3 @@ [build-system]

name = "disunity"
version = "0.1.8"
version = "0.1.9"
authors = [

@@ -30,2 +30,2 @@ {name="Tadeo Murillo"},

"Homepoge" = "https://github.com/murillotadeo/disunity"
"Bug Tracker" = "https://github.com/murillotadeo/disunity/issues"
"Bug Tracker" = "https://github.com/murillotadeo/disunity/issues"

@@ -0,0 +0,0 @@ # disunity

Metadata-Version: 2.1
Name: disunity
Version: 0.1.8
Version: 0.1.9
Summary: Python framework for Discord interactions using a web server

@@ -5,0 +5,0 @@ Author: Tadeo Murillo,

@@ -17,3 +17,2 @@ LICENSE

src/disunity/models/__init__.py
src/disunity/models/attachment.py
src/disunity/models/components.py

@@ -20,0 +19,0 @@ src/disunity/models/context.py

from . import utils
from .embed import Embed
from .identifiers import SubOption
from .models import Message, Attachment
from .models import Message
from .package import Package
from .server import DisunityServer

@@ -0,0 +0,0 @@ from .identifiers import (

@@ -22,5 +22,9 @@ from __future__ import annotations

self.title = title
self.description = description
if self._title is not None:
self._title = str(self.title)
self.__json["title"] = self.title
if self._description is not None:
self.__json["description"] = str(self._description)
@property

@@ -27,0 +31,0 @@ def description(self) -> None | str:

@@ -0,0 +0,0 @@ class InvalidMethodUse(Exception):

@@ -0,0 +0,0 @@ from datetime import datetime, timezone

@@ -16,2 +16,1 @@ from .components import (

from .user import User
from .attachment import Attachment

@@ -61,3 +61,3 @@ from __future__ import annotations

style: int = ButtonStyles.PRIMARY,
emoji: dict | None = None,
emoji: dict = {},
url: str | None = None,

@@ -71,8 +71,5 @@ disabled: bool = False,

"style": style,
"disabled": disabled
"emoji": emoji,
"disabled": disabled,
}
# Very wonky patch for whatever the hell Discord just did
if emoji and isinstance(emoji, dict):
self.dict["emoji"] = emoji

@@ -103,3 +100,3 @@ if self.dict["style"] == ButtonStyles.LINK and url is not None:

def __init__(
self, label: str, value: str | int, description: str = "", emoji: dict | None = None
self, label: str, value: str | int, description: str = "", emoji: dict = {}
):

@@ -109,8 +106,6 @@ self.dict = {

"value": value,
"description": description
"description": description,
"emoji": emoji,
}
if emoji and isinstance(emoji, dict):
self.dict["emoji"] = emoji
def to_dict(self) -> dict:

@@ -117,0 +112,0 @@ return self.dict

@@ -5,3 +5,2 @@ from .. import embed, errors, utils

from .message import Message
from .attachment import Attachment

@@ -74,3 +73,2 @@

components: list[ActionRow] | ActionRow = [],
attachments: list[Attachment] | Attachment = [],
ephemeral: bool = False,

@@ -88,4 +86,2 @@ ) -> Message:

List of components to send with the message
attachments: List[Attachment] | Attachment
List of attachments to send with the message
ephemeral: bool

@@ -104,4 +100,2 @@ Will the message show publically or privately

components = [components]
if isinstance(attachments, Attachment):
attachments = [attachments]

@@ -114,7 +108,2 @@ message_body = {

],
"attachments": [
{"id": i, "filename": att.filename, "description": att.description}
for i, att in enumerate(attachments)
if isinstance(att, Attachment)
],
}

@@ -125,10 +114,2 @@

files = None
if attachments:
files = [
{"id": i, "filename": att.filename, "content": att.content}
for i, att in enumerate(attachments)
if isinstance(att, Attachment)
]
maybe_message = await self._app.make_https_request(

@@ -138,3 +119,2 @@ "POST",

payload=message_body,
files=files,
)

@@ -141,0 +121,0 @@

@@ -0,0 +0,0 @@ from .. import utils

@@ -0,0 +0,0 @@ from .. import utils

@@ -32,3 +32,2 @@ from __future__ import annotations

self.embeds: list | list[dict] = raw_message["embeds"]
self.attachments: list | list[dict] = raw_message.get("attachements")
self.content: str = raw_message["content"]

@@ -35,0 +34,0 @@ self.interaction_token: str | None = token

@@ -0,0 +0,0 @@ from .. import utils

@@ -0,0 +0,0 @@ from __future__ import annotations

import asyncio
import importlib
import json
import mimetypes
import time

@@ -102,3 +100,2 @@

payload: None | dict = None,
files: None | dict = None,
override_checks: bool = False,

@@ -112,2 +109,3 @@ ):

The method to use. Can be either: GET, PUT, PATCH, DELETE, POST
url: str

@@ -121,38 +119,17 @@ The url to make the request to. If performing a request to discord, do not include

The payload to send to the url. Only applicable for POST, PUT, and PATCH requests.
files: Optional[list]
A list of dictionaries with 'id', 'filename' and 'content'.
"""
if not url.startswith("https://"):
url = "https://discord.com/api/v10/" + url
if headers is None and self.config["BOT_TOKEN"] is not None:
headers = {"Authorization": "Bot " + self.config["BOT_TOKEN"]}
elif headers is None:
headers = self.auth()
if files:
data = aiohttp.FormData()
if payload:
data.add_field(
"payload_json",
json.dumps(payload),
content_type="application/json",
)
for file in files:
content_type, _ = mimetypes.guess_type(file["filename"])
if content_type is None:
content_type = "application/octet-stream"
data.add_field(
f"files[{file['id']}]",
file["content"],
filename=file["filename"],
content_type=content_type,
)
request_kwargs = {"data": data}
if headers is not None:
_headers = headers
elif headers is None and self.config["BOT_TOKEN"] is not None:
_headers = {"Authorization": "Bot " + self.config["BOT_TOKEN"]}
else:
request_kwargs = {"json": payload} if payload else {}
_headers = self.auth()
async with aiohttp.ClientSession() as session:
async with session.request(
method, url, headers=headers, **request_kwargs
method, url, headers=_headers, json=payload
) as maybe_response:

@@ -159,0 +136,0 @@ if override_checks:

@@ -0,0 +0,0 @@ from enum import Enum, IntEnum

class Attachment:
def __init__(self, filename: str, content: bytes, description: str = None):
self._filename = filename
self._content = content
self._description = description
@property
def filename(self) -> str:
return self._filename
@filename.setter
def filename(self, value: str) -> None:
self._filename = value
@property
def description(self) -> str:
return self._description
@description.setter
def description(self, value: str) -> None:
self._description = value
@property
def content(self) -> bytes:
return self._content
@content.setter
def content(self, value: bytes) -> None:
self._content = value
def as_dict(self) -> dict:
return {
"filename": self._filename,
"description": self._description,
"content": self._content,
}