async def play(self, ctx, *, query: str): player = self.zt.lavalink.players.get(ctx.guild.id) query = query.strip('<>') if not query.startswith('scsearch:') and not query.startswith('ytsearch:') and not re.compile('https?:\\/\\/(?:www\\.)?.+').match(query): query = f'ytsearch:{query}' results = await player.node.get_tracks(query) embed = utils.baseEmbed() if not results or not results['tracks']: embed.description = f'<{self.zt.emoji("Error")}> **| Não foi encontrado nada com esses termos.**' return await ctx.send(embed=embed) if results['loadType'] == 'PLAYLIST_LOADED': tracks = results['tracks'] for track in tracks: player.add(requester=ctx.author.id, track=track) embed.description = f'**<{self.zt.emoji("Verificado")}> | Playlist `{results["playlistInfo"]["name"]}` adicionada a queue.**' await ctx.send(embed=embed) else: track = results['tracks'][0] embed.description = f'**<{self.zt.emoji("Verificado")}> | [{track["info"]["title"]}]({track["info"]["uri"]}) adicionada a queue.**' await ctx.send(embed=embed) player.add(requester=ctx.author.id, track=track) if not player.is_playing: await player.play()
async def find(self, ctx, *, query): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not query.startswith('ytsearch:') and not query.startswith('scsearch:'): query = 'ytsearch:' + query results = await player.node.get_tracks(query) if not results or not results['tracks']: embed.description = f'{self.zt.emoji("Error")}** | Não foi encontrado nada com esses termos.**' return await ctx.send(embed=embed) tracks = results['tracks'][:9] embed.description = '**' for index, track in enumerate(tracks, start=1): track_title = track['info']['title'] track_uri = track['info']['uri'] embed.description += f'<{self.zt.emoji(f"{index}_")}> [{track_title}]({track_uri})\n\n' embed.description += '**' r = await ctx.send(embed=embed) for emoji in list(range(1, len(tracks)+1)): await r.add_reaction(self.zt.emoji(f"{emoji}_")) await asyncio.sleep(0.2)
async def ensure_voice(self, ctx): embed = utils.baseEmbed() player = self.zt.lavalink.players.create(ctx.guild.id, endpoint=ctx.guild.region.value) should_connect = ctx.command.name in ('play', 'connect') if ctx.guild.id == 498011182620475412 and not 529365459397509130 in [role.id for role in ctx.author.roles]: raise commands.CheckFailure() if not ctx.author.voice or not ctx.author.voice.channel: embed.description = f'<{self.zt.emoji("Error")}> **| Você precisa estar em um canal de voz.**' await ctx.send(embed=embed) raise commands.CheckFailure() if not player.is_connected: if not should_connect: embed.description = f'<{self.zt.emoji("Error")}> **| Não estou conectada.**' await ctx.send(embed=embed) raise commands.CheckFailure() player.store('channel', ctx.channel.id) await self.connect_to(ctx.guild.id, str(ctx.author.voice.channel.id)) else: if int(player.channel_id) != ctx.author.voice.channel.id: embed.description = f'<{self.zt.emoji("Error")}> **| Você precisa estar no meu canal de voz.**' await ctx.send(embed=embed) raise commands.CheckFailure()
async def shuffle(self, ctx): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.is_playing: embed.description = f'<{self.zt.emoji("Error")}> **| Eu não estou tocando.**' return await ctx.send(embed=embed) player.shuffle = not player.shuffle embed.description = f'**<{self.zt.emoji("Verificado")}> | Shuffle ' + ('ativado' if player.shuffle else 'desativado') + ' com sucesso.**' await ctx.send(embed=embed)
async def track_hook(self, event): embed = utils.baseEmbed() if isinstance(event, TrackStartEvent): pass elif isinstance(event, TrackEndEvent): pass elif isinstance(event, QueueEndEvent): pass
async def volume(self, ctx, volume: int = None): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not volume: embed.description = f'**<{self.zt.emoji("Speaker")}> |{player.volume}%**' return await ctx.send(embed=embed) await player.set_volume(volume) await ctx.send(f'**<{self.zt.emoji("Speaker")}> | Volume alterado para {player.volume}%.**')
async def stop(self, ctx): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.is_playing: embed.description = f'**<{self.zt.emoji("Error")}> | Eu não estou tocando.**' return await ctx.send(embed=embed) player.queue.clear() await player.stop() embed.description = f'**<{self.zt.emoji("Verificado")}> | Player parado com sucesso.**' await ctx.send(embed=embed)
async def disconnect(self, ctx): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.is_connected: embed.description = f'<{self.zt.emoji("Error")}> **| Eu não estou conectado.**' return await ctx.send(embed=embed) player.queue.clear() await player.stop() await self.connect_to(ctx.guild.id, None) embed.description = f'<{self.zt.emoji("Verificado")}> **| Desconectado com sucesso.**' await ctx.send(embed=embed)
async def pause(self, ctx): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.is_playing: embed.description = f'<{self.zt.emoji("Error")}> **| Eu não estou tocando.**' return await ctx.send(embed=embed) if player.paused: await player.set_pause(False) await ctx.send(f'<{self.zt.emoji("Verificado")}> **| Música retomada com sucesso.**') else: await player.set_pause(True) await ctx.send(f'<{self.zt.emoji("Verificado")}> **| Música pausada com sucesso.**')
async def remove(self, ctx, index: int): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.queue: embed.description = f'<{self.zt.emoji("Error")}> **| Minha queue está vazia.**' return await ctx.send(embed=embed) if index > len(player.queue) or index < 1: embed.description = f'<{self.zt.emoji("Error")}> **| O número deve ser entre 1 e {len(player.queue)}.**' return await ctx.send(embed=embed) index -= 1 removed = player.queue.pop(index) embed.description = f'<{self.zt.emoji("Verificado")}> **| [{removed.title}]({removed.uri}) removida da queue com sucesso.**' await ctx.send(embed=embed)
async def now(self, ctx): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.current: embed.description = f'<{self.zt.emoji("Error")}> **| Eu não estou tocando.**' return await ctx.send(embed=embed) position = lavalink.utils.format_time(player.position) if player.current.stream: duration = 'Ao vivo' else: duration = lavalink.utils.format_time(player.current.duration) song = f'**[{player.current.title}]({player.current.uri})**\n({position}/{duration})' embed.description = song await ctx.send(embed=embed)
async def seek(self, ctx, *, time: str=''): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) seconds = re.compile('[0-9]+').search(time) if time == '' or not seconds: embed.description = f'<{self.zt.emoji("Error")}> **| Você precisa especificar o tempo para alterar a posição.**' return await ctx.send(embed=embed) seconds = int(seconds.group()) * 1000 if time.startswith('-'): seconds *= -1 track_time = player.position + seconds await player.seek(track_time) embed.description = f'**<{self.zt.emoji("Verificado")}> | Posição alterada para `{lavalink.utils.format_time(track_time)}`.**' await ctx.send(embed=embed)
async def img(self, ctx, *, tag: str = None): embed = utils.baseEmbed() if tag is None: embed.description = f'<{self.zt.emoji("Error")}> **| Você não especificou uma tag. Use `zt.img tags`.**' return await ctx.send(embed=embed) tag = tag.lower() if tag == 'tags' or tag == 'tag': embed.description = ('**' + ' - '.join( [f'`{tag}`' for tag in await self.naegin.get_all_tags()]) + '**').title() return await ctx.send(embed=embed) if not tag in (await self.naegin.get_all_tags()): embed.description = f'<{self.zt.emoji("Error")}> **| Insira uma tag válida. Use `zt.img tags`.**' return await ctx.send(embed=embed) img = await self.naegin.get_random(tag) if not ctx.channel.nsfw and img.nsfw: embed.description = f'<{self.zt.emoji("Error")}> **| Só posso enviar isso em canais nsfw.**' return await ctx.send(embed=embed) embed.set_image(url=img.url) await ctx.send(embed=embed)
async def skip(self, ctx, *, num: int=None): embed = utils.baseEmbed() player = self.zt.lavalink.players.get(ctx.guild.id) if not player.is_playing: embed.description = f'<{self.zt.emoji("Error")}> **| Eu não estou tocando.**' return await ctx.send(embed=embed) if num is None: await player.skip() embed.description = f'<{self.zt.emoji("Verificado")}> **| Música pulada.**' return await ctx.send(embed=embed) if num > len(player.queue) or num <0: embed.description = f'<{self.zt.emoji("Error")}> **| Digite um número valido.**' return await ctx.send(embed=embed) index = 0 while index < num: await player.skip() index += 1 embed.description = f'<{self.zt.emoji("Verificado")}> **| {num} músicas puladas.**' await ctx.send(embed=embed)
async def botinfo(self, ctx): thomas = await self.zt.get_user_info(171715191992483840) shiba = await self.zt.get_user_info(355750436424384524) lrv = await self.zt.get_user_info(286589600452050954) djinn = await self.zt.get_user_info(376460601909706773) ssd = psutil.disk_usage('/') memory = psutil.virtual_memory() uptime = getuptime(self.zt, ctx).replace("I'm online at ", '').replace("Ich bin online bei ", '').replace("Estoy en línea ", '').replace("Estou online à ", '') embed = baseEmbed() \ .set_author(name=str(self.zt.user), icon_url=self.zt.user.avatar_url) \ .add_field(name=f'<{self.zt.emoji("Moderator")}> Criadores:', value=f'`{thomas}\n{shiba}`') \ .add_field(name=f'<{self.zt.emoji("UserGroups")}> Ajudantes:', value=f'`{lrv}\n{djinn}`') \ .add_field(name=f'<{self.zt.emoji("Right")}> Prefixos:', value='`zt `, `zt.`, `02 `, `002`') \ .add_field(name=f'<{self.zt.emoji("MembershipCard")}> ID:', value=f'`{self.zt.user.id}`') \ .add_field(name=f'<{self.zt.emoji("RAM")}> Memória RAM usada:', value=f'`{"%.2f" % (memory.used/1024**3)}GB/{"%.2f" % (memory.total/1024**3)}GB ({memory.percent}%)`') \ .add_field(name=f'<{self.zt.emoji("SSD")}> Armazenamento usado:', value=f'`{"%.2f" % (ssd.used/1024**3)}GB/{"%.2f" % (ssd.total/1024**3)}GB ({ssd.percent}%)`') \ .add_field(name=f'<{self.zt.emoji("Electronics")}> CPU:', value=f'`{info[0]["cpu cores"]} x {info[0]["model name"]}`', inline=False) \ .add_field(name=f'<{self.zt.emoji("Signal")}> Ping:', value=f'`{"%.0f" % (self.zt.latencies[ctx.guild.shard_id][1]*1000)}ms`') \ .add_field(name=f'<{self.zt.emoji("Discord")}> Api:', value=f'`discord.py {discord.__version__}`') \ .add_field(name=f'<{self.zt.emoji("Python")}> Linguagem de programação:', value='`Python`')# \ # .add_field(name=f'<{self.zt.emoji("Clock")}> Uptime:', value=f'`{uptime}`') await ctx.send(embed=embed)
async def ping_(self, ctx): embed = baseEmbed() embed.description = f'**<{self.zt.emoji("Signal")}> | {"%.0f" % (self.zt.latencies[ctx.guild.shard_id][1]*1000)}ms**' await ctx.send(embed=embed)
async def lol(self, ctx): def check3(m): return m.content and m.author == ctx.author embed = utils.baseEmbed() embed.description = self.zt.lang(ctx, "Lol")["Embed2"][0] embed.timestamp = ctx.message.created_at a = await ctx.send(embed=embed) await ctx.message.delete() try: msg = await self.zt.wait_for('message', check=check3, timeout=180) region = msg.content cass.set_default_region(region) embed1 = utils.baseEmbed() embed1.description = self.zt.lang(ctx, "Lol")["Embed2"][1] embed1.timestamp = ctx.message.created_at await a.edit(embed=embed1) try: await msg.delete() except: pass msg2 = await self.zt.wait_for('message', check=check3, timeout=180) nickname = msg2.content summoner = cass.get_summoner(name=nickname) try: await msg2.delete() except: pass await a.delete() champ = " " try: for mastery in summoner.champion_masteries[:5]: champ += ("**• {}:** ``{}``\n".format( mastery.champion.name, mastery.points).replace(" ", "")) except: pass embed2 = utils.baseEmbed() embed2.description = "**Perfil de " + summoner.name + "**" embed2.timestamp = ctx.message.created_at embed2.set_thumbnail(url=summoner.profile_icon.url) embed2.add_field(name=self.zt.lang(ctx, "Lol")["Embed"][0], value=f'**{summoner.name}**', inline=False) embed2.add_field(name=self.zt.lang(ctx, "Lol")["Embed"][1], value=f'**{summoner.level}**', inline=False) try: embed2.add_field(name=self.zt.lang(ctx, "Lol")["Embed"][2], value=f'**{summoner.rank_last_season}**', inline=False) except: pass try: embed2.add_field(name=self.zt.lang(ctx, "Lol")["Embed"][3], value=(f'\n{champ}').replace("[", "").replace( "'", "").replace("]", "").replace( ",", "\n").replace('"', ''), inline=False) except: pass await ctx.send(embed=embed2) except Exception as e: embed3 = utils.baseEmbed() embed3.description = f'<{self.zt.emoji("Error")}> **| {self.zt.lang(ctx, "Lol")["Embed"][4]}**' await ctx.send(embed=embed3)