mirror of
https://github.com/UiO-Gaming/mustafa.git
synced 2026-11-05 13:56:48 +01:00
add discord file to bytesio util function
This commit is contained in:
1 file changed
+21
@@ -1,3 +1,5 @@
|
||||
from io import BytesIO
|
||||
|
||||
import discord
|
||||
|
||||
from .misc_utils import Paginator
|
||||
@@ -22,6 +24,25 @@ def get_color(discord_object: discord.User | discord.Member | discord.Role) -> d
|
||||
return discord.Colour(0x99AAB5)
|
||||
|
||||
|
||||
async def get_file_bytesio(file: discord.Attachment | discord.Asset) -> BytesIO:
|
||||
"""
|
||||
Returns a BytesIO object of the file
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
file (discord.Attatchment | discord.Asset): The file to get the BytesIO object of
|
||||
|
||||
Returns
|
||||
-----------
|
||||
(BytesIO): The file as a BytesIO object
|
||||
"""
|
||||
|
||||
input = BytesIO()
|
||||
input.write(await file.read())
|
||||
input.seek(0)
|
||||
return input
|
||||
|
||||
|
||||
class ScrollerButton(discord.ui.Button):
|
||||
"""Button that scrolls through pages in a scroller view"""
|
||||
|
||||
|
||||
Reference in new issue
Block a user