Improve file naming
This commit is contained in:
parent
eb55f0a3cb
commit
af5166767f
1 changed files with 4 additions and 1 deletions
|
@ -4,6 +4,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
import typing
|
import typing
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
|
||||||
|
@ -140,10 +141,12 @@ class FFMeta(commands.Cog):
|
||||||
] = False
|
] = False
|
||||||
):
|
):
|
||||||
"""Converts a given URL or attachment to an Opus file"""
|
"""Converts a given URL or attachment to an Opus file"""
|
||||||
|
filename = "opusinated.ogg"
|
||||||
if url is None:
|
if url is None:
|
||||||
if attachment is None:
|
if attachment is None:
|
||||||
return await ctx.respond("No URL or attachment provided")
|
return await ctx.respond("No URL or attachment provided")
|
||||||
url = attachment.url
|
url = attachment.url
|
||||||
|
filename = str(Path(attachment.filename).with_suffix(".ogg"))
|
||||||
|
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
channels = 2 if not mono else 1
|
channels = 2 if not mono else 1
|
||||||
|
@ -219,7 +222,7 @@ class FFMeta(commands.Cog):
|
||||||
file = io.BytesIO(stdout)
|
file = io.BytesIO(stdout)
|
||||||
if (fs := len(file.getvalue())) > (24.75 * 1024 * 1024):
|
if (fs := len(file.getvalue())) > (24.75 * 1024 * 1024):
|
||||||
return await ctx.respond("The file is too large to send ({:,.2f} MiB).".format(fs / 1024 / 1024))
|
return await ctx.respond("The file is too large to send ({:,.2f} MiB).".format(fs / 1024 / 1024))
|
||||||
await ctx.respond(file=discord.File(file, filename="opusinated.ogg"))
|
await ctx.respond(file=discord.File(file, filename=filename))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
|
|
Loading…
Reference in a new issue