Example #1
0
    async def suggest(self, ctx, option, *, suggestion):
        """
        Suggestion command that sends them to the creator.
        This command is on a 2 minute cooldown after one use
        Example: rd/suggest Feature Your bot is dumb, stop programming.
        :param ctx:
        :param option:
        :param suggestion:
        :return:
        """
        await ctx.message.delete()
        features = ['feature', 'bug', 'general']

        embed = discord.Embed(title='Suggestion',
                              color=discord.Color.from_rgb(0, 128, 0))

        if option.lower() not in features:
            embed.add_field(name='General', value=f'{option} {suggestion}')
        else:
            option = f'{option[0].upper()}{option[1:]}'
            embed.add_field(name=option, value=suggestion)

        owner = self.bot.get_user(self.bot.owner_id)

        await owner.send(embed=embed)
        await ctx.send('Your suggestion has been sent.')
        log.commandinfo(ctx)
Example #2
0
    async def unsub(self, ctx, *subreddit):
        """
        This command will 'unsubscribe' from a reddit and will no longer make posts.
        Usage: rd/unsub <subreddit>
        Ex. rd/unsub news funny husky
        Permissions required: Administrator
        :param ctx:
        :param subreddit:
        :return:
        """
        sid = ctx.message.guild.id
        sid = str(sid)
        subs = self.jfile.data[sid]['watching']
        removed = []
        for reddit in subreddit:
            if reddit in subs:
                subs.remove(reddit.lower())
                removed.append(reddit.lower())
            else:
                await ctx.send(
                    f'Subreddit: {reddit} not found. Please make sure you are spelling'
                    f' it correctly.')
        if removed:
            self.jfile.data[sid]['watching'] = subs
            await ctx.send(
                f"Subreddit(s): {', '.join(removed)} removed!\n"
                f"You will notice this change when I scour reddit again.")
            self.jfile.save

        log.commandinfo(ctx)
Example #3
0
 async def about(self, ctx):
     """
     Base command for all about commands.
     :param ctx:
     :return:
     """
     if ctx.invoked_subcommand is None:
         log.commandinfo(ctx)
         ctx.message.content = ctx.prefix + 'help ' + ctx.invoked_with
         await self.bot.process_commands(ctx.message)
Example #4
0
 async def setDefaults(self, ctx):
     """
     Base command to set the options for a guild.
     Usage: rd/default
     Permissions required: Administrator
     :param ctx:
     :return:
     """
     if ctx.invoked_subcommand is None:
         log.commandinfo(ctx)
         ctx.message.content = ctx.prefix + 'help ' + ctx.invoked_with
         await self.bot.process_commands(ctx.message)
Example #5
0
 async def botabout(self, ctx):
     """
     About the bot.
     Usage rd/about bot
     :param ctx:
     :return:
     """
     await ctx.send(
         '```'
         'This is a bot developed by LittlemanSMG in python using discord.py v1.0.0(rewrite\n'
         'I use a standard json file to store ID\'s and all the options for each guild.\n'
         'Code is free to use/look at, following the MIT lisence at '
         'www.github.com/littlemansmg/pydumpster \n'
         'Have any recommendations for/issues with the bot? Open up an Issue on github!\n'
         '```')
     log.commandinfo(ctx)
Example #6
0
 async def devabout(self, ctx):
     """
     About the Developer
     Usage: rd/about dev
     :param ctx:
     :return:
     """
     await ctx.send(
         '```'
         "I really don't feel like I need this, but here it is. I'm Scott 'LittlemanSMG' Goes, and"
         "I made this bot, with some help from the r/discord_bots discord. Originally, this bot was "
         "made using Praw, a reddit api wrapper, but ran into some massive blocking issues. There was so many"
         "issues that I had to remake the bot using aiohttp and it's a much better bot now. "
         "mee6 has this kind of functionality, but I didn't want to deal with all of mee6. I just wanted "
         "the reddit portion. The original intention was to streamline my meme consumption, but "
         "I realised that this bot could be used for more than just memes. All of my work is currently "
         "on github(www.github.com/littlemansmg). It isn't much because i'm still learning, "
         "but I am getting better.\n"
         "```")
     log.commandinfo(ctx)
Example #7
0
    async def listsubs(self, ctx):
        """
        Shows a list of subreddits that the bot is subscribed to on a guild.
        Usage rd/listsubs
        :param ctx:
        :return:
        """
        sid = ctx.message.guild.id
        sid = str(sid)
        subs = self.jfile.data[sid]['watching']
        strsub = ''
        if not subs:
            await ctx.send(
                'This guild isn\'t subbed to anything. Have an adminstrator type '
                '`r/sub <subreddit name>` to sub. EX `r/sub funny`')
        else:
            for sub in subs:
                strsub += f'r/{sub}\n'

            await ctx.send(f"This guild is subbed to:\n{strsub}")

        log.commandinfo(ctx)
Example #8
0
    async def subscribe(self, ctx, *subreddit):
        """
        This command will 'subscribe' to a reddit and will make posts from it.
        Usage: rd/sub <subreddit>
        Ex. rd/sub news funny husky
        Permissions required: Administrator
        :param ctx:
        :param subreddit:
        :return:
        """
        sid = ctx.message.guild.id
        sid = str(sid)
        subs = self.jfile.data[sid]['watching']
        added = []
        for reddit in subreddit:
            url = f"https://www.reddit.com/r/{reddit}/new/.json"
            posts = await resp.respcheck(url)

            if posts:
                if reddit.lower() in subs:
                    await ctx.send(f'{reddit} is already in your list!')
                    continue
                else:
                    subs.append(reddit.lower())
                    added.append(reddit.lower())
            else:
                await ctx.send(
                    f'Sorry, I can\'t reach {reddit}. '
                    f'Check your spelling or make sure that the reddit actually exists.'
                )
        if added:
            self.jfile.data[sid]['watching'] = subs
            await ctx.send(
                f"Subreddit(s): {', '.join(added)} added!\n"
                f"You will notice this change when I scour reddit again.")

            self.jfile.save

        log.commandinfo(ctx)