Ejemplo n.º 1
0
        //Users
        public static async Task <RestGuildUser> AddGuildUserAsync(IGuild guild, BaseDiscordClient client, ulong userId, string accessToken,
                                                                   Action <AddGuildUserProperties> func, RequestOptions options)
        {
            AddGuildUserProperties args = new AddGuildUserProperties();

            func?.Invoke(args);

            if (args.Roles.IsSpecified)
            {
                IEnumerable <ulong> ids = args.Roles.Value.Select(r => r.Id);

                if (args.RoleIds.IsSpecified)
                {
                    args.RoleIds.Value.Concat(ids);
                }
                else
                {
                    args.RoleIds = Optional.Create(ids);
                }
            }
            AddGuildMemberParams apiArgs = new AddGuildMemberParams
            {
                AccessToken = accessToken,
                Nickname    = args.Nickname,
                IsDeafened  = args.Deaf,
                IsMuted     = args.Mute,
                RoleIds     = args.RoleIds.IsSpecified ? args.RoleIds.Value.Distinct().ToArray() : Optional.Create <ulong[]>()
            };

            GuildMemberJson model = await client.ApiClient.AddGuildMemberAsync(guild.Id, userId, apiArgs, options);

            return(model is null ? null : RestGuildUser.Create(client, guild, model));
        }
Ejemplo n.º 2
0
        public static async Task <RestGuildUser> GetUserAsync(IGuild guild, BaseDiscordClient client,
                                                              ulong id, RequestOptions options)
        {
            GuildMemberJson model = await client.ApiClient.GetGuildMemberAsync(guild.Id, id, options).ConfigureAwait(false);

            if (model != null)
            {
                return(RestGuildUser.Create(client, guild, model));
            }
            return(null);
        }
Ejemplo n.º 3
0
 private void Load(GuildMemberJson guildMemberJson)
 {
     if (guildMemberJson != null)
     {
         Rank = guildMemberJson.Rank;
         if (guildMemberJson.Member != null)
         {
             CharacterId   = guildMemberJson.Member.Id;
             CharacterName = guildMemberJson.Member.Name;
             if (guildMemberJson.Member.Realm != null)
             {
                 CharacterRealmSlug = guildMemberJson.Member.Realm.Slug;
             }
         }
     }
 }
Ejemplo n.º 4
0
 public GuildMember(GuildMemberJson guildMemberJson) : base()
 {
     Load(guildMemberJson);
 }