Пример #1
0
async def ex(args, message, bot, invoke):
    with open('lists/password_data.json', encoding='utf-8') as pass_file:
        pass_data = json.loads(pass_file.read())
    pswd = pass_data.get('pswd')
    msg = ' '.join(args)
    available_stamp = pass_data['time']
    current_stamp = arrow.utcnow().timestamp
    time_diff = arrow.get(available_stamp + 5).humanize(arrow.utcnow())
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                if current_stamp > available_stamp or msg in pswd:
                    response = discord.Embed(
                        title=f'🔏 Password reset. It will be available in 24h',
                        color=0xFFCC4D)
                    available_stamp = arrow.utcnow().timestamp + 86400
                    set_time(pass_data, available_stamp)
                    set_pswd(pass_data, secrets.token_hex(3)())
                else:
                    response = discord.Embed(
                        title='🔐 A password is already set', color=0xFFCC4D)
                    response.set_footer(
                        text=f'It will be available in {time_diff}')
            else:
                response = discord.Embed(
                    title='⛔ Access denied: Manage Server required',
                    color=0xBE1931)
        else:
            response = discord.Embed(
                title='🔒 You can\'t use that command on this server',
                color=0xFFCC4D)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM',
                                 color=0xFFCC4D)
    await message.channel.send(embed=response)
Пример #2
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                with open('permissions/roles.json',
                          encoding='utf-8') as roles_file:
                    roles_data = json.loads(roles_file.read())
                dm_p = roles_data['dm']
                if 'No' not in dm_p:
                    set_dm(roles_data, 'No')
                with open('permissions/roles.json',
                          encoding='utf-8') as roles_file:
                    roles_data = json.loads(roles_file.read())
                clear_roles(roles_data)
                with open('permissions/channels.txt', 'w') as a:
                    a.write('')
                with open('permissions/users.txt', 'w') as a:
                    a.write('')
                response = discord.Embed(title='🗑️ Cleared', color=0x67757f)
            else:
                response = discord.Embed(
                    title='⛔ Access denied: Manage Server required',
                    color=0xBE1931)
        else:
            response = discord.Embed(
                title='🔒 You can\'t use that command on this server',
                color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM',
                                 color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #3
0
def auth_check(message):
    if message.guild:
        if server_check(message):
            auth = True
        else:
            auth = False
    else:
        if dm_check():
            auth = True
        else:
            auth = False
    return auth
Пример #4
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                with open('permissions/channels.txt', 'r') as file:
                    a = file.read()
                    if '' == a:
                        chn = 'None\n'
                    else:
                        chn = f'\n{a}'
                with open('permissions/roles.json',
                          encoding='utf-8') as vote_data_file:
                    vote_file = json.loads(vote_data_file.read())
                rol_p = vote_file['roles']
                roles = ''
                for role in rol_p:
                    roles += f'<@&{role}>\n'
                if '' == roles:
                    rol = 'None\n'
                else:
                    rol = f'\n{roles}'
                with open('permissions/users.txt', 'r') as file:
                    c = file.read()
                    if '' == c:
                        usr = '******'
                    else:
                        usr = f'\n{c}'
                with open('permissions/roles.json') as roles_data:
                    roles_file = json.loads(roles_data.read())
                dm_p = roles_file['dm']
                if 'Yes' in dm_p:
                    dm = 'Yes\n'
                else:
                    dm = 'No\n'
                response = discord.Embed(title='🔏 **Poll permissions:**\n',
                                         description=f'**DMs Allowed:** {dm}'
                                         f'**Channels:** {chn}'
                                         f'**Roles:** {rol}'
                                         f'**Users:** {usr}',
                                         color=0xFFCC4d)
            else:
                response = discord.Embed(
                    title='⛔ Access denied: Manage Server required',
                    color=0xBE1931)
        else:
            response = discord.Embed(
                title='🔒 You can\'t use that command on this server',
                color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM',
                                 color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #5
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                with open('lists/password_data.json') as json_data_file:
                    password_cfg = json.load(json_data_file)
                pswd = password_cfg.get('pswd')
                if args:
                    if os.path.exists('lists/vote_data.json'):
                        with open('lists/vote_data.json') as json_data_file:
                            votes_cfg = json.load(json_data_file)
                        msg = ' '.join(args)
                        if msg in pswd:
                            yes_points = votes_cfg.get('yes') or 0
                            no_points = votes_cfg.get('no') or 0
                            total = yes_points + no_points
                            yes_bar = make_bar(yes_points, total)
                            try:
                                yes_perc_base = yes_points / total
                            except ZeroDivisionError:
                                yes_perc_base = 0
                            yes_stat_line = f'[{yes_points}] {yes_bar} {int(yes_perc_base * 100)}% - Yes'
                            no_bar = make_bar(no_points, total)
                            try:
                                no_perc_base = no_points / total
                            except ZeroDivisionError:
                                no_perc_base = 0
                            no_stat_line = f'[{no_points}] {no_bar} {int(no_perc_base * 100)}% - No'
                            response = discord.Embed(title=f'📊 Poll Statistics', color=0xd2dae1)
                            output = f'{yes_stat_line}\n' \
                                     f'{no_stat_line}'
                            response.description = f'```{output}```'
                        else:
                            response = discord.Embed(title='🔒 Incorrect password', color=0xFFCC4d)
                    else:
                        response = discord.Embed(title='❗ There is no vote data', color=0xBE1931)
                else:
                    response = discord.Embed(title='🔒 A password is required', color=0xFFCC4d)
            else:
                response = discord.Embed(title='⛔ Access denied: Administrator required', color=0xBE1931)
        else:
            response = discord.Embed(title='🔒 You can\'t use that command on this server', color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM', color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #6
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                if args:
                    if os.path.exists('lists/vote_data.json'):
                        with open('lists/vote_data.json') as json_data_file:
                            votes_cfg = json.load(json_data_file)
                        with open(
                                'lists/password_data.json') as pswd_data_file:
                            pswd_data = json.loads(pswd_data_file.read())
                        pswd = pswd_data.get('pswd')
                        msg = ' '.join(args)
                        if msg in pswd:
                            voters = votes_cfg.get('voters') or []
                            line_list = []
                            for voter in voters:
                                line_list.append(f'<@{voter}>')
                            a = '\n'.join(line_list)
                            response = discord.Embed(title="👥 Voters:",
                                                     color=0x292f33)
                            response.description = ('%s' % a)
                        else:
                            response = discord.Embed(
                                title='🔒 Incorrect password', color=0xFFCC4d)
                    else:
                        response = discord.Embed(
                            title='❗ There is no vote data', color=0xBE1931)
                else:
                    response = discord.Embed(title='🔒 A password is required',
                                             color=0xFFCC4d)
            else:
                response = discord.Embed(
                    title='⛔ Access denied: Administrator required',
                    color=0xBE1931)
        else:
            response = discord.Embed(
                title='🔒 You can\'t use that command on this server',
                color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM',
                                 color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #7
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                if os.path.exists('lists/vote_data.json'):
                    os.remove('lists/vote_data.json')
                response = discord.Embed(title='🗑️ Cleared', color=0x67757f)
            else:
                response = discord.Embed(
                    title='⛔ Access denied: Manage Server required',
                    color=0xBE1931)
        else:
            response = discord.Embed(
                title='🔒 You can\'t use that command on this server',
                color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM',
                                 color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #8
0
async def ex(args, message, bot, invoke):
    with open('lists/password_data.json', encoding='utf-8') as pass_file:
        pass_data = json.loads(pass_file.read())
    available_stamp = pass_data['time']
    current_stamp = arrow.utcnow().timestamp
    time_diff = arrow.get(available_stamp + 5).humanize(arrow.utcnow())
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                if current_stamp > available_stamp:
                    response = discord.Embed(title=f'🔑 Here is the password `{get_pswd()}`', color=0xc1694f)
                    response.set_footer(text='^votes/voters password')
                else:
                    response = discord.Embed(title='🔒 The password is not yet available', color=0xFFCC4d)
                    response.set_footer(text=f'It will be available in {time_diff}')
            else:
                response = discord.Embed(title='â›” Access denied: Manage Server required', color=0xBE1931)
        else:
            response = discord.Embed(title='🔒 You can\'t use that command on this server', color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM', color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #9
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            colors = [xxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxx]
            if auth_check(message):
                if args:
                    if str.isdigit(args[0]):
                        lookup = int(colors[int(args[0]) - 1])
                        color_role = discord.utils.find(lambda x: x.id == lookup, message.guild.roles)
                        if color_role:
                            target = message.author
                            for role in colors:
                                if role in [y.id for y in target.roles]:
                                    rem_role = discord.utils.get(message.guild.roles, id=role)
                                    await target.remove_roles(rem_role, reason='Role Self Assigned')
                            await message.author.add_roles(color_role, reason='Role Self Assigned')
                            response = discord.Embed(title=f'✅ Vanity role changed to {color_role.name}', color=0x77b255)
                        else:
                            response = discord.Embed(title=f'❗ Error finding that role', color=0xBE1931)
                    else:
                        response = discord.Embed(title='❗ Input must be a number', color=0xBE1931)
                else:
                    i = 1
                    output = ''
                    for color in colors:
                        output += f'#{i} - <@&{color}>\n'
                        i += 1
                    response = discord.Embed(color=0x66757F)
                    response.add_field(name='🎨 Staff Colors', value=output)
                    response.set_footer(text='^color 1 to assign a role')
            else:
                response = discord.Embed(title="⛔ You are not a staff member", color=0xBE1931)
        else:
            response = discord.Embed(title='🔒 You can\'t use that command on this server', color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM', color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #10
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                if args:
                    mode = args[0].lower()
                    if len(args) >= 2:
                        if mode == 'c':
                            if message.channel_mentions:
                                channel = message.channel_mentions[0]
                                if not channel_auth(message):
                                    with open('permissions/channels.txt', 'a') as a:
                                        a.write(f'{channel.mention}\n')
                                    response = discord.Embed(title=f"🔓 Permitted {channel}", color=0xFFCC4d)
                                else:
                                    response = discord.Embed(title=f"❗ {channel} is already permitted", color=0xBE1931)
                            else:
                                response = discord.Embed(title='❗ Input must be a channel', color=0xBE1931)
                        elif mode == 'u':
                            if message.mentions:
                                user = message.mentions[0]
                                if not user_auth(message):
                                    with open('permissions/users.txt', 'a') as a:
                                        a.write(f'{user.mention}\n')
                                    response = discord.Embed(title=f"🔓 Permitted {user.display_name}", color=0xFFCC4d)
                                else:
                                    response = discord.Embed(title=f"❗ {user.display_name} is already permitted",
                                                             color=0xBE1931)
                            else:
                                response = discord.Embed(title='❗ Input must be a user', color=0xBE1931)
                        elif mode == 'r':
                            lookup = ' '.join(args[1:]).lower()
                            target = discord.utils.find(lambda x: x.name.lower() == lookup, message.guild.roles)
                            if target is not None:
                                with open('permissions/roles.json', encoding='utf-8') as vote_data_file:
                                    vote_file = json.loads(vote_data_file.read())
                                rol_p = vote_file['roles']
                                if not role_auth(args, message):
                                    rol_p.append(target.id)
                                    vote_file.update({'roles': rol_p})
                                    with open('permissions/roles.json', 'w', encoding='utf-8') as vote_data_file:
                                        json.dump(vote_file, vote_data_file)
                                    response = discord.Embed(title=f"🔓 Permitted {target}", color=0xFFCC4d)
                                else:
                                    response = discord.Embed(title=f"❗ {target} is already permitted", color=0xBE1931)
                            else:
                                response = discord.Embed(title=f'🔍 I couldn\'t find {lookup} on this server', color=0x696969)
                        else:
                            response = discord.Embed(title='❗ Invalid input', color=0xBE1931)
                    elif len(args) == 1:
                        if mode == 'dm':
                            with open('permissions/roles.json', encoding='utf-8') as roles_file:
                                roles_data = json.loads(roles_file.read())
                            dm_p = roles_data['dm']
                            if 'Yes' not in dm_p:
                                set_dm(roles_data, 'Yes')
                                response = discord.Embed(title="🔓 Permitted DMs", color=0xFFCC4d)
                            else:
                                response = discord.Embed(title="❗ DMs already permitted", color=0xBE1931)
                        else:
                            response = discord.Embed(title='❗ Invalid input', color=0xBE1931)
                    else:
                        response = discord.Embed(title='❗ Two inputs are required', color=0xBE1931)
                else:
                    response = discord.Embed(title='❗ No input', color=0xBE1931)
            else:
                response = discord.Embed(title='⛔ Access denied: Manage Server required', color=0xBE1931)
        else:
            response = discord.Embed(title='🔒 You can\'t use that command on this server', color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM', color=0xFFCC4d)
    await message.channel.send(embed=response)
Пример #11
0
async def ex(args, message, bot, invoke):
    if message.guild:
        if server_check(message):
            if message.author.permissions_in(message.channel).manage_guild:
                if args:
                    mode = args[0].lower()
                    if len(args) >= 2:
                        if mode == 'c':
                            if message.channel_mentions:
                                channel = message.channel_mentions[0]
                                if channel_auth(message):
                                    fn = 'permissions/channels.txt'
                                    a = open(fn)
                                    output = []
                                    for line in a:
                                        if f'{channel.id}' not in line:
                                            output.append(line)
                                    a.close()
                                    a = open(fn, 'w')
                                    a.writelines(output)
                                    a.close()
                                    channel = message.channel_mentions[0]
                                    response = discord.Embed(
                                        title=f"🔒 Unpermitted {channel}",
                                        color=0xFFCC4d)
                                else:
                                    response = discord.Embed(
                                        title=f"❗ {channel} wasn't permitted",
                                        color=0xBE1931)
                            else:
                                response = discord.Embed(
                                    title='❗ Input must be a channel',
                                    color=0xBE1931)
                        elif mode == 'u':
                            user = message.mentions[0]
                            if message.mentions:
                                if user_auth(message):
                                    fn = 'permissions/users.txt'
                                    a = open(fn)
                                    output = []
                                    for line in a:
                                        if f'{user.id}' not in line:
                                            output.append(line)
                                    a.close()
                                    a = open(fn, 'w')
                                    a.writelines(output)
                                    a.close()
                                    response = discord.Embed(
                                        title=
                                        f"🔒 Unpermitted {user.display_name}",
                                        color=0xFFCC4d)
                                else:
                                    response = discord.Embed(
                                        title=
                                        f"❗ {user.display_name} wasn't permitted",
                                        color=0xBE1931)
                            else:
                                response = discord.Embed(
                                    title='❗ Input must be a user',
                                    color=0xBE1931)
                        elif mode == 'r':
                            lookup = ' '.join(args[1:]).lower()
                            target = discord.utils.find(
                                lambda x: x.name.lower() == lookup,
                                message.guild.roles)
                            if target is not None:
                                with open('permissions/roles.json',
                                          encoding='utf-8') as roles_file:
                                    roles_data = json.loads(roles_file.read())
                                rol_p = roles_data['roles']
                                roles = []
                                role_ex = False
                                for role in rol_p:
                                    if role == target.id:
                                        role_ex = True
                                    else:
                                        roles.append(role)
                                if role_ex:
                                    roles_data.update({'roles': roles})
                                    with open('permissions/roles.json',
                                              'w',
                                              encoding='utf-8') as roles_file:
                                        json.dump(roles_data, roles_file)
                                    response = discord.Embed(
                                        title=f"🔒 Unpermitted {target}",
                                        color=0xFFCC4d)
                                else:
                                    response = discord.Embed(
                                        title=f"❗ {target} wasn't permitted",
                                        color=0xBE1931)
                            else:
                                response = discord.Embed(
                                    title=
                                    f'🔍 I couldn\'t find {lookup} on this server',
                                    color=0x696969)
                        else:
                            response = discord.Embed(title='❗ Invalid input',
                                                     color=0xBE1931)
                    elif len(args) == 1:
                        if mode == 'dm':
                            with open('permissions/roles.json',
                                      encoding='utf-8') as roles_file:
                                roles_data = json.loads(roles_file.read())
                            dm_p = roles_data['dm']
                            if 'No' not in dm_p:
                                set_dm(roles_data, 'No')
                                response = discord.Embed(
                                    title="🔒 Unpermitted DMs", color=0xFFCC4d)
                            else:
                                response = discord.Embed(
                                    title="❗ DMs wasn't permitted",
                                    color=0xBE1931)
                        else:
                            response = discord.Embed(title='❗ Invalid input',
                                                     color=0xBE1931)
                    else:
                        response = discord.Embed(
                            title='❗ Two inputs are required', color=0xBE1931)
                else:
                    response = discord.Embed(title='❗ No input',
                                             color=0xBE1931)
            else:
                response = discord.Embed(
                    title='⛔ Access denied: Manage Server required',
                    color=0xBE1931)
        else:
            response = discord.Embed(
                title='🔒 You can\'t use that command on this server',
                color=0xFFCC4d)
    else:
        response = discord.Embed(title='🔒 You can\'t use that command in a DM',
                                 color=0xFFCC4d)
    await message.channel.send(embed=response)