Exemplo n.º 1
0
 public SocketRole this[int levelNumber]
 {
     get
     {
         LevelRoles.TryGetValue(levelNumber.ToString(), out ulong id);
         return(DiscordGuild?.GetRole(id));
     }
     set => LevelRoles[$"{levelNumber}"] = value.Id;
Exemplo n.º 2
0
        private static void PollRole(SocketUser user, uint messageCount)
        {
            int currentIndex   = LevelRoles.GetRoleIndexFromUser(user);
            int potentialIndex = LevelRoles.GetRoleIndexFromMessageCount(messageCount);

            if (currentIndex != potentialIndex)
            {
                LevelRoles.RemoveAllLevelRoles(user);

                SocketRole role = LevelRoles.GetRoleFromIndex(potentialIndex);

                Debug.Log($"Adding {role.Name} to {user.Username}");

                SocketGuildUser guildUser = Program.GetGuildUser(user);
                guildUser.AddRoleAsync(role);
            }
        }
 private async Task OnUserJoined(SocketGuildUser user)
 {
     await user.AddRoleAsync(LevelRoles.GetRoleFromIndex(0));
 }