Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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 message.channel.send(None, embed=out_content)
        return

    role_qry = ' '.join(args).replace('"', '')
    self_roles = cmd.db.get_settings(str(message.guild.id), 'SelfRoles')
    self_role_id = None
    target_role = discord.utils.find(
        lambda x: x.name.lower() == role_qry.lower(), message.guild.roles)

    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 that role on this server.')
        await message.channel.send(None, embed=out_content)

    for self_role in self_roles:
        if self_role == target_role.id or self_role == target_role.name:
            self_role_id = target_role.id
            break

    if not self_role_id:
        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 message.channel.send(None, embed=out_content)
        return

    user_role_match = user_matching_role(message.author, target_role.name)

    if not user_role_match:
        await message.author.add_roles(target_role)
        embed = discord.Embed(title='✅ ' + target_role.name +
                              ' has been added to you.',
                              color=0x66cc66)
    else:
        await message.author.remove_roles(target_role)
        embed = discord.Embed(title='⚠ ' + target_role.name +
                              ' has been removed from you.',
                              color=0xFF9900)

    await message.channel.send(None, embed=embed)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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)