Skip to content

Commit

Permalink
cleanup some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lovvskillz committed Jun 2, 2023
1 parent 731f8d3 commit c34f852
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 45 deletions.
2 changes: 1 addition & 1 deletion discord_webhook/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Entry point to trigger webhook(s). """
import sys
import argparse
import sys

from discord_webhook import DiscordWebhook

Expand Down
76 changes: 38 additions & 38 deletions discord_webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class DiscordEmbed:
Discord Embed
"""

title: Optional[str]
description: Optional[str]
url: Optional[str]
timestamp: Optional[str]
author: Optional[Dict[str, Optional[str]]]
color: Optional[int]
description: Optional[str]
fields: List[Dict[str, Optional[Any]]]
footer: Optional[Dict[str, Optional[str]]]
image: Optional[Dict[str, Optional[Union[str, int]]]]
provider: Optional[Dict[str, Any]]
thumbnail: Optional[Union[str, Dict[str, Optional[Union[str, int]]]]]
timestamp: Optional[str]
title: Optional[str]
url: Optional[str]
video: Optional[Union[str, Dict[str, Optional[Union[str, int]]]]]
provider: Optional[Dict[str, Any]]
author: Optional[Dict[str, Optional[str]]]
fields: List[Dict[str, Optional[Any]]]

def __init__(
self,
Expand All @@ -40,20 +40,20 @@ def __init__(
"""
Init Discord Embed
-----------
:keyword ``title:`` title of embed\n
:keyword ``description:`` description body of embed\n
:keyword ``url:`` add an url to make your embedded title a clickable
link\n
:keyword ``timestamp:`` timestamp of embed content\n
:keyword ``author:`` author information\n
:keyword ``color:`` color code of the embed as int\n
:keyword ``description:`` description body of embed\n
:keyword ``fields:`` fields information
:keyword ``footer:`` footer texts\n
:keyword ``image:`` your image url here\n
:keyword ``provider:`` provider information\n
:keyword ``thumbnail:`` your thumbnail url here\n
:keyword ``timestamp:`` timestamp of embed content\n
:keyword ``title:`` title of embed\n
:keyword ``url:`` add an url to make your embedded title a clickable
link\n
:keyword ``video:`` to apply video with embedded, your video source
url here\n
:keyword ``provider:`` provider information\n
:keyword ``author:`` author information\n
:keyword ``fields:`` fields information
"""
self.title = title
self.description = description
Expand Down Expand Up @@ -233,24 +233,24 @@ class DiscordWebhook:
Webhook for Discord
"""

url: str
id: Optional[str]
content: Optional[Union[str, bytes]]
username: Optional[str]
avatar_url: Optional[str]
tts: bool
allowed_mentions: List[str]
attachments: Optional[List[Dict[str, Any]]]
files: Dict[str, Tuple[Optional[str], Union[bytes, str]]]
avatar_url: Optional[str]
components: Optional[list]
content: Optional[Union[str, bytes]]
embeds: List[Dict[str, Any]]
files: Dict[str, Tuple[Optional[str], Union[bytes, str]]]
id: Optional[str]
proxies: Optional[Dict[str, str]]
allowed_mentions: List[str]
timeout: Optional[float]
rate_limit_retry: bool = False
timeout: Optional[float]
tts: bool
url: str
username: Optional[str]

def __init__(
self,
url: str,
*,
id: Optional[str] = None,
content: Optional[str] = None,
username: Optional[str] = None,
Expand Down Expand Up @@ -284,27 +284,27 @@ def __init__(
:keyword ``timeout:`` (optional) amount of seconds to wait for a
response from Discord
"""
if embeds is None:
embeds = []
if files is None:
files = {}
if allowed_mentions is None:
allowed_mentions = []
if attachments is None:
attachments = []
self.url = url
self.id = id
self.content = content
self.username = username
self.avatar_url = avatar_url
self.tts = tts
if embeds is None:
embeds = []
if files is None:
files = {}

self.allowed_mentions = allowed_mentions
self.attachments = attachments
self.avatar_url = avatar_url
self.content = content
self.files = files
self.embeds = embeds
self.id = id
self.proxies = proxies
self.allowed_mentions = allowed_mentions
self.timeout = timeout
self.rate_limit_retry = rate_limit_retry
self.timeout = timeout
self.tts = tts
self.url = url
self.username = username

def add_file(self, file: bytes, filename: str) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions discord_webhook/webhook_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

class ColorNotInRangeException(Exception):
"""
A valid color must take an integer value between 0 and 16777216 inclusive
This Exception will be raised when a color is not in that range.
This Exception will be raised when a colour is not in that range.
A valid color must take an integer value between 0 and 16777216 inclusive
"""

color: Union[str, int]
Expand Down
2 changes: 1 addition & 1 deletion examples/send_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from discord_webhook import DiscordEmbed, DiscordWebhook
from discord_webhook import DiscordWebhook

webhook = DiscordWebhook(url="your webhook url", username="Webhook with files")

Expand Down
3 changes: 1 addition & 2 deletions examples/use_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


async def send_webhook(message):
webhook = AsyncDiscordWebhook(url='your webhook url',
content=message)
webhook = AsyncDiscordWebhook(url='your webhook url', content=message)
await webhook.execute()


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ discord_webhook = "discord_webhook.__main__:main"
[tool.black]
line-length = 88
skip-string-normalization=true
experimental-string-processing = true
preview = true
target-version = ["py310"]
include = '\.pyi?$'
exclude = '''
Expand Down
File renamed without changes.

0 comments on commit c34f852

Please sign in to comment.