Example #1
0
 async def get_tag(self, ctx):
     try:
         command = bot_tools.parse_command(ctx.message.content, 1)
     except ValueError:
         try:
             command = bot_tools.parse_command(ctx.message.content, 0)
         except:
             await ctx.send(embed=bot_tools.create_simple_embed(
                 ctx=ctx,
                 _title='Error',
                 _description=
                 f'{ctx.command.usage}. Use `!help {ctx.command.name}` for more details.'
             ))
             return
     if len(command) == 1:
         tags = [t['name'] for t in bot_db.get_all_tags()]
         await ctx.send(embed=bot_tools.create_list_embed(
             ctx=ctx,
             _title='Tags',
             _description='Here is a list of all the tags you can use.',
             _field_name='Tags',
             items=tags))
     else:
         [_, tag_name] = command
         tag = bot_db.get_tag(tag_name)
         if not bot_db.exists_tag(tag_name):
             await ctx.send(embed=bot_tools.create_simple_embed(
                 ctx=ctx,
                 _title='Error',
                 _description=f'The Tag `{tag_name}` does not exists.'))
         else:
             await ctx.send(tag['response'])
Example #2
0
async def get_tag(ctx):
    try: 
        command = bot_tools.parse_command(ctx.message.content, 1)
    except ValueError:
        await ctx.send('Error: Tags are all one word.')
        return
    [_, tag_name] = command
    tag = bot_db.get_tag(tag_name)
    if not bot_db.exists_tag(tag_name):
        await ctx.send(f'Error: The tag `{tag_name}` does not exist.')
    else:
        await ctx.send(tag['response'])
Example #3
0
async def remove_tag(ctx):
    if bot_tools.is_admin(ctx.author):
        try:
            command = bot_tools.parse_command(ctx.message.content, 1)
        except ValueError:
            await ctx.send('Error: To remove a tag, use !t_remove followed by just the name of tag.')
            return
        [_, tag_name] = command
        if not bot_db.exists_tag(tag_name):
            await ctx.send(f'Error: `{tag_name}` does not exists!')
            return
        else:
            bot_db.remove_tag(tag_name)
            await ctx.send(f'Sucessfully removed tag `{tag_name}`.')
    else:
        await ctx.send('Erorr: **You must be an admin to use this command!**')
Example #4
0
async def add_tag(ctx):
    if bot_tools.is_admin(ctx.author):
        try:
            command = bot_tools.parse_command(ctx.message.content, 2)
        except ValueError:
            await ctx.send('Error: To create tags, use !t_add followed by the name followed by the messsage.')
            return
        [_, tag_name, tag_content] = command
        if bot_db.exists_tag(tag_name):
            await ctx.send(f'Error: The tag `{tag_name}` already exists.')
            return
        else:
            bot_db.add_tag(tag_name, tag_content)
            await ctx.send(f'Successfully added tag `{tag_name}`!')
    else:
        await ctx.send('Error: **You must be an admin to use this command!**')
Example #5
0
    async def add_tag_command(self, ctx):
        if not bot_db.is_mod(ctx.author.name):
            utils.log_body('[Bot#add_tag_command] Access denied to ' + ctx.author.name)
            return
        try:
            command = bot_tools.parse_command(ctx.message.content, 2)
        except ValueError:
            return await ctx.send('Usage: add_tag <tag_name> <tag_response>')

        [_, tag_name, tag_response] = command
        utils.log_kv('Adding tag', [tag_name, tag_response])

        if bot_db.exists_tag(tag_name):
            await ctx.send(f'Tag {tag_name} already exists.')
        else:
            bot_db.add_tag(tag_name, tag_response)
            self.add_command(Command(name=tag_name, func=self.get_tag, aliases=[], instance=None))
            await ctx.send(f'Added tag {tag_name}.')
Example #6
0
    async def remove_tag_command(self, ctx):
        if not bot_db.is_mod(ctx.author.name):
            utils.log_body('[Bot#remove_tag_command] Access denied to ' + ctx.author.name)
            return
        try:
            command = bot_tools.parse_command(ctx.message.content, 1)
        except ValueError:
            return await ctx.send('Usage: remove_tag <tag_name>')

        [_, tag_name] = command
        utils.log_kv('Removing tag', tag_name)

        if bot_db.exists_tag(tag_name):
            bot_db.remove_tag(tag_name)

            async def dummy_func():
                pass

            self.remove_command(Command(name=tag_name, func=dummy_func))

            await ctx.send(f'Removed tag {tag_name}.')
        else:
            await ctx.send(f'Tag {tag_name} does not exist.')
Example #7
0
 async def remove_tag(self, ctx):
     try:
         command = bot_tools.parse_command(ctx.message.content, 1)
     except ValueError:
         await ctx.send(embed=bot_tools.create_simple_embed(
             ctx=ctx,
             _title='Error',
             _description=
             f'{ctx.command.usage}. Use `!help {ctx.command.name}` for more details.'
         ))
         return
     [_, tag_name] = command
     if not bot_db.exists_tag(tag_name):
         await ctx.send(embed=bot_tools.create_simple_embed(
             ctx=ctx,
             _title='Error',
             _description=f'`{tag_name}` does not exists!'))
         return
     else:
         bot_db.remove_tag(tag_name)
         await ctx.send(embed=bot_tools.create_simple_embed(
             ctx=ctx,
             _title='Tag',
             _description=f'Successfully removed tag `{tag_name}`'))
Example #8
0
 async def add_tag(self, ctx):
     try:
         command = bot_tools.parse_command(ctx.message.content, 2)
     except ValueError:
         await ctx.send(embed=bot_tools.create_simple_embed(
             ctx=ctx,
             _title='Error',
             _description=
             f'{ctx.command.usage}. Use `!help {ctx.command.name}` for more details.'
         ))
         return
     [_, tag_name, tag_content] = command
     if bot_db.exists_tag(tag_name):
         await ctx.send(embed=bot_tools.create_simple_embed(
             ctx=ctx,
             _title='Error',
             _description=f'The tag `{tag_name}` already exists.'))
         return
     else:
         bot_db.add_tag(tag_name, tag_content)
         await ctx.send(embed=bot_tools.create_simple_embed(
             ctx=ctx,
             _title='Tag',
             _description=f'Successfully added tag `{tag_name}`!'))