@@ -113,7 +113,8 @@ namespace Discord | |||||
/// A task that represents the asynchronous modification operation. | /// A task that represents the asynchronous modification operation. | ||||
/// </returns> | /// </returns> | ||||
Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null); | Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null); | ||||
//TODO add docs | |||||
Task AddRoleAsync(ulong id, RequestOptions options = null); | |||||
/// <summary> | /// <summary> | ||||
/// Adds the specified role to this user in the guild. | /// Adds the specified role to this user in the guild. | ||||
/// </summary> | /// </summary> | ||||
@@ -123,6 +124,8 @@ namespace Discord | |||||
/// A task that represents the asynchronous role addition operation. | /// A task that represents the asynchronous role addition operation. | ||||
/// </returns> | /// </returns> | ||||
Task AddRoleAsync(IRole role, RequestOptions options = null); | Task AddRoleAsync(IRole role, RequestOptions options = null); | ||||
//TODO: Add docs | |||||
Task AddRolesAsync(IEnumerable<ulong> roleIds, RequestOptions options = null); | |||||
/// <summary> | /// <summary> | ||||
/// Adds the specified <paramref name="roles"/> to this user in the guild. | /// Adds the specified <paramref name="roles"/> to this user in the guild. | ||||
/// </summary> | /// </summary> | ||||
@@ -132,6 +135,8 @@ namespace Discord | |||||
/// A task that represents the asynchronous role addition operation. | /// A task that represents the asynchronous role addition operation. | ||||
/// </returns> | /// </returns> | ||||
Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null); | Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null); | ||||
//TODO add docs | |||||
Task RemoveRoleAsync(ulong id, RequestOptions options = null); | |||||
/// <summary> | /// <summary> | ||||
/// Removes the specified <paramref name="role"/> from this user in the guild. | /// Removes the specified <paramref name="role"/> from this user in the guild. | ||||
/// </summary> | /// </summary> | ||||
@@ -141,6 +146,8 @@ namespace Discord | |||||
/// A task that represents the asynchronous role removal operation. | /// A task that represents the asynchronous role removal operation. | ||||
/// </returns> | /// </returns> | ||||
Task RemoveRoleAsync(IRole role, RequestOptions options = null); | Task RemoveRoleAsync(IRole role, RequestOptions options = null); | ||||
//TODO: Add docs | |||||
Task RemoveRolesAsync(IEnumerable<ulong> roleIds, RequestOptions options = null); | |||||
/// <summary> | /// <summary> | ||||
/// Removes the specified <paramref name="roles"/> from this user in the guild. | /// Removes the specified <paramref name="roles"/> from this user in the guild. | ||||
/// </summary> | /// </summary> | ||||
@@ -112,15 +112,27 @@ namespace Discord.Rest | |||||
public Task KickAsync(string reason = null, RequestOptions options = null) | public Task KickAsync(string reason = null, RequestOptions options = null) | ||||
=> UserHelper.KickAsync(this, Discord, reason, options); | => UserHelper.KickAsync(this, Discord, reason, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task AddRoleAsync(ulong roleId, RequestOptions options = null) | |||||
=> throw new NotImplementedException(); | |||||
/// <inheritdoc /> | |||||
public Task AddRoleAsync(IRole role, RequestOptions options = null) | public Task AddRoleAsync(IRole role, RequestOptions options = null) | ||||
=> AddRolesAsync(new[] { role }, options); | => AddRolesAsync(new[] { role }, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task AddRolesAsync(IEnumerable<ulong> roleIds, RequestOptions options = null) | |||||
=> throw new NotImplementedException(); | |||||
/// <inheritdoc /> | |||||
public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | ||||
=> UserHelper.AddRolesAsync(this, Discord, roles, options); | => UserHelper.AddRolesAsync(this, Discord, roles, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task RemoveRoleAsync(ulong roleId, RequestOptions options = null) | |||||
=> throw new NotImplementedException(); | |||||
/// <inheritdoc /> | |||||
public Task RemoveRoleAsync(IRole role, RequestOptions options = null) | public Task RemoveRoleAsync(IRole role, RequestOptions options = null) | ||||
=> RemoveRolesAsync(new[] { role }, options); | => RemoveRolesAsync(new[] { role }, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task RemoveRolesAsync(IEnumerable<ulong> roleIds, RequestOptions options = null) | |||||
=> throw new NotImplementedException(); | |||||
/// <inheritdoc /> | |||||
public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | ||||
=> UserHelper.RemoveRolesAsync(this, Discord, roles, options); | => UserHelper.RemoveRolesAsync(this, Discord, roles, options); | ||||
@@ -59,27 +59,35 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue); | ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task IGuildUser.KickAsync(string reason, RequestOptions options) => | |||||
Task IGuildUser.KickAsync(string reason, RequestOptions options) => | |||||
throw new NotSupportedException("Webhook users cannot be kicked."); | throw new NotSupportedException("Webhook users cannot be kicked."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task IGuildUser.ModifyAsync(Action<GuildUserProperties> func, RequestOptions options) => | |||||
Task IGuildUser.ModifyAsync(Action<GuildUserProperties> func, RequestOptions options) => | |||||
throw new NotSupportedException("Webhook users cannot be modified."); | throw new NotSupportedException("Webhook users cannot be modified."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task IGuildUser.AddRoleAsync(IRole role, RequestOptions options) => | |||||
Task IGuildUser.AddRoleAsync(ulong role, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task IGuildUser.AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
Task IGuildUser.AddRoleAsync(IRole role, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task IGuildUser.RemoveRoleAsync(IRole role, RequestOptions options) => | |||||
Task IGuildUser.AddRolesAsync(IEnumerable<ulong> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
Task IGuildUser.AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
Task IGuildUser.RemoveRoleAsync(ulong role, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
Task IGuildUser.RemoveRoleAsync(IRole role, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
Task IGuildUser.RemoveRolesAsync(IEnumerable<ulong> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task IGuildUser.RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
Task IGuildUser.RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
//IVoiceState | //IVoiceState | ||||
@@ -63,7 +63,7 @@ namespace Discord.WebSocket | |||||
/// <summary> | /// <summary> | ||||
/// Returns a collection of roles that the user possesses. | /// Returns a collection of roles that the user possesses. | ||||
/// </summary> | /// </summary> | ||||
public IReadOnlyCollection<SocketRole> Roles | |||||
public IReadOnlyCollection<SocketRole> Roles | |||||
=> _roleIds.Select(id => Guild.GetRole(id)).Where(x => x != null).ToReadOnlyCollection(() => _roleIds.Length); | => _roleIds.Select(id => Guild.GetRole(id)).Where(x => x != null).ToReadOnlyCollection(() => _roleIds.Length); | ||||
/// <summary> | /// <summary> | ||||
/// Returns the voice channel the user is in, or <c>null</c> if none. | /// Returns the voice channel the user is in, or <c>null</c> if none. | ||||
@@ -177,9 +177,15 @@ namespace Discord.WebSocket | |||||
public Task KickAsync(string reason = null, RequestOptions options = null) | public Task KickAsync(string reason = null, RequestOptions options = null) | ||||
=> UserHelper.KickAsync(this, Discord, reason, options); | => UserHelper.KickAsync(this, Discord, reason, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task AddRoleAsync(ulong roleId, RequestOptions options = null) | |||||
=> throw new NotImplementedException(); | |||||
/// <inheritdoc /> | |||||
public Task AddRoleAsync(IRole role, RequestOptions options = null) | public Task AddRoleAsync(IRole role, RequestOptions options = null) | ||||
=> AddRolesAsync(new[] { role }, options); | => AddRolesAsync(new[] { role }, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task AddRolesAsync(IEnumerable<ulong> roleIds, RequestOptions options = null) | |||||
=> throw new NotImplementedException(); | |||||
/// <inheritdoc /> | |||||
public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | public Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) | ||||
=> UserHelper.AddRolesAsync(this, Discord, roles, options); | => UserHelper.AddRolesAsync(this, Discord, roles, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -31,7 +31,7 @@ namespace Discord.WebSocket | |||||
public override bool IsWebhook => true; | public override bool IsWebhook => true; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null, null); } set { } } | internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null, null); } set { } } | ||||
internal override SocketGlobalUser GlobalUser => | |||||
internal override SocketGlobalUser GlobalUser => | |||||
throw new NotSupportedException(); | throw new NotSupportedException(); | ||||
internal SocketWebhookUser(SocketGuild guild, ulong id, ulong webhookId) | internal SocketWebhookUser(SocketGuild guild, ulong id, ulong webhookId) | ||||
@@ -73,32 +73,52 @@ namespace Discord.WebSocket | |||||
ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue); | ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="NotSupportedException">Webhook users cannot be kicked.</exception> | /// <exception cref="NotSupportedException">Webhook users cannot be kicked.</exception> | ||||
Task IGuildUser.KickAsync(string reason, RequestOptions options) => | |||||
Task IGuildUser.KickAsync(string reason, RequestOptions options) => | |||||
throw new NotSupportedException("Webhook users cannot be kicked."); | throw new NotSupportedException("Webhook users cannot be kicked."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="NotSupportedException">Webhook users cannot be modified.</exception> | /// <exception cref="NotSupportedException">Webhook users cannot be modified.</exception> | ||||
Task IGuildUser.ModifyAsync(Action<GuildUserProperties> func, RequestOptions options) => | |||||
Task IGuildUser.ModifyAsync(Action<GuildUserProperties> func, RequestOptions options) => | |||||
throw new NotSupportedException("Webhook users cannot be modified."); | throw new NotSupportedException("Webhook users cannot be modified."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | /// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | ||||
Task IGuildUser.AddRoleAsync(IRole role, RequestOptions options) => | |||||
Task IGuildUser.AddRoleAsync(ulong roleId, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | /// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | ||||
Task IGuildUser.AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
Task IGuildUser.AddRoleAsync(IRole role, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | /// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | ||||
Task IGuildUser.RemoveRoleAsync(IRole role, RequestOptions options) => | |||||
Task IGuildUser.AddRolesAsync(IEnumerable<ulong> roleIds, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | /// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | ||||
Task IGuildUser.RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
Task IGuildUser.AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | |||||
Task IGuildUser.RemoveRoleAsync(ulong roleId, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | |||||
Task IGuildUser.RemoveRoleAsync(IRole role, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | |||||
Task IGuildUser.RemoveRolesAsync(IEnumerable<ulong> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | |||||
/// <inheritdoc /> | |||||
/// <exception cref="NotSupportedException">Roles are not supported on webhook users.</exception> | |||||
Task IGuildUser.RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options) => | |||||
throw new NotSupportedException("Roles are not supported on webhook users."); | throw new NotSupportedException("Roles are not supported on webhook users."); | ||||
//IVoiceState | //IVoiceState | ||||