@@ -213,12 +213,12 @@ namespace Discord.Commands | |||||
{ | { | ||||
if (parseResult.Error == CommandError.MultipleMatches) | if (parseResult.Error == CommandError.MultipleMatches) | ||||
{ | { | ||||
TypeReaderValue[] argList, paramList; | |||||
IReadOnlyList<TypeReaderValue> argList, paramList; | |||||
switch (multiMatchHandling) | switch (multiMatchHandling) | ||||
{ | { | ||||
case MultiMatchHandling.Best: | case MultiMatchHandling.Best: | ||||
argList = parseResult.ArgValues.Select(x => x.Values.OrderByDescending(y => y.Score).First()).ToArray(); | |||||
paramList = parseResult.ParamValues.Select(x => x.Values.OrderByDescending(y => y.Score).First()).ToArray(); | |||||
argList = parseResult.ArgValues.Select(x => x.Values.OrderByDescending(y => y.Score).First()).ToImmutableArray(); | |||||
paramList = parseResult.ParamValues.Select(x => x.Values.OrderByDescending(y => y.Score).First()).ToImmutableArray(); | |||||
parseResult = ParseResult.FromSuccess(argList, paramList); | parseResult = ParseResult.FromSuccess(argList, paramList); | ||||
break; | break; | ||||
} | } | ||||
@@ -1,5 +1,6 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.Immutable; | |||||
using System.Globalization; | using System.Globalization; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -74,7 +75,7 @@ namespace Discord.Commands | |||||
} | } | ||||
if (results.Count > 0) | if (results.Count > 0) | ||||
return TypeReaderResult.FromSuccess(results.Values.ToArray()); | |||||
return TypeReaderResult.FromSuccess(results.Values.ToImmutableArray()); | |||||
return TypeReaderResult.FromError(CommandError.ObjectNotFound, "User not found."); | return TypeReaderResult.FromError(CommandError.ObjectNotFound, "User not found."); | ||||
} | } | ||||
@@ -832,7 +832,7 @@ namespace Discord.API | |||||
Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
var roles = args.ToArray(); | |||||
var roles = args.ToImmutableArray(); | |||||
switch (roles.Length) | switch (roles.Length) | ||||
{ | { | ||||
case 0: | case 0: | ||||
@@ -15,11 +15,11 @@ namespace Discord.Rest | |||||
public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites; | public IReadOnlyCollection<Overwrite> PermissionOverwrites => _overwrites; | ||||
internal IGuild Guild { get; } | internal IGuild Guild { get; } | ||||
public ulong GuildId => Guild.Id; | |||||
public string Name { get; private set; } | public string Name { get; private set; } | ||||
public int Position { get; private set; } | public int Position { get; private set; } | ||||
public ulong GuildId => Guild.Id; | |||||
internal RestGuildChannel(BaseDiscordClient discord, IGuild guild, ulong id) | internal RestGuildChannel(BaseDiscordClient discord, IGuild guild, ulong id) | ||||
: base(discord, id) | : base(discord, id) | ||||
{ | { | ||||
@@ -17,7 +17,6 @@ namespace Discord.Rest | |||||
public bool IsSyncing { get; private set; } | public bool IsSyncing { get; private set; } | ||||
public ulong ExpireBehavior { get; private set; } | public ulong ExpireBehavior { get; private set; } | ||||
public ulong ExpireGracePeriod { get; private set; } | public ulong ExpireGracePeriod { get; private set; } | ||||
public ulong GuildId { get; private set; } | public ulong GuildId { get; private set; } | ||||
public ulong RoleId { get; private set; } | public ulong RoleId { get; private set; } | ||||
public RestUser User { get; private set; } | public RestUser User { get; private set; } | ||||
@@ -9,7 +9,6 @@ namespace Discord.Rest | |||||
{ | { | ||||
public string ChannelName { get; private set; } | public string ChannelName { get; private set; } | ||||
public string GuildName { get; private set; } | public string GuildName { get; private set; } | ||||
public ulong ChannelId { get; private set; } | public ulong ChannelId { get; private set; } | ||||
public ulong GuildId { get; private set; } | public ulong GuildId { get; private set; } | ||||
@@ -19,7 +19,6 @@ namespace Discord.Rest | |||||
public virtual bool IsPinned => false; | public virtual bool IsPinned => false; | ||||
public virtual bool IsWebhook => false; | public virtual bool IsWebhook => false; | ||||
public virtual DateTimeOffset? EditedTimestamp => null; | public virtual DateTimeOffset? EditedTimestamp => null; | ||||
public virtual IReadOnlyCollection<IAttachment> Attachments => ImmutableArray.Create<IAttachment>(); | public virtual IReadOnlyCollection<IAttachment> Attachments => ImmutableArray.Create<IAttachment>(); | ||||
public virtual IReadOnlyCollection<IEmbed> Embeds => ImmutableArray.Create<IEmbed>(); | public virtual IReadOnlyCollection<IEmbed> Embeds => ImmutableArray.Create<IEmbed>(); | ||||
public virtual IReadOnlyCollection<ulong> MentionedChannelIds => ImmutableArray.Create<ulong>(); | public virtual IReadOnlyCollection<ulong> MentionedChannelIds => ImmutableArray.Create<ulong>(); | ||||
@@ -25,7 +25,6 @@ namespace Discord.Rest | |||||
public override bool IsPinned => _isPinned; | public override bool IsPinned => _isPinned; | ||||
public override bool IsWebhook => WebhookId != null; | public override bool IsWebhook => WebhookId != null; | ||||
public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | ||||
public override IReadOnlyCollection<IAttachment> Attachments => _attachments; | public override IReadOnlyCollection<IAttachment> Attachments => _attachments; | ||||
public override IReadOnlyCollection<IEmbed> Embeds => _embeds; | public override IReadOnlyCollection<IEmbed> Embeds => _embeds; | ||||
public override IReadOnlyCollection<ulong> MentionedChannelIds => _mentionedChannelIds; | public override IReadOnlyCollection<ulong> MentionedChannelIds => _mentionedChannelIds; | ||||
@@ -10,7 +10,6 @@ namespace Discord.Rest | |||||
public class RestRole : RestEntity<ulong>, IRole | public class RestRole : RestEntity<ulong>, IRole | ||||
{ | { | ||||
public RestGuild Guild { get; } | public RestGuild Guild { get; } | ||||
public Color Color { get; private set; } | public Color Color { get; private set; } | ||||
public bool IsHoisted { get; private set; } | public bool IsHoisted { get; private set; } | ||||
public bool IsManaged { get; private set; } | public bool IsManaged { get; private set; } | ||||
@@ -12,7 +12,6 @@ namespace Discord | |||||
public string Type { get; } | public string Type { get; } | ||||
public string Name { get; } | public string Name { get; } | ||||
public bool IsRevoked { get; } | public bool IsRevoked { get; } | ||||
public IReadOnlyCollection<ulong> IntegrationIds { get; } | public IReadOnlyCollection<ulong> IntegrationIds { get; } | ||||
internal RestConnection(string id, string type, string name, bool isRevoked, IReadOnlyCollection<ulong> integrationIds) | internal RestConnection(string id, string type, string name, bool isRevoked, IReadOnlyCollection<ulong> integrationIds) | ||||
@@ -14,8 +14,6 @@ namespace Discord.API.Gateway | |||||
public int Limit { get; set; } | public int Limit { get; set; } | ||||
[JsonProperty("guild_id")] | [JsonProperty("guild_id")] | ||||
private ulong[] _guildIds { get; set; } | |||||
public IEnumerable<ulong> GuildIds { set { _guildIds = value.ToArray(); } } | |||||
public IEnumerable<IGuild> Guilds { set { _guildIds = value.Select(x => x.Id).ToArray(); } } | |||||
private ulong[] GuildIds { get; set; } | |||||
} | } | ||||
} | } |
@@ -404,11 +404,11 @@ namespace Discord.WebSocket | |||||
=> DownloadUsersAsync(guilds.Select(x => x as SocketGuild).Where(x => x != null)); | => DownloadUsersAsync(guilds.Select(x => x as SocketGuild).Where(x => x != null)); | ||||
private async Task DownloadUsersAsync(IEnumerable<SocketGuild> guilds) | private async Task DownloadUsersAsync(IEnumerable<SocketGuild> guilds) | ||||
{ | { | ||||
var cachedGuilds = guilds.ToArray(); | |||||
var cachedGuilds = guilds.ToImmutableArray(); | |||||
if (cachedGuilds.Length == 0) return; | if (cachedGuilds.Length == 0) return; | ||||
//Wait for unsynced guilds to sync first. | //Wait for unsynced guilds to sync first. | ||||
var unsyncedGuilds = guilds.Select(x => x.SyncPromise).Where(x => !x.IsCompleted).ToArray(); | |||||
var unsyncedGuilds = guilds.Select(x => x.SyncPromise).Where(x => !x.IsCompleted).ToImmutableArray(); | |||||
if (unsyncedGuilds.Length > 0) | if (unsyncedGuilds.Length > 0) | ||||
await Task.WhenAll(unsyncedGuilds); | await Task.WhenAll(unsyncedGuilds); | ||||
@@ -1565,7 +1565,7 @@ namespace Discord.WebSocket | |||||
} | } | ||||
private async Task SyncGuildsAsync() | private async Task SyncGuildsAsync() | ||||
{ | { | ||||
var guildIds = Guilds.Where(x => !x.IsSynced).Select(x => x.Id).ToArray(); | |||||
var guildIds = Guilds.Where(x => !x.IsSynced).Select(x => x.Id).ToImmutableArray(); | |||||
if (guildIds.Length > 0) | if (guildIds.Length > 0) | ||||
await ApiClient.SendGuildSyncAsync(guildIds).ConfigureAwait(false); | await ApiClient.SendGuildSyncAsync(guildIds).ConfigureAwait(false); | ||||
} | } | ||||