Exemplo n.º 1
0
 async def admin_get_member_status(self, context, name=None):
     member = find_member(name, roles)
     if member is not None:
         response = ''
         for role in member.roles:
             if role.name != '@everyone':
                 response += f'{role.name} ,'
         response = response[:-1]
         headers = {'Authorization': roles.auth_token}
         web_response = requests.get(
             f'{roles.BASE_URL}/api/users/discord/{member.id}',
             headers=headers,
             verify=roles.VERIFY_SSL)
         if web_response.status_code == 200:
             web_privs = web_response.json()['role']
             if web_response.json(
             )['is_active'] == False or web_response.json(
             )['guild']['is_active'] == False:
                 web_privs = 'none'
             await context.send(
                 f'User `{web_response.json()["username"]}` found for {member.mention}, they have the roles: {response}. They have web privilage level of: {web_privs}'
             )
         else:
             await context.send(
                 f'No user found for {context.author.mention}')
             await context.send(response)
     else:
         await context.send(
             'you must provide a valid member name in order to use a find query.'
         )
Exemplo n.º 2
0
 async def admin_demote_user_permisions(self, context, name=None):
     roles.log.info(f'demote_user {context.author}')
     member = find_member(name, roles)
     if (roles.admin_role in context.author.roles) and member is not None:
         data = json.dumps({'is_active': True, 'role': 'verified'})
         headers = {
             'Authorization': roles.auth_token,
             'Content-Type': 'application/json'
         }
         response = requests.patch(
             f'{roles.BASE_URL}/api/users/discordRoles/{member.id}',
             data=data,
             headers=headers,
             verify=roles.VERIFY_SSL)
         if response.status_code == 200:
             await context.send(
                 f'{member.mention} has been demoted on flamesofexile.com')
             roles.log.info('demote member completed')
         else:
             roles.log.info('problem with api request when demoting member')
             await context.send(
                 f'Their was a problem demoting {member.mention} on flamesofexile.com'
             )
     elif member is not None:
         await context.send(
             'You do not have the authority to invoke this action')
         roles.admin_channel.send(
             f'{roles.it_role.mention}{context.author.mention} attempted to demote {member.mention} this action is reserved for {roles.admin_role.mention}'
         )
     else:
         await context.send(
             'You need to include the name of a member in order to invoke this action'
         )
Exemplo n.º 3
0
 async def diplo_vouch(self, context, user=None):
     diplo = context.author
     if (roles.diplo_role
             not in context.author.roles) and (roles.admin_role
                                               not in context.author.roles):
         await context.send(
             'you do not have the required permissions to invoke this action'
         )
         await roles.admin_channel.send(
             f'{context.author.mention} attempted to invoke "vouch" but does not have the required permissions'
         )
         return
     target_user = find_member(user, roles)
     if target_user is None:
         await context.send(
             'you must provide a valid username to invoke this action')
         return
     data = json.dumps({'diplo': diplo.id, 'target_user': target_user.id})
     headers = {
         'Authorization': roles.auth_token,
         'Content-Type': 'application/json'
     }
     response = requests.patch(f'{roles.BASE_URL}/api/users/alliance/vouch',
                               data=data,
                               headers=headers,
                               verify=roles.VERIFY_SSL)
     if response.status_code == 200:
         await target_user.add_roles(roles.alliance_role)
         roles.log.info(roles.alliance_role)
         await context.send(
             f'{target_user.mention} has been vouched for by {diplo.mention}'
         )
         await roles.admin_channel.send(
             f'{roles.admin_role.mention}: {target_user.mention} has been granted roles by {diplo.mention}'
         )
     elif response.status_code == 403:
         await context.send(
             f'You must belong to the same guild to give {target_user.mention}\'s roles '
         )
         await roles.admin_channel.send(
             f'{context.author.mention} attempted to add roles to a member of a different guild ({target_user.mention})'
         )
     else:
         await context.send(
             f'there was a problem processing your request. If this problem continues contact {roles.it_role.mention}'
         )
         await roles.it_channel.send(
             f'{diplo.mention} had a problem running vouch for {target_user.mention}'
         )
Exemplo n.º 4
0
 async def admin_exile_member(self, context, name=None, reason=None):
     roles.log.info(f'exile_member called by {context.author}')
     try:
         member = find_member(name, roles)
         if context.author == member:
             context.send('you cannot exile yourself')
             return
         if (roles.admin_role
                 in context.author.roles) and member is not None:
             await member.remove_roles(roles.member_role, roles.admin_role,
                                       roles.recruit_role,
                                       roles.alliance_role,
                                       roles.diplo_role)
             data = json.dumps({'is_active': False, 'role': 'guest'})
             headers = {
                 'Authorization': roles.auth_token,
                 'Content-Type': 'application/json'
             }
             response = requests.patch(
                 f'{roles.BASE_URL}/api/users/discordRoles/{member.id}',
                 data=data,
                 headers=headers,
                 verify=roles.VERIFY_SSL)
             if response.status_code == 200:
                 await context.send(
                     f'{member.mention} has been exiled and their roles have been revoked from flamesofexile.com'
                 )
                 roles.log.info('exile member completed')
             else:
                 roles.log.info(
                     'problem with api request when exileing member')
                 await context.send(
                     f'{member.mention} has been exiled but an error was encountered removing roles from flamesofexile.com manual removal will be needed'
                 )
         elif member:
             await context.send(
                 'You do not have the authority to invoke this acction')
             roles.admin_channel.send(
                 f'{roles.it_role.mention}{context.author.mention} attempted to exile {member.mention} this action is reserved for {roles.admin_role.mention}'
             )
         else:
             await context.send(
                 'You need to include the name of a member in order to invoke this action'
             )
     except HTTPException:
         await context.send(
             'An error was encountered USER Privilages May not have been completely removed.'
         )
         roles.log.info('exile member raised HTTP Exception')
Exemplo n.º 5
0
 async def admin_grant_user_permissions(self, context, name=None):
     roles.log.info(f'grant_user_permissions called by {context.author}')
     try:
         member = find_member(name, roles)
         if (roles.admin_role
                 in context.author.roles) and member is not None:
             await member.add_roles(roles.member_role)
             await member.remove_roles(roles.recruit_role)
             data = json.dumps({'is_active': True, 'role': 'verified'})
             headers = {
                 'Authorization': roles.auth_token,
                 'Content-Type': 'application/json'
             }
             response = requests.patch(
                 f'{roles.BASE_URL}/api/users/discordRoles/{member.id}',
                 data=data,
                 headers=headers,
                 verify=roles.VERIFY_SSL)
             if response.status_code == 200:
                 await context.send(
                     f'{member.mention} has been granted and their roles have been verified on flamesofexile.com'
                 )
                 roles.log.info('grant member completed')
             else:
                 roles.log.info(
                     'problem with api request when granting member')
                 await context.send(
                     f'{member.mention} has had roles granted on discord but their was a problem granting them permissions on flamesofexile.com'
                 )
         elif member is not None:
             await context.send(
                 'You do not have the authority to invoke this action')
             roles.admin_channel.send(
                 f'{roles.it_role.mention}{context.author.mention} attempted to grant {member.mention} this action is reserved for {roles.admin_role.mention}'
             )
         else:
             await context.send(
                 'You need to include the name of a valid member in order to invoke this action'
             )
     except HTTPException:
         await context.send(
             'An error was encountered NO USER Privilages have been modified.'
         )