Merge Labs 3.X into dev (#1923)

* meta: bump version

* Null or empty fix (#176)

* Add components and stickers to ReplyAsync extension

* Fixed null or empty

* Changed Label to Description

* -||-

Co-authored-by: quin lynch <lynchquin@gmail.com>

* More regions (#177)

* Preconditions

* ChannelHelper

* RestDMChannel

* RestGroupChannel

* RestBan

* RestGroupUser

* EntityExtensions

* DiscordSocketClient

* DiscordSocketClient

* Discord.net.core.xml fix (#178)

* Changed Label to Description

* Added Discord- .MessageComponent .ISticker[]

,Discord.MessageComponent,Discord.ISticker[] to ReplyAsync

* Remove references to labs

* Update Discord.Net.sln

* Added SendMessagesInThreads and StartEmbeddedActivities. (#175)

* Added SendMessagesInThreads and StartEmbeddedActivities.

Adjusted owner perms.
Change UsePublicThreads -> CreatePublicThreads
Change UsePrivateThreads -> CreatePrivateThreads

* removed extra ///

* Added UsePublicThreads and UsePrivateThreads back with Obsolete Attribute

* removed 'false' from Obsolete Attribute

* Squashed commit of the following:

commit dca41a348e36a9b4e7006ef3a76377eb32aad276
Author: quin lynch <lynchquin@gmail.com>
Date:   Thu Sep 23 07:02:19 2021 -0300

    Autocomplete commands

* meta: xml. closes #171

* Revert user agent and $device to dnet

* meta: bump version

* meta: bump vers

* Fix sticker args

* Grammer fix (#179)

* Made IVoiceChannel mentionable

* Embeds array for send message async (#181)

* meta: bump version

* meta: bump vers

* Fix sticker args

* Grammer fix (#179)

* Added embeds for SendMessageAsync

* [JsonProperty("embed")] forgot to remove this

 public Optional<Embed> Embed { get; set; }

* It has been done as requested.

* Changed the old way of handeling single embeds

* Moved embeds param and added options param

* xmls

Co-authored-by: quin lynch <lynchquin@gmail.com>

* Fix thread permissions (#183)

* Update GuildPermissionsTests.cs

* Update GuildPermissions.cs

* Use compound assignment (#186)

* Used compound assignment

* -||-

* -||-

* Remove unnecessary suppression (#188)

* Inlined variable declarations (#185)

* Fixed some warnings (#184)

* Fixed some warnings

* Another fixed warning

* Changed the SSendFileAsync to SendFileAsync

* Removed para AlwaysAcknowledgeInteractions

* Moved it back to the previous version

* Added periods to the end like quin requested!! :((

Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com>

* Object initialization can be simplified fixed (#189)

* Conditional-expression-simplification (#193)

* Capitlazation fixes (#192)

* Removed-this. (#191)

* Use 'switch' expression (#187)

* Use 'switch' expression

* Reverted it to the old switch case

* Fixed-compiler-error (#194)

* Submitting updates to include new permissions. (#195)

* Submitting updates to include new permissions.

* Make old permissions obsolete and update tests

Co-authored-by: quin lynch <lynchquin@gmail.com>

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Add support for long in autocomplete option

* Add support for sending files with multiple embeds (#196)

* Add support for sending files with multiple embeds

* Simplify prepending single embed to embed array

* Consistency for embeds endpoints (#197)

* Changed the way of handling prepending of embeds.

For consistency.

* reformatted the summary

* Revert pipeline

* Fix duplicate merge conflicts

* Changed minimum slash command name length to 1 per Discord API docs (#198)

* Channel endpoints requirements correction (#199)

* Added some requirements to channels for topic

* Changed check from NotNullOrEmpty to NotNullOrEmpty

* Added some requirements to channels for name

Preconditions.LessThan

* Formatting of file

* Added restriction for description not being null (#200)

* Update azure-pipelines.yml

* Update deploy.yml

* Remove version tag from proj

* Update deploy.yml

* Removed versions from project files

* Removed style of the nuget badge and added logo (#201)

The style was not properly added to it and the plastic version does not look good with the discord badge.
I thought it would look better with a logo

* Fix Type not being set in SocketApplicationCommand

* Remove useless GuildId property

* meta: update XML

* Add Autocomplete to SlashCommandOptionBuilder

* Added autocomplete in SlashCommandOptionBuilder. (#206)

Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>

* Fix duplicate autocomplete

* Fix #208

* Fix sub commands being interpreted as a parameter for autocomplete

* Fix exposed optional

* Support the discord:// protocol in buttons (#207)

* Update UrlValidation.cs

* Update ComponentBuilder.cs

* Add docs and better error messages.

* Fix wonky intentation

* Add competing activity status type (#205)

* Update GuildPermissionsTests.cs

* Update GuildPermissions.cs

* Add competing status type

* Add Icons to IRole (#204)

* Added icon field to IRole

* Added GetGuildRoleIconUrl()

* Added Clean Content Function (#174)

* Added Clean Content Function

* Fixed Spelling problems and bad var handling

* Add StripMarkDown Method

* Clean Content Expanded (#212)

* Implement CleanContent In IMessage & RestMessage

* Update Spelling and Documentation

* Add SanatizeMessage to MessageHelper and Refactor Rest and Socket Message

* Add event for autocomplete interaction (#214)

* Spelling corrections (#215)

* Remove null collections

* Followup with file async warnings (#216)

* Changed from NotNullOrWhitespace to NotNullOrEmpty

* Added NotNullOrEmpty on filename

* Added system to interpret from the path

* Added a check for if it contains a period

* It has been done, how ever it will break stuff

* Changed to use ??= how ever still added error check

* Added space under check

* Changed from with a period to valid file extension

* Added checks for SendFileAsync

* Removed filename != null &&

* Add channel types in application command options. (#217)

* add channel types in application command options

* Indent Docs

* Stage instance audit logs as well as thread audit log type

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Fix system messages not including mentioned users. Added ContextMenuCommand message type

* Remove file extension check (#218)

* Fix NRE in modify guild channel

* Fix 429's not being accounted for in ratelimit updates

* meta: add net5 framework

Co-Authored-By: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com>

* Proper doc logos (#221)

* Update GuildPermissionsTests.cs

* Update GuildPermissions.cs

* Add competing activity status type

* logo changes

* logo text as path

* add missing logo

* Update package logo and favicon

* Update docfx references

* Remove XML files and use original pipeline format

* Remove console writeline

* Remove Console.WriteLine

* Remove useless log

* Rename Available sticker field to IsAvailable

* Rename Available to IsAvailable in stickers

* Add summary indent for role members

* Add summary indent to SocketInvite

* Rename DefaultPermission to IsDefaultPermission

* Rename Default to IsDefault and Required to IsRequired in IApplicationCommandOption

* Rename Default and Required to IsDefault and IsRequired in IApplicationCommandOption. Rename DefaultPermission to IsDefaultPermission in IApplicationCommand

* Remove extra white spaces

* Renamed Joined, Archived, and Locked to HasJoined, IsArchived, and IsLocked

* Rename Live and DiscoverableDisabled to IsDiscoverableDisabled and IsLive in IStageChannel

* Remove newline

* Add indent to summaries

* Remove unnecessary json serializer field

* Fix ToEntity for roletags incorrectly using IsPremiumSubscriber

* Update RestChannel for new channel types

* Fix different rest channels not deserializing properly

* fully qualify internal for UrlValidation and add indent to summary

* Add missing periods to InteractionResponseType

* Fix summary in IApplicationCommandOptionChoice

* Update IApplicationCommandOption summaries

* Update IApplicationCommandInteractionDataOption summaries

* Update IApplicationCommandInteractionData summaries

* Update IApplicationCommand summaries

* Update ApplicationCommandType summaries

* rename DefaultPermission to IsDefaultPermission in ApplicationCommandProperties

* update ApplicationCommandOptionChoiceProperties summaries

* Rename Default, Required, and Autocomplete to IsDefault, IsRequired, and IsAutocomplete in ApplicationCommandOptionProperties

* Update SlashCommandProperties summaries

* update SlashCommandBuilder boolean field names, summaries, and choice parameters

* Update SelectMenuOption summaries, Rename Default to IsDefault in SelectMenuOption

* update SelectMenuComponent summaries. Rename Disabled to IsDisabled in SelectMenuComponent

* update ComponentBuilder summaries and boolean fields.

* Update ButtonComponent summaries and boolean fields

* update ActionRowComponent summaries

* Update UserCommandBuilder

* Update MessageCommandBuilder summaries and boolean properties

* Update IGuild summary

* Update IGuild summaries

* Update StagePrivacyLevel summary

* update IThreadChannel summaries

* Update IStageChannel summaries

* Refactor summaries and boolean property names

* General cleanup (#223)

* General cleanup

* Add Async suffix to SendAutocompleteResult

* Fix more formatting

* Fix unused RequestOptions in GetActiveThreadsAsync

* Add message to ArgumentNullException

* Ephemeral attachments

* Add missing jsonproperty attribute

* Add IMessage.Interaction

* Update attachment checks for embed urls

* meta: bump version

* Remove old package configs and update image

* Update package logos

* Fix logo reference for azure

* Deprecate old package definitions in favor for target file

* Deprecate old package definitions in favor for target file

Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>

* Update package ids

* Fix url validation

* meta: bump version

* Fix assignment of UserMentions (#233)

* Fix CleanContent (#231)

* Fix SocketSlashCommandData access modifier. (#237)

Fixes #229

* Update README with better header (#232)

* Update README with better header

Adds HTML elements that implement the main logo & improve the redirection tag positions.

* Resolving border issue in light-mode

* Update sponsor section

* Implement checks for interaction respond times and multiple interaction responses. closes #236, #235

* Add response check to socket auto complete

* meta: bump versions

* Fix #239

* meta: bump version

* meta: update logo

* meta: bump versions

* Revert received at time, confirmed by discord staff to be accurate

* Merge branch 'release/3.x' of https://github.com/Discord-Net-Labs/Discord.Net-Labs into merger-labs

Update requested changes of obsolete and references to labs.

Added `Interaction` to `IMessage`
Fixed grammar
Fixed bugs relating to interactions.

* Update docs

* Update CHANGELOG.md

* meta: docs building

* Update docs.yml

* Update docs.yml

* Fix docfx version

* Update docs.yml

* Update docs.bat

* Rename docs repo for clone

* update docfx version

* Update docs.bat

* Update docfx version

* Remove docs from pipeline

* FAQ revamped, metadata updated (#241)

* FAQ revamped, metadata updated

* Update FAQ.md

* Update README.md

* Docs index improvement

* Fix InvalidOperationException in modify channel

* feature: guild avatars, closes #238

* feature: modify role icons

* meta: changelog

* meta: bump version

* Update README.md

* Fix non value type options not being included in autocomplete

* Add new activity flags (#254)

* Add new activity flags

* Add missing commas

* Added support for GUILD_JOIN_REQUEST_DELETE event (#253)

Fixes #247

* Adding BotHTTPInteraction user flag (#252)

* animated guild banner support (#255)

* Docs work (WIP) (#242)

* Main page work

* Metadata logo dir

* More main page edits

* Naming change

* Dnet guide entries pruned

* Add student hub guild directory channel (#256)

* animated guild banner support

* Add guild directory channel

* Fix followup with file overwrite having incorrect parameter locations

* Merge labs 3.x

* Update GUILD_JOIN_REQUEST_DELETE event

* Update head.tmpl.partial

* Removed BannerId and AccentColor  (#260)

* Removed BannerId property, GetBannerURL method, and AccentColor property from IUser and socket entities.

* Fixed errors in IUser.cs

* Added back summary for GetAvatarUrl method in IUser.cs

* Support Guild Boost Progress Bars (#262)

* Support Guild Boost Progress Bars

* Update SocketChannel.cs

* Fix non-optional and unnecessary values.

* Spelling

* Reordering and consistency.

* Remove log for reconnect

* Add missing flags to SystemChannelMessageDeny (#267)

* Fix labs reference in analyzer project and provider project

* Rename new activity flags

* Guild feature revamp and smart gateway intent checks

* Get thread user implementation

* Amend creating slash command guide (#269)

* Adding BotHTTPInteraction user flag

* Added comments explaining the Global command create stipulations.

* Fix numeric type check for options

* Add state checking to ConnectionManager.StartAsync (#272)

* initial interface changes

* Multi file upload + attachment editing

* meta: bump versions

* Update CHANGELOG.md

* Update CHANGELOG.md

* Support Min and Max values on ApplicationCommandOptions (#273)

* Support Min and Max values on ApplicationCommandOptions

* Support decimal min/max values

* Docs imrpovments + use ToNullable

* Logomark, doc settings edit (#258)

* Logomark, doc settings edit

* Replace standard logo

* Bumping docfx plugins to latest release

* Bump version metadata

* Logo svg fix

* Change default sticker behavior and add AlwaysResolveSticker to the config

* Implement rest based interactions. Added ED25519 checks. Updated summaries.

* Update package logo

* Automatically fix ordering of optional command options (#276)

* auto fix optional command option order

* clean up indentation

* Fix maximum number of Select Menu Options (#282)

As of https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure the maximum number of options is 25, not less than 25. Hopefully the change catches all necessary locations

* Add voice region to modify voice channels

* Update summaries on rest interactions

* Interaction Specific Interfaces (#283)

* added interaction specific interfaces

* fix build error

* implement change requests

* Update application

* Add Guild Scheduled Events (#279)

* guild events initial

* sharded events

* Add new gateway intents and fix bugs

* More work on new changes to guild events

* Update guild scheduled events

* Added events to extended guild and add event start event

* Update preconditions

* Implement breaking changes guild guild events. Add guild event permissions

* Update tests and change privacy level requirements

* Update summaries and add docs for guild events

* meta: bump version

* Increment meta version (#285)

* Increment meta version

* Update docfx.json

* Fix #289 and add configureawaits to rest based interactions

* meta: bump version

* Add GUILD_SCHEDULED_EVENT_USER_ADD and GUILD_SCHEDULED_EVENT_USER_REMOVE (#287)

* Remove newline

* Fix autocomplete result value

* meta: bump versions

* Add `GuildScheduledEventUserAdd` and `GuildScheduledEventUserRemove` to sharded client

* Make RestUserCommand public (#292)

* Fix Components not showing on FUWF (#288) (#293)

Adds Components to Payload JSON Generation

* Implement smarter rest resolvable interaction data. Fixes #294

* Add UseInteractionSnowflakeDate to config #286

* Implement Better Discord Errors (#291)

* Initial error parsing

* Implement better errors

* Add missing error codes

* Add voice disconnect opcodes

* Remove unused class, add summaries to discordjsonerror, and remove public constructor of slash command properties

* Add error code summary

* Update error message summary

* Update src/Discord.Net.Core/DiscordJsonError.cs

Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>

* Update src/Discord.Net.WebSocket/API/Voice/VoiceCloseCode.cs

Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>

* Fix autocomplete result value

Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>

* Change the minimum length of slash commands to 1 (#284)

* Change the minimum length of slash commands to 1. This is the correct value according to the docs and it has been changed after user feedback.

* Fix the limit in 3 other places

Co-authored-by: quin lynch <lynchquin@gmail.com>

* Add new thread creation properties

* Add role emoji. Fixes #295

* Fix mocked text channel

* Fix precondition checks. Closes #281

* Initial fix (#297)

* meta: bump version

* Update from release/3.x

* Remove more labs references

* Remove doc file for Discord.Net.Analyzers

Co-authored-by: Simon Hjorthøj <sh2@live.dk>
Co-authored-by: drobbins329 <drobbins329@gmail.com>
Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com>
Co-authored-by: d4n3436 <dan3436@hotmail.com>
Co-authored-by: Will <WilliamWelsh@users.noreply.github.com>
Co-authored-by: Eugene Garbuzov <kkxo.mail@gmail.com>
Co-authored-by: CottageDwellingCat <80918250+CottageDwellingCat@users.noreply.github.com>
Co-authored-by: Emily <89871431+emillly-b@users.noreply.github.com>
Co-authored-by: marens101 <marens101@gmail.com>
Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>
Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Co-authored-by: Bill <billchirico@gmail.com>
Co-authored-by: Liege72 <65319395+Liege72@users.noreply.github.com>
Co-authored-by: Floowey <floowey@gmx.at>
Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
Co-authored-by: exsersewo <exsersewo@systemexit.co.uk>
Co-authored-by: Dennis Fischer <fischer_dennis@live.de>
This commit is contained in:
Quin Lynch
2021-11-23 09:58:05 -04:00
committed by GitHub
parent 3395700720
commit 933ea42eaa
591 changed files with 34402 additions and 1465 deletions

View File

@@ -15,10 +15,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -18,7 +18,7 @@ namespace TestHelper
/// Apply the inputted CodeAction to the inputted document.
/// Meant to be used to apply codefixes.
/// </summary>
/// <param name="document">The Document to apply the fix on</param>
/// <param name="document">The Document to apply the fix on.</param>
/// <param name="codeAction">A CodeAction that will be applied to the Document.</param>
/// <returns>A Document with the changes from the CodeAction</returns>
private static Document ApplyFix(Document document, CodeAction codeAction)
@@ -33,8 +33,8 @@ namespace TestHelper
/// Note: Considers Diagnostics to be the same if they have the same Ids. In the case of multiple diagnostics with the same Id in a row,
/// this method may not necessarily return the new one.
/// </summary>
/// <param name="diagnostics">The Diagnostics that existed in the code before the CodeFix was applied</param>
/// <param name="newDiagnostics">The Diagnostics that exist in the code after the CodeFix was applied</param>
/// <param name="diagnostics">The Diagnostics that existed in the code before the CodeFix was applied.</param>
/// <param name="newDiagnostics">The Diagnostics that exist in the code after the CodeFix was applied.</param>
/// <returns>A list of Diagnostics that only surfaced in the code after the CodeFix was applied</returns>
private static IEnumerable<Diagnostic> GetNewDiagnostics(IEnumerable<Diagnostic> diagnostics, IEnumerable<Diagnostic> newDiagnostics)
{
@@ -61,7 +61,7 @@ namespace TestHelper
/// <summary>
/// Get the existing compiler diagnostics on the inputted document.
/// </summary>
/// <param name="document">The Document to run the compiler diagnostic analyzers on</param>
/// <param name="document">The Document to run the compiler diagnostic analyzers on.</param>
/// <returns>The compiler diagnostics that were found in the code</returns>
private static IEnumerable<Diagnostic> GetCompilerDiagnostics(Document document)
{
@@ -71,7 +71,7 @@ namespace TestHelper
/// <summary>
/// Given a document, turn it into a string based on the syntax root
/// </summary>
/// <param name="document">The Document to be converted to a string</param>
/// <param name="document">The Document to be converted to a string.</param>
/// <returns>A string containing the syntax of the Document after formatting</returns>
private static string GetStringFromDocument(Document document)
{

View File

@@ -20,9 +20,9 @@ namespace TestHelper
throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1");
}
this.Path = path;
this.Line = line;
this.Column = column;
Path = path;
Line = line;
Column = column;
}
public string Path { get; }
@@ -41,16 +41,16 @@ namespace TestHelper
{
get
{
if (this.locations == null)
if (locations == null)
{
this.locations = new DiagnosticResultLocation[] { };
locations = new DiagnosticResultLocation[] { };
}
return this.locations;
return locations;
}
set
{
this.locations = value;
locations = value;
}
}
@@ -64,7 +64,7 @@ namespace TestHelper
{
get
{
return this.Locations.Length > 0 ? this.Locations[0].Path : "";
return Locations.Length > 0 ? Locations[0].Path : "";
}
}
@@ -72,7 +72,7 @@ namespace TestHelper
{
get
{
return this.Locations.Length > 0 ? this.Locations[0].Line : -1;
return Locations.Length > 0 ? Locations[0].Line : -1;
}
}
@@ -80,7 +80,7 @@ namespace TestHelper
{
get
{
return this.Locations.Length > 0 ? this.Locations[0].Column : -1;
return Locations.Length > 0 ? Locations[0].Column : -1;
}
}
}

View File

@@ -35,9 +35,9 @@ namespace TestHelper
/// <summary>
/// Given classes in the form of strings, their language, and an IDiagnosticAnlayzer to apply to it, return the diagnostics found in the string after converting it to a document.
/// </summary>
/// <param name="sources">Classes in the form of strings</param>
/// <param name="language">The language the source classes are in</param>
/// <param name="analyzer">The analyzer to be run on the sources</param>
/// <param name="sources">Classes in the form of strings.</param>
/// <param name="language">The language the source classes are in.</param>
/// <param name="analyzer">The analyzer to be run on the sources.</param>
/// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns>
private static Diagnostic[] GetSortedDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer)
{
@@ -48,8 +48,8 @@ namespace TestHelper
/// Given an analyzer and a document to apply it to, run the analyzer and gather an array of diagnostics found in it.
/// The returned diagnostics are then ordered by location in the source document.
/// </summary>
/// <param name="analyzer">The analyzer to run on the documents</param>
/// <param name="documents">The Documents that the analyzer will be run on</param>
/// <param name="analyzer">The analyzer to run on the documents.</param>
/// <param name="documents">The Documents that the analyzer will be run on.</param>
/// <returns>An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location</returns>
protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer analyzer, Document[] documents)
{
@@ -93,7 +93,7 @@ namespace TestHelper
/// <summary>
/// Sort diagnostics by location in source document
/// </summary>
/// <param name="diagnostics">The list of Diagnostics to be sorted</param>
/// <param name="diagnostics">The list of Diagnostics to be sorted.</param>
/// <returns>An IEnumerable containing the Diagnostics in order of Location</returns>
private static Diagnostic[] SortDiagnostics(IEnumerable<Diagnostic> diagnostics)
{
@@ -106,8 +106,8 @@ namespace TestHelper
/// <summary>
/// Given an array of strings as sources and a language, turn them into a project and return the documents and spans of it.
/// </summary>
/// <param name="sources">Classes in the form of strings</param>
/// <param name="language">The language the source code is in</param>
/// <param name="sources">Classes in the form of strings.</param>
/// <param name="language">The language the source code is in.</param>
/// <returns>A Tuple containing the Documents produced from the sources and their TextSpans if relevant</returns>
private static Document[] GetDocuments(string[] sources, string language)
{
@@ -130,8 +130,8 @@ namespace TestHelper
/// <summary>
/// Create a Document from a string through creating a project that contains it.
/// </summary>
/// <param name="source">Classes in the form of a string</param>
/// <param name="language">The language the source code is in</param>
/// <param name="source">Classes in the form of a string.</param>
/// <param name="language">The language the source code is in.</param>
/// <returns>A Document created from the source string</returns>
protected static Document CreateDocument(string source, string language = LanguageNames.CSharp)
{
@@ -141,8 +141,8 @@ namespace TestHelper
/// <summary>
/// Create a project using the inputted strings as sources.
/// </summary>
/// <param name="sources">Classes in the form of strings</param>
/// <param name="language">The language the source code is in</param>
/// <param name="sources">Classes in the form of strings.</param>
/// <param name="language">The language the source code is in.</param>
/// <returns>A Project created out of the Documents created from the source strings</returns>
private static Project CreateProject(string[] sources, string language = LanguageNames.CSharp)
{
@@ -187,7 +187,7 @@ namespace TestHelper
private static HashSet<Assembly> RecursiveReferencedAssemblies(Assembly a, HashSet<Assembly> assemblies = null)
{
assemblies = assemblies ?? new HashSet<Assembly>();
assemblies ??= new HashSet<Assembly>();
if (assemblies.Add(a))
{
foreach (var referencedAssemblyName in a.GetReferencedAssemblies())

View File

@@ -1,4 +1,4 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
@@ -38,10 +38,10 @@ namespace TestHelper
/// <summary>
/// Called to test a C# codefix when applied on the inputted string as a source
/// </summary>
/// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it</param>
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
/// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it.</param>
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it.</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple.</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied.</param>
protected void VerifyCSharpFix(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
{
VerifyFix(LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), GetCSharpCodeFixProvider(), oldSource, newSource, codeFixIndex, allowNewCompilerDiagnostics);
@@ -50,10 +50,10 @@ namespace TestHelper
/// <summary>
/// Called to test a VB codefix when applied on the inputted string as a source
/// </summary>
/// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it</param>
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
/// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it.</param>
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it.</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple.</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied.</param>
protected void VerifyBasicFix(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false)
{
VerifyFix(LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), GetBasicCodeFixProvider(), oldSource, newSource, codeFixIndex, allowNewCompilerDiagnostics);
@@ -65,13 +65,13 @@ namespace TestHelper
/// Then gets the string after the codefix is applied and compares it with the expected result.
/// Note: If any codefix causes new diagnostics to show up, the test fails unless allowNewCompilerDiagnostics is set to true.
/// </summary>
/// <param name="language">The language the source code is in</param>
/// <param name="analyzer">The analyzer to be applied to the source code</param>
/// <param name="codeFixProvider">The codefix to be applied to the code wherever the relevant Diagnostic is found</param>
/// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it</param>
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
/// <param name="language">The language the source code is in.</param>
/// <param name="analyzer">The analyzer to be applied to the source code.</param>
/// <param name="codeFixProvider">The codefix to be applied to the code wherever the relevant Diagnostic is found.</param>
/// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it.</param>
/// <param name="newSource">A class in the form of a string after the CodeFix was applied to it.</param>
/// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple.</param>
/// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied.</param>
private void VerifyFix(string language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex, bool allowNewCompilerDiagnostics)
{
var document = CreateDocument(oldSource, language);
@@ -126,4 +126,4 @@ namespace TestHelper
Assert.Equal(newSource, actual);
}
}
}
}

View File

@@ -37,8 +37,8 @@ namespace TestHelper
/// Called to test a C# DiagnosticAnalyzer when applied on the single inputted string as a source
/// Note: input a DiagnosticResult for each Diagnostic expected
/// </summary>
/// <param name="source">A class in the form of a string to run the analyzer on</param>
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source</param>
/// <param name="source">A class in the form of a string to run the analyzer on.</param>
/// <param name="expected"> DiagnosticResults that should appear after the analyzer is run on the source.</param>
protected void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected)
{
VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
@@ -48,8 +48,8 @@ namespace TestHelper
/// Called to test a VB DiagnosticAnalyzer when applied on the single inputted string as a source
/// Note: input a DiagnosticResult for each Diagnostic expected
/// </summary>
/// <param name="source">A class in the form of a string to run the analyzer on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the source</param>
/// <param name="source">A class in the form of a string to run the analyzer on.</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the source.</param>
protected void VerifyBasicDiagnostic(string source, params DiagnosticResult[] expected)
{
VerifyDiagnostics(new[] { source }, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
@@ -59,8 +59,8 @@ namespace TestHelper
/// Called to test a C# DiagnosticAnalyzer when applied on the inputted strings as a source
/// Note: input a DiagnosticResult for each Diagnostic expected
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on.</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources.</param>
protected void VerifyCSharpDiagnostic(string[] sources, params DiagnosticResult[] expected)
{
VerifyDiagnostics(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected);
@@ -70,8 +70,8 @@ namespace TestHelper
/// Called to test a VB DiagnosticAnalyzer when applied on the inputted strings as a source
/// Note: input a DiagnosticResult for each Diagnostic expected
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on.</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources.</param>
protected void VerifyBasicDiagnostic(string[] sources, params DiagnosticResult[] expected)
{
VerifyDiagnostics(sources, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected);
@@ -81,10 +81,10 @@ namespace TestHelper
/// General method that gets a collection of actual diagnostics found in the source after the analyzer is run,
/// then verifies each of them.
/// </summary>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
/// <param name="language">The language of the classes represented by the source strings</param>
/// <param name="analyzer">The analyzer to be run on the source code</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
/// <param name="sources">An array of strings to create source documents from to run the analyzers on.</param>
/// <param name="language">The language of the classes represented by the source strings.</param>
/// <param name="analyzer">The analyzer to be run on the source code.</param>
/// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources.</param>
private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expected)
{
var diagnostics = GetSortedDiagnostics(sources, language, analyzer);
@@ -98,9 +98,9 @@ namespace TestHelper
/// Checks each of the actual Diagnostics found and compares them with the corresponding DiagnosticResult in the array of expected results.
/// Diagnostics are considered equal only if the DiagnosticResultLocation, Id, Severity, and Message of the DiagnosticResult match the actual diagnostic.
/// </summary>
/// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code</param>
/// <param name="analyzer">The analyzer that was being run on the sources</param>
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param>
/// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code.</param>
/// <param name="analyzer">The analyzer that was being run on the sources.</param>
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code.</param>
private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
{
int expectedCount = expectedResults.Length;
@@ -173,10 +173,10 @@ namespace TestHelper
/// <summary>
/// Helper method to VerifyDiagnosticResult that checks the location of a diagnostic and compares it with the location in the expected DiagnosticResult.
/// </summary>
/// <param name="analyzer">The analyzer that was being run on the sources</param>
/// <param name="diagnostic">The diagnostic that was found in the code</param>
/// <param name="actual">The Location of the Diagnostic found in the code</param>
/// <param name="expected">The DiagnosticResultLocation that should have been found</param>
/// <param name="analyzer">The analyzer that was being run on the sources.</param>
/// <param name="diagnostic">The diagnostic that was found in the code.</param>
/// <param name="actual">The Location of the Diagnostic found in the code.</param>
/// <param name="expected">The DiagnosticResultLocation that should have been found.</param>
private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected)
{
var actualSpan = actual.GetLineSpan();
@@ -215,8 +215,8 @@ namespace TestHelper
/// <summary>
/// Helper method to format a Diagnostic into an easily readable string
/// </summary>
/// <param name="analyzer">The analyzer that this verifier tests</param>
/// <param name="diagnostics">The Diagnostics to be formatted</param>
/// <param name="analyzer">The analyzer that this verifier tests.</param>
/// <param name="diagnostics">The Diagnostics to be formatted.</param>
/// <returns>The Diagnostics formatted as a string</returns>
private static string FormatDiagnostics(DiagnosticAnalyzer analyzer, params Diagnostic[] diagnostics)
{

View File

@@ -19,7 +19,7 @@ namespace Discord
public ChannelsTests(RestGuildFixture guildFixture, ITestOutputHelper output)
{
guild = guildFixture.Guild;
this.output = output;
output = output;
output.WriteLine($"RestGuildFixture using guild: {guild.Id}");
// capture all console output
guildFixture.Client.Log += LogAsync;

View File

@@ -15,9 +15,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -18,7 +18,7 @@ namespace Discord
{
client = guildFixture.Client;
guild = guildFixture.Guild;
this.output = output;
output = output;
output.WriteLine($"RestGuildFixture using guild: {guild.Id}");
guildFixture.Client.Log += LogAsync;
}

View File

@@ -85,6 +85,10 @@ namespace Discord
AssertFlag(() => new ChannelPermissions(stream: true), ChannelPermission.Stream);
AssertFlag(() => new ChannelPermissions(manageRoles: true), ChannelPermission.ManageRoles);
AssertFlag(() => new ChannelPermissions(manageWebhooks: true), ChannelPermission.ManageWebhooks);
AssertFlag(() => new ChannelPermissions(useApplicationCommands: true), ChannelPermission.UseApplicationCommands);
AssertFlag(() => new ChannelPermissions(createPrivateThreads: true), ChannelPermission.CreatePrivateThreads);
AssertFlag(() => new ChannelPermissions(createPublicThreads: true), ChannelPermission.CreatePublicThreads);
AssertFlag(() => new ChannelPermissions(sendMessagesInThreads: true), ChannelPermission.SendMessagesInThreads);
}
/// <summary>

View File

@@ -10,12 +10,11 @@ namespace Discord
/// </summary>
public class ColorTests
{
[Fact]
public void Color_New()
{
Assert.Equal(0u, new Color().RawValue);
Assert.Equal(uint.MinValue, new Color(uint.MinValue).RawValue);
Assert.Equal(uint.MaxValue, new Color(uint.MaxValue).RawValue);
Assert.Throws<ArgumentException>(() => new Color(uint.MaxValue));
}
[Fact]
public void Color_Default()

View File

@@ -13,9 +13,9 @@
<ProjectReference Include="../../src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -9,9 +9,9 @@ namespace Discord
/// </summary>
public class EmbedBuilderTests
{
private const string name = "chrisj";
private const string icon = "https://meowpuffygottem.fun/blob.png";
private const string url = "https://meowpuffygottem.fun/";
private const string Name = "chrisj";
private const string Icon = "https://meowpuffygottem.fun/blob.png";
private const string Url = "https://meowpuffygottem.fun/";
/// <summary>
/// Tests the behavior of <see cref="EmbedBuilder.WithAuthor(string, string, string)"/>.
@@ -24,12 +24,12 @@ namespace Discord
Assert.Null(builder.Author);
builder = new EmbedBuilder()
.WithAuthor(name, icon, url);
.WithAuthor(Name, Icon, Url);
Assert.NotNull(builder.Author);
Assert.Equal(name, builder.Author.Name);
Assert.Equal(icon, builder.Author.IconUrl);
Assert.Equal(url, builder.Author.Url);
Assert.Equal(Name, builder.Author.Name);
Assert.Equal(Icon, builder.Author.IconUrl);
Assert.Equal(Url, builder.Author.Url);
}
/// <summary>
@@ -39,15 +39,15 @@ namespace Discord
public void WithAuthor_AuthorBuilder()
{
var author = new EmbedAuthorBuilder()
.WithIconUrl(icon)
.WithName(name)
.WithUrl(url);
.WithIconUrl(Icon)
.WithName(Name)
.WithUrl(Url);
var builder = new EmbedBuilder()
.WithAuthor(author);
Assert.NotNull(builder.Author);
Assert.Equal(name, builder.Author.Name);
Assert.Equal(icon, builder.Author.IconUrl);
Assert.Equal(url, builder.Author.Url);
Assert.Equal(Name, builder.Author.Name);
Assert.Equal(Icon, builder.Author.IconUrl);
Assert.Equal(Url, builder.Author.Url);
}
/// <summary>
@@ -58,13 +58,13 @@ namespace Discord
{
var builder = new EmbedBuilder()
.WithAuthor((author) =>
author.WithIconUrl(icon)
.WithName(name)
.WithUrl(url));
author.WithIconUrl(Icon)
.WithName(Name)
.WithUrl(Url));
Assert.NotNull(builder.Author);
Assert.Equal(name, builder.Author.Name);
Assert.Equal(icon, builder.Author.IconUrl);
Assert.Equal(url, builder.Author.Url);
Assert.Equal(Name, builder.Author.Name);
Assert.Equal(Icon, builder.Author.IconUrl);
Assert.Equal(Url, builder.Author.Url);
}
/// <summary>
@@ -74,12 +74,12 @@ namespace Discord
public void EmbedAuthorBuilder()
{
var builder = new EmbedAuthorBuilder()
.WithIconUrl(icon)
.WithName(name)
.WithUrl(url);
Assert.Equal(icon, builder.IconUrl);
Assert.Equal(name, builder.Name);
Assert.Equal(url, builder.Url);
.WithIconUrl(Icon)
.WithName(Name)
.WithUrl(Url);
Assert.Equal(Icon, builder.IconUrl);
Assert.Equal(Name, builder.Name);
Assert.Equal(Url, builder.Url);
}
/// <summary>
@@ -95,8 +95,10 @@ namespace Discord
{
Assert.Throws<ArgumentException>(() =>
{
var builder = new EmbedBuilder();
builder.Title = title;
var builder = new EmbedBuilder
{
Title = title
};
});
Assert.Throws<ArgumentException>(() =>
{
@@ -113,8 +115,10 @@ namespace Discord
[InlineData("jVyLChmA7aBZozXQuZ3VDEcwW6zOq0nteOVYBZi31ny73rpXfSSBXR4Jw6FiplDKQseKskwRMuBZkUewrewqAbkBZpslHirvC5nEzRySoDIdTRnkVvTXZUXg75l3bQCjuuHxDd6DfrY8ihd6yZX1Y0XFeg239YBcYV4TpL9uQ8H3HFYxrWhLlG2PRVjUmiglP5iXkawszNwMVm1SZ5LZT4jkMZHxFegVi7170d16iaPWOovu50aDDHy087XBtLKV")]
public void Tile_Valid(string title)
{
var builder = new EmbedBuilder();
builder.Title = title;
var builder = new EmbedBuilder
{
Title = title
};
new EmbedBuilder().WithTitle(title);
}
@@ -133,8 +137,10 @@ namespace Discord
Assert.Throws<ArgumentException>(() => new EmbedBuilder().WithDescription(description));
Assert.Throws<ArgumentException>(() =>
{
var b = new EmbedBuilder();
b.Description = description;
var b = new EmbedBuilder
{
Description = description
};
});
}
}
@@ -156,14 +162,16 @@ namespace Discord
var b = new EmbedBuilder().WithDescription(description);
Assert.Equal(description, b.Description);
b = new EmbedBuilder();
b.Description = description;
b = new EmbedBuilder
{
Description = description
};
Assert.Equal(description, b.Description);
}
}
/// <summary>
/// Tests that valid urls do not throw any exceptions.
/// Tests that valid url's do not throw any exceptions.
/// </summary>
/// <param name="url">The url to set.</param>
[Theory]
@@ -181,10 +189,12 @@ namespace Discord
Assert.Equal(result.ImageUrl, url);
Assert.Equal(result.ThumbnailUrl, url);
result = new EmbedBuilder();
result.Url = url;
result.ImageUrl = url;
result.ThumbnailUrl = url;
result = new EmbedBuilder
{
Url = url,
ImageUrl = url,
ThumbnailUrl = url
};
Assert.Equal(result.Url, url);
Assert.Equal(result.ImageUrl, url);
Assert.Equal(result.ThumbnailUrl, url);
@@ -207,15 +217,15 @@ namespace Discord
public void Length()
{
var e = new EmbedBuilder()
.WithAuthor(name, icon, url)
.WithAuthor(Name, Icon, Url)
.WithColor(Color.Blue)
.WithDescription("This is the test description.")
.WithFooter("This is the footer", url)
.WithImageUrl(url)
.WithThumbnailUrl(url)
.WithFooter("This is the footer", Url)
.WithImageUrl(Url)
.WithThumbnailUrl(Url)
.WithTimestamp(DateTimeOffset.MinValue)
.WithTitle("This is the title")
.WithUrl(url)
.WithUrl(Url)
.AddField("Field 1", "Inline", true)
.AddField("Field 2", "Not Inline", false);
Assert.Equal(100, e.Length);
@@ -253,11 +263,11 @@ namespace Discord
var e = new EmbedBuilder()
.WithFooter(x =>
{
x.IconUrl = url;
x.Text = name;
x.IconUrl = Url;
x.Text = Name;
});
Assert.Equal(url, e.Footer.IconUrl);
Assert.Equal(name, e.Footer.Text);
Assert.Equal(Url, e.Footer.IconUrl);
Assert.Equal(Name, e.Footer.Text);
}
/// <summary>
@@ -268,18 +278,20 @@ namespace Discord
{
var footer = new EmbedFooterBuilder()
{
IconUrl = url,
Text = name
IconUrl = Url,
Text = Name
};
var e = new EmbedBuilder()
.WithFooter(footer);
Assert.Equal(url, e.Footer.IconUrl);
Assert.Equal(name, e.Footer.Text);
Assert.Equal(Url, e.Footer.IconUrl);
Assert.Equal(Name, e.Footer.Text);
// use the property
e = new EmbedBuilder();
e.Footer = footer;
Assert.Equal(url, e.Footer.IconUrl);
Assert.Equal(name, e.Footer.Text);
e = new EmbedBuilder
{
Footer = footer
};
Assert.Equal(Url, e.Footer.IconUrl);
Assert.Equal(Name, e.Footer.Text);
}
/// <summary>
@@ -289,9 +301,9 @@ namespace Discord
public void WithFooter_Strings()
{
var e = new EmbedBuilder()
.WithFooter(name, url);
Assert.Equal(url, e.Footer.IconUrl);
Assert.Equal(name, e.Footer.Text);
.WithFooter(Name, Url);
Assert.Equal(Url, e.Footer.IconUrl);
Assert.Equal(Name, e.Footer.Text);
}
/// <summary>
@@ -301,10 +313,10 @@ namespace Discord
public void EmbedFooterBuilder()
{
var footer = new EmbedFooterBuilder()
.WithIconUrl(url)
.WithText(name);
Assert.Equal(url, footer.IconUrl);
Assert.Equal(name, footer.Text);
.WithIconUrl(Url)
.WithText(Name);
Assert.Equal(Url, footer.IconUrl);
Assert.Equal(Name, footer.Text);
}
/// <summary>
/// Tests that invalid text throws an <see cref="ArgumentException"/>.
@@ -375,10 +387,12 @@ namespace Discord
Assert.Equal("value", e.Value);
Assert.True(e.IsInline);
// use the properties
e = new EmbedFieldBuilder();
e.IsInline = true;
e.Name = "name";
e.Value = "value";
e = new EmbedFieldBuilder
{
IsInline = true,
Name = "name",
Value = "value"
};
Assert.Equal("name", e.Name);
Assert.Equal("value", e.Value);
Assert.True(e.IsInline);

View File

@@ -59,5 +59,20 @@ namespace Discord
{
Assert.Equal(expected, Format.BlockQuote(input));
}
[Theory]
[InlineData("", "")]
[InlineData("\n", "\n")]
[InlineData("**hi**", "hi")]
[InlineData("__uwu__", "uwu")]
[InlineData(">>__uwu__", "uwu")]
[InlineData("```uwu```", "uwu")]
[InlineData("~uwu~", "uwu")]
[InlineData("berries __and__ *Cream**, I'm a little lad who loves berries and cream", "berries and Cream, I'm a little lad who loves berries and cream")]
public void StripMarkdown(string input, string expected)
{
var test = Format.StripMarkDown(input);
Assert.Equal(expected, test);
}
}
}

View File

@@ -91,7 +91,14 @@ namespace Discord
AssertFlag(() => new GuildPermissions(manageNicknames: true), GuildPermission.ManageNicknames);
AssertFlag(() => new GuildPermissions(manageRoles: true), GuildPermission.ManageRoles);
AssertFlag(() => new GuildPermissions(manageWebhooks: true), GuildPermission.ManageWebhooks);
AssertFlag(() => new GuildPermissions(manageEmojis: true), GuildPermission.ManageEmojis);
AssertFlag(() => new GuildPermissions(manageEmojisAndStickers: true), GuildPermission.ManageEmojisAndStickers);
AssertFlag(() => new GuildPermissions(useApplicationCommands: true), GuildPermission.UseApplicationCommands);
AssertFlag(() => new GuildPermissions(requestToSpeak: true), GuildPermission.RequestToSpeak);
AssertFlag(() => new GuildPermissions(manageEvents: true), GuildPermission.ManageEvents);
AssertFlag(() => new GuildPermissions(manageThreads: true), GuildPermission.ManageThreads);
AssertFlag(() => new GuildPermissions(createPublicThreads: true), GuildPermission.CreatePublicThreads);
AssertFlag(() => new GuildPermissions(createPrivateThreads: true), GuildPermission.CreatePrivateThreads);
AssertFlag(() => new GuildPermissions(useExternalStickers: true), GuildPermission.UseExternalStickers);
}
/// <summary>
@@ -161,7 +168,14 @@ namespace Discord
AssertUtil(GuildPermission.ManageNicknames, x => x.ManageNicknames, (p, enable) => p.Modify(manageNicknames: enable));
AssertUtil(GuildPermission.ManageRoles, x => x.ManageRoles, (p, enable) => p.Modify(manageRoles: enable));
AssertUtil(GuildPermission.ManageWebhooks, x => x.ManageWebhooks, (p, enable) => p.Modify(manageWebhooks: enable));
AssertUtil(GuildPermission.ManageEmojis, x => x.ManageEmojis, (p, enable) => p.Modify(manageEmojis: enable));
AssertUtil(GuildPermission.ManageEmojisAndStickers, x => x.ManageEmojisAndStickers, (p, enable) => p.Modify(manageEmojisAndStickers: enable));
AssertUtil(GuildPermission.UseApplicationCommands, x => x.UseApplicationCommands, (p, enable) => p.Modify(useApplicationCommands: enable));
AssertUtil(GuildPermission.RequestToSpeak, x => x.RequestToSpeak, (p, enable) => p.Modify(requestToSpeak: enable));
AssertUtil(GuildPermission.ManageEvents, x => x.ManageEvents, (p, enable) => p.Modify(manageEvents: enable));
AssertUtil(GuildPermission.ManageThreads, x => x.ManageThreads, (p, enable) => p.Modify(manageThreads: enable));
AssertUtil(GuildPermission.CreatePublicThreads, x => x.CreatePublicThreads, (p, enable) => p.Modify(createPublicThreads: enable));
AssertUtil(GuildPermission.CreatePrivateThreads, x => x.CreatePrivateThreads, (p, enable) => p.Modify(createPrivateThreads: enable));
AssertUtil(GuildPermission.UseExternalStickers, x => x.UseExternalStickers, (p, enable) => p.Modify(useExternalStickers: enable));
}
}
}

View File

@@ -47,9 +47,7 @@ namespace Discord
var parsed = MentionUtils.ParseUser(user);
Assert.Equal(id, parsed);
// also check tryparse
ulong result;
Assert.True(MentionUtils.TryParseUser(user, out result));
Assert.True(MentionUtils.TryParseUser(user, out ulong result));
Assert.Equal(id, result);
}
[Theory]
@@ -75,9 +73,7 @@ namespace Discord
var parsed = MentionUtils.ParseChannel(channel);
Assert.Equal(id, parsed);
// also check tryparse
ulong result;
Assert.True(MentionUtils.TryParseChannel(channel, out result));
Assert.True(MentionUtils.TryParseChannel(channel, out ulong result));
Assert.Equal(id, result);
}
[Theory]
@@ -103,9 +99,7 @@ namespace Discord
var parsed = MentionUtils.ParseRole(role);
Assert.Equal(id, parsed);
// also check tryparse
ulong result;
Assert.True(MentionUtils.TryParseRole(role, out result));
Assert.True(MentionUtils.TryParseRole(role, out ulong result));
Assert.Equal(id, result);
}
[Theory]

View File

@@ -78,24 +78,15 @@ namespace Discord
throw new NotImplementedException();
}
public Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
{
throw new NotImplementedException();
}
public Task<IUserMessage> 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)
{
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
{
throw new NotImplementedException();
}
public Task TriggerTypingAsync(RequestOptions options = null)
{
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IUserMessage> 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 component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IUserMessage> 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 component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
}
}

View File

@@ -86,17 +86,17 @@ namespace Discord
throw new NotImplementedException();
}
public Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
public Task<IUserMessage> 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 component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
throw new NotImplementedException();
}
public Task<IUserMessage> 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)
public Task<IUserMessage> 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 component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
throw new NotImplementedException();
}
@@ -105,5 +105,8 @@ namespace Discord
{
throw new NotImplementedException();
}
public Task<IUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
}
}

View File

@@ -46,6 +46,10 @@ namespace Discord
{
throw new NotImplementedException();
}
public Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge, int? maxUses = default(int?), bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
=> throw new NotImplementedException();
public Task<IInviteMetadata> CreateInviteToStreamAsync(IUser user, int? maxAge, int? maxUses = default(int?), bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
=> throw new NotImplementedException();
public Task<IWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
{
@@ -172,17 +176,17 @@ namespace Discord
throw new NotImplementedException();
}
public Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
public Task<IUserMessage> 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 component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
throw new NotImplementedException();
}
public Task<IUserMessage> 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)
public Task<IUserMessage> 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 component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
throw new NotImplementedException();
}
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
public Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
throw new NotImplementedException();
}
@@ -206,5 +210,9 @@ namespace Discord
{
throw new NotImplementedException();
}
public Task<IUserMessage> SendFileAsync(FileAttachment attachment, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException();
public Task<IThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null) => throw new NotImplementedException();
}
}

View File

@@ -27,7 +27,6 @@ namespace Discord
public string Name => throw new NotImplementedException();
public DateTimeOffset CreatedAt => throw new NotImplementedException();
public ulong Id => throw new NotImplementedException();
public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)
@@ -49,6 +48,10 @@ namespace Discord
{
throw new NotImplementedException();
}
public Task<IInviteMetadata> CreateInviteToApplicationAsync(ulong applicationId, int? maxAge, int? maxUses = default(int?), bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
=> throw new NotImplementedException();
public Task<IInviteMetadata> CreateInviteToStreamAsync(IUser user, int? maxAge, int? maxUses = default(int?), bool isTemporary = false, bool isUnique = false, RequestOptions options = null)
=> throw new NotImplementedException();
public Task DeleteAsync(RequestOptions options = null)
{