Exemplo n.º 1
0
async def createrole(cmd, message, args):
    
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(type='rich', color=0xDB0000, title='⛔ Insufficient Permissions. Server Admin Only.')
        await message.channel.send(None, embed=out_content)
        return
    
    if not args:
        out_content = discord.Embed(type='rich', color=0xDB0000, title='❗ Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await message.channel.send(None, embed=out_content)
        return
    
    role_qry = ' '.join(args)
    exists = matching_role(message.guild, role_qry)
    
    if exists:
        out_content = discord.Embed(type='rich', color=0xFF9900, title='⚠ Error')
        out_content.add_field(name='Role Exists', value='A role with the name **' + role_qry + '** already exists.')
        await message.channel.send(None, embed=out_content)
        return

    await message.guild.create_role(name=role_qry)
    out_content = discord.Embed(type='rich', color=0x33CC33, title='✅ Role ' + role_qry + ' created.')
    await message.channel.send(None, embed=out_content)
Exemplo n.º 2
0
async def destroyrole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title='⛔ Insufficient Permissions. Server Admin Only.')
        await message.channel.send(None, embed=out_content)
        return
    if not args:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await message.channel.send(None, embed=out_content)
        return
    role_qry = ' '.join(args)
    target_role = matching_role(message.guild, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='❗ Error')
        out_content.add_field(name='Role Not Found',
                              value='I was unable to find **' + role_qry +
                              '** on this server.')
        await message.channel.send(None, embed=out_content)
    else:
        await target_role.delete()
        out_content = discord.Embed(type='rich',
                                    color=0x66cc66,
                                    title='✅ Role ' + role_qry + ' destroyed.')
        await message.channel.send(None, embed=out_content)
Exemplo n.º 3
0
async def destroyrole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':no_entry: Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if not args:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title=':exclamation: Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    role_qry = ' '.join(args)
    target_role = matching_role(message.server, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title=':exclamation: Error')
        out_content.add_field(name='Role Not Found',
                              value='I was unable to find **' + role_qry +
                              '** on this server.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
    else:
        await cmd.bot.delete_role(message.server, target_role)
        out_content = discord.Embed(type='rich',
                                    color=0x66cc66,
                                    title=':white_check_mark: Role ' +
                                    role_qry + ' destroyed.')
        await cmd.bot.create_role(message.server, name=role_qry)
        await cmd.bot.send_message(message.channel, None, embed=out_content)
Exemplo n.º 4
0
async def delselfrole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(type='rich', color=0xDB0000,
                                    title=':no_entry: Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if not args:
        out_content = discord.Embed(type='rich', color=0xDB0000, title=':exclamation: Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    role_qry = ' '.join(args)
    target_role = matching_role(message.server, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich', color=0xFF9900, title=':exclamation: Error')
        out_content.add_field(name='Role Not Found', value='I was unable to find **' + role_qry + '** on this server.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
    else:
        try:
            self_roles = cmd.db.get_settings(message.server.id, 'SelfRoles')
        except:
            cmd.db.set_settings(message.server.id, 'SelfRoles', [])
            self_roles = []
        if target_role.name in self_roles:
            self_roles.remove(target_role.name)
            cmd.db.set_settings(message.server.id, 'SelfRoles', self_roles)
            out_content = discord.Embed(type='rich', color=0x66cc66,
                                        title=':white_check_mark: Role **' + target_role.name + '** removed from the self assignable roles list.')
            await cmd.bot.send_message(message.channel, None, embed=out_content)
        else:
            out_content = discord.Embed(type='rich', color=0xFF9900, title=':warning: Error')
            out_content.add_field(name='Role Not Self Assignable',
                                  value='I was unable to find **' + role_qry + '** in the list of self assignable roles.')
            await cmd.bot.send_message(message.channel, None, embed=out_content)
Exemplo n.º 5
0
async def createrole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':no_entry: Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if not args:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title=':exclamation: Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    role_qry = ' '.join(args)
    exists = matching_role(message.server, role_qry)
    if exists:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title=':warning: Error')
        out_content.add_field(name='Role Exists',
                              value='A role with the name **' + role_qry +
                              '** already exists.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
    else:
        out_content = discord.Embed(type='rich',
                                    color=0x33CC33,
                                    title=':white_check_mark: Role ' +
                                    role_qry + ' created.')
        await cmd.bot.create_role(message.server, name=role_qry)
        await cmd.bot.send_message(message.channel, None, embed=out_content)
Exemplo n.º 6
0
async def addselfrole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(type='rich', color=0xDB0000,
                                    title='⛔ Insufficient Permissions. Server Admin Only.')
        await message.channel.send(None, embed=out_content)
        return
    if not args:
        out_content = discord.Embed(type='rich', color=0xDB0000, title='❗ Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await message.channel.send(None, embed=out_content)
        return
    role_qry = ' '.join(args)
    target_role = matching_role(message.guild, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich', color=0xFF9900, title='❗ Error')
        out_content.add_field(name='Role Not Found', value='I was unable to find **' + role_qry + '** on this server.')
        await message.channel.send(None, embed=out_content)
    else:
        try:
            self_roles = cmd.db.get_settings(message.guild.id, 'SelfRoles')
        except:
            cmd.db.set_settings(message.guild.id, 'SelfRoles', [])
            self_roles = []
        if target_role.id not in self_roles:
            self_roles.append(target_role.id)
            cmd.db.set_settings(message.guild.id, 'SelfRoles', self_roles)
            out_content = discord.Embed(type='rich', color=0x66cc66,
                                        title='✅ Role **' + target_role.name + '** added to the self assignable roles list.')
            await message.channel.send(None, embed=out_content)
        else:
            out_content = discord.Embed(type='rich', color=0xFF9900, title='⚠ Error')
            out_content.add_field(name='Role In List',
                                  value='The role **' + role_qry + '** is already in the list of self assignable roles.')
            await message.channel.send(None, embed=out_content)
Exemplo n.º 7
0
async def unpermitrole(cmd, message, args):
    if args:
        if len(args) >= 2:
            if not check_admin(message.author, message.channel):
                response = discord.Embed(title='⛔ Unpermitted. Server Admin Only.', color=0xDB0000)
            else:
                target_name = args[1]
                target = matching_role(message.guild, target_name)
                if target:
                    error_response = discord.Embed(color=0xDB0000, title='❗ Bad Input')
                    try:
                        perm_mode, cmd_name = args[0].split(':')
                    except:
                        await message.channel.send(embed=error_response)
                        return
                    cmd_name = cmd_name.lower()
                    perm_mode = perm_mode.lower()
                    if perm_mode == 'c':
                        exception_group = 'CommandExceptions'
                        check_group = cmd.bot.plugin_manager.commands
                        check_alts = True
                    elif perm_mode == 'm':
                        exception_group = 'ModuleExceptions'
                        check_group = cmd.bot.module_list
                        check_alts = False
                    else:
                        await message.channel.send(embed=error_response)
                        return
                    if check_alts:
                        if cmd_name in cmd.bot.alts:
                            cmd_name = cmd.bot.alts[cmd_name]
                    if cmd_name in check_group:
                        perms = get_all_perms(cmd.db, message)
                        cmd_exc = perms[exception_group]
                        if cmd_name in perms[exception_group]:
                            inner_exc = cmd_exc[cmd_name]
                        else:
                            inner_exc = generate_cmd_data(cmd_name)[cmd_name]
                        exc_usrs = inner_exc['Roles']
                        if target.id in exc_usrs:
                            exc_usrs.remove(target.id)
                            inner_exc.update({'Roles': exc_usrs})
                            cmd_exc.update({cmd_name: inner_exc})
                            perms.update({exception_group: cmd_exc})
                            cmd.db.update_one('Permissions', {'ServerID': message.guild.id}, {'$set': perms})
                            response = discord.Embed(color=0x66CC66,
                                                     title=f'✅ `{target.name}` can no longer use `{cmd_name}`.')
                        else:
                            response = discord.Embed(color=0xFF9900,
                                                     title=f'⚠ {target.name} is not able to use `{cmd_name}`')
                    else:
                        response = discord.Embed(color=0x696969, title='🔍 Command/Module Not Found')
                else:
                    response = discord.Embed(color=0x696969, title=f'🔍 No {target_name} Role Found')
        else:
            response = discord.Embed(color=0xDB0000, title='❗ Not Enough Arguments')
    else:
        response = discord.Embed(color=0xDB0000, title='❗ Not Arguments Given')
    await message.channel.send(embed=response)
Exemplo n.º 8
0
async def shopadd(cmd, message, args):
    if not check_admin(message.author, message.channel):
        status = discord.Embed(
            type='rich',
            color=0xDB0000,
            title='⛔ Insufficient Permissions. Server Admin Only.')
        await message.channel.send(None, embed=status)
        return
    if not args:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title='❗ Insufficient Arguments.')
        await message.channel.send(None, embed=status)
        return
    if len(args) < 2:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title='❗ Insufficient Arguments.')
        await message.channel.send(None, embed=status)
        return
    price = args[0]
    role_name = ' '.join(args[1:])
    rtrl = matching_role(message.guild, role_name)
    if not rtrl:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title='❗ The Role ' + role_name +
                               ' was not found on the server.')
        await message.channel.send(None, embed=status)
        return
    role_data = {
        'RoleName': rtrl.name,
        'RoleID': rtrl.id,
        'RoleColor': str(rtrl.color),
        'Price': price
    }
    shop_list = cmd.db.get_settings(message.guild.id, 'ShopItems')
    if not shop_list:
        cmd.db.set_settings(message.guild.id, 'ShopItems', [])
        shop_list = []
    found = False
    for item in shop_list:
        if item['RoleID'] == rtrl.id:
            found = True
            status = discord.Embed(type='rich',
                                   color=0xFF9900,
                                   title='⚠ The Role ' + rtrl.name +
                                   ' is already in the shop.')
            await message.channel.send(None, embed=status)
            break
    if found == 0:
        shop_list.append(role_data)
        cmd.db.set_settings(message.guild.id, 'ShopItems', shop_list)
        status = discord.Embed(type='rich',
                               color=0x66CC66,
                               title='✅ ' + rtrl.name +
                               ' has been added to the shop.')
        await message.channel.send(None, embed=status)
Exemplo n.º 9
0
async def giverole(cmd, message, args):

    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title='⛔ Insufficient Permissions. Needs manage roles permission.')
        await message.channel.send(None, embed=out_content)
        return

    if len(args) < 2:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Error')
        out_content.add_field(name='Missing Arguments', value=cmd.help())
        await message.channel.send(None, embed=out_content)
        return

    if not message.mentions:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Error')
        out_content.add_field(name='Missing Target User', value=cmd.help())
        await message.channel.send(None, embed=out_content)
        return

    role_qry = ' '.join(args[1:])
    target_role = matching_role(message.guild, role_qry)
    target_user = message.mentions[0]
    user_contained_role = user_matching_role(target_user, role_qry)

    if not target_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='❗ Error')
        out_content.add_field(name='Role Not Found',
                              value='I was unable to find **' + role_qry +
                              '** on this server.')
        await message.channel.send(None, embed=out_content)
        return

    if user_contained_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='❗ Error')
        out_content.add_field(name='User Has Role',
                              value='The user **' + target_user.name +
                              '** already has this role.')
        await message.channel.send(None, embed=out_content)

    await target_user.add_roles(target_role)
    out_content = discord.Embed(type='rich',
                                color=0x66cc66,
                                title='✅ Role ' + role_qry + ' given to **' +
                                target_user.name + '**.')
    await message.channel.send(None, embed=out_content)
Exemplo n.º 10
0
async def takerole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title='⛔ Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if len(args) < 2:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Error')
        out_content.add_field(name='Missing Arguments', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if not message.mentions:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Error')
        out_content.add_field(name='Missing Target User', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    role_qry = ' '.join(args[1:])
    target_role = matching_role(message.server, role_qry)
    target_user = message.mentions[0]
    user_contained_role = user_matching_role(target_user, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='❗ Error')
        out_content.add_field(name='Role Not Found',
                              value='I was unable to find **' + role_qry +
                              '** on this server.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
    else:
        if user_contained_role:
            await cmd.bot.remove_roles(target_user, target_role)
            out_content = discord.Embed(type='rich',
                                        color=0x66cc66,
                                        title='✅ Role ' + role_qry +
                                        ' removed from **' + target_user.name +
                                        '**.')
            await cmd.bot.create_role(message.server, name=role_qry)
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
        else:
            out_content = discord.Embed(type='rich',
                                        color=0xFF9900,
                                        title='❗ Error')
            out_content.add_field(name='User Missing Role',
                                  value='I was unable to find **' + role_qry +
                                  '** in ' + target_user.name + '\'s roles.')
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
Exemplo n.º 11
0
async def shopremove(cmd, message, args):

    if not check_admin(message.author, message.channel):
        status = discord.Embed(
            type='rich',
            color=0xDB0000,
            title='⛔ Insufficient Permissions. Server Admin Only.')
        await message.channel.send(None, embed=status)
        return

    if not args:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title='❗ Insufficient Arguments.')
        await message.channel.send(None, embed=status)
        return

    role_name = ' '.join(args)
    rtrl = matching_role(message.guild, role_name)
    shop_list = cmd.db.get_settings(str(message.guild.id), 'ShopItems')

    if not rtrl:
        for item in shop_list:
            if item['RoleName'].lower() != role_name.lower(): continue

            shop_list.remove(item)
            status.set_footer(
                text='It was found in the shop however, and removed.')
            cmd.db.set_settings(str(message.guild.id), 'ShopItems', shop_list)
            break

        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title='❗ The Role ' + role_name +
                               ' was not found on the server.')
        await message.channel.send(None, embed=status)
        return

    for item in shop_list:
        if item['RoleID'] != rtrl.id: continue
        shop_list.remove(item)
        cmd.db.set_settings(str(message.guild.id), 'ShopItems', shop_list)

        status = discord.Embed(type='rich',
                               color=0x66CC66,
                               title='✅ ' + rtrl.name +
                               ' has been removed from the shop.')
        await message.channel.send(None, embed=status)
        return

    status = discord.Embed(type='rich',
                           color=0xFF9900,
                           title='⚠ The Role ' + rtrl.name +
                           ' is not in the shop.')
    await message.channel.send(None, embed=status)
Exemplo n.º 12
0
async def giverole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':no_entry: Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if len(args) < 2:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title=':exclamation: Error')
        out_content.add_field(name='Missing Arguments', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if not message.mentions:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title=':exclamation: Error')
        out_content.add_field(name='Missing Target User', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    role_qry = ' '.join(args[1:])
    target_role = matching_role(message.server, role_qry)
    target_user = message.mentions[0]
    user_contained_role = user_matching_role(target_user, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title=':exclamation: Error')
        out_content.add_field(name='Role Not Found',
                              value='I was unable to find **' + role_qry +
                              '** on this server.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
    else:
        if not user_contained_role:
            await cmd.bot.add_roles(target_user, target_role)
            out_content = discord.Embed(type='rich',
                                        color=0x66cc66,
                                        title=':white_check_mark: Role ' +
                                        role_qry + ' given to **' +
                                        target_user.name + '**.')
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
        else:
            out_content = discord.Embed(type='rich',
                                        color=0xFF9900,
                                        title=':exclamation: Error')
            out_content.add_field(name='User Has Role',
                                  value='The user **' + target_user.name +
                                  '** already has this role.')
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
Exemplo n.º 13
0
async def shopremove(cmd, message, args):
    if not check_admin(message.author, message.channel):
        status = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':no_entry: Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=status)
        return
    if not args:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title=':exclamation: Insufficient Arguments.')
        await cmd.bot.send_message(message.channel, None, embed=status)
        return
    role_name = ' '.join(args)
    rtrl = matching_role(message.server, role_name)
    shop_list = cmd.db.get_settings(message.server.id, 'ShopItems')
    if not rtrl:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title=':exclamation: The Role ' + role_name +
                               ' was not found on the server.')
        for item in shop_list:
            if item['RoleName'].lower() == role_name.lower():
                shop_list.remove(item)
                status.set_footer(
                    text='It was found in the shop however, and removed.')
                cmd.db.set_settings(message.server.id, 'ShopItems', shop_list)
                break
        await cmd.bot.send_message(message.channel, None, embed=status)
        return
    else:
        found = False
        for item in shop_list:
            if item['RoleID'] == rtrl.id:
                found = True
                shop_list.remove(item)
                cmd.db.set_settings(message.server.id, 'ShopItems', shop_list)
                status = discord.Embed(type='rich',
                                       color=0x66CC66,
                                       title=':white_check_mark: ' +
                                       rtrl.name +
                                       ' has been removed from the shop.')
                await cmd.bot.send_message(message.channel, None, embed=status)
                break
        if not found:
            status = discord.Embed(type='rich',
                                   color=0xFF9900,
                                   title=':warning: The Role ' + rtrl.name +
                                   ' is not in the shop.')
            await cmd.bot.send_message(message.channel, None, embed=status)
Exemplo n.º 14
0
async def autorole(cmd, message, args):
    
    if not check_admin(message.author, message.channel):
        out_content = discord.Embed(type='rich', color=0xDB0000, title='⛔ Insufficient Permissions. Server Admin Only.')
        await message.channel.send(None, embed=out_content)
        return
    
    try: current_role = cmd.db.get_settings(str(message.guild.id), 'AutoRole')
    except KeyError:
        cmd.db.set_settings(str(message.guild.id), 'AutoRole', None)
        current_role = None
    
    if not args:
        if current_role:
            current_role = discord.utils.find(lambda x: x.id == current_role, message.guild.roles)
    
        if current_role:
            out_content = discord.Embed(type='rich', color=0x0099FF, title='ℹ Current Auto Role: ' + current_role.name)
            await message.channel.send(None, embed=out_content)
            return
    
        out_content = discord.Embed(type='rich', color=0x0099FF, title='ℹ No Auto Role Set')
        await message.channel.send(None, embed=out_content)
        return
    
    role_qry = ' '.join(args)
    role_qry_low = role_qry.lower()
    if role_qry_low == 'disable':
        cmd.db.set_settings(str(message.guild.id), 'AutoRole', None)
        out_content = discord.Embed(type='rich', color=0x66CC66, title='✅ Auto Role Disabled and Cleaned.')
        await message.channel.send(None, embed=out_content)
        return
    
    target_role = matching_role(message.guild, role_qry)
    if not target_role:
        out_content = discord.Embed(type='rich', color=0xDB0000, title='❗ Error')
        out_content.add_field(name='Role Not Found', value='I have not found **' + role_qry + '** on this server.')
        await message.channel.send(None, embed=out_content)
        return

    if current_role == target_role.id or current_role == target_role.name:
        out_content = discord.Embed(type='rich', color=0xFF9900, title='⚠ Error')
        out_content.add_field(name='Present Role', value='This Role is already the Auto Role for this server.')
        await message.channel.send(None, embed=out_content)
        return
    
    cmd.db.set_settings(str(message.guild.id), 'AutoRole', target_role.id)
    out_content = discord.Embed(type='rich', color=0x33CC33)
    out_content.add_field(name='✅ Success', value='The role **' + role_qry + '** has been set as the Auto Role.')
    await message.channel.send(None, embed=out_content)
Exemplo n.º 15
0
async def shopbuy(cmd, message, args):

    if not args:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title='❗ Insufficient Arguments.')
        await message.channel.send(None, embed=status)
        return

    role_name = ' '.join(args)
    item_list = cmd.db.get_settings(str(message.guild.id), 'ShopItems')

    for item in item_list:
        if item['RoleName'].lower() != role_name.lower(): continue

        found = True
        price = abs(int(item['Price']))
        role = matching_role(message.guild, role_name)

        if user_matching_role(message.author, role_name):
            status = discord.Embed(type='rich',
                                   color=0xFF9900,
                                   title='⚠ You already have this role.')
            await message.channel.send(None, embed=status)
            return

        user_points = cmd.db.get_points(message.author)

        if user_points['Current'] < price:
            status = discord.Embed(type='rich',
                                   color=0xFF9900,
                                   title='⚠ You can\'t afford it.')
            await message.channel.send(None, embed=status)
            return

        await message.author.add_roles(role)
        cmd.db.take_points(message.guild, message.author, price)

        status = discord.Embed(type='rich',
                               color=0x66cc66,
                               title='✅ You bought ' + role.name + ' .')
        await message.channel.send(None, embed=status)
        return

    status = discord.Embed(type='rich',
                           color=0xDB0000,
                           title='❗ Couldn\'t find  this in the shop.')
    await message.channel.send(None, embed=status)
Exemplo n.º 16
0
async def shopbuy(cmd, message, args):
    if not args:
        status = discord.Embed(type='rich',
                               color=0xDB0000,
                               title=':exclamation: Insufficient Arguments.')
        await cmd.bot.send_message(message.channel, None, embed=status)
        return
    role_name = ' '.join(args)
    item_list = cmd.db.get_settings(message.server.id, 'ShopItems')
    found = False
    for item in item_list:
        if item['RoleName'].lower() == role_name.lower():
            found = True
            price = int(item['Price'])
            role = matching_role(message.server, role_name)
            if not user_matching_role(message.author, role_name):
                user_points = cmd.db.get_points(message.server, message.author)
                if user_points >= price:
                    await cmd.bot.add_roles(message.author, role)
                    cmd.db.take_points(message.server, message.author, price)
                    status = discord.Embed(
                        type='rich',
                        color=0x66cc66,
                        title=':white_check_mark: You bought ' + role.name +
                        ' .')
                else:
                    status = discord.Embed(
                        type='rich',
                        color=0xFF9900,
                        title=':warning: You can\'t afford it.')
                await cmd.bot.send_message(message.channel, None, embed=status)
            else:
                status = discord.Embed(
                    type='rich',
                    color=0xFF9900,
                    title=':warning: You already have this role.')
                await cmd.bot.send_message(message.channel, None, embed=status)
            break
    if not found:
        status = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':exclamation: Couldn\'t find  this in the shop.')
        await cmd.bot.send_message(message.channel, None, embed=status)
Exemplo n.º 17
0
async def clrrole(cmd, message, args):

    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title='⛔ Requires the Manage Roles Permission.')
        await message.channel.send(None, embed=out_content)
        return

    if not args:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Missing Arguments.')
        await message.channel.send(None, embed=out_content)
        return

    qry = ' '.join(args[1:])
    clr = args[0].replace('#', '')

    try:
        clr_int = int(clr, 16)
        clr_obj = discord.Colour(clr_int)
    except:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Invalid Color. Please use HEX.')
        await message.channel.send(None, embed=out_content)
        return

    role = matching_role(message.guild, qry)
    if not role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='⚠ ' + qry + ' was not found.')
        await message.channel.send(None, embed=out_content)
        return

    await role.edit(color=clr_obj)
    edit_success = discord.Embed(type='rich',
                                 color=0x66cc66,
                                 title='✅ Color Changed.')
    await message.channel.send(None, embed=edit_success)
Exemplo n.º 18
0
async def togglerole(cmd, message, args):
    if not args:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='❗ Error')
        out_content.add_field(name='Not Enough Arguments', value=cmd.help())
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    else:
        role_qry = ' '.join(args)
        self_roles = cmd.db.get_settings(message.server.id, 'SelfRoles')
        role_name = None
        for role in self_roles:
            if role.lower() == role_qry.lower():
                role_name = role
                break
        if role_name:
            user_role_match = user_matching_role(message.author, role_name)
            if not user_role_match:
                target_role = matching_role(message.server, role_name)
                await cmd.bot.add_roles(message.author, target_role)
                embed = discord.Embed(title='✅ ' + role_name +
                                      ' has been added to you.',
                                      color=0x66cc66)
            else:
                target_role = user_role_match
                await cmd.bot.remove_roles(message.author, target_role)
                embed = discord.Embed(title='⚠ ' + role_name +
                                      ' has been removed from you.',
                                      color=0xFF9900)
            await cmd.bot.send_message(message.channel, None, embed=embed)
        else:
            out_content = discord.Embed(type='rich',
                                        color=0xFF9900,
                                        title='⚠ Error')
            out_content.add_field(
                name='Role Not Found',
                value=
                'I was unable to find that role in the list of self assignable roles for this server.'
            )
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
Exemplo n.º 19
0
async def clrrole(cmd, message, args):
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':no_entry: Requires the Manage Roles Permission.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if not args:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title=':exclamation: Missing Arguments.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    qry = ' '.join(args[1:])
    clr = args[0].replace('#', '')
    try:
        clr_int = int(clr, 16)
        clr_obj = discord.Colour(clr_int)
    except:
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':exclamation: Invalid Color. Please use HEX.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    role = matching_role(message.server, qry)
    if not role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title=':warning: ' + qry +
                                    ' was not found.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    await cmd.bot.edit_role(message.server, role, color=clr_obj)
    edit_success = discord.Embed(type='rich',
                                 color=0x66cc66,
                                 title=':white_check_mark: Color Changed.')
    await cmd.bot.send_message(message.channel, None, embed=edit_success)
Exemplo n.º 20
0
async def permitrole(cmd, message, args):

    if not args:
        await message.channel.send(cmd.help())
        return

    if len(args) < 2:
        response = discord.Embed(color=0xDB0000,
                                 title='� Not Enough Arguments')
        message.channel.send(embed=response)
        return

    if not check_admin(message.author, message.channel):
        response = discord.Embed(title='â›” Unpermitted. Server Admin Only.',
                                 color=0xDB0000)
        message.channel.send(embed=response)
        return

    target_name = args[1]
    target = matching_role(message.guild, target_name)

    if not target:
        response = discord.Embed(color=0x696969,
                                 title=f'� No {target_name} Role Found')
        message.channel.send(embed=response)
        return

    try:
        perm_mode, cmd_name = args[0].split(':')
    except:
        response = discord.Embed(color=0xDB0000, title='� Bad Input')
        await message.channel.send(embed=response)
        return

    cmd_name = cmd_name.lower()
    perm_mode = perm_mode.lower()

    if perm_mode == 'c':
        exception_group = 'CommandExceptions'
        check_group = cmd.bot.plugin_manager.commands
        check_alts = True
    elif perm_mode == 'm':
        exception_group = 'ModuleExceptions'
        check_group = cmd.bot.module_list
        check_alts = False
    else:
        response = discord.Embed(color=0xDB0000, title='� Bad Input')
        await message.channel.send(embed=response)
        return

    if check_alts:
        if cmd_name in cmd.bot.alts:
            cmd_name = cmd.bot.alts[cmd_name]

    if cmd_name not in check_group:
        response = discord.Embed(color=0x696969,
                                 title='� Command/Module Not Found')
        await message.channel.send(embed=response)
        return

    perms = get_all_perms(cmd.db, message)
    cmd_exc = perms[exception_group]

    if cmd_name in perms[exception_group]:
        inner_exc = cmd_exc[cmd_name]
    else:
        inner_exc = generate_cmd_data(cmd_name)[cmd_name]

    exc_usrs = inner_exc['Roles']

    if target.id not in exc_usrs:
        response = discord.Embed(
            color=0xFF9900,
            title=f'âš  {target.name} can already use `{cmd_name}`')
        await message.channel.send(embed=response)
        return

    exc_usrs.append(target.id)
    inner_exc.update({'Roles': exc_usrs})
    cmd_exc.update({cmd_name: inner_exc})
    perms.update({exception_group: cmd_exc})
    cmd.db.update_one('Permissions', {'ServerID': message.guild.id},
                      {'$set': perms})

    response = discord.Embed(
        color=0x66CC66, title=f'✅ `{target.name}` can now use `{cmd_name}`.')
    await message.channel.send(embed=response)
Exemplo n.º 21
0
async def setcolor(cmd, message, args):
    # if no args, send help message
    if not args:
        await message.channel.send(cmd.help())
        return

    # checks permissions
    if not check_man_roles(message.author, message.channel):
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title='⛔ Error')
        out_content.add_field(name='Insufficient Permissions',
                              value='You require the Manage Roles permission.')
        await message.channel.send(None, embed=out_content)
        return

    color = args[0].lstrip('#').upper()
    # check if color is a proper format
    if not is_valid_hex(color):
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='⚠ Error')
        out_content.add_field(
            name='Invalid Input',
            value=
            'A valid hexadecimal color code has numbers from 0–9 and letters from A–F, and has six characters.'
        )
        await message.channel.send(None, embed=out_content)
        return

    # check if user has role
    target = message.author if not message.mentions else message.mentions[0]
    has_role = discord.utils.get(target.roles,
                                 name=color)  #returns None if no role found
    if has_role:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title='⚠ Error')
        out_content.add_field(
            name='Role Present',
            value=f'This user already has the role **{color}**.')
        await message.channel.send(None, embed=out_content)
        return

    # check if role exists
    exists = matching_role(message.guild, color)
    if not exists:
        discord_colour = discord.Colour(int(color, 16))
        target_role = await message.guild.create_role(name=color,
                                                      colour=discord_colour,
                                                      reason="Color role")
    else:
        target_role = exists

    # loop through list of user's roles and delete/remove any color roles as necessary
    for role in target.roles:
        if is_valid_hex(role.name):
            if len(role.members) == 1:
                await role.delete()
            else:
                await target.remove_roles(role)

    await target.add_roles(target_role)

    # display confirmation
    out_content = discord.Embed(type='rich',
                                color=int(color, base=16),
                                title='✅ Success')
    out_content.add_field(
        name='Role Added Successfully',
        value=f'Role **{target_role.name}** was added to <@{target.id}>.')
    await message.channel.send(None, embed=out_content)
Exemplo n.º 22
0
async def autorole(cmd, message, args):
    if not check_admin(message.author, message.channel):
        out_content = discord.Embed(
            type='rich',
            color=0xDB0000,
            title=':no_entry: Insufficient Permissions. Server Admin Only.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    try:
        current_role = cmd.db.get_settings(message.server.id, 'AutoRole')
    except KeyError:
        cmd.db.set_settings(message.server.id, 'AutoRole', None)
        current_role = None
    if not args:
        if current_role:
            out_content = discord.Embed(
                type='rich',
                color=0x0099FF,
                title=':information_source: Current Auto Role: ' +
                current_role)
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
            return
        else:
            out_content = discord.Embed(
                type='rich',
                color=0x0099FF,
                title=':information_source: No Auto Role Set')
            await cmd.bot.send_message(message.channel,
                                       None,
                                       embed=out_content)
            return
    role_qry = ' '.join(args)
    role_qry_low = role_qry.lower()
    if role_qry_low == 'disable':
        cmd.db.set_settings(message.server.id, 'AutoRole', None)
        out_content = discord.Embed(
            type='rich',
            color=0x66CC66,
            title=':white_check_mark: Auto Role Disabled and Cleaned.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    target_role = matching_role(message.server, role_qry)
    if current_role and current_role.lower() == role_qry_low:
        out_content = discord.Embed(type='rich',
                                    color=0xFF9900,
                                    title=':warning: Error')
        out_content.add_field(
            name='Present Role',
            value='This Role is already the Auto Role for this server.')
        await cmd.bot.send_message(message.channel, None, embed=out_content)
        return
    if target_role:
        cmd.db.set_settings(message.server.id, 'AutoRole', role_qry)
        out_content = discord.Embed(type='rich', color=0x33CC33)
        out_content.add_field(name=':white_check_mark: Success',
                              value='The role **' + role_qry +
                              '** has been set as the Auto Role.')
    else:
        out_content = discord.Embed(type='rich',
                                    color=0xDB0000,
                                    title=':exclamation: Error')
        out_content.add_field(name='Role Not Found',
                              value='I have not found **' + role_qry +
                              '** on this server.')
    await cmd.bot.send_message(message.channel, None, embed=out_content)