コード例 #1
0
 async def _resume(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     current_guild.voice_client.resume()
     await ctx.send("Resumed playback :arrow_forward:")
コード例 #2
0
ファイル: music.py プロジェクト: mitch3b/DiscordJockey
 async def _history(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     await utils.send_message(
         ctx, utils.guild_to_audiocontroller[current_guild].track_history())
コード例 #3
0
ファイル: music.py プロジェクト: nuggetcatsoftware/Alpaca-bot
    async def _volume(self, ctx, *args):
        if ctx.guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return

        if await utils.play_check(ctx) == False:
            return

        if len(args) == 0:
            await ctx.send("Current volume: {}% :speaker:".format(
                utils.guild_to_audiocontroller[ctx.guild]._volume))
            return

        try:
            volume = args[0]
            volume = int(volume)
            if volume > 100:
                raise Exception('')
            current_guild = utils.get_guild(self.bot, ctx.message)

            if utils.guild_to_audiocontroller[current_guild]._volume >= volume:
                await ctx.send('Volume set to {}% :sound:'.format(str(volume)))
            else:
                await ctx.send('Volume set to {}% :loud_sound:'.format(
                    str(volume)))
            utils.guild_to_audiocontroller[current_guild].volume = volume
        except:
            await ctx.send("Error: Volume must be a number 1-100")
コード例 #4
0
ファイル: music.py プロジェクト: nuggetcatsoftware/Alpaca-bot
    async def _play_song(self, ctx, *, track: str):
        if (await utils.is_connected(ctx) == None):
            await General.uconnect(self, ctx)
        if track.isspace() or not track:
            return

        if await utils.play_check(ctx) == False:
            return

        current_guild = utils.get_guild(self.bot, ctx.message)
        audiocontroller = utils.guild_to_audiocontroller[current_guild]

        if audiocontroller.playlist.loop == True:
            await ctx.send("Loop is enabled! Use {}loop to disable".format(
                config.BOT_PREFIX))
            return

        song = await audiocontroller.process_song(track)

        if song is None:
            await ctx.send(config.SONGINFO_UNKNOWN_SITE)
            return

        if song.origin == linkutils.Origins.Default:

            if audiocontroller.current_song != None and len(
                    audiocontroller.playlist.playque) == 0:
                await ctx.send(
                    embed=song.info.format_output(config.SONGINFO_NOW_PLAYING))
            else:
                await ctx.send(
                    embed=song.info.format_output(config.SONGINFO_QUEUE_ADDED))

        elif song.origin == linkutils.Origins.Playlist:
            await ctx.send(config.SONGINFO_PLAYLIST_QUEUED)
コード例 #5
0
 async def _clear(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     audiocontroller = utils.guild_to_audiocontroller[current_guild]
     audiocontroller.clear_queue()
     current_guild.voice_client.stop()
     audiocontroller.playlist.loop = False
     await ctx.send("Cleared queue :no_entry_sign:")
コード例 #6
0
    async def _queue(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)
        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing(
        ):
            await ctx.send("Queue is empty :x:")
            return

        playlist = utils.guild_to_audiocontroller[current_guild].playlist

        songlist = []
        counter = 1

        for song in playlist.playque:
            entry = "{}. {}".format(str(counter), song.info.webpage_url)
            songlist.append(entry)
            counter = counter + 1

        try:
            await ctx.send("Queue[**{}**]:\n{}".format(
                len(songlist), '\n'.join(songlist[:10])))
        except:
            await ctx.send("Queue to long to post. Working on this feature.")
コード例 #7
0
ファイル: music.py プロジェクト: mitch3b/DiscordJockey
    async def _volume(self, ctx, volume):
        current_guild = utils.get_guild(self.bot, ctx.message)
        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return

        utils.guild_to_audiocontroller[current_guild].volume = volume
コード例 #8
0
    async def uconnect(self, ctx):

        vchannel = await utils.is_connected(ctx)

        if vchannel is not None:
            await utils.send_message(ctx, config.ALREADY_CONNECTED_MESSAGE)
            return

        current_guild = utils.get_guild(self.bot, ctx.message)

        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return

        if utils.guild_to_audiocontroller[current_guild] is None:
            utils.guild_to_audiocontroller[current_guild] = AudioController(
                self.bot, current_guild)

        guild_to_audiocontroller[current_guild] = AudioController(
            self.bot, current_guild)
        await guild_to_audiocontroller[current_guild].register_voice_channel(
            ctx.author.voice.channel)

        await ctx.send("Connected to {} {}".format(
            ctx.author.voice.channel.name, ":white_check_mark:"))
コード例 #9
0
    async def _queue(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if await utils.play_check(ctx) == False:
            return

        if current_guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing():
            await ctx.send("Queue is empty :x:")
            return

        playlist = utils.guild_to_audiocontroller[current_guild].playlist

        # Embeds are limited to 25 fields
        if config.MAX_SONG_PRELOAD > 25:
            config.MAX_SONG_PRELOAD = 25

        embed = discord.Embed(title=":scroll: Queue [{}]".format(
            len(playlist.playque)), color=config.EMBED_COLOR, inline=False)

        for counter, song in enumerate(list(playlist.playque)[:config.MAX_SONG_PRELOAD], start=1):
            if song.info.title is None:
                embed.add_field(name="{}.".format(str(counter)), value="[{}]({})".format(
                    song.info.webpage_url, song.info.webpage_url), inline=False)
            else:
                embed.add_field(name="{}.".format(str(counter)), value="[{}]({})".format(
                    song.info.title, song.info.webpage_url), inline=False)

        await ctx.send(embed=embed)
コード例 #10
0
    async def _play_song(self, ctx, *, track: str):
        await ctx.send(":musical_note: Searching :mag_right: " + f"`{track}`")
        if (await utils.is_connected(ctx) == None):
            await General.uconnect(self, ctx)
        if track.isspace() or not track:
            return

        current_guild = utils.get_guild(self.bot, ctx.message)
        audiocontroller = utils.guild_to_audiocontroller[current_guild]

        if audiocontroller.playlist.loop == True:
            await ctx.send("Loop is enabled! Use {}loop to disable".format(
                config.BOT_PREFIX))
            return

        song = await audiocontroller.process_song(track)

        if song is None:
            await ctx.send("Unknown site :question:")
            return

        if song.origin == linkutils.Origins.Default:

            if len(audiocontroller.playlist.playque) == 1:
                await ctx.send(embed=song.info.format_output("Now playing"))
            else:
                await ctx.send(embed=song.info.format_output("Added to queue"))

        elif song.origin == linkutils.Origins.Playlist:
            await ctx.send("Queued playlist :page_with_curl:")
コード例 #11
0
    async def udisconnect(self, ctx, guild):

        if guild is not False:

            current_guild = guild

            await utils.guild_to_audiocontroller[current_guild].stop_player()
            await current_guild.voice_client.disconnect(force=True)

        else:
            current_guild = utils.get_guild(self.bot, ctx.message)

            if current_guild is None:
                await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
                return

            if await utils.is_connected(ctx) is None:
                await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
                return

            await utils.guild_to_audiocontroller[current_guild].stop_player()
            await current_guild.voice_client.disconnect(force=True)
            await ctx.send(
                "Disconnected from voice channel. Use '{}c' to rejoin.".format(
                    config.BOT_PREFIX))
コード例 #12
0
ファイル: general.py プロジェクト: mitch3b/DiscordJockey
    async def _disconnect(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return
        await utils.guild_to_audiocontroller[current_guild].stop_player()
        await current_guild.voice_client.disconnect()
コード例 #13
0
 async def _prev(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     audiocontroller = utils.guild_to_audiocontroller[current_guild]
     audiocontroller.playlist.loop = False
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     await utils.guild_to_audiocontroller[current_guild].prev_song()
     await ctx.send("Playing previous song :track_previous:")
コード例 #14
0
 async def _stop(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     audiocontroller = utils.guild_to_audiocontroller[current_guild]
     audiocontroller.playlist.loop = False
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     await utils.guild_to_audiocontroller[current_guild].stop_player()
     await ctx.send("Stopped all sessions :octagonal_sign:")
コード例 #15
0
 async def _songinfo(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     song = utils.guild_to_audiocontroller[current_guild].current_song
     if song is None:
         return
     await ctx.send(embed=song.info.format_output("Songinfo"))
コード例 #16
0
ファイル: music.py プロジェクト: mitch3b/DiscordJockey
 async def _pause(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     if current_guild.voice_client is None or not current_guild.voice_client.is_playing(
     ):
         return
     current_guild.voice_client.pause()
コード例 #17
0
ファイル: music.py プロジェクト: mitch3b/DiscordJockey
 async def _songinfo(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     songinfo = utils.guild_to_audiocontroller[
         current_guild].current_songinfo
     if songinfo is None:
         return
     await ctx.message.author.send(songinfo.output)
コード例 #18
0
    async def _history(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if await utils.play_check(ctx) == False:
            return

        if current_guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return
        await ctx.send(utils.guild_to_audiocontroller[current_guild].track_history())
コード例 #19
0
ファイル: music.py プロジェクト: mitch3b/DiscordJockey
    async def _play_youtube(self, ctx, *, track: str):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return
        audiocontroller = utils.guild_to_audiocontroller[current_guild]

        if track.isspace() or not track:
            return
        await audiocontroller.add_youtube(track)
コード例 #20
0
ファイル: general.py プロジェクト: mitch3b/DiscordJockey
    async def _changechannel(self, ctx, *, dest_channel_name: str):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return

        await utils.connect_to_channel(current_guild,
                                       dest_channel_name,
                                       ctx,
                                       switch=True,
                                       default=False)
コード例 #21
0
 async def _skip(self, ctx):
     current_guild = utils.get_guild(self.bot, ctx.message)
     audiocontroller = utils.guild_to_audiocontroller[current_guild]
     audiocontroller.playlist.loop = False
     if current_guild is None:
         await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
         return
     if current_guild.voice_client is None or (
             not current_guild.voice_client.is_paused()
             and not current_guild.voice_client.is_playing()):
         return
     current_guild.voice_client.stop()
     await ctx.send("Skipped current song :fast_forward:")
コード例 #22
0
ファイル: music.py プロジェクト: nuggetcatsoftware/Alpaca-bot
    async def _songinfo(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if await utils.play_check(ctx) == False:
            return

        if current_guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return
        song = utils.guild_to_audiocontroller[current_guild].current_song
        if song is None:
            return
        await ctx.send(embed=song.info.format_output(config.SONGINFO_SONGINFO))
コード例 #23
0
    async def _pause(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if await utils.play_check(ctx) == False:
            return

        if current_guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing():
            return
        current_guild.voice_client.pause()
        await ctx.send("Playback Paused :pause_button:")
コード例 #24
0
ファイル: general.py プロジェクト: Raptor123471/DingoLingo
    async def _reset(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if current_guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return
        await utils.guild_to_audiocontroller[current_guild].stop_player()
        await current_guild.voice_client.disconnect(force=True)

        guild_to_audiocontroller[current_guild] = AudioController(
            self.bot, current_guild)
        await guild_to_audiocontroller[current_guild].register_voice_channel(ctx.author.voice.channel)

        await ctx.send("{} Connected to {}".format(":white_check_mark:", ctx.author.voice.channel.name))
コード例 #25
0
    async def _shuffle(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)
        audiocontroller = utils.guild_to_audiocontroller[current_guild]

        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing(
        ):
            await ctx.send("Queue is empty :x:")
            return

        audiocontroller.playlist.shuffle()
        await ctx.send("Shuffled queue :twisted_rightwards_arrows:")
コード例 #26
0
    async def _loop(self, ctx):

        current_guild = utils.get_guild(self.bot, ctx.message)
        audiocontroller = utils.guild_to_audiocontroller[current_guild]

        if len(audiocontroller.playlist.playque) < 1:
            await ctx.send("No songs in queue!")
            return

        if audiocontroller.playlist.loop == False:
            audiocontroller.playlist.loop = True
            await ctx.send("Loop enabled :arrows_counterclockwise:")
        else:
            audiocontroller.playlist.loop = False
            await ctx.send("Loop disabled :x:")
コード例 #27
0
ファイル: general.py プロジェクト: mitch3b/DiscordJockey
    async def _connect(self, ctx, *, dest_channel_name: str):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if current_guild is None:
            await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
            return

        if utils.guild_to_audiocontroller[current_guild] is None:
            utils.guild_to_audiocontroller[current_guild] = AudioController(
                self.bot, current_guild, config.DEFAULT_VOLUME)
        await utils.connect_to_channel(current_guild,
                                       dest_channel_name,
                                       ctx,
                                       switch=False,
                                       default=True)
コード例 #28
0
    async def _prev(self, ctx):
        current_guild = utils.get_guild(self.bot, ctx.message)

        if await utils.play_check(ctx) == False:
            return

        audiocontroller = utils.guild_to_audiocontroller[current_guild]
        audiocontroller.playlist.loop = False

        audiocontroller.timer.cancel()
        audiocontroller.timer = utils.Timer(audiocontroller.timeout_handler)

        if current_guild is None:
            await ctx.send(config.NO_GUILD_MESSAGE)
            return
        await utils.guild_to_audiocontroller[current_guild].prev_song()
        await ctx.send("Playing previous song :track_previous:")
コード例 #29
0
    async def on_raw_reaction_add(self, reaction):

        serv = self.bot.get_guild(reaction.guild_id)

        sett = utils.guild_to_settings[serv]
        button_name = sett.get('button_emote')

        if button_name == "":
            return

        if reaction.emoji.name == button_name:
            channels = serv.text_channels

            for chan in channels:
                if chan.id == reaction.channel_id:
                    if reaction.member == self.bot.user:
                        return

                    try:
                        if reaction.member.voice.channel == None:
                            return
                    except:
                        message = await chan.fetch_message(reaction.message_id)
                        await message.remove_reaction(reaction.emoji,
                                                      reaction.member)
                        return
                    message = await chan.fetch_message(reaction.message_id)
                    await message.remove_reaction(reaction.emoji,
                                                  reaction.member)

            current_guild = utils.get_guild(self.bot, message)
            audiocontroller = utils.guild_to_audiocontroller[current_guild]

            url = linkutils.get_url(message.content)

            host = linkutils.identify_url(url)

            if host == linkutils.Sites.Spotify:
                await audiocontroller.process_song(url)

            if host == linkutils.Sites.Spotify.Spotify_Playlist:
                await audiocontroller.process_song(url)

            if host == linkutils.Sites.YouTube:
                await audiocontroller.process_song(url)
コード例 #30
0
ファイル: music.py プロジェクト: mitch3b/DiscordJockey
    async def _play_youtube_list(self, ctx, *, trackListAsStr: str):
        tracks = trackListAsStr.split(',')
        count = 0
        for track in tracks:
            count = count + 1
            print("Adding track: " + track + " count: " + str(count) + "/" +
                  str(len(tracks)))
            current_guild = utils.get_guild(self.bot, ctx.message)

            if current_guild is None:
                await utils.send_message(ctx, config.NO_GUILD_MESSAGE)
                return
            audiocontroller = utils.guild_to_audiocontroller[current_guild]

            if track.isspace() or not track:
                return
            await audiocontroller.add_youtube(track)

        print("added : " + str(count) + " tracks.")