async def create(self, ctx: commands.Context, name: str, *, value: commands.clean_content) -> None: """Create tags for your server. Example: tag create hello Hi! I am the bot responding! Complex usage: https://github.com/fourjr/rainbot/wiki/Tags """ if value.startswith('http'): if value.startswith('https://hasteb.in') and 'raw' not in value: value = 'https://hasteb.in/raw/' + value[18:] async with self.bot.session.get(value) as resp: value = await resp.text() if name in [i.qualified_name for i in self.bot.commands]: await ctx.send('Name is already a pre-existing bot command') else: await self.bot.db.update_guild_config( ctx.guild.id, {'$push': { 'tags': { 'name': name, 'value': value } }}) await ctx.send(self.bot.accept)
async def link(self, ctx, *, username: commands.clean_content): """Link a reddit account with your discord account. This will replace any existing reddit accounts you have linked. """ if username.startswith('/u/'): username = username.replace('/u/', '', 1) elif username.startswith('u/'): username = username.replace('u/', '', 1) # throw away the value, this is just so we can tell if the user is valid try: _ = ctx.r.redditor(username).fullname except AttributeError: # seems to happen when a user has no activity, like /u/asdf. pass except NotFound: await ctx.send("Sorry! That username doesn't appear to be valid.") return if ctx.author.guild_permissions.ban_members is True \ or await self.bot.is_owner(ctx.author): # I'm bad at DRY query = """ INSERT INTO reddit_config (user_id, reddit_username) VALUES ($1, $2) ON CONFLICT (user_id) DO UPDATE SET reddit_username = EXCLUDED.reddit_username;""" await ctx.db.execute(query, ctx.author.id, username) await ctx.auto_react() await ctx.send("You've been approved! Woo!") return msg = ( 'Mods: can you please check that this is correct. If so, react ' 'with :white_check_mark:. Otherwise, react with :no_entry_sign:.') result = await ctx.prompt(msg, timeout=10 * 60, needs_mod=True, reacquire=False) if result is None: await ctx.send( 'Looks like a mod took too long to respond. Try again later :)' ) elif result is False: await ctx.send('Sorry mate. A mod denied your request.') else: query = """ INSERT INTO reddit_config (user_id, reddit_username) VALUES ($1, $2) ON CONFLICT (user_id) DO UPDATE SET reddit_username = EXCLUDED.reddit_username;""" await ctx.db.execute(query, ctx.author.id, username) await ctx.auto_react() await ctx.send("You've been approved! Woo!")