Exemplo n.º 1
0
    async def artist(self, ctx, *, artist_name: str = None):
        """Returns info about a certain given artist."""
        if artist_name is None:
            error_d = 'you could uh, pass an artist\'s name to do that maybe?'
            ctx.send(embed=error_embed(error_d))
        else:
            async with ctx.channel.typing():
                artist_obj = genius_api.search_artist(artist_name, max_songs=1)
                if artist_obj is None:
                    error_d = f'i didn\'t find any artist named "{artist_name.lower()}"'
                    await ctx.send(embed=error_embed(error_d))
                else:
                    artist_em = discord.Embed(title=artist_obj.name,
                                              colour=ctx.author.colour)
                    artist_em.set_author(
                        name=f'requested by {ctx.author.name.lower()}',
                        icon_url=ctx.author.avatar_url)

                    artist_img = artist_obj.image_url
                    artist_em.set_image(url=artist_img)

                    artist_song = artist_obj.songs
                    artist_em.add_field(name='most viewed song lyrics',
                                        value=artist_song[0].title)

                    artist_em.set_footer(text='check genius.com for more info',
                                         icon_url=self.bot.user.avatar_url)

                    await ctx.send(embed=artist_em)
Exemplo n.º 2
0
 async def wikipedia(self, ctx, language: str):
     """Wikipedia based command. Do !help wp."""
     global wiki_lang
     if language in wikipedia.languages():
         wiki_lang = language
         wikipedia.set_lang(language)
     else:
         error_d = f'"{language}" isn\'t in the list of languages.'
         await ctx.send(embed=error_embed(error_d))
     if ctx.invoked_subcommand is None:
         error_d = 'this is a f****n subcommand, idiot. can\'t you just do !help wp or something?'
         await ctx.send(embed=error_embed(error_d))
Exemplo n.º 3
0
    async def search(self,
                     ctx,
                     *,
                     user_search: str = "",
                     result_limit: int = 10):
        """Wikipedia article searcher."""
        if user_search is "":
            error_d = 'uhh will you search for something or what.'
            await ctx.send(embed=error_embed(error_d))
        else:
            search_results = wikipedia.search(user_search,
                                              results=result_limit)

            counter = -1
            res_content = discord.Embed(title=f'Results for {user_search}:',
                                        colour=ctx.author.colour)
            for s_result in search_results:
                counter += 1
                res_content.add_field(name=f'result #{counter}',
                                      value=f'{s_result}',
                                      inline=False)
            global wiki_lang
            res_content.set_author(
                name=f'requested by {ctx.author.name.lower()}',
                icon_url=ctx.author.avatar_url)
            res_content.set_footer(
                text=
                f'choose an article to show. | current language: {wiki_lang}',
                icon_url=self.bot.user.avatar_url)
            await ctx.send(embed=res_content)
Exemplo n.º 4
0
    async def page(self, ctx, *, article_name: str):
        """Shows an article from the provided name."""
        async with ctx.channel.typing():
            article_obj = wikipedia.page(article_name)
            if article_obj is None:
                error_d = f'no page returned with "{article_name.lower()}", check your spelling or something.'
                await ctx.send(embed=error_embed(error_d))
            else:
                article_em = discord.Embed(title=article_obj.title,
                                           colour=ctx.author.colour,
                                           url=article_obj.url)

                article_em.set_author(
                    name=f'requested by {ctx.author.name.lower()}',
                    icon_url=ctx.author.avatar_url)
                article_obj_summary = wikipedia.summary(article_obj.title)
                article_em.add_field(name='Summary:',
                                     value=str_limit(article_obj_summary),
                                     inline=False)
                global wiki_lang
                article_em.set_footer(text=f'current language: {wiki_lang}',
                                      icon_url=self.bot.user.avatar_url)
                article_em.set_image(url=random.choice(article_obj.images))

                await ctx.send(embed=article_em)
Exemplo n.º 5
0
 async def kick(self,
                ctx,
                member: discord.Member = None,
                reason: str = None):
     """Kicks a member. You can optionally provide a reason after the mention."""
     async with ctx.channel.typing():
         if member is not None:
             await member.kick(reason=reason)
             await ctx.send('done')
         else:
             error_d = 'mention the user dumbass'
             await ctx.send(embed=error_embed(error_d))
Exemplo n.º 6
0
    async def song(self, ctx, *, song_name: str = None):
        """Searches a song and returns the lyrics."""
        if song_name is None:
            error_d = 'no search term was passed, asshat'
            await ctx.send(embed=error_embed(error_d))
        else:
            async with ctx.channel.typing():
                song_obj = genius_api.search_song(song_name)
                if song_obj is None:
                    error_d = f'no song was found with the name "{song_name.lower()}"'
                    await ctx.send(embed=error_embed(error_d))
                else:
                    song_em = discord.Embed(title=song_obj.title,
                                            url=song_obj.url,
                                            colour=ctx.author.colour)
                    song_em.set_author(
                        name=f'requested by {ctx.author.name.lower()}',
                        icon_url=ctx.author.avatar_url)

                    song_cover = song_obj.song_art_image_url
                    song_em.set_thumbnail(url=song_cover)

                    song_em.add_field(name='artist', value=song_obj.artist)
                    song_em.add_field(name='album',
                                      value=song_obj.album,
                                      inline=False)
                    song_em.add_field(name='year', value=song_obj.year)

                    song_lyrics = str_limit(song_obj.lyrics)
                    song_em.add_field(name='lyrics',
                                      value=song_lyrics,
                                      inline=False)

                    song_em.set_footer(
                        text='click the song\'s url for more info',
                        icon_url=self.bot.user.avatar_url)

                    await ctx.send(embed=song_em)
Exemplo n.º 7
0
    async def cat(self, ctx, format: str = None):
        """Returns a random image of a cat.
		You can optionally provide a format."""
        async with ctx.channel.typing():
            formats = ['png', 'jpg', 'gif']
            if format is None:
                format = random.choice(formats)
            if format in formats:
                url = f'http://thecatapi.com/api/images/get?type={format}'
                async with self.session.get(url) as resp:
                    buffer = BytesIO(await resp.read())
                    img = discord.File(fp=buffer, filename=f'cat.{format}')
                    await ctx.send(content='meow', file=img)
            else:
                error_d = f'"{format}" is not a valid format, dumbass.'
                await ctx.send(embed=error_embed(error_d))
Exemplo n.º 8
0
    async def tmail(self, ctx, *, echo: str = None):
        """Sends a message directly to tatan :)."""
        tatan = self.bot.get_user(ids["tatan"])
        attachments = ctx.message.attachments
        if attachments:
            img = random.choice(attachments)
            async with self.session.get(img.url) as resp:
                buffer = BytesIO(await resp.read())

                content_type = resp.headers['content-type']
                ext = mimetypes.guess_extension(content_type)

                if ext.endswith('jpe'):
                    n_ext = '.jpeg'
                elif ext.endswith('mp2'):
                    n_ext = '.mp3'
                else:
                    n_ext = ext

                img_file = discord.File(fp=buffer, filename=f'attached{n_ext}')

                if echo is not None:
                    await tatan.send(
                        f'{echo}\n`sent by {ctx.author.display_name} in {ctx.channel.name}`',
                        file=img_file)
                else:
                    await tatan.send(
                        f'`sent by {ctx.author.display_name} in {ctx.channel.name}`',
                        file=img_file)
                await ctx.send(':+1: mailed to tatan :)')

        elif not attachments and echo is None:
            error_d = error_embed(
                'can you uh gimme a message or an image or somethin\'')
            await ctx.send(embed=error_d)
        else:
            await tatan.send(
                f'{echo}\n`sent by {ctx.author.display_name} in {ctx.channel.name}`'
            )
            await ctx.send(':+1: mailed to tatan :)')
Exemplo n.º 9
0
    async def avatar(self, ctx, member: discord.Member = None):
        """Changes the bot's avatar to that of the context's attachment."""
        async with ctx.typing():
            if member is None:
                attachments = ctx.message.attachments
                if attachments:
                    avatar = random.choice(attachments)
                    async with self.session.get(avatar.url) as resp:
                        buffer = BytesIO(await resp.read())

                        content_type = resp.headers['content-type']
                        ext = mimetypes.guess_extension(content_type)

                        if ext.endswith('jpe'):
                            n_ext = '.jpeg'
                        else:
                            n_ext = ext

                        avatar_file = discord.File(fp=buffer,
                                                   filename=f'avatar{n_ext}')

                        await self.bot.user.edit(avatar=await resp.read())
                        await ctx.send('new avatar set to:', file=avatar_file)
                else:
                    error_d = 'send an avatar idiot'
                    await ctx.send(embed=error_embed(error_d))
            else:
                async with self.session.get(
                        member.avatar_url_as(format='png')) as resp:
                    buffer = BytesIO(await resp.read())
                    avatar_file = discord.File(fp=buffer,
                                               filename='avatar.png')

                    await self.bot.user.edit(avatar=await resp.read())
                    await ctx.send(
                        f'new avatar set to {member.display_name.lower()}\'s:',
                        file=avatar_file)
Exemplo n.º 10
0
 async def genius(self, ctx):
     """For interacting with genius.com. Do !help genius."""
     if ctx.invoked_subcommand is None:
         error_d = 'ask tatan or something'
         await ctx.send(embed=error_embed(error_d))
Exemplo n.º 11
0
 async def music(self, ctx):
     if ctx.invoked_subcommand is None:
         error_d = 'no recognizable music command was called'
         await ctx.send(embed=error_embed(error_d))
Exemplo n.º 12
0
 async def debug(self, ctx):
     """Debug commands for debugging bugs."""
     if ctx.invoked_subcommand is None:
         error_d = "no debug command was called"
         await ctx.send(embed=error_embed(error_d))
Exemplo n.º 13
0
 async def config(self, ctx):
     """Configuration commands. Only the Owners can access them."""
     if ctx.invoked_subcommand is None:
         error_d = "no subcommand was called"
         await ctx.send(embed=error_embed(error_d))
Exemplo n.º 14
0
 async def mod(self, ctx):
     """Moderation commands. Quick shortcuts for moderating stuff."""
     if ctx.invoked_subcommand is None:
         error_d = 'you either didn\'t pass any command or you wrote some f****n typo'
         await ctx.send(embed=error_embed(error_d))
Exemplo n.º 15
0
 async def admin(self, ctx):
     """Admin commands. Useful for quickly administrating."""
     if ctx.invoked_subcommand is None:
         error_d = 'you either didn\'t pass any command or you wrote some f****n typo'
         await ctx.send(embed=error_embed(error_d))