Stylish update

This commit is contained in:
Rafael Vargas
2022-01-08 17:07:02 -04:00
parent 13bc51fae7
commit ef2d7bb8fa
10 changed files with 228 additions and 180 deletions

View File

@@ -15,7 +15,7 @@ class Control(commands.Cog):
'WARFRAME': ['warframe'],
'RANDOM': ['escolha', 'cara', 'random'],
'HELP': ['help'],
'OTHERS': ['frase', 'drop']
'OTHERS': ['frase']
}
@commands.Cog.listener()
@@ -27,21 +27,36 @@ class Control(commands.Cog):
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, MissingRequiredArgument):
await ctx.channel.send(f'Falta argumentos. Digite {config.BOT_PREFIX}help para ver todos os comandos\n\nOu tente {config.BOT_PREFIX}command help para mais informações')
elif isinstance(error, CommandNotFound):
await ctx.channel.send(f'O comando não existe')
else:
await ctx.channel.send(f'Teve um erro aí bicho')
raise error
embed = discord.Embed(
title=config.ERROR_TITLE,
description=config.ERROR_MISSING_ARGUMENTS,
colour=config.COLOURS['red']
)
await ctx.send(embed=embed)
@commands.command(name="help", alisases=['ajuda'], help=config.HELP_HELP)
elif isinstance(error, CommandNotFound):
embed = discord.Embed(
title=config.ERROR_TITLE,
description=config.COMMAND_NOT_FOUND,
colour=config.COLOURS['red']
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title=config.ERROR_TITLE,
description=config.UNKNOWN_ERROR,
colour=config.COLOURS['red']
)
await ctx.send(embed=embed)
@commands.command(name="help", help=config.HELP_HELP, alisases=['h', 'ajuda'])
async def help_msg(self, ctx):
helptxt = ''
help_music = '-- MUSIC\n'
help_random = '-- RANDOM\n'
help_warframe = '-- WARFRAME\n'
help_help = '-- HELP\n'
help_others = '-- OTHERS\n'
help_music = '🎧 `MUSIC`\n'
help_random = '🎲 `RANDOM`\n'
help_warframe = '🎮 `WARFRAME`\n'
help_help = '👾 `HELP`\n'
help_others = '🕹️ `OTHERS`\n'
for command in self.__bot.commands:
if command.name in self.__comandos['MUSIC']:
@@ -58,9 +73,9 @@ class Control(commands.Cog):
helptxt = f'{help_music}\n{help_warframe}\n{help_random}\n{help_others}\n{help_help}'
embedhelp = discord.Embed(
colour=config.COLOURS['grey'],
title=f'Comandos do {self.__bot.user.name}',
description=helptxt
title=f'**Available Commands of {self.__bot.user.name}**',
description=helptxt,
colour=config.COLOURS['blue']
)
embedhelp.set_thumbnail(url=self.__bot.user.avatar_url)

View File

@@ -7,35 +7,35 @@ from vulkan.music.utils import *
class Music(commands.Cog):
def __init__(self, bot):
def __init__(self, bot) -> None:
self.__guilds = {}
self.__bot: discord.Client = bot
@commands.Cog.listener()
async def on_ready(self):
async def on_ready(self) -> None:
for guild in self.__bot.guilds:
self.__guilds[guild] = Player(self.__bot, guild)
@commands.command(name="play", help=config.HELP_PLAY, aliases=['p', 'tocar'])
async def play(self, ctx, *args):
user_input = " ".join(args)
async def play(self, ctx, *args) -> None:
track = " ".join(args)
requester = ctx.author.name
player = self.__get_player(ctx)
if player == None:
await self.__send_embed(ctx, description=config.NO_GUILD, colour_name='red')
await self.__send_embed(ctx, config.ERROR_TITLE, config.NO_GUILD, 'red')
return
if is_connected(ctx) == None:
result = await player.connect(ctx)
if result['success'] == False:
await self.__send_embed(ctx, description=result['reason'], colour_name='red')
success = await player.connect(ctx)
if success == False:
await self.__send_embed(ctx, config.ERROR_TITLE, config.NO_CHANNEL, 'red')
return
await player.play(ctx, user_input, requester)
await player.play(ctx, track, requester)
@commands.command(name="queue", help=config.HELP_QUEUE, aliases=['q', 'fila'])
async def queue(self, ctx):
async def queue(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
@@ -43,8 +43,8 @@ class Music(commands.Cog):
embed = await player.queue()
await ctx.send(embed=embed)
@commands.command(name="skip", help=config.HELP_SKIP, aliases=['pular'])
async def skip(self, ctx):
@commands.command(name="skip", help=config.HELP_SKIP, aliases=['s', 'pular'])
async def skip(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
@@ -52,7 +52,7 @@ class Music(commands.Cog):
await player.skip()
@commands.command(name='stop', help=config.HELP_STOP, aliases=['parar'])
async def stop(self, ctx):
async def stop(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
@@ -60,37 +60,36 @@ class Music(commands.Cog):
await player.stop()
@commands.command(name='pause', help=config.HELP_PAUSE, aliases=['pausar'])
async def pause(self, ctx):
async def pause(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
print('No player')
return
else:
success = await player.pause()
if success:
await self.__send_embed(ctx, description='Song paused', colour_name='blue')
await self.__send_embed(ctx, config.SONG_PLAYER, config.SONG_PAUSED, 'blue')
@commands.command(name='resume', help=config.HELP_RESUME, aliases=['soltar'])
async def resume(self, ctx):
async def resume(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
else:
success = await player.resume()
if success:
await self.__send_embed(ctx, description='Song Playing', colour_name='blue')
await self.__send_embed(ctx, config.SONG_PLAYER, config.SONG_RESUMED, 'blue')
@commands.command(name='loop', help=config.HELP_LOOP, aliases=['repeat'])
async def loop(self, ctx, args: str):
@commands.command(name='loop', help=config.HELP_LOOP, aliases=['l', 'repeat'])
async def loop(self, ctx, args: str) -> None:
player = self.__get_player(ctx)
if player == None:
return
else:
result = await player.loop(args)
await self.__send_embed(ctx, description=result, colour_name='blue')
description = await player.loop(args)
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
@commands.command(name='clear', help=config.HELP_CLEAR, aliases=['limpar'])
async def clear(self, ctx):
@commands.command(name='clear', help=config.HELP_CLEAR, aliases=['c', 'limpar'])
async def clear(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
@@ -98,7 +97,7 @@ class Music(commands.Cog):
await player.clear()
@commands.command(name='np', help=config.HELP_NP, aliases=['playing', 'now'])
async def now_playing(self, ctx):
async def now_playing(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
@@ -108,45 +107,44 @@ class Music(commands.Cog):
await ctx.send(embed=embed)
@commands.command(name='shuffle', help=config.HELP_SHUFFLE, aliases=['aleatorio'])
async def shuffle(self, ctx):
async def shuffle(self, ctx) -> None:
player = self.__get_player(ctx)
if player == None:
return
else:
result = await player.shuffle()
await self.__send_embed(ctx, description=result, colour_name='blue')
description = await player.shuffle()
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
@commands.command(name='move', help=config.HELP_MOVE, aliases=['mover'])
async def move(self, ctx, pos1, pos2='1'):
@commands.command(name='move', help=config.HELP_MOVE, aliases=['m', 'mover'])
async def move(self, ctx, pos1, pos2='1') -> None:
player = self.__get_player(ctx)
if player == None:
return
else:
result = await player.move(pos1, pos2)
await self.__send_embed(ctx, description=result, colour_name='blue')
description = await player.move(pos1, pos2)
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
@commands.command(name='remove', help=config.HELP_REMOVE, aliases=['remover'])
async def remove(self, ctx, position):
"""Remove a song from the queue in the position"""
async def remove(self, ctx, position) -> None:
player = self.__get_player(ctx)
if player == None:
return
else:
result = await player.remove(position)
await self.__send_embed(ctx, description=result, colour_name='blue')
description = await player.remove(position)
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
@commands.command(name='reset', help=config.HELP_RESET, aliases=['resetar'])
async def reset(self, ctx):
async def reset(self, ctx) -> None:
player = self.__get_player(ctx)
if player != None:
await player.stop()
self.__guilds[ctx.guild] = Player(self.__bot, ctx.guild)
async def __send_embed(self, ctx, title='', description='', colour_name='grey'):
async def __send_embed(self, ctx, title='', description='', colour='grey') -> None:
try:
colour = config.COLOURS[colour_name]
except Exception as e:
colour = config.COLOURS[colour]
except:
colour = config.COLOURS['grey']
embedvc = discord.Embed(
@@ -156,8 +154,7 @@ class Music(commands.Cog):
)
await ctx.send(embed=embedvc)
async def __clean_messages(self, ctx):
"""Clear Bot messages if send recently"""
async def __clean_messages(self, ctx) -> None:
last_messages = await ctx.channel.history(limit=5).flatten()
for message in last_messages:
@@ -165,12 +162,12 @@ class Music(commands.Cog):
if message.author == self.__bot.user:
if len(message.embeds) > 0:
embed = message.embeds[0]
if embed.title == 'Song Playing Now' or embed.title == 'Song Looping Now':
if embed.title in config.SONGS_PLAYING_TITLES:
await message.delete()
except:
continue
def __get_player(self, ctx):
def __get_player(self, ctx) -> Player:
try:
return self.__guilds[ctx.guild]
except:

View File

@@ -36,6 +36,7 @@ class Phrases(commands.Cog):
while True:
tries += 1
if tries > config.MAX_API_PHRASES_TRIES:
return config.ERROR_WHILE_REQUEST
return 'O banco de dados dos cara tá off, bando de vagabundo, tenta depois aí bicho'
try:
@@ -51,7 +52,7 @@ class Phrases(commands.Cog):
text = f'{phrase} \nBy: {author}'
return text
except Exception as e:
except:
continue