[fix]: Demotivator fix
This commit is contained in:
parent
b66deb3278
commit
5dac10f2fd
@ -9,6 +9,8 @@ from discord.ext import commands
|
|||||||
from os import remove
|
from os import remove
|
||||||
from os.path import splitext, join
|
from os.path import splitext, join
|
||||||
|
|
||||||
|
from simpledemotivators import Demotivator as Dem
|
||||||
|
|
||||||
tmp_dir = "tmp"
|
tmp_dir = "tmp"
|
||||||
|
|
||||||
class Fun(commands.Cog):
|
class Fun(commands.Cog):
|
||||||
@ -61,15 +63,11 @@ class Fun(commands.Cog):
|
|||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
async def demotivator(self, inter: discord.Interaction, title: str, text: str, image: discord.Attachment):
|
async def demotivator(self, inter: discord.Interaction, title: str, text: str, image: discord.Attachment):
|
||||||
logger.debug((title, text))
|
|
||||||
|
|
||||||
if not "image" in image.content_type:
|
if not "image" in image.content_type:
|
||||||
await inter.response.send_message("Это не изображение")
|
await inter.response.send_message("Это не изображение")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.debug("Meow")
|
|
||||||
filename = join("tmp", f"{inter.id}_{image.filename}")
|
filename = join("tmp", f"{inter.id}_{image.filename}")
|
||||||
logger.debug(filename)
|
|
||||||
await image.save(filename)
|
await image.save(filename)
|
||||||
Dem(title, text).create(filename, font_name="FreeSans.ttf")
|
Dem(title, text).create(filename, font_name="FreeSans.ttf")
|
||||||
with open('demresult.jpg', 'rb') as f:
|
with open('demresult.jpg', 'rb') as f:
|
||||||
|
Reference in New Issue
Block a user