add discord file to bytesio util function

This commit is contained in:
LBlend committed 2023-05-10 01:44:09 +09:00
1 parent e5d1424cda
commit 1d5d0ab5cd
1 file changed
+21
+21
View File
@@ -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"""