* Fix: Using the correct discord domain. * Fix: Using the correct discord domain. * Docs: Using the correct discord domain. * Fix: Changed canary and ptb to the new domain.tags/2.3.0
| @@ -2,7 +2,7 @@ | |||||
| [](https://www.nuget.org/packages/Discord.Net) | [](https://www.nuget.org/packages/Discord.Net) | ||||
| [](https://www.myget.org/feed/Packages/discord-net) | [](https://www.myget.org/feed/Packages/discord-net) | ||||
| [](https://dev.azure.com/discord-net/Discord.Net/_build/latest?definitionId=1&branchName=dev) | [](https://dev.azure.com/discord-net/Discord.Net/_build/latest?definitionId=1&branchName=dev) | ||||
| [](https://discord.gg/jkrBmQR) | |||||
| [](https://discord.gg/jkrBmQR) | |||||
| An unofficial .NET API Wrapper for the Discord client (http://discordapp.com). | An unofficial .NET API Wrapper for the Discord client (http://discordapp.com). | ||||
| @@ -4,10 +4,10 @@ field, and 2 normal fields using an @Discord.EmbedBuilder: | |||||
| ```cs | ```cs | ||||
| var exampleAuthor = new EmbedAuthorBuilder() | var exampleAuthor = new EmbedAuthorBuilder() | ||||
| .WithName("I am a bot") | .WithName("I am a bot") | ||||
| .WithIconUrl("https://discordapp.com/assets/e05ead6e6ebc08df9291738d0aa6986d.png"); | |||||
| .WithIconUrl("https://discord.com/assets/e05ead6e6ebc08df9291738d0aa6986d.png"); | |||||
| var exampleFooter = new EmbedFooterBuilder() | var exampleFooter = new EmbedFooterBuilder() | ||||
| .WithText("I am a nice footer") | .WithText("I am a nice footer") | ||||
| .WithIconUrl("https://discordapp.com/assets/28174a34e77bb5e5310ced9f95cb480b.png"); | |||||
| .WithIconUrl("https://discord.com/assets/28174a34e77bb5e5310ced9f95cb480b.png"); | |||||
| var exampleField = new EmbedFieldBuilder() | var exampleField = new EmbedFieldBuilder() | ||||
| .WithName("Title of Another Field") | .WithName("Title of Another Field") | ||||
| .WithValue("I am an [example](https://example.com).") | .WithValue("I am an [example](https://example.com).") | ||||
| @@ -22,4 +22,4 @@ var embed = new EmbedBuilder() | |||||
| .WithAuthor(exampleAuthor) | .WithAuthor(exampleAuthor) | ||||
| .WithFooter(exampleFooter) | .WithFooter(exampleFooter) | ||||
| .Build(); | .Build(); | ||||
| ``` | |||||
| ``` | |||||
| @@ -30,7 +30,7 @@ There are few possible reasons why this may occur. | |||||
| [TokenType]: xref:Discord.TokenType | [TokenType]: xref:Discord.TokenType | ||||
| [827]: https://github.com/RogueException/Discord.Net/issues/827 | [827]: https://github.com/RogueException/Discord.Net/issues/827 | ||||
| [958]: https://github.com/RogueException/Discord.Net/issues/958 | [958]: https://github.com/RogueException/Discord.Net/issues/958 | ||||
| [Discord API Terms of Service]: https://discordapp.com/developers/docs/legal | |||||
| [Discord API Terms of Service]: https://discord.com/developers/docs/legal | |||||
| ## How do I do X, Y, Z when my bot connects/logs on? Why do I get a `NullReferenceException` upon calling any client methods after connect? | ## How do I do X, Y, Z when my bot connects/logs on? Why do I get a `NullReferenceException` upon calling any client methods after connect? | ||||
| @@ -19,7 +19,7 @@ channels, and are often referred to as "servers". | |||||
| * A **Channel** ([IChannel]) represents a generic channel. | * A **Channel** ([IChannel]) represents a generic channel. | ||||
| - Example: #dotnet_discord-net | - Example: #dotnet_discord-net | ||||
| - See [Channel Types](#channel-types) | - See [Channel Types](#channel-types) | ||||
| [IGuild]: xref:Discord.IGuild | [IGuild]: xref:Discord.IGuild | ||||
| [IChannel]: xref:Discord.IChannel | [IChannel]: xref:Discord.IChannel | ||||
| @@ -79,4 +79,4 @@ activity for listening to a song on Spotify. | |||||
| [RichGame]: xref:Discord.RichGame | [RichGame]: xref:Discord.RichGame | ||||
| [StreamingGame]: xref:Discord.StreamingGame | [StreamingGame]: xref:Discord.StreamingGame | ||||
| [SpotifyGame]: xref:Discord.SpotifyGame | [SpotifyGame]: xref:Discord.SpotifyGame | ||||
| [Rich Presence Intro]: https://discordapp.com/developers/docs/rich-presence/best-practices | |||||
| [Rich Presence Intro]: https://discord.com/developers/docs/rich-presence/best-practices | |||||
| @@ -31,7 +31,7 @@ the Discord Applications Portal first. | |||||
|  |  | ||||
| [Discord Applications Portal]: https://discordapp.com/developers/applications/ | |||||
| [Discord Applications Portal]: https://discord.com/developers/applications/ | |||||
| ## Adding your bot to a server | ## Adding your bot to a server | ||||
| @@ -165,11 +165,11 @@ or any other blocking method, such as reading from the console. | |||||
| > the source code for your bot. | > the source code for your bot. | ||||
| > | > | ||||
| > In the following example, we retrieve the token from a pre-defined | > In the following example, we retrieve the token from a pre-defined | ||||
| > variable, which is **NOT** secure, especially if you plan on | |||||
| > variable, which is **NOT** secure, especially if you plan on | |||||
| > distributing the application in any shape or form. | > distributing the application in any shape or form. | ||||
| > | > | ||||
| > We recommend alternative storage such as | |||||
| > [Environment Variables], an external configuration file, or a | |||||
| > We recommend alternative storage such as | |||||
| > [Environment Variables], an external configuration file, or a | |||||
| > secrets manager for safe-handling of secrets. | > secrets manager for safe-handling of secrets. | ||||
| > | > | ||||
| > [Environment Variables]: https://en.wikipedia.org/wiki/Environment_variable | > [Environment Variables]: https://en.wikipedia.org/wiki/Environment_variable | ||||
| @@ -221,4 +221,4 @@ should be to separate... | |||||
| 2. the modules (handle commands) | 2. the modules (handle commands) | ||||
| 3. the services (persistent storage, pure functions, data manipulation) | 3. the services (persistent storage, pure functions, data manipulation) | ||||
| [CommandService]: xref:Discord.Commands.CommandService | |||||
| [CommandService]: xref:Discord.Commands.CommandService | |||||
| @@ -11,12 +11,12 @@ title: Home | |||||
| [](https://www.nuget.org/packages/Discord.Net) | [](https://www.nuget.org/packages/Discord.Net) | ||||
| [](https://www.myget.org/feed/Packages/discord-net) | [](https://www.myget.org/feed/Packages/discord-net) | ||||
| [](https://dev.azure.com/discord-net/Discord.Net/_build/latest?definitionId=1&branchName=dev) | [](https://dev.azure.com/discord-net/Discord.Net/_build/latest?definitionId=1&branchName=dev) | ||||
| [](https://discord.gg/jkrBmQR) | |||||
| [](https://discord.gg/jkrBmQR) | |||||
| ## What is Discord.Net? | ## What is Discord.Net? | ||||
| Discord.Net is an asynchronous, multi-platform .NET Library used to | Discord.Net is an asynchronous, multi-platform .NET Library used to | ||||
| interface with the [Discord API](https://discordapp.com/). | |||||
| interface with the [Discord API](https://discord.com/). | |||||
| ## Where to begin? | ## Where to begin? | ||||
| @@ -14,10 +14,10 @@ namespace _04_webhook_client | |||||
| public async Task MainAsync() | public async Task MainAsync() | ||||
| { | { | ||||
| // The webhook url follows the format https://discordapp.com/api/webhooks/{id}/{token} | |||||
| // The webhook url follows the format https://discord.com/api/webhooks/{id}/{token} | |||||
| // Because anyone with the webhook URL can use your webhook | // Because anyone with the webhook URL can use your webhook | ||||
| // you should NOT hard code the URL or ID + token into your application. | |||||
| using (var client = new DiscordWebhookClient("https://discordapp.com/api/webhooks/123/abc123")) | |||||
| // you should NOT hard code the URL or ID + token into your application. | |||||
| using (var client = new DiscordWebhookClient("https://discord.com/api/webhooks/123/abc123")) | |||||
| { | { | ||||
| var embed = new EmbedBuilder | var embed = new EmbedBuilder | ||||
| { | { | ||||
| @@ -26,7 +26,7 @@ namespace _04_webhook_client | |||||
| }; | }; | ||||
| // Webhooks are able to send multiple embeds per message | // Webhooks are able to send multiple embeds per message | ||||
| // As such, your embeds must be passed as a collection. | |||||
| // As such, your embeds must be passed as a collection. | |||||
| await client.SendMessageAsync(text: "Send a message to this webhook!", embeds: new[] { embed.Build() }); | await client.SendMessageAsync(text: "Send a message to this webhook!", embeds: new[] { embed.Build() }); | ||||
| } | } | ||||
| } | } | ||||
| @@ -13,7 +13,7 @@ namespace Discord | |||||
| /// <returns> | /// <returns> | ||||
| /// An <see cref="int"/> representing the API version that Discord.Net uses to communicate with Discord. | /// An <see cref="int"/> representing the API version that Discord.Net uses to communicate with Discord. | ||||
| /// <para>A list of available API version can be seen on the official | /// <para>A list of available API version can be seen on the official | ||||
| /// <see href="https://discordapp.com/developers/docs/reference#api-versioning">Discord API documentation</see> | |||||
| /// <see href="https://discord.com/developers/docs/reference#api-versioning">Discord API documentation</see> | |||||
| /// .</para> | /// .</para> | ||||
| /// </returns> | /// </returns> | ||||
| public const int APIVersion = 6; | public const int APIVersion = 6; | ||||
| @@ -50,7 +50,7 @@ namespace Discord | |||||
| /// <returns> | /// <returns> | ||||
| /// The Discord API URL using <see cref="APIVersion"/>. | /// The Discord API URL using <see cref="APIVersion"/>. | ||||
| /// </returns> | /// </returns> | ||||
| public static readonly string APIUrl = $"https://discordapp.com/api/v{APIVersion}/"; | |||||
| public static readonly string APIUrl = $"https://discord.com/api/v{APIVersion}/"; | |||||
| /// <summary> | /// <summary> | ||||
| /// Returns the base Discord CDN URL. | /// Returns the base Discord CDN URL. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -17,7 +17,7 @@ namespace Discord | |||||
| public static string GetJumpUrl(this IMessage msg) | public static string GetJumpUrl(this IMessage msg) | ||||
| { | { | ||||
| var channel = msg.Channel; | var channel = msg.Channel; | ||||
| return $"https://discordapp.com/channels/{(channel is IDMChannel ? "@me" : $"{(channel as ITextChannel).GuildId}")}/{channel.Id}/{msg.Id}"; | |||||
| return $"https://discord.com/channels/{(channel is IDMChannel ? "@me" : $"{(channel as ITextChannel).GuildId}")}/{channel.Id}/{msg.Id}"; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -13,7 +13,7 @@ namespace Discord.Net | |||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// An | /// An | ||||
| /// <see href="https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#http">HTTP status code</see> | |||||
| /// <see href="https://discord.com/developers/docs/topics/opcodes-and-status-codes#http">HTTP status code</see> | |||||
| /// from Discord. | /// from Discord. | ||||
| /// </returns> | /// </returns> | ||||
| public HttpStatusCode HttpCode { get; } | public HttpStatusCode HttpCode { get; } | ||||
| @@ -22,7 +22,7 @@ namespace Discord.Net | |||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A | /// A | ||||
| /// <see href="https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#json">JSON error code</see> | |||||
| /// <see href="https://discord.com/developers/docs/topics/opcodes-and-status-codes#json">JSON error code</see> | |||||
| /// from Discord, or <c>null</c> if none. | /// from Discord, or <c>null</c> if none. | ||||
| /// </returns> | /// </returns> | ||||
| public int? DiscordCode { get; } | public int? DiscordCode { get; } | ||||
| @@ -11,7 +11,7 @@ namespace Discord.Net | |||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| /// A | /// A | ||||
| /// <see href="https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes">close code</see> | |||||
| /// <see href="https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes">close code</see> | |||||
| /// from Discord. | /// from Discord. | ||||
| /// </returns> | /// </returns> | ||||
| public int CloseCode { get; } | public int CloseCode { get; } | ||||
| @@ -87,7 +87,7 @@ namespace Discord.WebSocket | |||||
| /// </para> | /// </para> | ||||
| /// <para> | /// <para> | ||||
| /// For more information, please see | /// For more information, please see | ||||
| /// <see href="https://discordapp.com/developers/docs/topics/gateway#request-guild-members">Request Guild Members</see> | |||||
| /// <see href="https://discord.com/developers/docs/topics/gateway#request-guild-members">Request Guild Members</see> | |||||
| /// on the official Discord API documentation. | /// on the official Discord API documentation. | ||||
| /// </para> | /// </para> | ||||
| /// <note> | /// <note> | ||||
| @@ -83,7 +83,7 @@ namespace Discord | |||||
| public void BotTokenDoesNotThrowExceptions(string token) | public void BotTokenDoesNotThrowExceptions(string token) | ||||
| { | { | ||||
| // This example token is pulled from the Discord Docs | // This example token is pulled from the Discord Docs | ||||
| // https://discordapp.com/developers/docs/reference#authentication-example-bot-token-authorization-header | |||||
| // https://discord.com/developers/docs/reference#authentication-example-bot-token-authorization-header | |||||
| // should not throw any exception | // should not throw any exception | ||||
| TokenUtils.ValidateToken(TokenType.Bot, token); | TokenUtils.ValidateToken(TokenType.Bot, token); | ||||
| } | } | ||||
| @@ -12,18 +12,18 @@ namespace Discord | |||||
| public class DiscordWebhookClientTests | public class DiscordWebhookClientTests | ||||
| { | { | ||||
| [Theory] | [Theory] | ||||
| [InlineData("https://discordapp.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| [InlineData("https://discord.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | ||||
| // ptb, canary, etc will have slightly different urls | // ptb, canary, etc will have slightly different urls | ||||
| [InlineData("https://ptb.discordapp.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| [InlineData("https://ptb.discord.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | ||||
| [InlineData("https://canary.discordapp.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| [InlineData("https://canary.discord.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | ||||
| // don't care about https | // don't care about https | ||||
| [InlineData("http://canary.discordapp.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| [InlineData("http://canary.discord.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | ||||
| // this is the minimum that the regex cares about | // this is the minimum that the regex cares about | ||||
| [InlineData("discordapp.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| [InlineData("discord.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK", | |||||
| 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | 123412347732897802, "_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | ||||
| public void TestWebhook_Valid(string webhookurl, ulong expectedId, string expectedToken) | public void TestWebhook_Valid(string webhookurl, ulong expectedId, string expectedToken) | ||||
| { | { | ||||
| @@ -48,7 +48,7 @@ namespace Discord | |||||
| [Theory] | [Theory] | ||||
| [InlineData("123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | [InlineData("123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK")] | ||||
| // trailing slash | // trailing slash | ||||
| [InlineData("https://discordapp.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK/")] | |||||
| [InlineData("https://discord.com/api/webhooks/123412347732897802/_abcde123456789-ABCDEFGHIJKLMNOP12345678-abcdefghijklmnopABCDEFGHIJK/")] | |||||
| public void TestWebhook_Invalid(string webhookurl) | public void TestWebhook_Invalid(string webhookurl) | ||||
| { | { | ||||
| Assert.Throws<ArgumentException>(() => | Assert.Throws<ArgumentException>(() => | ||||