Skip to content

Commit

Permalink
style: Please my proper convention
Browse files Browse the repository at this point in the history
B1ue-Dev committed May 17, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 852a5c9 commit 1364302
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/exts/fun/ascii.py
Original file line number Diff line number Diff line change
@@ -115,7 +115,6 @@ async def text(
i = Image.new("RGB", (2000, 1000))
img = ImageDraw.Draw(i)
ascii_text = pyfiglet.figlet_format(text, width=150)
print(ascii_text)
size = img.textbbox((1, 1), ascii_text)
text_width, text_height = (size[2] - size[0], size[3] - size[1])
imgs = Image.new("RGB", (text_width + 30, text_height))
3 changes: 2 additions & 1 deletion src/exts/fun/fun.py
Original file line number Diff line number Diff line change
@@ -140,6 +140,7 @@ async def quote(self, ctx: HybridContext) -> None:
async def xkcd(self, ctx: HybridContext, page: int = None) -> None:
"""Sends a xkcd comic page."""

await ctx.defer()
url = "https://xkcd.com/info.0.json"
resp = await get_response(url)
newest = resp["num"]
@@ -166,7 +167,7 @@ async def xkcd(self, ctx: HybridContext, page: int = None) -> None:
author = interactions.EmbedAuthor(
name=f"{title}",
url=f"https://xkcd.com/{page}/",
icon_url="https://camo.githubusercontent.com/8bd4217be107c9c190ef649b3d1550841f8b45c32fc0b71aa851b9107d70cdea/68747470733a2f2f6173736574732e7365727661746f6d2e636f6d2f786b63642d626f742f62616e6e6572332e706e67",
icon_url="https://xkcd.com/s/0b7742.png",
)
embed = interactions.Embed(
description=alt,
19 changes: 10 additions & 9 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

import logging
import math
import io
from io import BytesIO, StringIO
from typing import Union
from enum import Enum
from datetime import datetime, timedelta, timezone
@@ -24,8 +24,8 @@ class tags(Document):


async def get_response(
url: str = None, params: dict = None, headers: dict = None
) -> io.BytesIO | dict | None:
url: str, params: dict | None = None, headers: dict | None = None
) -> dict | BytesIO | None:
"""Return the data type from the request."""

async with aiohttp.ClientSession() as session:
@@ -38,7 +38,7 @@ async def get_response(
"image/jpeg",
"image/gif",
}:
return io.BytesIO(await resp.read())
return BytesIO(await resp.read())
else:
logging.critical(f"{url} returned {resp.status}.")
return None
@@ -53,7 +53,7 @@ def natural_size(size_in_bytes: int) -> str:
return f"{size_in_bytes / (1024 ** power):.2f} {units[power]}"


def timestamp(times: str) -> int:
def timestamp(times: str) -> str:
"""Return the round() format of a timestamp."""

res = int(f"{times.timestamp():.0f}")
@@ -110,21 +110,21 @@ def pretty_date(time: int) -> str:
return str(day_diff // 365) + " years ago"


def send_as_file(text: str) -> io.StringIO:
def send_as_file(text: str) -> StringIO:
"""Converts a text into a bytesteam object."""

_io = io.StringIO(text)
_io = StringIO(text)
_io.seek(0)
return _io


def get_color(img) -> str:
def get_color(img) -> int:
"""
Get the dominant color of an image.
:param img: The image.
:type img:
:return: The dominant color hex.
:rtype: str
:rtype: int
"""

clr_thief = ColorThief(img)
@@ -210,6 +210,7 @@ class Permissions(Enum):
USE_SOUNDBOARD = 42
USE_EXTERNAL_SOUNDS = 45
SEND_VOICE_MESSAGES = 46
SEND_POLLS = 49


# https://discord.com/developers/docs/topics/permissions#permissions

0 comments on commit 1364302

Please sign in to comment.