public async Task <bool> UpdateDiscordPVPProfileAsync(FortnitePVPProfile mockUser, bool nameTag, IGuildUser guser, IUserMessage msg = null, bool IsNameLocked = false) { if (guser.IsServerOwner()) { return(true); } var curUser = await guser.Guild.GetCurrentUserAsync(CacheMode.AllowDownload, Core.Utils.RequestOption); var mn_NickName = curUser.GuildPermissions.ManageNicknames; if (msg != null && IsNameLocked) { await msg.SetLockAsync(); } if (mn_NickName) { try { var newWinName = ModifyPVPTag(mockUser.PlayerName, mockUser.PvpCurrentModeWins(GameUserMode.PVP_WIN_ALL), nameTag); var changeName = newWinName != guser?.Nickname; if (!changeName) { return(true); } else if (IsNameLocked) { return(true); } guser.ModifyAsync((o) => { if (curUser.GuildPermissions.ManageNicknames && IsNameLocked == false) { o.Nickname = newWinName; } }, Core.Utils.RequestOption).Wait(); } catch (Exception e) { if (msg != null) { await msg.SetErrorAsync(); return(false); } } } return(true); }
public async Task <bool> UpdateDiscordPVEProfileAsync(FortnitePVEProfile mockUser, bool nameTag, IGuildUser guser, IUserMessage msg = null, bool IsNameLocked = false, bool PVEDecimals = true) { if (guser.IsServerOwner()) { return(true); } var gconfig = Guild.GetConfig(guser.Guild.Id.ToString()); var UserRoles = await guser.GetUserRolesAsync(gconfig.Owner.DefaultLanguage); var addRole = true; var curUser = await guser.Guild.GetCurrentUserAsync(CacheMode.AllowDownload, Core.Utils.RequestOption); if (curUser.GuildPermissions.ManageRoles) { try { foreach (var role in UserRoles) { if (role.Key == mockUser.Map) { addRole = false; continue; } guser.RemoveRoleAsync(role.Value, Core.Utils.RequestOption).Wait(); } } catch (Exception e) { } if (!gconfig.Event.MythicSKStates.Active)//mythic storm king role remover { try { ulong msk_roleId = ulong.Parse(gconfig.Event.MythicSKStates.RoleIdToMythicSK); var userRole = guser.RoleIds.Any(id => id == msk_roleId); if (userRole) { var role = guser.Guild.GetRole(msk_roleId); guser.RemoveRoleAsync(role, Core.Utils.RequestOption).Wait(); } } catch (Exception e) { } } if (!gconfig.Event.EliteFrostnite2019s.Active)//elite frostnite 2019 role remover { try { ulong msk_roleId = ulong.Parse(gconfig.Event.EliteFrostnite2019s.RoleId); var userRole = guser.RoleIds.Any(id => id == msk_roleId); if (userRole) { var role = guser.Guild.GetRole(msk_roleId); guser.RemoveRoleAsync(role, Core.Utils.RequestOption).Wait(); } } catch (Exception e) { } } } var mn_NickName = curUser.GuildPermissions.ManageNicknames; var nm_Role = curUser.GuildPermissions.ManageRoles; if (msg != null && IsNameLocked) { await msg.SetLockAsync(); } if ((mn_NickName || nm_Role)) { try { // if (mockUser.NumMythicSchematics > 0 && gconfig.Event.MythicSKStates.Active) { ulong msk_roleId = ulong.Parse(gconfig.Event.MythicSKStates.RoleIdToMythicSK); var userRole = guser.RoleIds.Any(id => id == msk_roleId); if (!userRole) { var guild_msk_role = guser.Guild.GetRole(msk_roleId); guser.AddRoleAsync(guild_msk_role).Wait(); } } if (mockUser.EliteFortnite2019 && gconfig.Event.EliteFrostnite2019s.Active) { ulong msk_roleId = ulong.Parse(gconfig.Event.EliteFrostnite2019s.RoleId); var userRole = guser.RoleIds.Any(id => id == msk_roleId); if (!userRole) { var guild_efn_role = guser.Guild.GetRole(msk_roleId); guser.AddRoleAsync(guild_efn_role).Wait(); } } // var newPowerName = ModifyPVETag(mockUser.PlayerName, mockUser.AccountPowerLevel, nameTag, PVEDecimals); var sameName = newPowerName != guser?.Nickname; if (!addRole && !sameName) { return(true); } else if (!addRole && IsNameLocked) { return(true); } guser.ModifyAsync((o) => { if (curUser.GuildPermissions.ManageNicknames && IsNameLocked == false) { o.Nickname = newPowerName; } if (addRole && curUser.GuildPermissions.ManageRoles) { var CurrentGuildMapRoles = guser.Guild.GetMapRolesAsync(gconfig.Owner.DefaultLanguage).Result; var rl = CurrentGuildMapRoles.FirstOrDefault(p => p.Key == mockUser.Map); if (rl.Value != null) { guser.AddRoleAsync(rl.Value, Core.Utils.RequestOption).Wait(); } } }, Core.Utils.RequestOption).Wait(); if (msg != null && guser.Id == guser.Guild.OwnerId) { await msg.SetErrorAsync(); } } catch (Exception e) { if (msg != null) { await msg.SetErrorAsync(); return(false); } } } return(true); }