Skip to content

Commit

Permalink
i love debugging in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilgames32 committed Sep 7, 2024
1 parent ddb381f commit c7234e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ gif-collections.json
__pycache__/
.venv/
.env
.vscode/
.vscode/
*.sh
14 changes: 9 additions & 5 deletions cogs/captioncog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from discord import app_commands
from discord.ext import commands

import io

from util.msgutil import devcheck, errorembed, errorrespond

from caption.src.pipeline import caption
import neptunfej
import neptunfej.generate

class CaptionCog(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
Expand All @@ -16,7 +18,7 @@ def __init__(self, bot: commands.Bot) -> None:
@app_commands.allowed_installs(guilds=True, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
@app_commands.command(name="caption", description="caption media")
async def captioning(self, interaction: discord.Interaction, link: str = None, text: str = "forgot the caption", image: discord.Attachment = None, force_gif: bool = False, gif_transparency: bool = False) -> None:
async def captioning(self, interaction: discord.Interaction, link: str = None, text: str = "forgot the caption", image: discord.Attachment = None, force_gif: bool = False, gif_transparency: bool = False, echo: bool = False) -> None:
if not await devcheck(interaction):
return

Expand All @@ -30,7 +32,7 @@ async def captioning(self, interaction: discord.Interaction, link: str = None, t
await interaction.response.defer()
try:
out = caption(link, text, force_gif, gif_transparency)
await interaction.followup.send(text, file=discord.File(out))
await interaction.followup.send(text if echo else None, file=discord.File(out))
except Exception as e:
await interaction.followup.send(embed=errorembed(str(e)))

Expand All @@ -44,8 +46,10 @@ async def neptun(self, interaction: discord.Interaction, text: str = "forgot the

await interaction.response.defer()
try:
out = neptunfej.generate(text, 2, (10, 10))
await interaction.followup.send(text, file=discord.File(out))
with io.BytesIO() as image_binary:
neptunfej.generate.neptunfej(text, 2, (10, 10)).save(image_binary, "png")
image_binary.seek(0)
await interaction.followup.send(file=discord.File(image_binary, "neptun.png"))
except Exception as e:
await interaction.followup.send(embed=errorembed(str(e)))

Expand Down
2 changes: 1 addition & 1 deletion neptunfej
Submodule neptunfej updated 1 files
+7 −8 generate.py

0 comments on commit c7234e6

Please sign in to comment.