Format the project with 'dotnet format' (#2551)
* Sync and Re-Format * Fix Title string. * Fix indentation.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using Discord.Logging;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Logging;
|
||||
using Discord.Rest;
|
||||
|
||||
namespace Discord.Webhook
|
||||
{
|
||||
@@ -18,13 +18,13 @@ namespace Discord.Webhook
|
||||
private readonly ulong _webhookId;
|
||||
internal IWebhook Webhook;
|
||||
internal readonly Logger _restLogger;
|
||||
|
||||
|
||||
internal API.DiscordRestApiClient ApiClient { get; }
|
||||
internal LogManager LogManager { get; }
|
||||
|
||||
/// <summary> Creates a new Webhook Discord client. </summary>
|
||||
public DiscordWebhookClient(IWebhook webhook)
|
||||
: this(webhook.Id, webhook.Token, new DiscordRestConfig()) { }
|
||||
: this(webhook.Id, webhook.Token, new DiscordRestConfig()) { }
|
||||
/// <summary> Creates a new Webhook Discord client. </summary>
|
||||
public DiscordWebhookClient(ulong webhookId, string webhookToken)
|
||||
: this(webhookId, webhookToken, new DiscordRestConfig()) { }
|
||||
@@ -117,7 +117,7 @@ namespace Discord.Webhook
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous deletion operation.
|
||||
/// </returns>
|
||||
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null, ulong ? threadId = null)
|
||||
public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null, ulong? threadId = null)
|
||||
=> WebhookClientHelper.DeleteMessageAsync(this, messageId, options, threadId);
|
||||
|
||||
/// <summary> Sends a message to the channel for this webhook with an attachment. </summary>
|
||||
@@ -141,7 +141,7 @@ namespace Discord.Webhook
|
||||
/// <returns> Returns the ID of the created message. </returns>
|
||||
public Task<ulong> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
|
||||
IEnumerable<Embed> embeds = null, string username = null, string avatarUrl = null,
|
||||
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null,
|
||||
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null,
|
||||
MessageFlags flags = MessageFlags.None, ulong? threadId = null)
|
||||
=> WebhookClientHelper.SendFileAsync(this, attachment, text, isTTS, embeds, username,
|
||||
avatarUrl, allowedMentions, components, options, flags, threadId);
|
||||
@@ -150,7 +150,7 @@ namespace Discord.Webhook
|
||||
/// <returns> Returns the ID of the created message. </returns>
|
||||
public Task<ulong> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
|
||||
IEnumerable<Embed> embeds = null, string username = null, string avatarUrl = null,
|
||||
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null,
|
||||
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent components = null,
|
||||
MessageFlags flags = MessageFlags.None, ulong? threadId = null)
|
||||
=> WebhookClientHelper.SendFilesAsync(this, attachments, text, isTTS, embeds, username, avatarUrl,
|
||||
allowedMentions, components, options, flags, threadId);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Discord.Webhook
|
||||
public string Name { get; private set; }
|
||||
public string AvatarId { get; private set; }
|
||||
public ulong? GuildId { get; private set; }
|
||||
public ulong? ApplicationId { get; private set; }
|
||||
public ulong? ApplicationId { get; private set; }
|
||||
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using ImageModel = Discord.API.Image;
|
||||
using WebhookModel = Discord.API.Webhook;
|
||||
|
||||
@@ -115,18 +115,18 @@ namespace Discord.Webhook
|
||||
MessageComponent components, MessageFlags flags, ulong? threadId)
|
||||
=> SendFileAsync(client, new FileAttachment(stream, filename, isSpoiler: isSpoiler), text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags, threadId);
|
||||
|
||||
public static Task<ulong> SendFileAsync(DiscordWebhookClient client, FileAttachment attachment, string text, bool isTTS,
|
||||
IEnumerable<Embed> embeds, string username, string avatarUrl, AllowedMentions allowedMentions,
|
||||
public static Task<ulong> SendFileAsync(DiscordWebhookClient client, FileAttachment attachment, string text, bool isTTS,
|
||||
IEnumerable<Embed> embeds, string username, string avatarUrl, AllowedMentions allowedMentions,
|
||||
MessageComponent components, RequestOptions options, MessageFlags flags, ulong? threadId)
|
||||
=> SendFilesAsync(client, new FileAttachment[] { attachment }, text, isTTS, embeds, username, avatarUrl, allowedMentions, components, options, flags, threadId);
|
||||
|
||||
public static async Task<ulong> SendFilesAsync(DiscordWebhookClient client,
|
||||
IEnumerable<FileAttachment> attachments, string text, bool isTTS, IEnumerable<Embed> embeds, string username,
|
||||
IEnumerable<FileAttachment> attachments, string text, bool isTTS, IEnumerable<Embed> embeds, string username,
|
||||
string avatarUrl, AllowedMentions allowedMentions, MessageComponent components, RequestOptions options,
|
||||
MessageFlags flags, ulong? threadId)
|
||||
{
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
|
||||
|
||||
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.Count(), 10, nameof(embeds), "A max of 10 embeds are allowed.");
|
||||
@@ -155,13 +155,14 @@ namespace Discord.Webhook
|
||||
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds)
|
||||
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds and none.", nameof(flags));
|
||||
|
||||
var args = new UploadWebhookFileParams(attachments.ToArray())
|
||||
var args = new UploadWebhookFileParams(attachments.ToArray())
|
||||
{
|
||||
AvatarUrl = avatarUrl,
|
||||
Username = username, Content = text,
|
||||
IsTTS = isTTS,
|
||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||
AvatarUrl = avatarUrl,
|
||||
Username = username,
|
||||
Content = text,
|
||||
IsTTS = isTTS,
|
||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||
Flags = flags
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user