示例#1
0
        /// <inheritdoc />
        public async Task ModifyAsync(Action <GuildUserProperties> func, RequestOptions options = null)
        {
            var args = await UserHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);

            if (args.Deaf.IsSpecified)
            {
                IsDeafened = args.Deaf.Value;
            }
            if (args.Mute.IsSpecified)
            {
                IsMuted = args.Mute.Value;
            }
            if (args.Nickname.IsSpecified)
            {
                Nickname = args.Nickname.Value;
            }
            if (args.Roles.IsSpecified)
            {
                UpdateRoles(args.Roles.Value.Select(x => x.Id).ToArray());
            }
            else if (args.RoleIds.IsSpecified)
            {
                UpdateRoles(args.RoleIds.Value.ToArray());
            }
        }
示例#2
0
        /// <inheritdoc />
        /// <exception cref="InvalidOperationException">Unable to modify this object using a different token.</exception>
        public async Task ModifyAsync(Action <SelfUserProperties> func, RequestOptions options = null)
        {
            if (Id != Discord.CurrentUser.Id)
            {
                throw new InvalidOperationException("Unable to modify this object using a different token.");
            }
            var model = await UserHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);

            Update(model);
        }