diff --git a/src/Discord.Net.Core/Utils/Preconditions.cs b/src/Discord.Net.Core/Utils/Preconditions.cs
index 60415852c..ff8eb7c0d 100644
--- a/src/Discord.Net.Core/Utils/Preconditions.cs
+++ b/src/Discord.Net.Core/Utils/Preconditions.cs
@@ -4,7 +4,7 @@ namespace Discord
{
internal static class Preconditions
{
- //Objects
+ #region Objects
/// must not be .
public static void NotNull(T obj, string name, string msg = null) where T : class { if (obj == null) throw CreateNotNullException(name, msg); }
/// must not be .
@@ -15,8 +15,9 @@ namespace Discord
if (msg == null) return new ArgumentNullException(paramName: name);
else return new ArgumentNullException(paramName: name, message: msg);
}
+ #endregion
- //Strings
+ #region Strings
/// cannot be blank.
public static void NotEmpty(string obj, string name, string msg = null) { if (obj.Length == 0) throw CreateNotEmptyException(name, msg); }
/// cannot be blank.
@@ -58,8 +59,9 @@ namespace Discord
private static ArgumentException CreateNotEmptyException(string name, string msg)
=> new ArgumentException(message: msg ?? "Argument cannot be blank.", paramName: name);
+ #endregion
- //Numerics
+ #region Numerics
/// Value may not be equal to .
public static void NotEqual(sbyte obj, sbyte value, string name, string msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); }
/// Value may not be equal to .
@@ -271,8 +273,9 @@ namespace Discord
private static ArgumentException CreateLessThanException(string name, string msg, T value)
=> new ArgumentException(message: msg ?? $"Value must be less than {value}.", paramName: name);
+ #endregion
- // Bulk Delete
+ #region Bulk Delete
/// Messages are younger than 2 weeks.
public static void YoungerThanTwoWeeks(ulong[] collection, string name)
{
@@ -293,5 +296,6 @@ namespace Discord
throw new ArgumentException(message: "The everyone role cannot be assigned to a user.", paramName: name);
}
}
+ #endregion
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
index bf95cfa6d..696ffa5af 100644
--- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
@@ -12,7 +12,7 @@ namespace Discord.Rest
{
internal static class ChannelHelper
{
- //General
+ #region General
public static async Task DeleteAsync(IChannel channel, BaseDiscordClient client,
RequestOptions options)
{
@@ -107,8 +107,9 @@ namespace Discord.Rest
return await client.ApiClient.ModifyStageInstanceAsync(channel.Id, apiArgs, options);
}
+ #endregion
- //Invites
+ #region Invites
public static async Task> GetInvitesAsync(IGuildChannel channel, BaseDiscordClient client,
RequestOptions options)
{
@@ -183,8 +184,9 @@ namespace Discord.Rest
var model = await client.ApiClient.CreateChannelInviteAsync(channel.Id, args, options).ConfigureAwait(false);
return RestInviteMetadata.Create(client, null, channel, model);
}
+ #endregion
- //Messages
+ #region Messages
public static async Task GetMessageAsync(IMessageChannel channel, BaseDiscordClient client,
ulong id, RequestOptions options)
{
@@ -285,12 +287,12 @@ namespace Discord.Rest
}
}
- if(stickers != null)
+ if (stickers != null)
{
Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed.");
}
- var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel(), MessageReference = messageReference?.ToModel(), Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified};
+ var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel(), MessageReference = messageReference?.ToModel(), Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified };
var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false);
return RestUserMessage.Create(client, channel, client.CurrentUser, model);
}
@@ -397,8 +399,9 @@ namespace Discord.Rest
await client.ApiClient.DeleteMessagesAsync(channel.Id, args, options).ConfigureAwait(false);
}
}
+ #endregion
- //Permission Overwrites
+ #region Permission Overwrites
public static async Task AddPermissionOverwriteAsync(IGuildChannel channel, BaseDiscordClient client,
IUser user, OverwritePermissions perms, RequestOptions options)
{
@@ -421,8 +424,9 @@ namespace Discord.Rest
{
await client.ApiClient.DeleteChannelPermissionAsync(channel.Id, role.Id, options).ConfigureAwait(false);
}
+ #endregion
- //Users
+ #region Users
/// Resolving permissions requires the parent guild to be downloaded.
public static async Task GetUserAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client,
ulong id, RequestOptions options)
@@ -467,8 +471,9 @@ namespace Discord.Rest
count: limit
);
}
+ #endregion
- //Typing
+ #region Typing
public static async Task TriggerTypingAsync(IMessageChannel channel, BaseDiscordClient client,
RequestOptions options = null)
{
@@ -477,8 +482,9 @@ namespace Discord.Rest
public static IDisposable EnterTypingState(IMessageChannel channel, BaseDiscordClient client,
RequestOptions options)
=> new TypingNotifier(channel, options);
+ #endregion
- //Webhooks
+ #region Webhooks
public static async Task CreateWebhookAsync(ITextChannel channel, BaseDiscordClient client, string name, Stream avatar, RequestOptions options)
{
var args = new CreateWebhookParams { Name = name };
@@ -501,7 +507,9 @@ namespace Discord.Rest
return models.Select(x => RestWebhook.Create(client, channel, x))
.ToImmutableArray();
}
- // Categories
+ #endregion
+
+ #region Categories
public static async Task GetCategoryAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options)
{
// if no category id specified, return null
@@ -515,7 +523,8 @@ namespace Discord.Rest
public static async Task SyncPermissionsAsync(INestedChannel channel, BaseDiscordClient client, RequestOptions options)
{
var category = await GetCategoryAsync(channel, client, options).ConfigureAwait(false);
- if (category == null) throw new InvalidOperationException("This channel does not have a parent channel.");
+ if (category == null)
+ throw new InvalidOperationException("This channel does not have a parent channel.");
var apiArgs = new ModifyGuildChannelParams
{
@@ -530,5 +539,6 @@ namespace Discord.Rest
};
await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
}
+ #endregion
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
index 6fe2c862c..57869ea58 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
@@ -15,6 +15,7 @@ namespace Discord.Rest
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestDMChannel : RestChannel, IDMChannel, IRestPrivateChannel, IRestMessageChannel
{
+ #region RestDMChannel
///
/// Gets the current logged-in user.
///
@@ -154,20 +155,24 @@ namespace Discord.Rest
///
public override string ToString() => $"@{Recipient}";
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";
+ #endregion
- //IDMChannel
+ #region IDMChannel
///
IUser IDMChannel.Recipient => Recipient;
+ #endregion
- //IRestPrivateChannel
+ #region IRestPrivateChannel
///
IReadOnlyCollection IRestPrivateChannel.Recipients => ImmutableArray.Create(Recipient);
+ #endregion
- //IPrivateChannel
+ #region IPrivateChannel
///
IReadOnlyCollection IPrivateChannel.Recipients => ImmutableArray.Create(Recipient);
+ #endregion
- //IMessageChannel
+ #region IMessageChannel
///
async Task IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{
@@ -212,8 +217,9 @@ namespace Discord.Rest
///
async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers)
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false);
+ #endregion
- //IChannel
+ #region IChannel
///
string IChannel.Name => $"@{Recipient}";
@@ -223,5 +229,6 @@ namespace Discord.Rest
///
IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> ImmutableArray.Create>(Users).ToAsyncEnumerable();
+ #endregion
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
index 25d34cd0b..1b5df0d87 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
@@ -16,6 +16,7 @@ namespace Discord.Rest
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestGroupChannel : RestChannel, IGroupChannel, IRestPrivateChannel, IRestMessageChannel, IRestAudioChannel
{
+ #region RestGroupChannel
private string _iconId;
private ImmutableDictionary _users;
@@ -143,14 +144,17 @@ namespace Discord.Rest
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Group)";
+ #endregion
- //ISocketPrivateChannel
+ #region ISocketPrivateChannel
IReadOnlyCollection IRestPrivateChannel.Recipients => Recipients;
+ #endregion
- //IPrivateChannel
+ #region IPrivateChannel
IReadOnlyCollection IPrivateChannel.Recipients => Recipients;
+ #endregion
- //IMessageChannel
+ #region IMessageChannel
async Task IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
@@ -190,17 +194,20 @@ namespace Discord.Rest
async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers)
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false);
+ #endregion
- //IAudioChannel
+ #region IAudioChannel
///
/// Connecting to a group channel is not supported.
Task IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); }
Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); }
+ #endregion
- //IChannel
+ #region IChannel
Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult(GetUser(id));
IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> ImmutableArray.Create>(Users).ToAsyncEnumerable();
+ #endregion
}
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs b/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs
index ec8f60ae5..d77d3b626 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestBan.cs
@@ -9,6 +9,7 @@ namespace Discord.Rest
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestBan : IBan
{
+ #region RestBan
///
/// Gets the banned user.
///
@@ -37,9 +38,11 @@ namespace Discord.Rest
///
public override string ToString() => User.ToString();
private string DebuggerDisplay => $"{User}: {Reason}";
+#endregion
- //IBan
+ #region IBan
///
IUser IBan.User => User;
+ #endregion
}
}
diff --git a/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs b/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs
index 63b89035b..40e45b135 100644
--- a/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs
+++ b/src/Discord.Net.Rest/Entities/Users/RestGroupUser.cs
@@ -10,6 +10,7 @@ namespace Discord.Rest
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestGroupUser : RestUser, IGroupUser
{
+ #region RestGroupUser
internal RestGroupUser(BaseDiscordClient discord, ulong id)
: base(discord, id)
{
@@ -20,8 +21,9 @@ namespace Discord.Rest
entity.Update(model);
return entity;
}
+#endregion
- //IVoiceState
+ #region IVoiceState
///
bool IVoiceState.IsDeafened => false;
///
@@ -40,5 +42,6 @@ namespace Discord.Rest
bool IVoiceState.IsStreaming => false;
///
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
+ #endregion
}
}
diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
index 7e3531d2a..f465571d6 100644
--- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
@@ -24,6 +24,7 @@ namespace Discord.WebSocket
///
public partial class DiscordSocketClient : BaseSocketClient, IDiscordClient
{
+ #region DiscordSocketClient
private readonly ConcurrentQueue _largeGuilds;
internal readonly JsonSerializer _serializer;
private readonly DiscordShardedClient _shardedClient;
@@ -62,6 +63,7 @@ namespace Discord.WebSocket
///
public override IActivity Activity { get => _activity.GetValueOrDefault(); protected set => _activity = Optional.Create(value); }
private Optional _activity;
+ #endregion
//From DiscordSocketConfig
internal int TotalShards { get; private set; }
@@ -436,7 +438,7 @@ namespace Discord.WebSocket
var entity = State.GetOrAddCommand(model.Id, (id) => SocketApplicationCommand.Create(this, model));
- // update it incase it was cached
+ //Update it incase it was cached
entity.Update(model);
return entity;
@@ -448,7 +450,7 @@ namespace Discord.WebSocket
var entities = models.Select(x => SocketApplicationCommand.Create(this, x));
- // purge our previous commands
+ //Purge our previous commands
State.PurgeCommands(x => x.IsGlobalCommand);
foreach(var entity in entities)
@@ -513,7 +515,7 @@ namespace Discord.WebSocket
{
var guild = State.GetGuild(model.GuildId.Value);
- // since the sticker can be from another guild, check if we are in the guild or its in the cache
+ //Since the sticker can be from another guild, check if we are in the guild or its in the cache
if (guild != null)
sticker = guild.AddOrUpdateSticker(model);
else
@@ -678,7 +680,7 @@ namespace Discord.WebSocket
return null;
GameModel game = null;
- // Discord only accepts rich presence over RPC, don't even bother building a payload
+ //Discord only accepts rich presence over RPC, don't even bother building a payload
if (activity.GetValueOrDefault() != null)
{
@@ -700,6 +702,7 @@ namespace Discord.WebSocket
game);
}
+ #region ProcessMessageAsync
private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string type, object payload)
{
if (seq != null)
@@ -772,7 +775,7 @@ namespace Discord.WebSocket
case GatewayOpCode.Dispatch:
switch (type)
{
- //Connection
+ #region Connection
case "READY":
{
try
@@ -849,8 +852,9 @@ namespace Discord.WebSocket
await _gatewayLogger.InfoAsync("Resumed previous session").ConfigureAwait(false);
}
break;
+ #endregion
- //Guilds
+ #region Guilds
case "GUILD_CREATE":
{
var data = (payload as JToken).ToObject(_serializer);
@@ -1000,8 +1004,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Channels
+ #region Channels
case "CHANNEL_CREATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (CHANNEL_CREATE)").ConfigureAwait(false);
@@ -1103,8 +1108,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Members
+ #region Members
case "GUILD_MEMBER_ADD":
{
await _gatewayLogger.DebugAsync("Received Dispatch (GUILD_MEMBER_ADD)").ConfigureAwait(false);
@@ -1275,8 +1281,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Roles
+ #region Roles
case "GUILD_ROLE_CREATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (GUILD_ROLE_CREATE)").ConfigureAwait(false);
@@ -1368,8 +1375,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Bans
+ #region Bans
case "GUILD_BAN_ADD":
{
await _gatewayLogger.DebugAsync("Received Dispatch (GUILD_BAN_ADD)").ConfigureAwait(false);
@@ -1422,8 +1430,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Messages
+ #region Messages
case "MESSAGE_CREATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (MESSAGE_CREATE)").ConfigureAwait(false);
@@ -1754,8 +1763,9 @@ namespace Discord.WebSocket
await TimedInvokeAsync(_messagesBulkDeletedEvent, nameof(MessagesBulkDeleted), cacheableList, cacheableChannel).ConfigureAwait(false);
}
break;
+ #endregion
- //Statuses
+ #region Statuses
case "PRESENCE_UPDATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (PRESENCE_UPDATE)").ConfigureAwait(false);
@@ -1843,8 +1853,9 @@ namespace Discord.WebSocket
await TimedInvokeAsync(_userIsTypingEvent, nameof(UserIsTyping), cacheableUser, cacheableChannel).ConfigureAwait(false);
}
break;
+ #endregion
- //Users
+ #region Users
case "USER_UPDATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (USER_UPDATE)").ConfigureAwait(false);
@@ -1863,8 +1874,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Voice
+ #region Voice
case "VOICE_STATE_UPDATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (VOICE_STATE_UPDATE)").ConfigureAwait(false);
@@ -1901,7 +1913,7 @@ namespace Discord.WebSocket
after = SocketVoiceState.Create(null, data);
}
- // per g250k, this should always be sent, but apparently not always
+ //Per g250k, this should always be sent, but apparently not always
user = guild.GetUser(data.UserId)
?? (data.Member.IsSpecified ? guild.AddOrUpdateUser(data.Member.Value) : null);
if (user == null)
@@ -1993,8 +2005,9 @@ namespace Discord.WebSocket
}
break;
+ #endregion
- //Invites
+ #region Invites
case "INVITE_CREATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (INVITE_CREATE)").ConfigureAwait(false);
@@ -2051,8 +2064,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- // Interactions
+ #region Interactions
case "INTERACTION_CREATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (INTERACTION_CREATE)").ConfigureAwait(false);
@@ -2189,8 +2203,9 @@ namespace Discord.WebSocket
await TimedInvokeAsync(_applicationCommandDeleted, nameof(ApplicationCommandDeleted), applicationCommand).ConfigureAwait(false);
}
break;
+ #endregion
- // Threads
+ #region Threads
case "THREAD_CREATE":
{
await _gatewayLogger.DebugAsync("Received Dispatch (THREAD_CREATE)").ConfigureAwait(false);
@@ -2251,7 +2266,7 @@ namespace Discord.WebSocket
}
else
{
- // Thread is updated but was not cached, likely meaning the thread was unarchived.
+ //Thread is updated but was not cached, likely meaning the thread was unarchived.
threadChannel = (SocketThreadChannel)guild.AddChannel(State, data);
if (data.ThreadMember.IsSpecified)
threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser);
@@ -2507,8 +2522,9 @@ namespace Discord.WebSocket
}
}
break;
+ #endregion
- //Ignored (User only)
+ #region Ignored (User only)
case "CHANNEL_PINS_ACK":
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false);
break;
@@ -2530,11 +2546,13 @@ namespace Discord.WebSocket
case "WEBHOOKS_UPDATE":
await _gatewayLogger.DebugAsync("Ignored Dispatch (WEBHOOKS_UPDATE)").ConfigureAwait(false);
break;
+ #endregion
- //Others
+ #region Others
default:
await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false);
break;
+ #endregion
}
break;
default:
@@ -2548,6 +2566,7 @@ namespace Discord.WebSocket
Console.WriteLine(ex);
}
}
+ #endregion
private async Task RunHeartbeatAsync(int intervalMillis, CancellationToken cancelToken)
{
diff --git a/src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs b/src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs
index cbe575075..46f5c1a26 100644
--- a/src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs
+++ b/src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs
@@ -9,7 +9,7 @@ namespace Discord.WebSocket
{
public static IActivity ToEntity(this API.Game model)
{
- // Custom Status Game
+ #region Custom Status Game
if (model.Id.IsSpecified && model.Id.Value == "custom")
{
return new CustomStatusGame()
@@ -21,13 +21,14 @@ namespace Discord.WebSocket
CreatedAt = DateTimeOffset.FromUnixTimeMilliseconds(model.CreatedAt.Value),
};
}
+ #endregion
- // Spotify Game
+ #region Spotify Game
if (model.SyncId.IsSpecified)
{
var assets = model.Assets.GetValueOrDefault()?.ToEntity();
string albumText = assets?[1]?.Text;
- string albumArtId = assets?[1]?.ImageId?.Replace("spotify:","");
+ string albumArtId = assets?[1]?.ImageId?.Replace("spotify:", "");
var timestamps = model.Timestamps.IsSpecified ? model.Timestamps.Value.ToEntity() : null;
return new SpotifyGame
{
@@ -37,7 +38,7 @@ namespace Discord.WebSocket
TrackUrl = CDN.GetSpotifyDirectUrl(model.SyncId.Value),
AlbumTitle = albumText,
TrackTitle = model.Details.GetValueOrDefault(),
- Artists = model.State.GetValueOrDefault()?.Split(';').Select(x=>x?.Trim()).ToImmutableArray(),
+ Artists = model.State.GetValueOrDefault()?.Split(';').Select(x => x?.Trim()).ToImmutableArray(),
StartedAt = timestamps?.Start,
EndsAt = timestamps?.End,
Duration = timestamps?.End - timestamps?.Start,
@@ -46,8 +47,9 @@ namespace Discord.WebSocket
Flags = model.Flags.GetValueOrDefault(),
};
}
+ #endregion
- // Rich Game
+ #region Rich Game
if (model.ApplicationId.IsSpecified)
{
ulong appId = model.ApplicationId.Value;
@@ -66,7 +68,9 @@ namespace Discord.WebSocket
Flags = model.Flags.GetValueOrDefault()
};
}
- // Stream Game
+ #endregion
+
+ #region Stream Game
if (model.StreamUrl.IsSpecified)
{
return new StreamingGame(
@@ -77,10 +81,13 @@ namespace Discord.WebSocket
Details = model.Details.GetValueOrDefault()
};
}
- // Normal Game
+ #endregion
+
+ #region Normal Game
return new Game(model.Name, model.Type.GetValueOrDefault() ?? ActivityType.Playing,
model.Flags.IsSpecified ? model.Flags.Value : ActivityProperties.None,
model.Details.GetValueOrDefault());
+ #endregion
}
// (Small, Large)