Browse Source

Merge branch 'Interactions' of https://github.com/Discord-Net-Labs/Discord.Net-Labs into Interactions

pull/1923/head
quin lynch 4 years ago
parent
commit
8053b08a8b
7 changed files with 33 additions and 2 deletions
  1. +3
    -0
      src/Discord.Net.Core/Utils/MentionUtils.cs
  2. +10
    -0
      src/Discord.Net.Rest/API/Common/InviteVanity.cs
  3. +2
    -2
      src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs
  4. +8
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
  5. +3
    -0
      src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs
  6. +4
    -0
      src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs
  7. +3
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketGroupUser.cs

+ 3
- 0
src/Discord.Net.Core/Utils/MentionUtils.cs View File

@@ -40,6 +40,7 @@ namespace Discord
/// <summary>
/// Parses a provided user mention string.
/// </summary>
/// <param name="text">The user mention.</param>
/// <exception cref="ArgumentException">Invalid mention format.</exception>
public static ulong ParseUser(string text)
{
@@ -50,6 +51,8 @@ namespace Discord
/// <summary>
/// Tries to parse a provided user mention string.
/// </summary>
/// <param name="text">The user mention.</param>
/// <param name="userId">The UserId of the user.</param>
public static bool TryParseUser(string text, out ulong userId)
{
if (text.Length >= 3 && text[0] == '<' && text[1] == '@' && text[text.Length - 1] == '>')


+ 10
- 0
src/Discord.Net.Rest/API/Common/InviteVanity.cs View File

@@ -2,10 +2,20 @@ using Newtonsoft.Json;

namespace Discord.API
{
/// <summary>
/// Represents a vanity invite.
/// </summary>
public class InviteVanity
{
/// <summary>
/// The unique code for the invite link.
/// </summary>
[JsonProperty("code")]
public string Code { get; set; }

/// <summary>
/// The total amount of vanity invite uses.
/// </summary>
[JsonProperty("uses")]
public int Uses { get; set; }
}


+ 2
- 2
src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs View File

@@ -44,7 +44,7 @@ namespace Discord.WebSocket
/// Sends a file to this message channel with an optional caption.
/// </summary>
/// <remarks>
/// This method follows the same behavior as described in <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>.
/// This method follows the same behavior as described in <see cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent)"/>.
/// Please visit its documentation for more details on this method.
/// </remarks>
/// <param name="filePath">The file path of the file.</param>
@@ -68,7 +68,7 @@ namespace Discord.WebSocket
/// Sends a file to this message channel with an optional caption.
/// </summary>
/// <remarks>
/// This method follows the same behavior as described in <see cref="IMessageChannel.SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>.
/// This method follows the same behavior as described in <see cref="IMessageChannel.SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent)"/>.
/// Please visit its documentation for more details on this method.
/// </remarks>
/// <param name="stream">The <see cref="Stream" /> of the file to be sent.</param>


+ 8
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs View File

@@ -31,7 +31,15 @@ namespace Discord.WebSocket

/// <inheritdoc />
public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>();

/// <summary>
/// Returns a collection representing all of the users in the group.
/// </summary>
public new IReadOnlyCollection<SocketGroupUser> Users => _users.ToReadOnlyCollection();

/// <summary>
/// Returns a collection representing all users in the group, not including the client.
/// </summary>
public IReadOnlyCollection<SocketGroupUser> Recipients
=> _users.Select(x => x.Value).Where(x => x.Id != Discord.CurrentUser.Id).ToReadOnlyCollection(() => _users.Count - 1);



+ 3
- 0
src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs View File

@@ -6,6 +6,9 @@ using Model = Discord.API.Gateway.InviteCreateEvent;

namespace Discord.WebSocket
{
/// <summary>
/// Represents a WebSocket-based invite to a guild.
/// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketInvite : SocketEntity<string>, IInviteMetadata
{


+ 4
- 0
src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs View File

@@ -50,6 +50,10 @@ namespace Discord.WebSocket
public bool IsEveryone => Id == Guild.Id;
/// <inheritdoc />
public string Mention => IsEveryone ? "@everyone" : MentionUtils.MentionRole(Id);

/// <summary>
/// Returns an IEnumerable containing all <see cref="SocketGuildUser"/> that have this role.
/// </summary>
public IEnumerable<SocketGuildUser> Members
=> Guild.Users.Where(x => x.Roles.Any(r => r.Id == Id));



+ 3
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketGroupUser.cs View File

@@ -3,6 +3,9 @@ using Model = Discord.API.User;

namespace Discord.WebSocket
{
/// <summary>
/// Represents a WebSocket-based group user.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SocketGroupUser : SocketUser, IGroupUser
{


Loading…
Cancel
Save