private async Task ChangeColor(Server s) { for(int i = 0; i < 100; i++) { Role role = s.GetUser(Disco.Bot.Client.CurrentUser.Id).Roles.FirstOrDefault(); currentColor++; await role.Edit(null, null, _colors[currentColor % 15].Color); Thread.Sleep(100); } }
internal User GetUserFast(ulong id) { //Can return users not in this channel, but that's usually okay if (IsPrivate) { if (id == Recipient.Id) { return(Recipient); } else if (id == Client.PrivateUser.Id) { return(Client.PrivateUser); } } else { return(Server.GetUser(id)); } return(null); }
public User GetUser(ulong id) { if (IsPrivate) { if (id == Recipient.Id) { return(Recipient); } else if (id == Client.PrivateUser.Id) { return(Client.PrivateUser); } } else if (!Client.Config.UsePermissionsCache) { var user = Server.GetUser(id); if (user != null) { ChannelPermissions perms = new ChannelPermissions(); UpdatePermissions(user, ref perms); if (perms.ReadMessages) { return(user); } } } else { Member result; if (_users.TryGetValue(id, out result)) { return(result.User); } } return(null); }
public async void RemoveRoles(Discord.Server server, Discord.User discorduser) { Summoner summoner = null; try { DataLibary.Models.User user = new UserRepo(new UserContext()).GetUserByDiscord(discorduser.Id); summoner = new SummonerAPI().GetSummoner( new SummonerRepo(new SummonerContext()).GetSummonerByUserId(user), ToolKit.LeagueAndDatabase.GetRegionFromDatabaseId( new RegionRepo(new RegionContext()).GetRegionId(user) )); } catch { Console.WriteLine("User is not registered."); } if (summoner != null) { SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext()); List <string> filter = new List <string>(); if (settingsRepo.RankCommandType(server.Id) == CommandType.Basic) { filter = Ranks.BasicRanks(); } else if (settingsRepo.RankCommandType(server.Id) == CommandType.PerQueue) { filter = Ranks.QueueRanks(); } else if (settingsRepo.RankCommandType(server.Id) == CommandType.Division) { filter = Ranks.DivisionRanks(); } List <Discord.Role> roles = new List <Discord.Role>(); foreach (Discord.Role role in discorduser.Roles) { foreach (string line in filter) { if (role.Name.ToLower() == line.ToLower()) { roles.Add(role); } else { try { if (server.GetRole(settingsRepo.GetOverride(line.ToLower(), server.Id)).Id == role.Id) { roles.Add(role); } } catch { //no override } } } } await server.GetUser(discorduser.Id).RemoveRoles(roles.ToArray()); //foreach (string line in filter) //{ // Discord.Role r = null; // try // { // r = server.GetRole(settingsRepo.GetOverride(line.ToLower(), server.Id)); // } // catch // { // try // { // r = server.FindRoles(line, false).First(); // } // catch { } // } // if (r != null) // { // if (discorduser.HasRole(r)) // { // roles.Add(r); // } // } //} } }
internal override User GetUser(ulong id) => Server.GetUser(id);