Format the project with 'dotnet format' (#2551)

* Sync and Re-Format

* Fix Title string.

* Fix indentation.
This commit is contained in:
NaN
2023-02-13 14:45:59 -03:00
committed by GitHub
parent 71e9ecb21e
commit 257f246d1d
401 changed files with 3178 additions and 2671 deletions

View File

@@ -37,7 +37,7 @@ namespace Discord.API
[JsonProperty("description_localized")]
public Optional<string> DescriptionLocalized { get; set; }
// V2 Permissions
[JsonProperty("dm_permission")]
public Optional<bool?> DmPermission { get; set; }

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Discord.API

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace Discord.API
{

View File

@@ -1,6 +1,6 @@
using System;
using Newtonsoft.Json;
using Discord.Net.Converters;
using Newtonsoft.Json;
using System;
namespace Discord.API
{

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace Discord.API
{

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace Discord.API
{
@@ -11,4 +11,4 @@ namespace Discord.API
[JsonProperty("spectate")]
public string Spectate { get; set; }
}
}
}

View File

@@ -1,5 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
namespace Discord.API
{
@@ -12,4 +12,4 @@ namespace Discord.API
[UnixTimestamp]
public Optional<DateTimeOffset> End { get; set; }
}
}
}

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace Discord.API
{

View File

@@ -14,5 +14,5 @@ internal class WelcomeScreenChannel
public Optional<ulong?> EmojiId { get; set; }
[JsonProperty("emoji_name")]
public Optional<string> EmojiName{ get; set; }
public Optional<string> EmojiName { get; set; }
}

View File

@@ -1,4 +1,4 @@
namespace Discord.API
namespace Discord.API
{
internal struct EntityOrId<T>
{

View File

@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
namespace Discord.API
{

View File

@@ -3,6 +3,6 @@ namespace Discord.API.Rest
internal class CreateGuildBanParams
{
public Optional<int> DeleteMessageDays { get; set; }
public string Reason { get; set; }
public string Reason { get; set; }
}
}

View File

@@ -28,7 +28,7 @@ namespace Discord.API.Rest
[JsonProperty("sticker_ids")]
public Optional<ulong[]> Stickers { get; set; }
[JsonProperty("flags")]
public Optional<MessageFlags> Flags { get; set; }

View File

@@ -13,7 +13,7 @@ namespace Discord.API.Rest
private static JsonSerializer _serializer = new JsonSerializer { ContractResolver = new DiscordContractResolver() };
[JsonProperty("content")]
public Optional<string> Content { get; set; }
public Optional<string> Content { get; set; }
[JsonProperty("nonce")]
public Optional<string> Nonce { get; set; }

View File

@@ -4,7 +4,7 @@ namespace Discord.API.Rest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
internal class ModifyGuildEmbedParams
{
{
[JsonProperty("enabled")]
public Optional<bool> Enabled { get; set; }
[JsonProperty("channel")]

View File

@@ -4,7 +4,7 @@ namespace Discord.API.Rest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
internal class ModifyGuildWidgetParams
{
{
[JsonProperty("enabled")]
public Optional<bool> Enabled { get; set; }
[JsonProperty("channel")]

View File

@@ -32,7 +32,7 @@ namespace Discord.API.Rest
public IReadOnlyDictionary<string, object> ToDictionary()
{
var d = new Dictionary<string, object>();
var payload = new Dictionary<string, object>();
if (Content.IsSpecified)
payload["content"] = Content.Value;
@@ -55,7 +55,7 @@ namespace Discord.API.Rest
List<object> attachments = new();
for(int n = 0; n != Files.Length; n++)
for (int n = 0; n != Files.Length; n++)
{
var attachment = Files[n];

View File

@@ -41,7 +41,7 @@ namespace Discord.API.Rest
public IReadOnlyDictionary<string, object> ToDictionary()
{
var d = new Dictionary<string, object>();
var payload = new Dictionary<string, object>();
payload["type"] = Type;

View File

@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using Discord.Net.Converters;
using Discord.Net.Rest;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Discord.API.Rest
{

View File

@@ -1,7 +1,7 @@
using System;
using System;
namespace Discord.API
{
[AttributeUsage(AttributeTargets.Property)]
internal class UnixTimestampAttribute : Attribute { }
}
}

View File

@@ -126,7 +126,8 @@ namespace Discord.Rest
}
internal virtual async Task LogoutInternalAsync()
{
if (LoginState == LoginState.LoggedOut) return;
if (LoginState == LoginState.LoggedOut)
return;
LoginState = LoginState.LoggingOut;
await ApiClient.LogoutAsync().ConfigureAwait(false);

View File

@@ -1,5 +1,5 @@
using System;
using Discord.API.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;

View File

@@ -563,7 +563,7 @@ namespace Discord.API
await SendAsync("DELETE", () => $"channels/{channelId}/thread-members/{userId}", bucket, options: options).ConfigureAwait(false);
}
public async Task<ThreadMember[]> ListThreadMembersAsync(ulong channelId, ulong? after = null, int? limit = null, RequestOptions options = null)
{
Preconditions.NotEqual(channelId, 0, nameof(channelId));
@@ -1154,7 +1154,7 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options);
var ids = new BucketIds(channelId: newsChannelId);
return await SendJsonAsync<FollowedChannel>("POST", () => $"channels/{newsChannelId}/followers", new { webhook_channel_id = followingChannelId}, ids, options: options).ConfigureAwait(false);
return await SendJsonAsync<FollowedChannel>("POST", () => $"channels/{newsChannelId}/followers", new { webhook_channel_id = followingChannelId }, ids, options: options).ConfigureAwait(false);
}
#endregion

View File

@@ -68,7 +68,7 @@ namespace Discord.Rest
ApiClient.CurrentUserId = user.Id;
base.CurrentUser = RestSelfUser.Create(this, user);
if(tokenType == TokenType.Bot)
if (tokenType == TokenType.Bot)
{
await GetApplicationInfoAsync(new RequestOptions { RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false);
ApiClient.CurrentApplicationId = _applicationInfo.Id;
@@ -151,7 +151,7 @@ namespace Discord.Rest
}
#endregion
public async Task<RestSelfUser> GetCurrentUserAsync(RequestOptions options = null)
{
var user = await ApiClient.GetMyUserAsync(options);

View File

@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{
@@ -10,56 +9,56 @@ namespace Discord.Rest
{
private static readonly Dictionary<ActionType, Func<BaseDiscordClient, Model, EntryModel, IAuditLogData>> CreateMapping
= new Dictionary<ActionType, Func<BaseDiscordClient, Model, EntryModel, IAuditLogData>>()
{
[ActionType.GuildUpdated] = GuildUpdateAuditLogData.Create,
{
[ActionType.GuildUpdated] = GuildUpdateAuditLogData.Create,
[ActionType.ChannelCreated] = ChannelCreateAuditLogData.Create,
[ActionType.ChannelUpdated] = ChannelUpdateAuditLogData.Create,
[ActionType.ChannelDeleted] = ChannelDeleteAuditLogData.Create,
[ActionType.ChannelCreated] = ChannelCreateAuditLogData.Create,
[ActionType.ChannelUpdated] = ChannelUpdateAuditLogData.Create,
[ActionType.ChannelDeleted] = ChannelDeleteAuditLogData.Create,
[ActionType.OverwriteCreated] = OverwriteCreateAuditLogData.Create,
[ActionType.OverwriteUpdated] = OverwriteUpdateAuditLogData.Create,
[ActionType.OverwriteDeleted] = OverwriteDeleteAuditLogData.Create,
[ActionType.OverwriteCreated] = OverwriteCreateAuditLogData.Create,
[ActionType.OverwriteUpdated] = OverwriteUpdateAuditLogData.Create,
[ActionType.OverwriteDeleted] = OverwriteDeleteAuditLogData.Create,
[ActionType.Kick] = KickAuditLogData.Create,
[ActionType.Prune] = PruneAuditLogData.Create,
[ActionType.Ban] = BanAuditLogData.Create,
[ActionType.Unban] = UnbanAuditLogData.Create,
[ActionType.MemberUpdated] = MemberUpdateAuditLogData.Create,
[ActionType.MemberRoleUpdated] = MemberRoleAuditLogData.Create,
[ActionType.MemberMoved] = MemberMoveAuditLogData.Create,
[ActionType.MemberDisconnected] = MemberDisconnectAuditLogData.Create,
[ActionType.BotAdded] = BotAddAuditLogData.Create,
[ActionType.Kick] = KickAuditLogData.Create,
[ActionType.Prune] = PruneAuditLogData.Create,
[ActionType.Ban] = BanAuditLogData.Create,
[ActionType.Unban] = UnbanAuditLogData.Create,
[ActionType.MemberUpdated] = MemberUpdateAuditLogData.Create,
[ActionType.MemberRoleUpdated] = MemberRoleAuditLogData.Create,
[ActionType.MemberMoved] = MemberMoveAuditLogData.Create,
[ActionType.MemberDisconnected] = MemberDisconnectAuditLogData.Create,
[ActionType.BotAdded] = BotAddAuditLogData.Create,
[ActionType.RoleCreated] = RoleCreateAuditLogData.Create,
[ActionType.RoleUpdated] = RoleUpdateAuditLogData.Create,
[ActionType.RoleDeleted] = RoleDeleteAuditLogData.Create,
[ActionType.RoleCreated] = RoleCreateAuditLogData.Create,
[ActionType.RoleUpdated] = RoleUpdateAuditLogData.Create,
[ActionType.RoleDeleted] = RoleDeleteAuditLogData.Create,
[ActionType.InviteCreated] = InviteCreateAuditLogData.Create,
[ActionType.InviteUpdated] = InviteUpdateAuditLogData.Create,
[ActionType.InviteDeleted] = InviteDeleteAuditLogData.Create,
[ActionType.InviteCreated] = InviteCreateAuditLogData.Create,
[ActionType.InviteUpdated] = InviteUpdateAuditLogData.Create,
[ActionType.InviteDeleted] = InviteDeleteAuditLogData.Create,
[ActionType.WebhookCreated] = WebhookCreateAuditLogData.Create,
[ActionType.WebhookUpdated] = WebhookUpdateAuditLogData.Create,
[ActionType.WebhookDeleted] = WebhookDeleteAuditLogData.Create,
[ActionType.WebhookCreated] = WebhookCreateAuditLogData.Create,
[ActionType.WebhookUpdated] = WebhookUpdateAuditLogData.Create,
[ActionType.WebhookDeleted] = WebhookDeleteAuditLogData.Create,
[ActionType.EmojiCreated] = EmoteCreateAuditLogData.Create,
[ActionType.EmojiUpdated] = EmoteUpdateAuditLogData.Create,
[ActionType.EmojiDeleted] = EmoteDeleteAuditLogData.Create,
[ActionType.EmojiCreated] = EmoteCreateAuditLogData.Create,
[ActionType.EmojiUpdated] = EmoteUpdateAuditLogData.Create,
[ActionType.EmojiDeleted] = EmoteDeleteAuditLogData.Create,
[ActionType.MessageDeleted] = MessageDeleteAuditLogData.Create,
[ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create,
[ActionType.MessagePinned] = MessagePinAuditLogData.Create,
[ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create,
[ActionType.MessageDeleted] = MessageDeleteAuditLogData.Create,
[ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create,
[ActionType.MessagePinned] = MessagePinAuditLogData.Create,
[ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create,
[ActionType.EventCreate] = ScheduledEventCreateAuditLogData.Create,
[ActionType.EventUpdate] = ScheduledEventUpdateAuditLogData.Create,
[ActionType.EventDelete] = ScheduledEventDeleteAuditLogData.Create,
[ActionType.EventCreate] = ScheduledEventCreateAuditLogData.Create,
[ActionType.EventUpdate] = ScheduledEventUpdateAuditLogData.Create,
[ActionType.EventDelete] = ScheduledEventDeleteAuditLogData.Create,
[ActionType.ThreadCreate] = ThreadCreateAuditLogData.Create,
[ActionType.ThreadUpdate] = ThreadUpdateAuditLogData.Create,
[ActionType.ThreadDelete] = ThreadDeleteAuditLogData.Create,
};
[ActionType.ThreadCreate] = ThreadCreateAuditLogData.Create,
[ActionType.ThreadUpdate] = ThreadUpdateAuditLogData.Create,
[ActionType.ThreadDelete] = ThreadDeleteAuditLogData.Create,
};
public static IAuditLogData CreateData(BaseDiscordClient discord, Model log, EntryModel entry)
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,5 +1,5 @@
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,5 +1,5 @@
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,5 +1,5 @@
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,8 +1,7 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using System;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,5 +1,5 @@
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,9 +1,8 @@
using Discord.API;
using System;
using System.Linq;
using Discord.API;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{
@@ -14,22 +13,22 @@ namespace Discord.Rest
{
private ScheduledEventCreateAuditLogData(ulong id, ulong guildId, ulong? channelId, ulong? creatorId, string name, string description, DateTimeOffset scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel privacyLevel, GuildScheduledEventStatus status, GuildScheduledEventType entityType, ulong? entityId, string location, RestUser creator, int userCount, string image)
{
Id = id ;
GuildId = guildId ;
ChannelId = channelId ;
CreatorId = creatorId ;
Name = name ;
Description = description ;
Id = id;
GuildId = guildId;
ChannelId = channelId;
CreatorId = creatorId;
Name = name;
Description = description;
ScheduledStartTime = scheduledStartTime;
ScheduledEndTime = scheduledEndTime ;
PrivacyLevel = privacyLevel ;
Status = status ;
EntityType = entityType ;
EntityId = entityId ;
Location = location ;
Creator = creator ;
UserCount = userCount ;
Image = image ;
ScheduledEndTime = scheduledEndTime;
PrivacyLevel = privacyLevel;
Status = status;
EntityType = entityType;
EntityId = entityId;
Location = location;
Creator = creator;
UserCount = userCount;
Image = image;
}
internal static ScheduledEventCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)

View File

@@ -1,9 +1,8 @@
using Discord.API;
using System;
using System.Linq;
using Discord.API;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -62,19 +62,19 @@ namespace Discord.Rest
internal ScheduledEventInfo(ulong? guildId, ulong? channelId, string name, string description, DateTimeOffset? scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel? privacyLevel, GuildScheduledEventStatus? status, GuildScheduledEventType? entityType, ulong? entityId, Optional<string> location, int? userCount, string image)
{
GuildId = guildId ;
ChannelId = channelId ;
Name = name ;
Description = description ;
GuildId = guildId;
ChannelId = channelId;
Name = name;
Description = description;
ScheduledStartTime = scheduledStartTime;
ScheduledEndTime = scheduledEndTime ;
PrivacyLevel = privacyLevel ;
Status = status ;
EntityType = entityType ;
EntityId = entityId ;
Location = location ;
UserCount = userCount ;
Image = image ;
ScheduledEndTime = scheduledEndTime;
PrivacyLevel = privacyLevel;
Status = status;
EntityType = entityType;
EntityId = entityId;
Location = location;
UserCount = userCount;
Image = image;
}
}
}

View File

@@ -1,8 +1,7 @@
using System;
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{
@@ -13,9 +12,9 @@ namespace Discord.Rest
{
private ScheduledEventUpdateAuditLogData(ulong id, ScheduledEventInfo before, ScheduledEventInfo after)
{
Id = id;
Id = id;
Before = before;
After = after;
After = after;
}
internal static ScheduledEventUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)

View File

@@ -1,6 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,6 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,6 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{
@@ -51,7 +50,7 @@ namespace Discord.Rest
var threadInfo = log.Threads.FirstOrDefault(x => x.Id == id);
var threadChannel = threadInfo == null ? null : RestThreadChannel.Create(discord, (IGuild)null, threadInfo);
return new ThreadUpdateAuditLogData(threadChannel,type, before, after);
return new ThreadUpdateAuditLogData(threadChannel, type, before, after);
}
// Doc Note: Corresponds to the *current* data

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -1,8 +1,7 @@
using System;
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
namespace Discord.Rest
{

View File

@@ -269,7 +269,7 @@ namespace Discord.Rest
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public static async Task<RestUserMessage> SendMessageAsync(IMessageChannel channel, BaseDiscordClient client,
string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference,
string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference,
MessageComponent components, ISticker[] stickers, RequestOptions options, Embed[] embeds, MessageFlags flags)
{
embeds ??= Array.Empty<Embed>();
@@ -345,41 +345,41 @@ namespace Discord.Rest
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
bool isSpoiler, Embed[] embeds, MessageFlags flags = MessageFlags.None)
{
string filename = Path.GetFileName(filePath);
using (var file = File.OpenRead(filePath))
return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions,
return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, isSpoiler, embeds, flags).ConfigureAwait(false);
}
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
bool isSpoiler, Embed[] embeds, MessageFlags flags = MessageFlags.None)
{
using (var file = new FileAttachment(stream, filename, isSpoiler: isSpoiler))
return await SendFileAsync(channel, client, file, text, isTTS, embed, allowedMentions, messageReference,
return await SendFileAsync(channel, client, file, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags).ConfigureAwait(false);
}
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public static Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
FileAttachment attachment, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
FileAttachment attachment, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
Embed[] embeds, MessageFlags flags = MessageFlags.None)
=> SendFilesAsync(channel, client, new[] { attachment }, text, isTTS, embed, allowedMentions, messageReference,
=> SendFilesAsync(channel, client, new[] { attachment }, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public static async Task<RestUserMessage> SendFilesAsync(IMessageChannel channel, BaseDiscordClient client,
IEnumerable<FileAttachment> attachments, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
IEnumerable<FileAttachment> attachments, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions,
MessageReference messageReference, MessageComponent components, ISticker[] stickers, RequestOptions options,
Embed[] embeds, MessageFlags flags)
{
embeds ??= Array.Empty<Embed>();
@@ -389,8 +389,8 @@ namespace Discord.Rest
Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed.");
Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed.");
Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed.");
foreach(var attachment in attachments)
foreach (var attachment in attachments)
{
Preconditions.NotNullOrEmpty(attachment.FileName, nameof(attachment.FileName), "File Name must not be empty or null");
}
@@ -429,18 +429,18 @@ namespace Discord.Rest
Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed.");
}
var args = new UploadFileParams(attachments.ToArray())
{
Content = text,
var args = new UploadFileParams(attachments.ToArray())
{
Content = text,
IsTTS = isTTS,
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
MessageReference = messageReference?.ToModel() ?? Optional<API.MessageReference>.Unspecified,
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
MessageReference = messageReference?.ToModel() ?? Optional<API.MessageReference>.Unspecified,
MessageComponent = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional<ulong[]>.Unspecified,
Flags = flags
};
var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false);
return RestUserMessage.Create(client, channel, client.CurrentUser, model);
}

View File

@@ -16,7 +16,7 @@ internal static class ForumHelper
func(args);
Preconditions.AtMost(args.Tags.IsSpecified ? args.Tags.Value.Count() : 0, 5, nameof(args.Tags), "Forum channel can have max 20 tags.");
var apiArgs = new API.Rest.ModifyForumChannelParams()
{
Name = args.Name,

View File

@@ -1,4 +1,4 @@
namespace Discord.Rest
namespace Discord.Rest
{
public interface IRestAudioChannel : IAudioChannel
{

View File

@@ -11,13 +11,13 @@ namespace Discord.Rest
{
/// <inheritdoc cref="IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
/// <inheritdoc cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
/// <inheritdoc cref="IMessageChannel.SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
/// <inheritdoc cref="IMessageChannel.SendFileAsync(FileAttachment, string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);

View File

@@ -95,10 +95,10 @@ namespace Discord.Rest
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
@@ -128,36 +128,36 @@ namespace Discord.Rest
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
@@ -271,7 +271,7 @@ namespace Discord.Rest
AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components,
ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false);
#endregion
#region IChannel

View File

@@ -70,7 +70,7 @@ namespace Discord.Rest
if (model.ThreadRateLimitPerUser.IsSpecified)
DefaultSlowModeInterval = model.ThreadRateLimitPerUser.Value;
if(model.SlowMode.IsSpecified)
if (model.SlowMode.IsSpecified)
ThreadCreationInterval = model.SlowMode.Value;
DefaultSortOrder = model.DefaultSortOrder.GetValueOrDefault();
@@ -90,7 +90,7 @@ namespace Discord.Rest
}
CategoryId = model.CategoryId.GetValueOrDefault();
DefaultLayout= model.DefaultForumLayout.GetValueOrDefault();
DefaultLayout = model.DefaultForumLayout.GetValueOrDefault();
}
/// <inheritdoc/>
@@ -101,7 +101,7 @@ namespace Discord.Rest
}
/// <inheritdoc cref="IForumChannel.CreatePostAsync(string, ThreadArchiveDuration, int?, string, Embed, RequestOptions, AllowedMentions, MessageComponent, ISticker[], Embed[], MessageFlags, ForumTag[])"/>
public Task<RestThreadChannel> CreatePostAsync(string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null,
public Task<RestThreadChannel> CreatePostAsync(string title, ThreadArchiveDuration archiveDuration = ThreadArchiveDuration.OneDay, int? slowmode = null,
string text = null, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None, ForumTag[] tags = null)
=> ThreadHelper.CreatePostAsync(this, Discord, title, archiveDuration, slowmode, text, embed, options, allowedMentions, components, stickers, embeds, flags, tags?.Select(tag => tag.Id).ToArray());

View File

@@ -105,10 +105,10 @@ namespace Discord.Rest
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
@@ -137,26 +137,26 @@ namespace Discord.Rest
/// <exception cref="IOException">An I/O error occurred while opening the file.</exception>
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions,
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
public Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference,
@@ -164,11 +164,11 @@ namespace Discord.Rest
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
public Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions,
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, embeds, flags);
/// <inheritdoc />
public Task TriggerTypingAsync(RequestOptions options = null)
@@ -246,16 +246,16 @@ namespace Discord.Rest
async Task<IUserMessage> IMessageChannel.SendFilesAsync(IEnumerable<FileAttachment> attachments, string text,
bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference,
MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components,
=> await SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components,
stickers, embeds, flags).ConfigureAwait(false);
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options,
AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components,
ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components,
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components,
stickers, embeds, flags).ConfigureAwait(false);
#endregion
#region IAudioChannel

View File

@@ -29,6 +29,6 @@ namespace Discord.Rest
/// <inheritdoc />
public Task<ulong> FollowAnnouncementChannelAsync(ulong channelId, RequestOptions options = null)
=> ChannelHelper.FollowAnnouncementChannelAsync(this, channelId, Discord, options);
=> ChannelHelper.FollowAnnouncementChannelAsync(this, channelId, Discord, options);
}
}

View File

@@ -39,7 +39,7 @@ namespace Discord.Rest
internal void Update(StageInstance model, bool isLive = false)
{
IsLive = isLive;
if(isLive)
if (isLive)
{
PrivacyLevel = model.PrivacyLevel;
IsDiscoverableDisabled = model.DiscoverableDisabled;

View File

@@ -111,10 +111,10 @@ namespace Discord.Rest
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public virtual Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
public virtual Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
@@ -143,39 +143,39 @@ namespace Discord.Rest
/// <exception cref="IOException">An I/O error occurred while opening the file.</exception>
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public virtual Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public virtual Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public virtual Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public virtual Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public virtual Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public virtual Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public virtual Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public virtual Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions, messageReference, components, stickers, options, embeds, flags);
@@ -371,34 +371,34 @@ namespace Discord.Rest
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed,
RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference,
RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference,
MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference,
=> await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference,
components, stickers, embeds, flags).ConfigureAwait(false);
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS,
Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference,
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS,
Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference,
MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference,
components, stickers, embeds, flags).ConfigureAwait(false);
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendFileAsync(FileAttachment attachment, string text, bool isTTS,
Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference,
async Task<IUserMessage> IMessageChannel.SendFileAsync(FileAttachment attachment, string text, bool isTTS,
Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference,
MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components,
stickers, embeds, flags).ConfigureAwait(false);
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendFilesAsync(IEnumerable<FileAttachment> attachments, string text,
async Task<IUserMessage> IMessageChannel.SendFilesAsync(IEnumerable<FileAttachment> attachments, string text,
bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference,
MessageComponent components, ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendFilesAsync(attachments, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false);
/// <inheritdoc />
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options,
AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components,
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options,
AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components,
ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false);
#endregion

View File

@@ -44,10 +44,10 @@ namespace Discord.Rest
{
base.Update(model);
if(model.Bitrate.IsSpecified)
if (model.Bitrate.IsSpecified)
Bitrate = model.Bitrate.Value;
if(model.UserLimit.IsSpecified)
if (model.UserLimit.IsSpecified)
UserLimit = model.UserLimit.Value != 0 ? model.UserLimit.Value : (int?)null;
VideoQualityMode = model.VideoQualityMode.GetValueOrDefault(VideoQualityMode.Auto);

View File

@@ -215,7 +215,7 @@ namespace Discord.Rest
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds)
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds and none.", nameof(flags));
if (channel.Flags.HasFlag(ChannelFlags.RequireTag))
throw new ArgumentException($"The channel {channel.Name} requires posts to have at least one tag.");

View File

@@ -3,13 +3,13 @@ using Discord.API.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using WidgetModel = Discord.API.GuildWidget;
using ImageModel = Discord.API.Image;
using Model = Discord.API.Guild;
using RoleModel = Discord.API.Role;
using ImageModel = Discord.API.Image;
using System.IO;
using WidgetModel = Discord.API.GuildWidget;
namespace Discord.Rest
{
@@ -1040,7 +1040,7 @@ namespace Discord.Rest
{
Enabled = enabled,
Description = description,
WelcomeChannels = channels?.Select(ch => new API.WelcomeScreenChannel
WelcomeChannels = channels?.Select(ch => new API.WelcomeScreenChannel
{
ChannelId = ch.Id,
Description = ch.Description,
@@ -1051,7 +1051,7 @@ namespace Discord.Rest
var model = await client.ApiClient.ModifyGuildWelcomeScreenAsync(args, guild.Id, options);
if(model.WelcomeChannels.Length == 0)
if (model.WelcomeChannels.Length == 0)
return null;
return new WelcomeScreen(model.Description.GetValueOrDefault(null), model.WelcomeChannels.Select(

View File

@@ -38,7 +38,7 @@ namespace Discord.Rest
/// </returns>
public override string ToString() => User.ToString();
private string DebuggerDisplay => $"{User}: {Reason}";
#endregion
#endregion
#region IBan
/// <inheritdoc />

View File

@@ -4,11 +4,11 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using WidgetModel = Discord.API.GuildWidget;
using Model = Discord.API.Guild;
using System.IO;
using WidgetModel = Discord.API.GuildWidget;
namespace Discord.Rest
{
@@ -950,7 +950,7 @@ namespace Discord.Rest
/// A task that represents the asynchronous get operation. The task result contains a read-only collection
/// of application commands found within the guild.
/// </returns>
public async Task<IReadOnlyCollection<RestGuildCommand>> GetApplicationCommandsAsync (bool withLocalizations = false, string locale = null, RequestOptions options = null)
public async Task<IReadOnlyCollection<RestGuildCommand>> GetApplicationCommandsAsync(bool withLocalizations = false, string locale = null, RequestOptions options = null)
=> await ClientHelper.GetGuildApplicationCommandsAsync(Discord, Id, withLocalizations, locale, options).ConfigureAwait(false);
/// <summary>
/// Gets an application command within this guild with the specified id.
@@ -1119,7 +1119,7 @@ namespace Discord.Rest
List<CustomSticker> stickers = new List<CustomSticker>();
foreach(var model in models)
foreach (var model in models)
{
var entity = CustomSticker.Create(Discord, model, this, model.User.IsSpecified ? model.User.Value.Id : null);
stickers.Add(entity);
@@ -1300,7 +1300,7 @@ namespace Discord.Rest
return null;
}
/// <inheritdoc />
async Task<IStageChannel> IGuild.GetStageChannelAsync(ulong id, CacheMode mode, RequestOptions options )
async Task<IStageChannel> IGuild.GetStageChannelAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetStageChannelAsync(id, options).ConfigureAwait(false);
@@ -1487,7 +1487,7 @@ namespace Discord.Rest
async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options)
=> await GetWebhooksAsync(options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (bool withLocalizations, string locale, RequestOptions options)
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync(bool withLocalizations, string locale, RequestOptions options)
=> await GetApplicationCommandsAsync(withLocalizations, locale, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options)

View File

@@ -43,7 +43,7 @@ namespace Discord.Rest
Permissions = new GuildPermissions(model.Permissions);
Features = model.Features;
}
public async Task LeaveAsync(RequestOptions options = null)
{
await Discord.ApiClient.LeaveGuildAsync(Id, options).ConfigureAwait(false);

View File

@@ -76,7 +76,7 @@ namespace Discord.Rest
_syncedAtTicks = model.SyncedAt.IsSpecified ? model.SyncedAt.Value.UtcTicks : null;
}
public async Task DeleteAsync()
{
await Discord.ApiClient.DeleteIntegrationAsync(GuildId, Id).ConfigureAwait(false);

View File

@@ -193,7 +193,7 @@ namespace Discord.Rest
Preconditions.NotNull(fileStream, nameof(fileStream), "File Stream must have data");
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
using(var file = new FileAttachment(fileStream, fileName))
using (var file = new FileAttachment(fileStream, fileName))
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
}

View File

@@ -77,7 +77,7 @@ namespace Discord.Rest
{
foreach (var role in resolved.Roles.Value)
{
var restRole = RestRole.Create(discord, guild, role.Value);
var restRole = RestRole.Create(discord, guild, role.Value);
Roles.Add(ulong.Parse(role.Key), restRole);
}
@@ -108,7 +108,7 @@ namespace Discord.Rest
Messages.Add(message.Id, message);
}
}
if (resolved.Attachments.IsSpecified)
{
foreach (var attachment in resolved.Attachments.Value)

View File

@@ -17,7 +17,7 @@ namespace Discord.Rest
internal RestMessageCommand(DiscordRestClient client, Model model)
: base(client, model)
{
}
internal new static async Task<RestMessageCommand> CreateAsync(DiscordRestClient client, Model model, bool doApiCall)
@@ -34,7 +34,7 @@ namespace Discord.Rest
var dataModel = model.Data.IsSpecified
? (DataModel)model.Data.Value
: null;
Data = await RestMessageCommandData.CreateAsync(client, dataModel, Guild, Channel, doApiCall).ConfigureAwait(false);
}

View File

@@ -51,7 +51,7 @@ namespace Discord.Rest
IDiscordInteraction interaction, RequestOptions options = null)
{
var model = await client.ApiClient.GetInteractionResponseAsync(interaction.Token, options).ConfigureAwait(false);
if(model != null)
if (model != null)
return RestInteractionMessage.Create(client, model, interaction.Token, channel);
return null;
}
@@ -150,7 +150,7 @@ namespace Discord.Rest
DefaultMemberPermission = arg.DefaultMemberPermissions.ToNullable(),
DmPermission = arg.IsDMEnabled.ToNullable(),
Nsfw = arg.IsNsfw.GetValueOrDefault(false)
};
};
if (arg is SlashCommandProperties slashProps)
{

View File

@@ -1,12 +1,12 @@
using Discord.Net.Rest;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model = Discord.API.Interaction;
using DataModel = Discord.API.MessageComponentInteractionData;
using System.IO;
using Discord.Net.Rest;
using Model = Discord.API.Interaction;
namespace Discord.Rest
{
@@ -286,7 +286,7 @@ namespace Discord.Rest
Preconditions.NotNull(fileStream, nameof(fileStream), "File Stream must have data");
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
using(var file = new FileAttachment(fileStream, fileName))
using (var file = new FileAttachment(fileStream, fileName))
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
}
@@ -308,7 +308,7 @@ namespace Discord.Rest
fileName ??= Path.GetFileName(filePath);
Preconditions.NotNullOrEmpty(fileName, nameof(fileName), "File Name must not be empty or null");
using(var file = new FileAttachment(File.OpenRead(filePath), fileName))
using (var file = new FileAttachment(File.OpenRead(filePath), fileName))
return await FollowupWithFileAsync(file, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
}

View File

@@ -32,7 +32,7 @@ namespace Discord.Rest
await entity.UpdateAsync(client, model, doApiCall);
return entity;
}
private object _lock = new object();
/// <summary>

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System;
using Model = Discord.API.ModalInteractionData;
using InterationModel = Discord.API.Interaction;
using DataModel = Discord.API.MessageComponentInteractionData;
using InterationModel = Discord.API.Interaction;
using Model = Discord.API.ModalInteractionData;
namespace Discord.Rest
{

View File

@@ -101,7 +101,7 @@ namespace Discord.Rest
NameLocalized = model.NameLocalized.GetValueOrDefault();
DescriptionLocalized = model.DescriptionLocalized.GetValueOrDefault();
IsEnabledInDm = model.DmPermission.GetValueOrDefault(true).GetValueOrDefault(true);
DefaultMemberPermissions = new GuildPermissions((ulong)model.DefaultMemberPermission.GetValueOrDefault(0).GetValueOrDefault(0));
IsNsfw = model.Nsfw.GetValueOrDefault(false).GetValueOrDefault(false);

View File

@@ -1,12 +1,12 @@
using Discord.Net;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Model = Discord.API.Interaction;
using DataModel = Discord.API.ApplicationCommandInteractionData;
using Newtonsoft.Json;
using Discord.Net;
using Model = Discord.API.Interaction;
namespace Discord.Rest
{
@@ -98,7 +98,7 @@ namespace Discord.Rest
internal static async Task<RestInteraction> CreateAsync(DiscordRestClient client, Model model, bool doApiCall)
{
if(model.Type == InteractionType.Ping)
if (model.Type == InteractionType.Ping)
{
return await RestPingInteraction.CreateAsync(client, model, doApiCall);
}
@@ -142,13 +142,13 @@ namespace Discord.Rest
GuildId = model.GuildId.IsSpecified
? model.GuildId.Value
: null;
IsDMInteraction = GuildId is null;
Data = model.Data.IsSpecified
? model.Data.Value
: null;
Token = model.Token;
Version = model.Version;
Type = model.Type;
@@ -176,7 +176,7 @@ namespace Discord.Rest
User = RestUser.Create(Discord, model.User.Value);
}
}
if (Channel is null && ChannelId is not null)
{
@@ -294,7 +294,7 @@ namespace Discord.Rest
}
/// <inheritdoc/>
public abstract string RespondWithModal(Modal modal, RequestOptions options = null);
/// <inheritdoc/>
public abstract string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null);

View File

@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model = Discord.API.Interaction;
using DataModel = Discord.API.AutocompleteInteractionData;
using System.IO;
using Model = Discord.API.Interaction;
namespace Discord.Rest
{

View File

@@ -20,7 +20,7 @@ namespace Discord.Rest
internal RestSlashCommand(DiscordRestClient client, Model model)
: base(client, model)
{
{
}
internal new static async Task<RestSlashCommand> CreateAsync(DiscordRestClient client, Model model, bool doApiCall)

View File

@@ -4,7 +4,7 @@ namespace Discord.Rest
{
internal static class InviteHelper
{
public static async Task DeleteAsync(IInvite invite, BaseDiscordClient client,
public static async Task DeleteAsync(IInvite invite, BaseDiscordClient client,
RequestOptions options)
{
await client.ApiClient.DeleteInviteAsync(invite.Code, options).ConfigureAwait(false);

View File

@@ -39,7 +39,7 @@ namespace Discord.Rest
public InviteGuild InviteGuild { get; private set; }
internal IChannel Channel { get; }
internal IGuild Guild { get; }
/// <inheritdoc />

View File

@@ -85,7 +85,7 @@ namespace Discord.Rest
Preconditions.AtMost(apiEmbeds?.Count ?? 0, 10, nameof(args.Embeds), "A max of 10 embeds are allowed.");
if(!args.Attachments.IsSpecified)
if (!args.Attachments.IsSpecified)
{
var apiArgs = new API.Rest.ModifyMessageParams
{
@@ -267,10 +267,13 @@ namespace Discord.Rest
while (true)
{
index = text.IndexOf('<', index);
if (index == -1) break;
if (index == -1)
break;
int endIndex = text.IndexOf('>', index + 1);
if (endIndex == -1) break;
if (CheckWrappedCode()) break;
if (endIndex == -1)
break;
if (CheckWrappedCode())
break;
string content = text.Substring(index, endIndex - index + 1);
if (MentionUtils.TryParseUser(content, out ulong id))
@@ -317,8 +320,10 @@ namespace Discord.Rest
while (true)
{
index = text.IndexOf("@everyone", index);
if (index == -1) break;
if (CheckWrappedCode()) break;
if (index == -1)
break;
if (CheckWrappedCode())
break;
var tagIndex = FindIndex(tags, index);
if (tagIndex.HasValue)
tags.Insert(tagIndex.Value, new Tag<IRole>(TagType.EveryoneMention, index, "@everyone".Length, 0, guild?.EveryoneRole));
@@ -330,8 +335,10 @@ namespace Discord.Rest
while (true)
{
index = text.IndexOf("@here", index);
if (index == -1) break;
if (CheckWrappedCode()) break;
if (index == -1)
break;
if (CheckWrappedCode())
break;
var tagIndex = FindIndex(tags, index);
if (tagIndex.HasValue)
tags.Insert(tagIndex.Value, new Tag<IRole>(TagType.HereMention, index, "@here".Length, 0, guild?.EveryoneRole));

View File

@@ -55,7 +55,7 @@ namespace Discord.Rest
return entity;
}
internal void Update(Model model)
{
{
Description = model.Description;
RPCOrigins = model.RPCOrigins.IsSpecified ? model.RPCOrigins.Value.ToImmutableArray() : ImmutableArray<string>.Empty;
Name = model.Name;

Some files were not shown because too many files have changed in this diff Show More