public async Task ToggleLam(IUser user) { if (IsSelf(user)) { await ReplyAsync("You can't change this role for yourself."); return; } var msg = await ReplyAsync($"{user.Mention}: Just a moment..."); var result = await RoleSyncHelpers.ToggleSyncedRolesAsync(user, LargeAreaManager.Ids, Context); if (result == SyncedRoleStatus.Added) { await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, StateManager.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, AreaManager.Ids, Context.Client); // some guilds have LAM and AM, some only have AM. have to do this to manage that. await RoleSyncHelpers.AddSyncedRolesAsync((SocketGuildUser)user, LargeAreaManager.Ids, Context.Client); await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Added LAM, removed SM and AM (if applicable)."); } else if (result == SyncedRoleStatus.Removed) { await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Removed LAM."); } }
public async Task ToggleL4(IUser user) { if (IsSelf(user)) { await ReplyAsync("You can't change this role for yourself."); return; } var msg = await ReplyAsync($"{user.Mention}: Just a moment..."); var result = await RoleSyncHelpers.ToggleSyncedRolesAsync(user, Level4.Ids, Context); if (result == SyncedRoleStatus.Added) { await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level6.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level5.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level3.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level2.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level1.Ids, Context.Client); await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Added L4, removed other level roles."); } else if (result == SyncedRoleStatus.Removed) { await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Removed L4."); } }
public async Task ToggleL1(IUser user) { var msg = await ReplyAsync($"{user.Mention}: Just a moment..."); var result = await RoleSyncHelpers.ToggleSyncedRolesAsync(user, Level1.Ids, Context); if (result == SyncedRoleStatus.Added) { await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level6.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level5.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level4.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level3.Ids, Context.Client); await RoleSyncHelpers.RemoveSyncedRolesAsync((SocketGuildUser)user, Level2.Ids, Context.Client); await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Added L1, removed other level roles."); } else if (result == SyncedRoleStatus.Removed) { await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Removed L1."); } }
public static async Task SyncRoles(SocketGuildUser user, IDiscordClient client) { var newGuild = user.Guild; // here we go boiz foreach (var guild in await RoleSyncHelpers.GetUserGuildsAsync(user, client)) { var roleSet = false; var guildUser = guild.GetUser(user.Id); // loop through each role we're tracking in the guild foreach (var role in _roleIds) { // check if the new guild has this role if (!role.TryGetValue(newGuild.Id, out var newRoleId)) { continue; } // check if the guild being checked has this role if (!role.TryGetValue(guild.Id, out var roleId)) { continue; } // check if this user has this role in the guild being checked if (!guildUser.Roles.Any(r => r.Id == roleId)) { continue; } // at this point, we've verified that: // - the new guild has this role // - the guild being checked has this role // - the user has this role in the guild being checked // // this means we can sync the role // first, get the role in the new guild var newRole = newGuild.GetRole(newRoleId); // now add the role to the user in the new guild await user.AddRoleAsync(newRole); // set this to true so the top loop is broken roleSet = true; break; } if (roleSet) { break; } } }
public async Task ToggleMentor(IUser user) { if (IsSelf(user)) { await ReplyAsync("You can't change this role for yourself."); return; } var msg = await ReplyAsync($"{user.Mention}: Just a moment..."); var result = await RoleSyncHelpers.ToggleSyncedRolesAsync(user, Mentor.Ids, Context); if (result == SyncedRoleStatus.Added) { await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Added mentor."); } else if (result == SyncedRoleStatus.Removed) { await msg.ModifyAsync(m => m.Content = $"{user.Mention}: Removed mentor."); } }