| @@ -4,13 +4,13 @@ using System.Threading.Tasks; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> Represents a guild channel. This includes a text channel, voice channel, and category channel. </summary> | |||||
| /// <summary> Represents a guild channel (text, voice, category). </summary> | |||||
| public interface IGuildChannel : IChannel, IDeletable | public interface IGuildChannel : IChannel, IDeletable | ||||
| { | { | ||||
| /// <summary> Gets the position of this channel in the guild's channel list, relative to others of the same type. </summary> | /// <summary> Gets the position of this channel in the guild's channel list, relative to others of the same type. </summary> | ||||
| int Position { get; } | int Position { get; } | ||||
| /// <summary> Gets the parentid (category) of this channel in the guild's channel list. </summary> | |||||
| /// <summary> Gets the parent ID (category) of this channel in the guild's channel list. </summary> | |||||
| ulong? CategoryId { get; } | ulong? CategoryId { get; } | ||||
| /// <summary> Gets the parent channel (category) of this channel. </summary> | /// <summary> Gets the parent channel (category) of this channel. </summary> | ||||
| Task<ICategoryChannel> GetCategoryAsync(); | Task<ICategoryChannel> GetCategoryAsync(); | ||||
| @@ -1,12 +1,16 @@ | |||||
| namespace Discord | |||||
| namespace Discord | |||||
| { | { | ||||
| /// <summary> Properties that are used to reorder an <see cref="IGuildChannel"/>. </summary> | |||||
| public class ReorderChannelProperties | public class ReorderChannelProperties | ||||
| { | { | ||||
| /// <summary>The id of the channel to apply this position to.</summary> | |||||
| /// <summary> Gets the ID of the channel to apply this position to. </summary> | |||||
| public ulong Id { get; } | public ulong Id { get; } | ||||
| /// <summary>The new zero-based position of this channel. </summary> | |||||
| /// <summary> Gets the new zero-based position of this channel. </summary> | |||||
| public int Position { get; } | public int Position { get; } | ||||
| /// <summary> Creates a <see cref="ReorderChannelProperties"/> used to reorder a channel. </summary> | |||||
| /// <param name="id"> Sets the ID of the channel to apply this position to. </param> | |||||
| /// <param name="position"> Sets the new zero-based position of this channel. </param> | |||||
| public ReorderChannelProperties(ulong id, int position) | public ReorderChannelProperties(ulong id, int position) | ||||
| { | { | ||||
| Id = id; | Id = id; | ||||
| @@ -22,20 +22,26 @@ namespace Discord | |||||
| IReadOnlyCollection<ulong> RoleIds { get; } | IReadOnlyCollection<ulong> RoleIds { get; } | ||||
| /// <summary> Gets the level permissions granted to this user to a given channel. </summary> | /// <summary> Gets the level permissions granted to this user to a given channel. </summary> | ||||
| /// <param name="channel"> The channel to get the permission from. </param> | |||||
| ChannelPermissions GetPermissions(IGuildChannel channel); | ChannelPermissions GetPermissions(IGuildChannel channel); | ||||
| /// <summary> Kicks this user from this guild. </summary> | /// <summary> Kicks this user from this guild. </summary> | ||||
| /// <param name="reason"> The reason for the kick which will be recorded in the audit log. </param> | |||||
| Task KickAsync(string reason = null, RequestOptions options = null); | Task KickAsync(string reason = null, RequestOptions options = null); | ||||
| /// <summary> Modifies this user's properties in this guild. </summary> | /// <summary> Modifies this user's properties in this guild. </summary> | ||||
| Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null); | Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null); | ||||
| /// <summary> Adds a role to this user in this guild. </summary> | /// <summary> Adds a role to this user in this guild. </summary> | ||||
| /// <param name="role"> The role to be added to the user. </param> | |||||
| Task AddRoleAsync(IRole role, RequestOptions options = null); | Task AddRoleAsync(IRole role, RequestOptions options = null); | ||||
| /// <summary> Adds roles to this user in this guild. </summary> | /// <summary> Adds roles to this user in this guild. </summary> | ||||
| /// <param name="roles"> The roles to be added to the user. </param> | |||||
| Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null); | Task AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null); | ||||
| /// <summary> Removes a role from this user in this guild. </summary> | /// <summary> Removes a role from this user in this guild. </summary> | ||||
| /// <param name="role"> The role to be removed from the user. </param> | |||||
| Task RemoveRoleAsync(IRole role, RequestOptions options = null); | Task RemoveRoleAsync(IRole role, RequestOptions options = null); | ||||
| /// <summary> Removes roles from this user in this guild. </summary> | /// <summary> Removes roles from this user in this guild. </summary> | ||||
| /// <param name="roles"> The roles to be removed from the user. </param> | |||||
| Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null); | Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,16 +1,16 @@ | |||||
| namespace Discord | |||||
| namespace Discord | |||||
| { | { | ||||
| public interface IVoiceState | public interface IVoiceState | ||||
| { | { | ||||
| /// <summary> Returns true if the guild has deafened this user. </summary> | |||||
| /// <summary> Returns <see langword="true"/> if the guild has deafened this user. </summary> | |||||
| bool IsDeafened { get; } | bool IsDeafened { get; } | ||||
| /// <summary> Returns true if the guild has muted this user. </summary> | |||||
| /// <summary> Returns <see langword="true"/> if the guild has muted this user. </summary> | |||||
| bool IsMuted { get; } | bool IsMuted { get; } | ||||
| /// <summary> Returns true if this user has marked themselves as deafened. </summary> | |||||
| /// <summary> Returns <see langword="true"/> if this user has marked themselves as deafened. </summary> | |||||
| bool IsSelfDeafened { get; } | bool IsSelfDeafened { get; } | ||||
| /// <summary> Returns true if this user has marked themselves as muted. </summary> | |||||
| /// <summary> Returns <see langword="true"/> if this user has marked themselves as muted. </summary> | |||||
| bool IsSelfMuted { get; } | bool IsSelfMuted { get; } | ||||
| /// <summary> Returns true if the guild is temporarily blocking audio to/from this user. </summary> | |||||
| /// <summary> Returns <see langword="true"/> if the guild is temporarily blocking audio to/from this user. </summary> | |||||
| bool IsSuppressed { get; } | bool IsSuppressed { get; } | ||||
| /// <summary> Gets the voice channel this user is currently in, if any. </summary> | /// <summary> Gets the voice channel this user is currently in, if any. </summary> | ||||
| IVoiceChannel VoiceChannel { get; } | IVoiceChannel VoiceChannel { get; } | ||||
| @@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> Extensions for <see cref="IDiscordClient"/>. </summary> | |||||
| /// <summary> An extension class for the Discord client. </summary> | |||||
| public static class DiscordClientExtensions | public static class DiscordClientExtensions | ||||
| { | { | ||||
| /// <summary> Gets the private channel with the provided ID. </summary> | /// <summary> Gets the private channel with the provided ID. </summary> | ||||
| @@ -2,7 +2,7 @@ using System; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> Extensions for building an embed. </summary> | |||||
| /// <summary> An extension class for building an embed. </summary> | |||||
| public static class EmbedBuilderExtensions | public static class EmbedBuilderExtensions | ||||
| { | { | ||||
| /// <summary> Adds embed color based on the provided raw value. </summary> | /// <summary> Adds embed color based on the provided raw value. </summary> | ||||
| @@ -3,11 +3,10 @@ using System.IO; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> An extension class for various Discord user objects. </summary> | |||||
| public static class UserExtensions | public static class UserExtensions | ||||
| { | { | ||||
| /// <summary> | |||||
| /// Sends a message to the user via DM. | |||||
| /// </summary> | |||||
| /// <summary> Sends a message to the user via DM. </summary> | |||||
| public static async Task<IUserMessage> SendMessageAsync(this IUser user, | public static async Task<IUserMessage> SendMessageAsync(this IUser user, | ||||
| string text, | string text, | ||||
| bool isTTS = false, | bool isTTS = false, | ||||
| @@ -17,9 +16,7 @@ namespace Discord | |||||
| return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); | return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Sends a file to the user via DM. | |||||
| /// </summary> | |||||
| /// <summary> Sends a file to the user via DM. </summary> | |||||
| public static async Task<IUserMessage> SendFileAsync(this IUser user, | public static async Task<IUserMessage> SendFileAsync(this IUser user, | ||||
| Stream stream, | Stream stream, | ||||
| string filename, | string filename, | ||||
| @@ -33,9 +30,7 @@ namespace Discord | |||||
| } | } | ||||
| #if FILESYSTEM | #if FILESYSTEM | ||||
| /// <summary> | |||||
| /// Sends a file to the user via DM. | |||||
| /// </summary> | |||||
| /// <summary> Sends a file to the user via DM. </summary> | |||||
| public static async Task<IUserMessage> SendFileAsync(this IUser user, | public static async Task<IUserMessage> SendFileAsync(this IUser user, | ||||
| string filePath, | string filePath, | ||||
| string text = null, | string text = null, | ||||
| @@ -46,7 +41,10 @@ namespace Discord | |||||
| return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false); | return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, text, isTTS, embed, options).ConfigureAwait(false); | ||||
| } | } | ||||
| #endif | #endif | ||||
| /// <summary> Bans the provided user from the guild and optionally prunes their recent messages. </summary> | |||||
| /// <param name="user"> The user to ban. </param> | |||||
| /// <param name="pruneDays"> The number of days to remove messages from this user for - must be between [0, 7]</param> | |||||
| /// <param name="reason"> The reason of the ban to be written in the audit log. </param> | |||||
| public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | ||||
| => user.Guild.AddBanAsync(user, pruneDays, reason, options); | => user.Guild.AddBanAsync(user, pruneDays, reason, options); | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System.Diagnostics; | |||||
| using System.Diagnostics; | |||||
| using Model = Discord.API.User; | using Model = Discord.API.User; | ||||
| namespace Discord.Rest | namespace Discord.Rest | ||||
| @@ -16,14 +16,21 @@ namespace Discord.Rest | |||||
| entity.Update(model); | entity.Update(model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| //IVoiceState | //IVoiceState | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsDeafened => false; | bool IVoiceState.IsDeafened => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsMuted => false; | bool IVoiceState.IsMuted => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSelfDeafened => false; | bool IVoiceState.IsSelfDeafened => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSelfMuted => false; | bool IVoiceState.IsSelfMuted => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSuppressed => false; | bool IVoiceState.IsSuppressed => false; | ||||
| /// <inheritdoc /> | |||||
| IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
| /// <inheritdoc /> | |||||
| string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System; | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| @@ -14,12 +14,17 @@ namespace Discord.Rest | |||||
| private long? _joinedAtTicks; | private long? _joinedAtTicks; | ||||
| private ImmutableArray<ulong> _roleIds; | private ImmutableArray<ulong> _roleIds; | ||||
| /// <inheritdoc /> | |||||
| public string Nickname { get; private set; } | public string Nickname { get; private set; } | ||||
| internal IGuild Guild { get; private set; } | internal IGuild Guild { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public bool IsDeafened { get; private set; } | public bool IsDeafened { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public bool IsMuted { get; private set; } | public bool IsMuted { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public ulong GuildId => Guild.Id; | public ulong GuildId => Guild.Id; | ||||
| /// <inheritdoc /> | |||||
| public GuildPermissions GuildPermissions | public GuildPermissions GuildPermissions | ||||
| { | { | ||||
| get | get | ||||
| @@ -29,8 +34,10 @@ namespace Discord.Rest | |||||
| return new GuildPermissions(Permissions.ResolveGuild(Guild, this)); | return new GuildPermissions(Permissions.ResolveGuild(Guild, this)); | ||||
| } | } | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| public IReadOnlyCollection<ulong> RoleIds => _roleIds; | public IReadOnlyCollection<ulong> RoleIds => _roleIds; | ||||
| /// <inheritdoc /> | |||||
| public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | ||||
| internal RestGuildUser(BaseDiscordClient discord, IGuild guild, ulong id) | internal RestGuildUser(BaseDiscordClient discord, IGuild guild, ulong id) | ||||
| @@ -67,11 +74,13 @@ namespace Discord.Rest | |||||
| _roleIds = roles.ToImmutable(); | _roleIds = roles.ToImmutable(); | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| public override async Task UpdateAsync(RequestOptions options = null) | public override async Task UpdateAsync(RequestOptions options = null) | ||||
| { | { | ||||
| var model = await Discord.ApiClient.GetGuildMemberAsync(GuildId, Id, options).ConfigureAwait(false); | var model = await Discord.ApiClient.GetGuildMemberAsync(GuildId, Id, options).ConfigureAwait(false); | ||||
| Update(model); | Update(model); | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| public async Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null) | public async Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null) | ||||
| { | { | ||||
| var args = await UserHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | var args = await UserHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | ||||
| @@ -86,6 +95,7 @@ namespace Discord.Rest | |||||
| else if (args.RoleIds.IsSpecified) | else if (args.RoleIds.IsSpecified) | ||||
| UpdateRoles(args.RoleIds.Value.ToArray()); | UpdateRoles(args.RoleIds.Value.ToArray()); | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| 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 /> | ||||
| @@ -101,6 +111,7 @@ namespace Discord.Rest | |||||
| 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); | ||||
| /// <inheritdoc /> | |||||
| public ChannelPermissions GetPermissions(IGuildChannel channel) | public ChannelPermissions GetPermissions(IGuildChannel channel) | ||||
| { | { | ||||
| var guildPerms = GuildPermissions; | var guildPerms = GuildPermissions; | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System; | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| @@ -10,10 +10,13 @@ namespace Discord.Rest | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class RestWebhookUser : RestUser, IWebhookUser | public class RestWebhookUser : RestUser, IWebhookUser | ||||
| { | { | ||||
| /// <inheritdoc /> | |||||
| public ulong WebhookId { get; } | public ulong WebhookId { get; } | ||||
| internal IGuild Guild { get; } | internal IGuild Guild { get; } | ||||
| /// <inheritdoc /> | |||||
| public override bool IsWebhook => true; | public override bool IsWebhook => true; | ||||
| /// <inheritdoc /> | |||||
| public ulong GuildId => Guild.Id; | public ulong GuildId => Guild.Id; | ||||
| internal RestWebhookUser(BaseDiscordClient discord, IGuild guild, ulong id, ulong webhookId) | internal RestWebhookUser(BaseDiscordClient discord, IGuild guild, ulong id, ulong webhookId) | ||||
| @@ -28,8 +31,9 @@ namespace Discord.Rest | |||||
| entity.Update(model); | entity.Update(model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| //IGuildUser | //IGuildUser | ||||
| /// <inheritdoc /> | |||||
| IGuild IGuildUser.Guild | IGuild IGuildUser.Guild | ||||
| { | { | ||||
| get | get | ||||
| @@ -39,45 +43,63 @@ namespace Discord.Rest | |||||
| throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); | throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); | ||||
| } | } | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| IReadOnlyCollection<ulong> IGuildUser.RoleIds => ImmutableArray.Create<ulong>(); | IReadOnlyCollection<ulong> IGuildUser.RoleIds => ImmutableArray.Create<ulong>(); | ||||
| /// <inheritdoc /> | |||||
| DateTimeOffset? IGuildUser.JoinedAt => null; | DateTimeOffset? IGuildUser.JoinedAt => null; | ||||
| /// <inheritdoc /> | |||||
| string IGuildUser.Nickname => null; | string IGuildUser.Nickname => null; | ||||
| /// <inheritdoc /> | |||||
| GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook; | GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook; | ||||
| /// <inheritdoc /> | |||||
| ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue); | ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue); | ||||
| /// <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 /> | |||||
| 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 /> | |||||
| Task IGuildUser.AddRoleAsync(IRole role, 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 /> | |||||
| Task IGuildUser.AddRolesAsync(IEnumerable<IRole> roles, RequestOptions options) | Task IGuildUser.AddRolesAsync(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."); | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| Task IGuildUser.RemoveRoleAsync(IRole role, RequestOptions options) | Task IGuildUser.RemoveRoleAsync(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 /> | |||||
| 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 | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsDeafened => false; | bool IVoiceState.IsDeafened => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsMuted => false; | bool IVoiceState.IsMuted => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSelfDeafened => false; | bool IVoiceState.IsSelfDeafened => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSelfMuted => false; | bool IVoiceState.IsSelfMuted => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSuppressed => false; | bool IVoiceState.IsSuppressed => false; | ||||
| /// <inheritdoc /> | |||||
| IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
| /// <inheritdoc /> | |||||
| string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| using Discord.Rest; | |||||
| using Discord.Rest; | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
| @@ -9,18 +9,23 @@ using Model = Discord.API.Channel; | |||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| { | { | ||||
| /// <summary> The WebSocket variant of <see cref="IGuildChannel"/>. Represents a guild channel (text, voice, category). </summary> | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class SocketGuildChannel : SocketChannel, IGuildChannel | public class SocketGuildChannel : SocketChannel, IGuildChannel | ||||
| { | { | ||||
| private ImmutableArray<Overwrite> _overwrites; | private ImmutableArray<Overwrite> _overwrites; | ||||
| public SocketGuild Guild { get; } | public SocketGuild Guild { get; } | ||||
| /// <inheritdoc /> | |||||
| public string Name { get; private set; } | public string Name { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public int Position { get; private set; } | public int Position { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public ulong? CategoryId { get; private set; } | public ulong? CategoryId { get; private set; } | ||||
| public ICategoryChannel Category | public ICategoryChannel Category | ||||
| => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; | => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; | ||||
| /// <inheritdoc /> | |||||
| public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites; | public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites; | ||||
| public new virtual IReadOnlyCollection<SocketGuildUser> Users => ImmutableArray.Create<SocketGuildUser>(); | public new virtual IReadOnlyCollection<SocketGuildUser> Users => ImmutableArray.Create<SocketGuildUser>(); | ||||
| @@ -57,8 +62,10 @@ namespace Discord.WebSocket | |||||
| _overwrites = newOverwrites.ToImmutable(); | _overwrites = newOverwrites.ToImmutable(); | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildChannelProperties> func, RequestOptions options = null) | ||||
| => ChannelHelper.ModifyAsync(this, Discord, func, options); | => ChannelHelper.ModifyAsync(this, Discord, func, options); | ||||
| /// <inheritdoc /> | |||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => ChannelHelper.DeleteAsync(this, Discord, options); | => ChannelHelper.DeleteAsync(this, Discord, options); | ||||
| @@ -132,38 +139,53 @@ namespace Discord.WebSocket | |||||
| internal override SocketUser GetUserInternal(ulong id) => GetUser(id); | internal override SocketUser GetUserInternal(ulong id) => GetUser(id); | ||||
| //IGuildChannel | //IGuildChannel | ||||
| /// <inheritdoc /> | |||||
| IGuild IGuildChannel.Guild => Guild; | IGuild IGuildChannel.Guild => Guild; | ||||
| /// <inheritdoc /> | |||||
| ulong IGuildChannel.GuildId => Guild.Id; | ulong IGuildChannel.GuildId => Guild.Id; | ||||
| /// <inheritdoc /> | |||||
| Task<ICategoryChannel> IGuildChannel.GetCategoryAsync() | Task<ICategoryChannel> IGuildChannel.GetCategoryAsync() | ||||
| => Task.FromResult(Category); | => Task.FromResult(Category); | ||||
| /// <inheritdoc /> | |||||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync(RequestOptions options) | ||||
| => await GetInvitesAsync(options).ConfigureAwait(false); | => await GetInvitesAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, bool isUnique, RequestOptions options) | async Task<IInviteMetadata> IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, bool isUnique, RequestOptions options) | ||||
| => await CreateInviteAsync(maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); | => await CreateInviteAsync(maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role) | OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role) | ||||
| => GetPermissionOverwrite(role); | => GetPermissionOverwrite(role); | ||||
| /// <inheritdoc /> | |||||
| OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) | OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user) | ||||
| => GetPermissionOverwrite(user); | => GetPermissionOverwrite(user); | ||||
| /// <inheritdoc /> | |||||
| async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options) | async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options) | ||||
| => await AddPermissionOverwriteAsync(role, permissions, options).ConfigureAwait(false); | => await AddPermissionOverwriteAsync(role, permissions, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options) | async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options) | ||||
| => await AddPermissionOverwriteAsync(user, permissions, options).ConfigureAwait(false); | => await AddPermissionOverwriteAsync(user, permissions, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options) | async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options) | ||||
| => await RemovePermissionOverwriteAsync(role, options).ConfigureAwait(false); | => await RemovePermissionOverwriteAsync(role, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) | async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options) | ||||
| => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); | => await RemovePermissionOverwriteAsync(user, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | ||||
| => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); | => ImmutableArray.Create<IReadOnlyCollection<IGuildUser>>(Users).ToAsyncEnumerable(); | ||||
| /// <inheritdoc /> | |||||
| Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
| => Task.FromResult<IGuildUser>(GetUser(id)); | => Task.FromResult<IGuildUser>(GetUser(id)); | ||||
| //IChannel | //IChannel | ||||
| /// <inheritdoc /> | |||||
| IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) | ||||
| => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); //Overridden in Text/Voice | => ImmutableArray.Create<IReadOnlyCollection<IUser>>(Users).ToAsyncEnumerable(); //Overridden in Text/Voice | ||||
| /// <inheritdoc /> | |||||
| Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
| => Task.FromResult<IUser>(GetUser(id)); //Overridden in Text/Voice | => Task.FromResult<IUser>(GetUser(id)); //Overridden in Text/Voice | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System.Diagnostics; | |||||
| using System.Diagnostics; | |||||
| using Model = Discord.API.User; | using Model = Discord.API.User; | ||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| @@ -9,12 +9,17 @@ namespace Discord.WebSocket | |||||
| public SocketGroupChannel Channel { get; } | public SocketGroupChannel Channel { get; } | ||||
| internal override SocketGlobalUser GlobalUser { get; } | internal override SocketGlobalUser GlobalUser { get; } | ||||
| /// <inheritdoc /> | |||||
| public override bool IsBot { get { return GlobalUser.IsBot; } internal set { GlobalUser.IsBot = value; } } | public override bool IsBot { get { return GlobalUser.IsBot; } internal set { GlobalUser.IsBot = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override string Username { get { return GlobalUser.Username; } internal set { GlobalUser.Username = value; } } | public override string Username { get { return GlobalUser.Username; } internal set { GlobalUser.Username = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override ushort DiscriminatorValue { get { return GlobalUser.DiscriminatorValue; } internal set { GlobalUser.DiscriminatorValue = value; } } | public override ushort DiscriminatorValue { get { return GlobalUser.DiscriminatorValue; } internal set { GlobalUser.DiscriminatorValue = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } } | public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } } | ||||
| internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } } | internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override bool IsWebhook => false; | public override bool IsWebhook => false; | ||||
| internal SocketGroupUser(SocketGroupChannel channel, SocketGlobalUser globalUser) | internal SocketGroupUser(SocketGroupChannel channel, SocketGlobalUser globalUser) | ||||
| @@ -33,12 +38,19 @@ namespace Discord.WebSocket | |||||
| internal new SocketGroupUser Clone() => MemberwiseClone() as SocketGroupUser; | internal new SocketGroupUser Clone() => MemberwiseClone() as SocketGroupUser; | ||||
| //IVoiceState | //IVoiceState | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsDeafened => false; | bool IVoiceState.IsDeafened => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsMuted => false; | bool IVoiceState.IsMuted => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSelfDeafened => false; | bool IVoiceState.IsSelfDeafened => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSelfMuted => false; | bool IVoiceState.IsSelfMuted => false; | ||||
| /// <inheritdoc /> | |||||
| bool IVoiceState.IsSuppressed => false; | bool IVoiceState.IsSuppressed => false; | ||||
| /// <inheritdoc /> | |||||
| IVoiceChannel IVoiceState.VoiceChannel => null; | IVoiceChannel IVoiceState.VoiceChannel => null; | ||||
| /// <inheritdoc /> | |||||
| string IVoiceState.VoiceSessionId => null; | string IVoiceState.VoiceSessionId => null; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| using Discord.Audio; | |||||
| using Discord.Audio; | |||||
| using Discord.Rest; | using Discord.Rest; | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| @@ -12,6 +12,7 @@ using PresenceModel = Discord.API.Presence; | |||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| { | { | ||||
| /// <summary> The WebSocket variant of <see cref="IGuildUser"/>. Represents a Discord user that is in a guild. </summary> | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class SocketGuildUser : SocketUser, IGuildUser | public class SocketGuildUser : SocketUser, IGuildUser | ||||
| { | { | ||||
| @@ -20,32 +21,46 @@ namespace Discord.WebSocket | |||||
| internal override SocketGlobalUser GlobalUser { get; } | internal override SocketGlobalUser GlobalUser { get; } | ||||
| public SocketGuild Guild { get; } | public SocketGuild Guild { get; } | ||||
| /// <inheritdoc /> | |||||
| public string Nickname { get; private set; } | public string Nickname { get; private set; } | ||||
| /// <inheritdoc /> | |||||
| public override bool IsBot { get { return GlobalUser.IsBot; } internal set { GlobalUser.IsBot = value; } } | public override bool IsBot { get { return GlobalUser.IsBot; } internal set { GlobalUser.IsBot = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override string Username { get { return GlobalUser.Username; } internal set { GlobalUser.Username = value; } } | public override string Username { get { return GlobalUser.Username; } internal set { GlobalUser.Username = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override ushort DiscriminatorValue { get { return GlobalUser.DiscriminatorValue; } internal set { GlobalUser.DiscriminatorValue = value; } } | public override ushort DiscriminatorValue { get { return GlobalUser.DiscriminatorValue; } internal set { GlobalUser.DiscriminatorValue = value; } } | ||||
| /// <inheritdoc /> | |||||
| public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } } | public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } } | ||||
| /// <inheritdoc /> | |||||
| public GuildPermissions GuildPermissions => new GuildPermissions(Permissions.ResolveGuild(Guild, this)); | public GuildPermissions GuildPermissions => new GuildPermissions(Permissions.ResolveGuild(Guild, this)); | ||||
| internal override SocketPresence Presence { get; set; } | internal override SocketPresence Presence { get; set; } | ||||
| /// <inheritdoc /> | |||||
| public override bool IsWebhook => false; | public override bool IsWebhook => false; | ||||
| /// <inheritdoc /> | |||||
| public bool IsSelfDeafened => VoiceState?.IsSelfDeafened ?? false; | public bool IsSelfDeafened => VoiceState?.IsSelfDeafened ?? false; | ||||
| /// <inheritdoc /> | |||||
| public bool IsSelfMuted => VoiceState?.IsSelfMuted ?? false; | public bool IsSelfMuted => VoiceState?.IsSelfMuted ?? false; | ||||
| /// <inheritdoc /> | |||||
| public bool IsSuppressed => VoiceState?.IsSuppressed ?? false; | public bool IsSuppressed => VoiceState?.IsSuppressed ?? false; | ||||
| /// <inheritdoc /> | |||||
| public bool IsDeafened => VoiceState?.IsDeafened ?? false; | public bool IsDeafened => VoiceState?.IsDeafened ?? false; | ||||
| /// <inheritdoc /> | |||||
| public bool IsMuted => VoiceState?.IsMuted ?? false; | public bool IsMuted => VoiceState?.IsMuted ?? false; | ||||
| /// <inheritdoc /> | |||||
| public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | public DateTimeOffset? JoinedAt => DateTimeUtils.FromTicks(_joinedAtTicks); | ||||
| 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); | ||||
| public SocketVoiceChannel VoiceChannel => VoiceState?.VoiceChannel; | public SocketVoiceChannel VoiceChannel => VoiceState?.VoiceChannel; | ||||
| /// <inheritdoc /> | |||||
| public string VoiceSessionId => VoiceState?.VoiceSessionId ?? ""; | public string VoiceSessionId => VoiceState?.VoiceSessionId ?? ""; | ||||
| public SocketVoiceState? VoiceState => Guild.GetVoiceState(Id); | public SocketVoiceState? VoiceState => Guild.GetVoiceState(Id); | ||||
| public AudioInStream AudioStream => Guild.GetAudioStream(Id); | public AudioInStream AudioStream => Guild.GetAudioStream(Id); | ||||
| /// <summary> The position of the user within the role hierarchy. </summary> | /// <summary> The position of the user within the role hierarchy. </summary> | ||||
| /// <remarks> The returned value equal to the position of the highest role the user has, | /// <remarks> The returned value equal to the position of the highest role the user has, | ||||
| /// or int.MaxValue if user is the server owner. </remarks> | |||||
| /// or <see cref="int.MaxValue"/> if user is the server owner. </remarks> | |||||
| public int Hierarchy | public int Hierarchy | ||||
| { | { | ||||
| get | get | ||||
| @@ -119,9 +134,11 @@ namespace Discord.WebSocket | |||||
| roles.Add(roleIds[i]); | roles.Add(roleIds[i]); | ||||
| _roleIds = roles.ToImmutable(); | _roleIds = roles.ToImmutable(); | ||||
| } | } | ||||
| /// <inheritdoc /> | |||||
| public Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildUserProperties> func, RequestOptions options = null) | ||||
| => UserHelper.ModifyAsync(this, Discord, func, options); | => UserHelper.ModifyAsync(this, Discord, func, options); | ||||
| /// <inheritdoc /> | |||||
| 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 /> | ||||
| @@ -137,17 +154,22 @@ namespace Discord.WebSocket | |||||
| 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); | ||||
| /// <inheritdoc /> | |||||
| public ChannelPermissions GetPermissions(IGuildChannel channel) | public ChannelPermissions GetPermissions(IGuildChannel channel) | ||||
| => new ChannelPermissions(Permissions.ResolveChannel(Guild, this, channel, GuildPermissions.RawValue)); | => new ChannelPermissions(Permissions.ResolveChannel(Guild, this, channel, GuildPermissions.RawValue)); | ||||
| internal new SocketGuildUser Clone() => MemberwiseClone() as SocketGuildUser; | internal new SocketGuildUser Clone() => MemberwiseClone() as SocketGuildUser; | ||||
| //IGuildUser | //IGuildUser | ||||
| /// <inheritdoc /> | |||||
| IGuild IGuildUser.Guild => Guild; | IGuild IGuildUser.Guild => Guild; | ||||
| /// <inheritdoc /> | |||||
| ulong IGuildUser.GuildId => Guild.Id; | ulong IGuildUser.GuildId => Guild.Id; | ||||
| /// <inheritdoc /> | |||||
| IReadOnlyCollection<ulong> IGuildUser.RoleIds => _roleIds; | IReadOnlyCollection<ulong> IGuildUser.RoleIds => _roleIds; | ||||
| //IVoiceState | //IVoiceState | ||||
| /// <inheritdoc /> | |||||
| IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel; | IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,24 +1,35 @@ | |||||
| using Discord.Rest; | |||||
| using Discord.Rest; | |||||
| using System; | using System; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.User; | using Model = Discord.API.User; | ||||
| namespace Discord.WebSocket | namespace Discord.WebSocket | ||||
| { | { | ||||
| /// <summary> The WebSocket variant of <see cref="IUser"/>. Represents a Discord user. </summary> | |||||
| public abstract class SocketUser : SocketEntity<ulong>, IUser | public abstract class SocketUser : SocketEntity<ulong>, IUser | ||||
| { | { | ||||
| /// <inheritdoc /> | |||||
| public abstract bool IsBot { get; internal set; } | public abstract bool IsBot { get; internal set; } | ||||
| /// <inheritdoc /> | |||||
| public abstract string Username { get; internal set; } | public abstract string Username { get; internal set; } | ||||
| /// <inheritdoc /> | |||||
| public abstract ushort DiscriminatorValue { get; internal set; } | public abstract ushort DiscriminatorValue { get; internal set; } | ||||
| /// <inheritdoc /> | |||||
| public abstract string AvatarId { get; internal set; } | public abstract string AvatarId { get; internal set; } | ||||
| /// <inheritdoc /> | |||||
| public abstract bool IsWebhook { get; } | public abstract bool IsWebhook { get; } | ||||
| internal abstract SocketGlobalUser GlobalUser { get; } | internal abstract SocketGlobalUser GlobalUser { get; } | ||||
| internal abstract SocketPresence Presence { get; set; } | internal abstract SocketPresence Presence { get; set; } | ||||
| /// <inheritdoc /> | |||||
| public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | ||||
| /// <inheritdoc /> | |||||
| public string Discriminator => DiscriminatorValue.ToString("D4"); | public string Discriminator => DiscriminatorValue.ToString("D4"); | ||||
| /// <inheritdoc /> | |||||
| public string Mention => MentionUtils.MentionUser(Id); | public string Mention => MentionUtils.MentionUser(Id); | ||||
| /// <inheritdoc /> | |||||
| public IActivity Activity => Presence.Activity; | public IActivity Activity => Presence.Activity; | ||||
| /// <inheritdoc /> | |||||
| public UserStatus Status => Presence.Status; | public UserStatus Status => Presence.Status; | ||||
| internal SocketUser(DiscordSocketClient discord, ulong id) | internal SocketUser(DiscordSocketClient discord, ulong id) | ||||
| @@ -53,14 +64,17 @@ namespace Discord.WebSocket | |||||
| hasChanges = true; | hasChanges = true; | ||||
| } | } | ||||
| return hasChanges; | return hasChanges; | ||||
| } | |||||
| } | |||||
| /// <inheritdoc /> | |||||
| public async Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | public async Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | ||||
| => GlobalUser.DMChannel ?? await UserHelper.CreateDMChannelAsync(this, Discord, options) as IDMChannel; | => GlobalUser.DMChannel ?? await UserHelper.CreateDMChannelAsync(this, Discord, options) as IDMChannel; | ||||
| /// <inheritdoc /> | |||||
| public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | ||||
| => CDN.GetUserAvatarUrl(Id, AvatarId, size, format); | => CDN.GetUserAvatarUrl(Id, AvatarId, size, format); | ||||
| /// <summary> Gets the username and the discriminator. </summary> | |||||
| public override string ToString() => $"{Username}#{Discriminator}"; | public override string ToString() => $"{Username}#{Discriminator}"; | ||||
| private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; | private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; | ||||
| internal SocketUser Clone() => MemberwiseClone() as SocketUser; | internal SocketUser Clone() => MemberwiseClone() as SocketUser; | ||||