Beispiel #1
0
 async def skip(self, ctx, arg: int = None):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_playing:
         embed = discord.Embed(title=get_lan(ctx.author.id,
                                             "music_not_playing"),
                               description='',
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         return await ctx.send(embed=embed)
     if arg is None:
         embed = discord.Embed(title=get_lan(ctx.author.id,
                                             "music_skip_next"),
                               description='',
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         await ctx.send(embed=embed)
         await player.skip()
     else:
         for i in range(arg):
             if not player.current:
                 arg = i
                 break
             await player.skip()
         embed = discord.Embed(
             title=get_lan(ctx.author.id,
                           "music_skip_many_music").format(music_count=arg),
             description='',
             color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         await ctx.send(embed=embed)
 async def chart(self, ctx, *, chart: Option(
     str,
     "Choose chart.",
     choices=["Melon", "Billboard", "Billboard Japan"])):
     """ I will tell you from the 1st to the 10th place on the chart site """
     if not chart == None:
         chart = chart.upper()
     if chart == "MELON":
         title, artist = await get_melon()
         embed = discord.Embed(title=get_lan(ctx.author.id,
                                             "chart_melon_chart"),
                               color=color_code)
     elif chart == "BILLBOARD":
         title, artist = await get_billboard()
         embed = discord.Embed(title=get_lan(ctx.author.id,
                                             "chart_billboard_chart"),
                               color=color_code)
     elif chart == "BILLBOARD JAPAN":
         title, artist = await get_billboardjp()
         embed = discord.Embed(title=get_lan(ctx.author.id,
                                             "chart_billboardjp_chart"),
                               color=color_code)
     for i in range(0, 10):
         embed.add_field(name=str(i + 1) + ".",
                         value=f"{artist[i]} - {title[i]}",
                         inline=False)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.respond(embed=embed)
    async def disconnect(self, ctx):
        """ Disconnects the player from the voice channel and clears its queue. """
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)

        if not player.is_connected:
            # We can't disconnect, if we're not connected.
            embed=discord.Embed(title=get_lan(ctx.author.id, "music_dc_not_connect_voice_channel"), description='', color=color_code)
            embed.set_footer(text=BOT_NAME_TAG_VER)
            return await ctx.respond(embed=embed)

        if not ctx.author.voice or (player.is_connected and ctx.author.voice.channel.id != int(player.channel_id)):
            # Abuse prevention. Users not in voice channels, or not in the same voice channel as the bot
            # may not disconnect the bot.
            embed=discord.Embed(title=get_lan(ctx.author.id, "music_dc_not_connect_my_voice_channel").format(name=ctx.author.name), description='', color=color_code)
            embed.set_footer(text=BOT_NAME_TAG_VER)
            return await ctx.respond(embed=embed)

        # Clear the queue to ensure old tracks don't start playing
        # when someone else queues something.
        player.queue.clear()
        # Stop the current track so Lavalink consumes less resources.
        await player.stop()
        # Disconnect from the voice channel.
        await ctx.voice_client.disconnect(force=True)

        embed=discord.Embed(title=get_lan(ctx.author.id, "music_dc_disconnected"), description='', color=color_code)
        embed.set_footer(text=BOT_NAME_TAG_VER)
        await ctx.respond(embed=embed)
Beispiel #4
0
    async def shell(self, ctx, *arg):
        try:
            cmd = " ".join(arg[:])
            res = subprocess.check_output(cmd, shell=True, encoding='utf-8')
            embed = discord.Embed(title=get_lan(ctx.author.id, 'owners_shell'),
                                  description=get_lan(
                                      ctx.author.id,
                                      'owners_shell_description'),
                                  color=self.color)
            embed.add_field(name="Input", value=f'```{cmd}```', inline=False)
            embed.add_field(name="Output", value=f"```{res}```", inline=False)
            footer(embed)
            await ctx.send(embed=embed)

        except (discord.errors.HTTPException):
            cmd = " ".join(arg[:])
            res = subprocess.check_output(cmd, shell=True, encoding='utf-8')
            await ctx.send(f"```{res}```")

        except (subprocess.CalledProcessError):
            embed = discord.Embed(title=get_lan(ctx.author.id,
                                                'owners_shell_error'),
                                  description=get_lan(
                                      ctx.author.id,
                                      'owners_shell_error_description'),
                                  color=self.color)
            footer(embed)
            await ctx.send(embed=embed)
Beispiel #5
0
    async def broadcast(self, ctx, *, arg):
        embed = discord.Embed(title=get_lan(ctx.author.id, 'owners_broadcast'),
                              description=str(arg),
                              color=color_code)
        embed.set_footer(text=BOT_NAME_TAG_VER)
        for i in self.bot.guilds:
            ch = self.bot.get_guild(int(i.id)).channels
            for a in ch:
                try:
                    target_channel = self.bot.get_channel(a.id)
                    await target_channel.send(embed=embed)

                except Exception:
                    pass
                else:
                    LOGGER.info(f"{a} ({a.id}) 서버에 공지 전송 완료!")
                    break
        embed = discord.Embed(
            title=get_lan(ctx.author.id, 'owners_broadcast_finish'),
            description=get_lan(
                ctx.author.id,
                'owners_broadcast_info').format(broadcast_info=arg),
            color=color_code)
        footer(embed)
        return await ctx.send(embed=embed)
Beispiel #6
0
    async def ensure_voice(self, ctx):
        player = self.bot.lavalink.player_manager.create(ctx.guild.id,
                                                         endpoint=str(
                                                             ctx.guild.region))
        should_connect = ctx.command.name in ('play', 'melonplay',
                                              'billboardplay', 'connect',
                                              'find', 'list')

        if not ctx.author.voice or not ctx.author.voice.channel:
            raise commands.CommandInvokeError(
                get_lan(ctx.author.id, "music_come_in_voice_channel"))
        if not player.is_connected:
            if not should_connect:
                raise commands.CommandInvokeError(
                    get_lan(ctx.author.id,
                            "music_not_connected_voice_channel"))
            permissions = ctx.author.voice.channel.permissions_for(ctx.me)
            if not permissions.connect or not permissions.speak:
                raise commands.CommandInvokeError(
                    get_lan(ctx.author.id, "music_no_permission"))
            player.store('channel', ctx.channel.id)
            player.fetch('channel')
            await self.connect_to(ctx.guild.id,
                                  str(ctx.author.voice.channel.id))
        else:
            if int(player.channel_id) != ctx.author.voice.channel.id:
                raise commands.CommandInvokeError(
                    get_lan(ctx.author.id, "music_come_in_my_voice_channel"))
Beispiel #7
0
 async def find(self, ctx, *, query):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not query.startswith('ytsearch:') and not query.startswith(
             'scsearch:'):
         query = 'ytsearch:' + query
     search_count = 1
     while True:
         results = await player.node.get_tracks(query)
         if not results or not results['tracks']:
             if search_count != 3:
                 search_count += 1
             else:
                 embed = discord.Embed(title=get_lan(
                     ctx.author.id, "music_youtube_can_not_found"),
                                       description='',
                                       color=self.normal_color)
                 embed.set_footer(text="audiscordbot.xyz")
                 return await ctx.send(embed=embed)
         break
     tracks = results['tracks'][:10]  # First 10 results
     o = ''
     for index, track in enumerate(tracks, start=1):
         track_title = track['info']['title']
         track_uri = track['info']['uri']
         o += f'`{index}.` [{track_title}]({track_uri})\n'
     embed = discord.Embed(color=self.normal_color,
                           title=get_lan(ctx.author.id,
                                         "music_youtube_result"),
                           description=o)
     embed.set_footer(text="audiscordbot.xyz")
     await ctx.send(embed=embed)
Beispiel #8
0
    async def disconnect(self, ctx):
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)
        if not player.is_connected:
            embed = discord.Embed(title=get_lan(
                ctx.author.id, "music_dc_not_connect_voice_channel"),
                                  description='',
                                  color=self.normal_color)
            embed.set_footer(text="audiscordbot.xyz")
            return await ctx.send(embed=embed)
        if not ctx.author.voice or (
                player.is_connected
                and ctx.author.voice.channel.id != int(player.channel_id)):
            embed = discord.Embed(title=get_lan(
                ctx.author.id, "music_dc_not_connect_my_voice_channel").format(
                    name=ctx.author.name),
                                  description='',
                                  color=self.normal_color)
            embed.set_footer(text="audiscordbot.xyz")
            return await ctx.send(embed=embed)
        player.queue.clear()
        await player.stop()
        await self.connect_to(ctx.guild.id, None)

        embed = discord.Embed(title=get_lan(ctx.author.id,
                                            "music_dc_disconnected"),
                              description='',
                              color=self.normal_color)
        embed.set_footer(text="audiscordbot.xyz")
        await ctx.send(embed=embed)
Beispiel #9
0
 async def remove(self, ctx, index: int):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.queue:
         embed = discord.Embed(title=get_lan(
             ctx.author.id, "music_remove_no_wating_music"),
                               description='',
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         return await ctx.send(embed=embed)
     if index > len(player.queue) or index < 1:
         embed = discord.Embed(title=get_lan(
             ctx.author.id, "music_remove_input_over").format(
                 last_queue=len(player.queue)),
                               description='',
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         return await ctx.send(embed=embed)
     removed = player.queue.pop(index - 1)  # Account for 0-index.
     embed = discord.Embed(title=get_lan(
         ctx.author.id,
         "music_remove_form_playlist").format(remove_music=removed.title),
                           description='',
                           color=self.normal_color)
     embed.set_footer(text="audiscordbot.xyz")
     await ctx.send(embed=embed)
Beispiel #10
0
 async def volume(self, ctx, volume: int = None):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if volume is None:
         volicon = await volumeicon(player.volume)
         embed = discord.Embed(title=get_lan(
             ctx.author.id, "music_pause").format(volicon=volicon,
                                                  volume=player.volume),
                               description='',
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         return await ctx.send(embed=embed)
     if volume > 1000 or volume < 1:
         embed = discord.Embed(title=get_lan(ctx.author.id,
                                             "music_input_over_vol"),
                               description=get_lan(ctx.author.id,
                                                   "music_default_vol"),
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         return await ctx.send(embed=embed)
     await player.set_volume(volume)
     volicon = await volumeicon(player.volume)
     embed = discord.Embed(title=get_lan(
         ctx.author.id, "music_set_vol").format(volume=player.volume),
                           description='',
                           color=self.normal_color)
     embed.set_footer(text="audiscordbot.xyz")
     await ctx.send(embed=embed)
Beispiel #11
0
 async def queue(self, ctx, page: int = 1):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.queue:
         embed = discord.Embed(title=get_lan(
             ctx.author.id, "music_no_music_in_the_playlist"),
                               description='',
                               color=self.normal_color)
         embed.set_footer(text="audiscordbot.xyz")
         await ctx.send(embed=embed)
         return
     items_per_page = 10
     pages = math.ceil(len(player.queue) / items_per_page)
     start = (page - 1) * items_per_page
     end = start + items_per_page
     queue_list = ''
     for index, track in enumerate(player.queue[start:end], start=start):
         queue_list += f'`{index + 1}.` [**{track.title}**]({track.uri})\n'
     embed = discord.Embed(colour=self.normal_color,
                           description=get_lan(ctx.author.id,
                                               "music_q").format(
                                                   lenQ=len(player.queue),
                                                   queue_list=queue_list))
     embed.set_footer(
         text=f'{get_lan(ctx.author.id, "music_page")} {page}/{pages}')
     embed.set_footer(text="audiscordbot.xyz")
     await ctx.send(embed=embed)
    async def ensure_voice(self, ctx):
        """ This check ensures that the bot and command author are in the same voicechannel. """
        player = self.bot.lavalink.player_manager.create(ctx.guild.id, endpoint=str(ctx.guild.region))
        # Create returns a player if one exists, otherwise creates.
        # This line is important because it ensures that a player always exists for a guild.

        # Most people might consider this a waste of resources for guilds that aren't playing, but this is
        # the easiest and simplest way of ensuring players are created.

        # These are commands that require the bot to join a voicechannel (i.e. initiating playback).
        # Commands such as volume/skip etc don't require the bot to be in a voicechannel so don't need listing here.
        should_connect = ctx.command.name in ('play', 'connect', 'list', 'chartplay',)

        if not ctx.author.voice or not ctx.author.voice.channel:
            # Our cog_command_error handler catches this and sends it to the voicechannel.
            # Exceptions allow us to "short-circuit" command invocation via checks so the
            # execution state of the command goes no further.
            raise commands.CommandInvokeError(get_lan(ctx.author.id, "music_come_in_voice_channel"))

        if not player.is_connected:
            if not should_connect:
                raise commands.CommandInvokeError(get_lan(ctx.author.id, "music_not_connected_voice_channel"))

            permissions = ctx.author.voice.channel.permissions_for(ctx.me)

            if not permissions.connect or not permissions.speak:  # Check user limit too?
                raise commands.CommandInvokeError(get_lan(ctx.author.id, "music_no_permission"))

            player.store('channel', ctx.channel.id)
            await ctx.author.voice.channel.connect(cls=LavalinkVoiceClient)
        else:
            if int(player.channel_id) != ctx.author.voice.channel.id:
                raise commands.CommandInvokeError(get_lan(ctx.author.id, "music_come_in_my_voice_channel"))
Beispiel #13
0
 async def shorturl(self, ctx, arg):
     client_id = ""  # 네이버 개발자센터에서 발급받은 Client ID 값
     client_secret = ""  # 네이버 개발자센터에서 발급받은 Client Secret 값
     encText = urllib.parse.quote(arg)
     data = "url=" + encText
     url = "https://openapi.naver.com/v1/util/shorturl"
     request = urllib.request.Request(url)
     request.add_header("X-Naver-Client-Id", client_id)
     request.add_header("X-Naver-Client-Secret", client_secret)
     response = urllib.request.urlopen(request, data=data.encode("utf-8"))
     rescode = response.getcode()
     if (rescode == 200):
         response_body = response.read()
         shorturl = json.loads(response_body.decode('utf-8'))
         returnurl = shorturl['result']['url']
         emb = discord.embeds.Embed(
             title=get_lan(ctx.author.id, 'short_url'))
         emb.add_field(name=get_lan(ctx.author.id, 'short_url_defalt'),
                       value=f"**{arg}**",
                       inline=False)
         emb.add_field(name=get_lan(ctx.author.id, 'short_url_convert'),
                       value=f"**{returnurl}**",
                       inline=False)
         emb.set_thumbnail(url=f"{returnurl}.qr")
         emb.set_footer(text="audiscordbot.xyz")
         await ctx.send(embed=emb)
     else:
         print("Error Code:" + rescode)
         emb = discord.embeds.Embed(
             title=get_lan(ctx.author.id, 'short_url'),
             description=get_lan(ctx.author.id,
                                 'short_url_error').format(rescode=rescode))
         emb.set_footer(text="audiscordbot.xyz")
         await ctx.send(embed=emb)
Beispiel #14
0
 async def invite(self, ctx):
     link = 'http://audiscordbot.xyz/'
     embed = discord.Embed(
         title=get_lan(ctx.author.id, "other_invite_title"),
         description=get_lan(ctx.author.id,
                             "other_invite_description").format(link=link),
         color=color_code)
     embed.set_footer(text="audiscordbot.xyz")
     await ctx.send(embed=embed)
Beispiel #15
0
 async def invite(self, ctx):
     link = 'https://discord.com/oauth2/authorize?client_id=%s&permissions=3165184&scope=bot' % self.bot.user.id
     embed = discord.Embed(
         title=get_lan(ctx.author.id, "other_invite_title"),
         description=get_lan(ctx.author.id,
                             "other_invite_description").format(link=link),
         color=color_code)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.send(embed=embed)
Beispiel #16
0
 async def 경고_error(self, ctx, error):
     embed = discord.Embed(title=get_lan(ctx.author.id, 'warning'),
                           description=get_lan(ctx.author.id,
                                               'warning_error_2'),
                           color=0xe74c3c)
     embed.set_footer(text="audiscordbot.xyz")
     if isinstance(error, commands.MissingRequiredArgument):
         await ctx.send(embed=embed)
     if isinstance(error, commands.MemberNotFound):
         await ctx.send(get_lan(ctx.author.id, 'member_none'))
 async def connect(self, ctx):
     """ Connect to voice channel! """
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_connected:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_connect_voice_channel"), description='', color=color_code)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.respond(embed=embed)
     embed=discord.Embed(title=get_lan(ctx.author.id, "music_already_connected_voice_channel"), description='', color=color_code)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     return await ctx.respond(embed=embed)
Beispiel #18
0
 async def connect(self, ctx):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_connected:
         #await self.connect_to(ctx.guild.id, ctx.author.voice.channel.id)
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_connect_voice_channel"), description='', color=self.normal_color)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.send(embed=embed)
     embed=discord.Embed(title=get_lan(ctx.author.id, "music_already_connected_voice_channel"), description='', color=self.normal_color)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     return await ctx.send(embed=embed)
Beispiel #19
0
    async def play(self, ctx, *, query: str = None):
        if query is None and ctx.message.reference is not None:
            query = await self.bot.get_channel(
                ctx.message.reference.channel_id
            ).fetch_message(ctx.message.reference.message_id)
            query = query.content

        player = self.bot.lavalink.player_manager.get(ctx.guild.id)
        query = query.strip('<>')
        if not url_rx.match(query):
            query = f'ytsearch:{query}'
        nofind = 0
        while True:
            results = await player.node.get_tracks(query)
            if not results or not results['tracks']:
                if nofind < 3:
                    nofind += 1
                elif nofind == 3:
                    embed = discord.Embed(title=get_lan(
                        ctx.author.id, "music_can_not_find_anything"),
                                          description='',
                                          color=self.normal_color)
                    embed.set_footer(text="audiscordbot.xyz")
                    return await ctx.send(embed=embed)
            else:
                break

        embed = discord.Embed(color=self.normal_color)
        embed.set_footer(text="audiscordbot.xyz")

        if results['loadType'] == 'PLAYLIST_LOADED':
            tracks = results['tracks']
            trackcount = 0
            for track in tracks:
                if trackcount != 1:
                    info = track['info']
                    trackcount = 1
                player.add(requester=ctx.author.id, track=track)
            embed.title = get_lan(ctx.author.id, "music_play_playlist")
            embed.description = f'{results["playlistInfo"]["name"]} - {len(tracks)} tracks'

        else:
            track = results['tracks'][0]
            embed.title = get_lan(ctx.author.id, "music_play_music")
            embed.description = f'[{track["info"]["title"]}]({track["info"]["uri"]})'
            info = track['info']
            track = lavalink.models.AudioTrack(track,
                                               ctx.author.id,
                                               recommended=True)
            player.add(requester=ctx.author.id, track=track)
        embed.set_thumbnail(url="http://img.youtube.com/vi/%s/0.jpg" %
                            (info['identifier']))
        await ctx.reply(embed=embed, mention_author=True)
        if not player.is_playing:
            await player.play()
    async def language(self, ctx, lang: Option(str,
                                               "Choose language pack.",
                                               choices=lanPack)):
        """ Apply the language pack. """
        if lang is None:
            files = ""
            for file in os.listdir("musicbot/languages"):
                if file.endswith(".json"):
                    files = files + file.replace(".json", "") + "\n"

            embed = discord.Embed(title=get_lan(ctx.author.id,
                                                "set_language_pack_list"),
                                  description=files,
                                  color=color_code)
            embed.set_footer(text=BOT_NAME_TAG_VER)
            return await ctx.respond(embed=embed)

        if not os.path.exists(f"musicbot/languages/{lang}.json"):
            embed = discord.Embed(title=get_lan(ctx.author.id,
                                                "set_language_pack_not_exist"),
                                  color=color_code)
            embed.set_footer(text=BOT_NAME_TAG_VER)
            return await ctx.respond(embed=embed)

        conn = sqlite3.connect("userdata.db", isolation_level=None)
        c = conn.cursor()
        c.execute(
            "CREATE TABLE IF NOT EXISTS userdata (id integer PRIMARY KEY, language text)"
        )
        # chack user data
        c.execute("SELECT * FROM userdata WHERE id=:id",
                  {"id": str(ctx.author.id)})
        a = c.fetchone()
        if a is None:
            # add user data
            c.execute(
                f"INSERT INTO userdata VALUES({ctx.author.id}, '{lang}')")
            embed = discord.Embed(title=get_lan(ctx.author.id,
                                                "set_language_complete"),
                                  description=f"{lang}",
                                  color=color_code)
        else:
            # modify user data
            c.execute("UPDATE userdata SET language=:language WHERE id=:id", {
                "language": lang,
                'id': ctx.author.id
            })
            embed = discord.Embed(title=get_lan(ctx.author.id,
                                                "set_language_complete"),
                                  description=f"{a[1]} --> {lang}",
                                  color=color_code)
        conn.close()

        embed.set_footer(text=BOT_NAME_TAG_VER)
        await ctx.respond(embed=embed)
Beispiel #21
0
 async def shuffle(self, ctx):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_playing:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_not_playing"), description='', color=self.normal_color)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.send(embed=embed)
     player.shuffle = not player.shuffle
     if player.shuffle:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_shuffle_on"), description='', color=self.normal_color)
     else:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_shuffle_off"), description='', color=self.normal_color)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.send(embed=embed)
async def play_list(player, ctx, musics, playmsg):
    trackcount = 0
    playmusic = get_lan(ctx.author.id, "music_none")
    passmusic = get_lan(ctx.author.id, "music_none")
    loading_dot_count = 0
    for i in range(0, len(musics)):
        # ... 개수 변경
        loading_dot = ""
        loading_dot_count += 1
        if loading_dot_count == 4:
            loading_dot_count = 1
        for a in range(0, loading_dot_count):
            loading_dot = loading_dot + "."
        embed = discord.Embed(title=get_lan(
            ctx.author.id,
            "music_adding_music").format(loading_dot=loading_dot),
                              description=musics[i],
                              color=color_code)
        await playmsg.edit_original_message(embed=embed)
        query = musics[i]
        if not url_rx.match(query):
            query = f'ytsearch:{query}'
        nofind = 0
        while True:
            results = await player.node.get_tracks(query)
            if results[
                    'loadType'] == 'PLAYLIST_LOADED' or not results or not results[
                        'tracks']:
                if nofind < 3:
                    nofind += 1
                elif nofind == 3:
                    if passmusic == get_lan(ctx.author.id, "music_none"):
                        passmusic = musics[i]
                    else:
                        passmusic = "%s\n%s" % (passmusic, musics[i])
            else:
                break
        track = results['tracks'][0]
        if playmusic == get_lan(ctx.author.id, "music_none"):
            playmusic = musics[i]
        else:
            playmusic = "%s\n%s" % (playmusic, musics[i])
        if trackcount != 1:
            info = track['info']
            trackcount = 1
        track = lavalink.models.AudioTrack(track,
                                           ctx.author.id,
                                           recommended=True)
        player.add(requester=ctx.author.id, track=track)
    return info, playmusic, passmusic
 async def repeat(self, ctx):
     """ Play all the songs in the playlist over and over again! """
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_playing:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_not_playing"), description='', color=color_code)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.respond(embed=embed)
     player.repeat = not player.repeat
     if player.repeat:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_repeat_on"), description='', color=color_code)
     else:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_repeat_off"), description='', color=color_code)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.respond(embed=embed)
Beispiel #24
0
 async def module_list(self, ctx):
     modulenum = 0
     for m in EXTENSIONS:
         if not m[0:3] == "*~~":
             modulenum += 1
     modulenum = get_lan(
         ctx.author.id,
         'owners_loaded_modules_len').format(modulenum=modulenum)
     e1 = "\n".join(EXTENSIONS)
     embed = discord.Embed(title=get_lan(ctx.author.id,
                                         'owners_modules_list'),
                           color=color_code)
     embed.add_field(name=modulenum, value=e1, inline=False)
     await ctx.send(embed=embed)
 async def shuffle(self, ctx):
     """ The music in the playlist comes out randomly from the next song! """
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_playing:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_not_playing"), description='', color=color_code)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.respond(embed=embed)
     player.shuffle = not player.shuffle
     if player.shuffle:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_shuffle_on"), description='', color=color_code)
     else:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_shuffle_off"), description='', color=color_code)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.respond(embed=embed)
    async def skip(self, ctx):
        """ Skip to the next song! """
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)

        if not player.is_playing:
            # We can't skip, if we're not playing the music.
            embed=discord.Embed(title=get_lan(ctx.author.id, "music_not_playing"), description='', color=color_code)
            embed.set_footer(text=BOT_NAME_TAG_VER)
            return await ctx.respond(embed=embed)

        await player.skip()

        embed=discord.Embed(title=get_lan(ctx.author.id, "music_skip_next"), description='', color=color_code)
        embed.set_footer(text=BOT_NAME_TAG_VER)
        await ctx.respond(embed=embed)
 async def remove(self, ctx, index: int):
     """ Remove music from the playlist! """
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.queue:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_remove_no_wating_music"), description='', color=color_code)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.respond(embed=embed)
     if index > len(player.queue) or index < 1:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_remove_input_over").format(last_queue=len(player.queue)), description='', color=color_code)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.respond(embed=embed)
     removed = player.queue.pop(index - 1)  # Account for 0-index.
     embed=discord.Embed(title=get_lan(ctx.author.id, "music_remove_form_playlist").format(remove_music=removed.title), description='', color=color_code)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.respond(embed=embed)
Beispiel #28
0
 async def softver(self, ctx):
     javaver = subprocess.check_output("java --version",
                                       shell=True,
                                       encoding='utf-8')
     lavalinkver = subprocess.check_output(
         "java -jar Lavalink.jar --version", shell=True, encoding='utf-8')
     embed = discord.Embed(title=get_lan(ctx.author.id, "other_soft_ver"),
                           color=color_code)
     embed.add_field(
         name="Python Ver",
         value=("%s %s") %
         (platform.python_implementation(), platform.python_version()),
         inline=False)
     embed.add_field(name="Discord.py Ver",
                     value=discord.__version__,
                     inline=False)
     embed.add_field(name="Lavalink.py Ver",
                     value=lavalink.__version__,
                     inline=False)
     embed.add_field(name="Java Ver",
                     value=f"```{javaver}```",
                     inline=False)
     embed.add_field(name="Lavalink Ver",
                     value=f"```{lavalinkver}```",
                     inline=False)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.send(embed=embed)
Beispiel #29
0
 async def pause(self, ctx):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.is_playing:
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_not_playing"), description='', color=self.normal_color)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         return await ctx.send(embed=embed)
     if player.paused:
         await player.set_pause(False)
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_resume"), description='', color=self.normal_color)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         await ctx.send(embed=embed)
     else:
         await player.set_pause(True)
         embed=discord.Embed(title=get_lan(ctx.author.id, "music_pause"), description='', color=self.normal_color)
         embed.set_footer(text=BOT_NAME_TAG_VER)
         await ctx.send(embed=embed)
 async def module_list(self, ctx):
     """ 모든 모듈들의 이름을 알려줘요! """
     modulenum = 0
     for m in EXTENSIONS:
         if not m[0:3] == "*~~":
             modulenum += 1
     modulenum = get_lan(
         ctx.author.id,
         'owners_loaded_modules_len').format(modulenum=modulenum)
     e1 = "\n".join(EXTENSIONS)
     embed = discord.Embed(title=get_lan(ctx.author.id,
                                         'owners_modules_list'),
                           color=color_code)
     embed.add_field(name=modulenum, value=e1, inline=False)
     embed.set_footer(text=BOT_NAME_TAG_VER)
     await ctx.respond(embed=embed)