Ejemplo n.º 1
0
    async def source(self, ctx, *, command: str = None):
        """Look at the bots code"""

        if command is None:
            embed = embed_create(ctx.author, title='Source Code:',
                                 description='[Github for **Reminder Friend**]'
                                             '(https://github.com/DoggieLicc/ReminderFriend)')
            return await ctx.send(embed=embed)

        if command == 'help':
            src = type(self.bot.help_command)
            filename = inspect.getsourcefile(src)
        else:
            obj = self.bot.get_command(command.replace('.', ' '))
            if obj is None:
                embed = embed_create(ctx, title='Command not found!',
                                     description='This command wasn\'t found in this bot.')
                return await ctx.send(embed=embed)

            src = obj.callback.__code__
            filename = src.co_filename

        lines, _ = inspect.getsourcelines(src)
        code = ''.join(lines)

        buffer = StringIO(code)

        file = discord.File(fp=buffer, filename=filename)

        await ctx.send(f"Here you go, {ctx.author.mention}. (You should view this on a PC)", file=file)
Ejemplo n.º 2
0
 async def send_error_message(self, error):
     embed = embed_create(self.context.author,
                          title='Help command error!',
                          description=error,
                          color=0xeb4034)
     channel = self.get_destination()
     await channel.send(embed=embed)
Ejemplo n.º 3
0
    async def send_bot_help(self, mapping):
        ctx = self.context
        prefix = ctx.bot.prefix.get_custom_prefix(ctx.guild)

        embed = embed_create(self.context.author,
                             title='Help:',
                             description=f'The current prefixes are '
                             f'`{prefix}` '
                             f'and {self.context.bot.user.mention}\n\n'
                             f'`{prefix} help [command]` for command info\n'
                             f'`<arg>` - Required argument\n'
                             f'`[arg]` - Optional argument')
        for cog, command in mapping.items():
            _filtered = []
            for c in command:
                _filtered.append(c)
                if isinstance(c, commands.Group):
                    [_filtered.append(subc) for subc in c.commands]

            filtered = await self.filter_commands(_filtered, sort=True)
            command_signatures = [
                self.get_command_signature(c) for c in filtered
            ]
            if command_signatures:
                cog_name = getattr(cog, 'qualified_name', 'Other')
                embed.add_field(name=cog_name,
                                value='\n'.join(command_signatures),
                                inline=False)

        await self.get_destination().send(embed=embed)
Ejemplo n.º 4
0
    async def prefix(self, ctx, *, prefix):
        """Sets a custom prefix for this server!
        You can ping the bot to get the custom prefix."""

        if len(prefix) > 100:
            embed = embed_create(ctx.author,
                                 title='Prefix is too long!',
                                 description='Your prefix has to be less than 100 characters!',
                                 color=discord.Color.red())

            return await ctx.send(embed=embed)

        await self.bot.prefix.set_custom_prefix(ctx.guild, prefix)

        embed = embed_create(ctx.author,
                             title='Prefix successfully set!',
                             description=f'Prefix has been set to `{prefix}`')

        await ctx.send(embed=embed)
Ejemplo n.º 5
0
    async def send_command_help(self, command):
        embed = embed_create(self.context.author,
                             title=self.get_command_signature(command))
        embed.add_field(name='Command Help:', value=command.help)
        alias = command.aliases
        if alias:
            embed.add_field(name='Aliases',
                            value=', '.join(alias),
                            inline=False)

        channel = self.get_destination()
        await channel.send(embed=embed)
Ejemplo n.º 6
0
 async def send_group_help(self, group):
     embed = embed_create(self.context.author,
                          title=self.get_command_signature(group))
     embed.add_field(name='Help:',
                     value=f'{group.short_doc}\n',
                     inline=False)
     embed.add_field(name='Subcommand Help:', value='᲼', inline=False)
     for command in group.commands:
         embed.add_field(name=self.get_command_signature(command),
                         value=command.help,
                         inline=False)
     channel = self.get_destination()
     await channel.send(embed=embed)
Ejemplo n.º 7
0
 async def info(self, ctx):
     """Shows information for the bot!"""
     embed = embed_create(ctx.author, title="Info for Reminder Friend!",
                          description="This bot sets reminders for you!")
     embed.add_field(name="Invite this bot!", value=
                     "[**Invite**]"
                     "(https://discord.com/api/oauth2/authorize?"
                     "client_id=812140712803827742&permissions=18432&scope=bot)",
                     inline=False)
     embed.add_field(name="Join support server!",
                     value="[**Support Server**](https://discord.gg/Uk6fg39cWn)",
                     inline=False)
     embed.add_field(name='Bot Creator:',
                     value='[Doggie](https://github.com/DoggieLicc)#1641',
                     inline=True)
     embed.add_field(name='Bot Uptime:',
                     value=str(timedelta(seconds=self.get_uptime())), inline=False)
     embed.add_field(name='Ping:',
                     value='{} ms'.format(round(1000 * self.bot.latency), inline=False))
     await ctx.send(embed=embed)