def citadel(body: dict) -> dict: returnmessage = {} citadelroleid = 636372439261249566 citadelchannelid = 636374196355858452 result = __query_cosmos_for_info_by_discordid(str(body['authorid'])) discordserverid = CommonFramework.RetrieveConfigOptions('discord') discordserverid = discordserverid['serverid'] if result is None or 'wgid' not in result: returnmessage[ 'author'] = "You have not registered with the bot, this is mandatory. Please visit <#507725600073449482> to register or please complete registration." return returnmessage wgid = [int(result['wgid'])] claninfo = wotframework.GetPlayersClanInfo(wgid) claninfo = claninfo[0] if claninfo[1] is None: returnmessage[ 'author'] = "You are not a member of clan, citadel access is denied" return returnmessage elif claninfo[2] not in [ 'commander', 'executive_officer', 'combat_officer', 'personnel_officer' ]: returnmessage[ 'author'] = "Citadel access is restricted to Clan officers only" return returnmessage results = CosmosFramework.QueryItems( 'SELECT * FROM c WHERE c.wgid = {0}'.format(claninfo[1]), 'citadel') if bool(results): #Meaning their clan ID is in citadel container result = results[0] if result['citadel'] is True: DiscordFramework.AddUserRole(citadelroleid, body['authorid'], discordserverid) returnmessage['author'] = "Access granted" DiscordFramework.SendDiscordMessage( "{0} from {1} has joined the citadel.".format( body['authordisplayname'], result['name']), citadelchannelid) result = __query_cosmos_for_info_by_discordid(str( body['authorid'])) result['citadel'] = True CosmosFramework.ReplaceItem(result['_self'], result) else: returnmessage[ 'author'] = 'Citadel access has been revoked because: {0}. If you believe access should be granted, please see moderator.'.format( result['excludereason']) else: returnmessage[ 'author'] = 'Citadel access is restricted to clans who rank on Global Map ELO. If you believe access should be granted, please see moderator.' return returnmessage
def cone(body: dict) -> dict: """Cones user, adds information to database and sends return messages""" discordmessage = body['message'].split() ConeOfShameDiscordId = '525870180505747467' returnmessage = {} config = CommonFramework.RetrieveConfigOptions('discord') try: if len(discordmessage) < 3: returnmessage['author'] = 'Invalid command format' return returnmessage timetocone = int(discordmessage[2]) if timetocone > 2880: returnmessage[ 'author'] = 'You cannot Cone someone longer then 2 days' return returnmessage discordid = int(__discord_id_from_mention( discordmessage[1])) ##Trys int to make sure it's int result = __query_cosmos_for_info_by_discordid(discordid) if result is None: newitem = {} newitem['discordid'] = str(discordid) result = CosmosFramework.InsertItem(newitem, 'users') if 'cone' in result: returnmessage['author'] = 'User is already coned' statuscode = DiscordFramework.AddUserRole(ConeOfShameDiscordId, discordid, config['serverid']) if statuscode == 204: #Meaning add role was successful result['cone'] = int(time.time()) + (60 * int(timetocone)) CosmosFramework.ReplaceItem(result['_self'], result) returnmessage['channel'] = '{0} muted user for {1} minutes'.format( body['authordisplayname'], timetocone) returnmessage['author'] = 'Cone issued as requested' returnmessage['targetdiscordid'] = discordid returnmessage[ 'target'] = 'You were muted for {0} minutes by {1}'.format( timetocone, body['authordisplayname']) except Exception as e: returnmessage['author'] = 'Following error has occured: {0}'.format(e) return returnmessage