diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs index ca9f092e0..5d7d0a0b0 100644 --- a/src/Discord.Net.Core/Entities/Users/IUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IUser.cs @@ -8,21 +8,44 @@ namespace Discord public interface IUser : ISnowflakeEntity, IMentionable, IPresence { /// - /// Gets the ID of this user's avatar. + /// Gets the identifier of this user's avatar. /// string AvatarId { get; } /// - /// Returns a URL to this user's avatar. + /// Gets the avatar URL for this user. /// + /// + /// This property retrieves a URL for this user's avatar. In event that the user does not have a valid avatar + /// (i.e. their avatar identifier is not set), this property will return null. If you wish to + /// retrieve the default avatar for this user, consider using (see + /// example). + /// + /// + /// The following example attempts to retrieve the user's current avatar and send it to a channel; if one is + /// not set, a default avatar for this user will be returned instead. + /// + /// var userAvatarUrl = user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl(); + /// await textChannel.SendMessageAsync(userAvatarUrl); + /// + /// /// The format to return. - /// The size of the image to return in. This can be any power of two between 16 and 2048. + /// The size of the image to return in. This can be any power of two between 16 and 2048. + /// /// - /// User's avatar URL. + /// A string representing the user's avatar URL; null if the user does not have an avatar in place. /// string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); /// - /// Returns the URL to this user's default avatar. + /// Gets the default avatar URL for this user. /// + /// + /// This property retrieves a URL for this user's default avatar generated by Discord (Discord logo followed + /// by a random color as its background). This property will always return a value as it is calculated based + /// on the user's (discriminator % 5). + /// + /// + /// A string representing the user's avatar URL. + /// string GetDefaultAvatarUrl(); /// /// Gets the per-username unique ID for this user. @@ -33,10 +56,14 @@ namespace Discord /// ushort DiscriminatorValue { get; } /// - /// Gets a value that indicates whether this user is a bot user. + /// Gets a value that indicates whether this user is identified as a bot. /// + /// + /// This property retrieves a value that indicates whether this user is a registered bot application + /// (indicated by the blue BOT tag within the official chat client). + /// /// - /// true if the user is a bot; otherwise false. + /// true if the user is a bot application; otherwise false. /// bool IsBot { get; } /// @@ -52,11 +79,37 @@ namespace Discord string Username { get; } /// - /// Returns a direct message channel to this user, or create one if it does not already exist. + /// Gets the direct message channel of this user, or create one if it does not already exist. /// + /// + /// This method is used to obtain or create a channel used to send a direct message. + /// + /// In event that the current user cannot send a message to the target user, a channel can and will still be + /// created by Discord. However, attempting to send a message will yield a + /// with a 403 as its + /// . There are currently no official workarounds by + /// Discord. + /// + /// + /// + /// The following example attempts to send a direct message to the target user and logs the incident should + /// it fail. + /// + /// var channel = await user.GetOrCreateDMChannelAsync(); + /// try + /// { + /// await channel.SendMessageAsync("Awesome stuff!"); + /// } + /// catch (Discord.Net.HttpException ex) when (ex.HttpCode == 403) + /// { + /// Console.WriteLine($"Boo, I cannot message {user}"); + /// } + /// + /// /// The options to be used when sending the request. /// - /// A task that represents the asynchronous operation for getting or creating a DM channel. + /// A task that represents the asynchronous operation for getting or creating a DM channel. The task result + /// contains the DM channel associated with this user. /// Task GetOrCreateDMChannelAsync(RequestOptions options = null); }