Moving
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import logging
|
||||
import lib
|
||||
|
||||
from os import path, makedirs, rename, remove
|
||||
from discord.ext import commands
|
||||
|
||||
from disnake.ext import commands
|
||||
|
||||
import lib
|
||||
|
||||
|
||||
class Audio(commands.Cog):
|
||||
@@ -34,7 +35,8 @@ class Audio(commands.Cog):
|
||||
|
||||
await at.save(f'tmp/{user.id}/{at.filename}')
|
||||
guess = mimetypes.guess_type(f'tmp/{user.id}/{at.filename}')
|
||||
if guess[0]:
|
||||
await ctx.reply(f'it`s {guess}')
|
||||
if guess[0].split('/')[0] == 'audio':
|
||||
from pymediainfo import MediaInfo
|
||||
file = f'tmp/{user.id}/{at.filename}'
|
||||
duration = round(MediaInfo.parse(file).tracks[0].duration / 1000)
|
||||
@@ -50,13 +52,13 @@ class Audio(commands.Cog):
|
||||
|
||||
lib.DB.add_audio(ctx.guild.id, user.id, audiolist)
|
||||
rename(f'tmp/{user.id}/{at.filename}', f'audio/{user.id}/{at.filename}')
|
||||
else:
|
||||
await ctx.reply(f'Failed to find MIME type of {at.filename}', ephemeral=True)
|
||||
elif guess[0].split('/')[0] != 'audio':
|
||||
await ctx.reply(f'It not audio {at.filename}\n it`s {guess[0]}')
|
||||
remove(f'tmp/{user.id}/{at.filename}')
|
||||
else:
|
||||
await ctx.reply("Has no Attachment", ephemeral=True)
|
||||
await ctx.reply("Has no Attachment")
|
||||
else:
|
||||
await ctx.reply(f'You`re not admin. You can add audio only for your own account', ephemeral=True)
|
||||
await ctx.reply(f'You`re not admin. You can add audio only for your own account')
|
||||
|
||||
|
||||
def setup(bot): # an extension must have a setup function
|
||||
|
||||
Reference in New Issue
Block a user