Example #1
0
    async def kick(self,
                   ctx,
                   member: commands.MemberConverter,
                   *,
                   reason=None):
        """**Kick the specified member from the guild**
        **Args**:
        - `member`: The member to kick.
        - `reason`: The reason for kicking. This is optional.
        **Required Perms**:
        - `kick_members`: This permission is required by both bot and the user.
        **Examples**: ```bash
        +kick 659094769607245845
        +kick @MEE6 cuz why not
        ```
        """

        if member == ctx.author:
            await ctx.send('You can\'t kick yourself.')
            return

        await member.kick(reason=reason)

        embed = normal_embed(
            ctx,
            title='Kicked',
            description=f'Successfully kicked `{member.name}`.')
        await ctx.send(embed=embed)
Example #2
0
    async def write_page(self, menu, categories):
        offset = (menu.current_page * self.per_page) + 1
        len_data = len(self.entries)

        menu_embed = normal_embed(
            self.ctx,
            title='Help!',
            description=cleandoc(f"""**Hi, what can I help you with?**
                тЦля╕П For more specific and detailed help for each commands, use:
                `{self.ctx.prefix}help [category | command_name]`
                тЦля╕П  For further help, join my support server.
                **Bot Prefix**: {self.ctx.prefix}
                """))
        menu_embed.set_thumbnail(url=self.ctx.guild.icon_url if self.ctx.
                                 guild else self.ctx.author.avatar_url)

        menu_embed.set_footer(
            text=
            f"Showing {offset:,} - {min(len_data, offset+self.per_page-1):,} of {len_data:,} categories.",
            icon_url=self.ctx.author.avatar_url)

        for category in categories:
            menu_embed.add_field(name=f'ЁЯФ╣ {category[0].capitalize()}',
                                 value=category[1],
                                 inline=False)

        return menu_embed
Example #3
0
    async def write_page(self, menu, commands):
        offset = (menu.current_page * self.per_page) + 1
        len_data = len(self.entries)

        menu_embed = normal_embed(
            self.ctx,
            title='Help!',
            description=cleandoc(
                f"""**Hi, These are all the available commands under this category.**
                тЦля╕П For more specific and detailed help for each commands, use:
                `{self.ctx.prefix}help [category | command_name]`
                """))
        menu_embed.set_thumbnail(url=self.ctx.guild.icon_url if self.ctx.
                                 guild else self.ctx.author.avatar_url)

        menu_embed.set_footer(
            text=
            f"Showing {offset:,} - {min(len_data, offset+self.per_page-1):,} of {len_data:,} commands.",
            icon_url=self.ctx.author.avatar_url)

        for command in commands:
            menu_embed.add_field(name=f'ЁЯФ╣ {command[0]}',
                                 value=command[1],
                                 inline=False)

        return menu_embed
Example #4
0
    async def add_auto_roles(self, ctx, roles: commands.Greedy[commands.RoleConverter]):
        """**You can add the roles for auto roles feature using this command.**
        **Args**:
        - `roles`: The roles you want to add.
        **Examples**: ```bash
        +add auto_roles @newbie @members
        +add auto_roles 741364951356276810
        +add ar 741364951356276810
        ```
        """
        if not roles:
            await ctx.send('Please provide atleast one role.')
            return

        for role in roles:
            await self.auto_roles_collection.insert_one({
                '_id': role.id,
                'guild_id': ctx.guild.id
            })

        embed = normal_embed(
            ctx,
            title='Done',
            description=f'Successfully added `{len(roles)}` roles for auto roles.'
        )
        await ctx.send(embed=embed)
Example #5
0
async def ask_yes_or_no_question(ctx, bot, embed_title, question, deny_message,
                                 timeout_message):
    """Ask a yes or no question using the wait_for feature."""
    def check(msg):
        return msg.content.lower().split()[0] in [
            'yes', 'no', 'y', 'n'
        ] and msg.channel == ctx.channel and msg.author == ctx.author

    embed = normal_embed(ctx, title=embed_title, description=question)
    await ctx.send(embed=embed)

    try:
        user_response_msg = await bot.wait_for('message',
                                               check=check,
                                               timeout=60.0)

        if user_response_msg.content.lower().split()[0] in ['no', 'n']:
            await ctx.send(deny_message)
            return False

        return True

    except asyncio.TimeoutError:
        await ctx.send(timeout_message)
        return False
Example #6
0
    async def meme(self, ctx):
        """**Fetches a random meme from reddit.**
        **Examples**: ```bash
        +meme
        +memes
        ```
        """
        json_response = await fetch_json(self.memeapi_base_url,
                                         self.bot.aio_session)

        if json_response['nsfw']:
            user_choice = await ask_yes_or_no_question(
                ctx, self.bot, 'NSFW Warning!',
                'The meme fetched by the api may be considered NSFW.\nWould you like to see it anyways? (yes/no)',
                'Alrighty, I won\'t show it.',
                'Sorry, You didn\'t respond on time. Please try again!')

            if not user_choice:
                return

        embed = normal_embed(
            ctx,
            title='A random meme for you!',
        )

        postlink = json_response['postLink']
        author = json_response['author']
        ups = json_response['ups']

        embed.add_field(name='Title:',
                        value=json_response['title'],
                        inline=True)
        embed.add_field(name='Subreddit:',
                        value=json_response['subreddit'],
                        inline=True)
        embed.add_field(name='Postlink:',
                        value=f'[Click me!]({postlink})',
                        inline=True)

        embed.add_field(name='Author:',
                        value=json_response['author'],
                        inline=True)
        embed.add_field(name='Upvotes:',
                        value=json_response['ups'],
                        inline=True)
        embed.add_field(name='NSFW:', value=json_response['nsfw'], inline=True)

        embed.set_image(url=json_response['url'])

        embed.set_footer(text='Powered by the meme-api',
                         icon_url=ctx.author.avatar_url)

        await ctx.send(embed=embed)
Example #7
0
 async def ping(self, ctx):
     """Get the bot's latency in ms's.
     This could be referred to as the Discord WebSocket protocol latency.
     If you're experiencing high latency then probably something's up on the discord side. https://status.discord.com
     """
     latency = round(self.bot.latency * 1000)
     embed = normal_embed(
         ctx,
         title='Pong!',
         description=f"""Hello, I currently am experiencing a latency of ``{latency}ms``.
         If you\'re experiencing high latency then probably something\'s up on the discord side."""
     )
     await ctx.send(embed=embed)
Example #8
0
    async def _set_config_value(self, ctx, config_type, config_value, success_msg):
        is_config_entry_exists = await is_config_value_set(
            self.config_collection,
            ctx.guild.id,
            config_type
        )

        if is_config_entry_exists:
            await update_config_value(
                self.config_collection,
                ctx.guild.id,
                config_type,
                config_value
            )

            embed = normal_embed(
                ctx,
                title='Set config value',
                description=success_msg
            )
            await ctx.send(embed=embed)

        else:
            await set_config_value(
                self.config_collection,
                ctx.guild.id,
                config_type,
                config_value
            )

            embed = normal_embed(
                ctx,
                title='Set config value',
                description=success_msg
            )
            await ctx.send(embed=embed)
Example #9
0
    async def purge(self, ctx, messages: int):
        """**Purges the specified amount of messages**
        **Args**:
        - `messages`: Number of messages to delete.
        **Required Perms**:
        - `manage_messages`: This permission is required by both bot and the user.
        **Examples**: ```bash
        +purge 10
        +purge 50
        ```
        """
        await ctx.message.delete()

        deleted = await ctx.channel.purge(limit=messages)
        embed = normal_embed(
            ctx,
            title='Purged messages',
            description=f'Successfully purged {len(deleted)} messages.')

        await ctx.send(embed=embed, delete_after=3)
Example #10
0
    async def unban(self, ctx, user: commands.UserConverter, *, reason=None):
        """**Unban the specified user from the guild**
        **Args**:
        - `user`: The user to unban.
        - `reason`: The reason for unban. This is optional.
        **Required Perms**:
        - `ban_members`: This permission is required by both bot and the user.
        **Examples**: ```bash
        +unban 659094769607245845
        +unban @MEE6 cuz people like you
        ```
        """

        await ctx.guild.unban(user, reason=reason)

        embed = normal_embed(
            ctx,
            title='Unbanned',
            description=f'Successfully unbanned `{user.name}`.')
        await ctx.send(embed=embed)
Example #11
0
    async def send_command_help(self, command, ctx):
        """Send help about a specific command"""
        embed = normal_embed(ctx,
                             title='Help!',
                             description=command.help or "No Help Message")
        embed.set_thumbnail(
            url=ctx.guild.icon_url if ctx.guild else ctx.author.avatar_url)

        embed.add_field(name='Name:', value=command.name, inline=True)
        embed.add_field(name='Category:',
                        value=command.cog.qualified_name,
                        inline=True)
        embed.add_field(name='Aliases:',
                        value=', '.join(command.aliases) or 'None',
                        inline=True)

        embed.add_field(name='Usage:',
                        value=self.format_command_usage(ctx, command),
                        inline=False)

        await ctx.send(embed=embed)
Example #12
0
    async def send_group_help(self, group):
        embed = normal_embed(self.context,
                             title='Help!',
                             description=(group.help or "No Help Message") +
                             "\n▫️ *This command is a group.*")
        embed.set_thumbnail(url=self.context.guild.icon_url if self.context.
                            guild else self.context.author.avatar_url)

        embed.add_field(name='🔹 __**Name**__:', value=group.name, inline=False)
        embed.add_field(name='🔹 __**Category**__:',
                        value=group.cog.qualified_name,
                        inline=False)
        embed.add_field(name='🔹 __**Aliases**__:',
                        value=', '.join(group.aliases) or 'None',
                        inline=True)

        embed.add_field(name='🔹 __**Usage**__:',
                        value=self.format_command_usage(self.context, group),
                        inline=False)

        await self.context.send(embed=embed)
Example #13
0
    async def _8ball(self, ctx, *, question):
        """**Ask a question to the magic 8ball.**
        **Args**:
        - `question`: The question to ask the 8ball.
        **Examples**: ```bash
        +8ball Is jeju the best bot ever?
        +8ball Will I be single forever?
        +8ball Am I a good coder? 
        ```
        """
        responses = self._8ball_responses

        choosen_response = random.choice(responses)

        embed = normal_embed(ctx, title='8ball')

        embed.add_field(name='You asked:', value=question, inline=False)
        embed.add_field(name='Magic 8ball thinks:',
                        value=choosen_response,
                        inline=False)

        await ctx.send(embed=embed)
Example #14
0
    async def set_prefix(self, ctx, prefix):
        """**You can set the bot prefix using this command.**
        **Args**:
        - `prefix`: The prefix you want to set.
        **Examples**: ```bash
        +set prefix !
        +set prefix +
        +set prefix j!
        ```
        """
        await set_custom_prefix(
            self.guilds_collection,
            ctx.guild.id,
            prefix
        )

        embed = normal_embed(
            ctx,
            title='Set prefix',
            description=f'Successfully set `{prefix}` as the bot prefix.\nYou can change it back later.'
        )
        await ctx.send(embed=embed)
Example #15
0
    async def ban(self, ctx, user: commands.UserConverter, *, reason=None):
        """**Ban the specified user from the guild**
        **Args**:
        - `user`: The user to ban.
        - `reason`: The reason for banning. This is optional.
        **Required Perms**:
        - `ban_members`: This permission is required by both bot and the user.
        **Examples**: ```bash
        +ban 659094769607245845
        +ban @MEE6 cuz why not
        ```
        """

        if user == ctx.author:
            await ctx.send('You can\'t ban yourself.')
            return

        await ctx.guild.ban(user, reason=reason)

        embed = normal_embed(ctx,
                             title='Banned',
                             description=f'Successfully banned `{user.name}`.')
        await ctx.send(embed=embed)
Example #16
0
    async def _disable_guild_feature(self, ctx, config_type, success_msg):
        is_config_entry_exists = await is_config_value_set(
            self.config_collection,
            ctx.guild.id,
            config_type
        )

        if is_config_entry_exists:
            is_feature_enabled = await get_config_value(
                self.config_collection,
                ctx.guild.id,
                config_type
            )

            if is_feature_enabled:
                await delete_config_value(
                    self.config_collection,
                    ctx.guild.id,
                    config_type
                )

                embed = normal_embed(
                    ctx,
                    title='Disabled feature',
                    description=success_msg
                )
                await ctx.send(embed=embed)

        else:
            embed = error_embed(
                ctx,
                error_name='Already Disabled',
                error_msg='Sorry, This Feature is already disabled.\nIf you want to enable it then use the `enable` command.'
            )
            await ctx.send(embed=embed)
            return