Commit Graph

54 Commits

Author SHA1 Message Date
Ge
ee617d8ef3 Fix typos in comments and documentation (#2608)
* Fix typos in comments and documentations

* Fixes more typo
2023-02-26 20:49:16 +01:00
Dedmen Miller
50e0e5941a Add ModalBuilder.AddModalCommand with option to specify callback (#2599)
Fixes: #2597
2023-02-14 22:31:50 +01:00
NaN
257f246d1d Format the project with 'dotnet format' (#2551)
* Sync and Re-Format

* Fix Title string.

* Fix indentation.
2023-02-13 18:45:59 +01:00
Christopher Bonnell
274be5df9e Fix permissions on deleteMissing=false (#2532) 2023-02-09 16:36:17 +01:00
Cenk Ergen
1602437c31 Update customId template generator to escape regex metachars used in … (#2557)
* update customId template generator to escape regex metachars used in template literals

* add clarification to TreatAsRegex prop documentation.

* Implement channel ApplicationCommandPermissionTarge

* implement channel target in ApplicationCommandPermission and add static methods for targeting @everyone and all channels

* Revert "add clarification to TreatAsRegex prop documentation."

This reverts commit 6eab5878a7ddff4e949a90d446f2e3dfe2e9c506.

* fix oopsie
2023-02-06 13:27:42 +01:00
Cenk Ergen
e7bda0f8a5 [Feature] RespondWithModal() which accepts an IModal instance as template (#2564)
* introduce overload for responding to an interaction with an instatiated IModal obj

* add inline docs to ModalInfo.PropertyInfo

* Apply suggestions from code review

Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>

---------

Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>
2023-02-06 13:52:16 +03:00
Gradyn Wursten
7acbcfdfa5 #2536 Add RemoveModulesFromGuildAsync (#2537)
* Add RemoveModulesFromGuildAsync

* fix RemoveModulesFromGuildAsync

* add docs

* fix parameter name
2023-01-21 11:52:37 +01:00
Misha133
48fb1b5df4 [Feature] Selects v2 support (#2507)
* Initial support for new select types

* Merge branch 'dev' of https://github.com/discord-net/Discord.Net into dev

* some component&action row builder additions

* remove redundant code

* changes1

* maybe working rest part?

* working-ish state?

* fix some xml docs & small rework

* typos

* fix `ActionRowBuilder`

* update DefaultArrayComponentConverter to accomodate new select-v2 types

* now supports dm channels in channel selects

* add a note to IF docs

* add notes about nullable properties

* <see langword="null"/>

* update Modal.cs

Co-authored-by: cat <lumitydev@gmail.com>
Co-authored-by: Cenngo <cenk.ergen1@gmail.com>
2022-12-25 13:41:15 +01:00
Misha133
56b1a930e7 [Feature] Age restricted (NSFW) application commands support (#2531)
* add `nsfw` to data model & internal methods; add missing property

* add `nsfw` prop to command builders

* add `NsfwCommandAttribute` to Interaction Framework

* working state

* docs?
2022-12-20 01:00:56 +03:00
Cenk Ergen
3b107c2d01 implement wildcard lenght quantifiers, TreatAsRegex property and solve catastrpohic backtracking (#2528) 2022-12-14 17:06:57 +03:00
Cenk Ergen
6869817184 Command execution code rework and TypeConverters auto-scope fix (#2306)
* command execution rework and sync service scopes for typeconverters

* replace ValueTask with Task

* fix implementation bugs

Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
2022-11-22 14:05:26 +03:00
Damian Kraaijeveld
376a812b6a Return a list instead of an array (#2451) 2022-09-02 14:04:53 -07:00
Kuba_Z2
0aa381d468 Fix typos of word length (#2443) 2022-08-29 11:24:32 +02:00
Cenk Ergen
39bbd298c3 Interactions Command Localization (#2395)
* Request headers (#2394)

* add support for per-request headers

* remove unnecessary usings

* Revert "remove unnecessary usings"

This reverts commit 8d674fe4faf985b117f143fae3877a1698170ad2.

* remove nullable strings from RequestOptions

* Add Localization Support to Interaction Service (#2211)

* add json and resx localization managers

* add utils class for getting command paths

* update json regex to make langage code optional

* remove IServiceProvider from ILocalizationManager method params

* replace the command path method in command map

* add localization fields to rest and websocket application command entity implementations

* move deconstruct extensions method to extensions folder

* add withLocalizations parameter to rest methods

* fix build error

* add rest conversions to interaction service

* add localization to the rest methods

* add inline docs

* fix implementation bugs

* add missing inline docs

* inline docs correction (Name/Description Localized properties)

* add choice localization

* fix conflicts

* fix conflicts

* add missing command props fields to ToApplicationCommandProps methods

* add locale parameter to Get*ApplicationCommandsAsync methods for fetching localized command names/descriptions

* Apply suggestions from code review

Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>

* Update src/Discord.Net.Core/Entities/Guilds/IGuild.cs

Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>

* add inline docs to LocalizationTarget

* fix upstream merge errors

* fix command parsing for context command names with space char

* fix command parsing for context command names with space char

* fix failed to generate buket id

* fix get guild commands endpoint

* update rexs localization manager to use single-file pattern

* Upstream Merge Localization Branch (#2434)

* fix ci/cd error (#2428)

* Fix role icon & emoji assignment. (#2416)

* Fix IGuild.GetBansAsync() (#2424)

fix the problem of not being able to get more than 1000 bans

* [DOCS] Add a note about `DontAutoRegisterAttribute`  (#2430)

* add a note about `DontAutoRegisterAttribute`

* Remove "to to" and add punctuation

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

* fix: Missing Fact attribute in ColorTests (#2425)

* feat: Embed comparison (#2347)

* Fix broken code snippet in dependency injection docs (#2420)

* Fixed markdown formatting to show code snippet

* Fixed constructor injection code snippet pointer

* Added support for lottie stickers (#2359)

Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Co-authored-by: BokuNoPasya <49203428+1NieR@users.noreply.github.com>
Co-authored-by: Misha133 <61027276+Misha-133@users.noreply.github.com>
Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com>
Co-authored-by: Ge <gehongyan1996@126.com>
Co-authored-by: Charlie U <52503242+cpurules@users.noreply.github.com>
Co-authored-by: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com>

* remove unnecassary fields from ResxLocalizationManager

* update int framework guides

* remove space character tokenization from ResxLocalizationManager

Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
Co-authored-by: BokuNoPasya <49203428+1NieR@users.noreply.github.com>
Co-authored-by: Misha133 <61027276+Misha-133@users.noreply.github.com>
Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com>
Co-authored-by: Ge <gehongyan1996@126.com>
Co-authored-by: Charlie U <52503242+cpurules@users.noreply.github.com>
Co-authored-by: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com>
2022-08-26 18:45:27 +03:00
Cenk Ergen
500e7b44ca Using RespondWithModalAsync<IModal>() without prior IModal declaration (#2369)
* add RespondWithModalAsync method for initializing missing ModalInfos on runtime

* update method name and add inline docs
2022-08-10 11:37:40 +03:00
Cenk Ergen
e551431d72 Max/Min length fields for ApplicationCommandOption (#2379)
* implement max/min length fields for ApplicationCommandOption

* fix badly formed xml comments
2022-08-03 16:44:30 +03:00
Armano den Boef
b0b8167efb fix: Remove group check from RequireContextAttribute (#2409) 2022-08-03 10:54:30 +02:00
Armano den Boef
902326d1f3 fix: Range of issues presented by analyzer (#2404) 2022-08-01 18:53:22 +02:00
d4n
0fad3e8b37 feat: Add method overloads to InteractionService (#2328) 2022-06-02 10:12:49 -03:00
Cenk Ergen
b465d609f0 fix: Application commands are disabled to everyone except admins by default (#2293) 2022-05-18 04:52:14 -03:00
Cenk Ergen
6fbd396832 Add Nullable ComponentTypeConverter and TypeReader (#2307)
* add nullable ComponentTypeConverter and TypeReader

* add converter and reader to interactionservice
2022-05-18 04:45:18 -03:00
Quin Lynch
e136759073 feature: Treat warnings as errors and set warning level to 5 (#2270) 2022-05-09 22:56:22 -03:00
Cenk Ergen
0d74c5cc62 fix: Implement fix for Custom Id Segments NRE (#2274) 2022-04-29 22:37:22 -03:00
Quin Lynch
d98b3cc495 feature: V2 Permissions (#2222)
* Initial V2 permissions

* add perms-v2 attributes and properties, add deprecation messages

* add perms-v2 properties to command info classes

* add perms-v2 fields to Rest/SocketApplicationCommand entities and IApplicationCommand

* fix json name of DmPermission field

Co-authored-by: Cenngo <cenk.ergen1@gmail.com>
2022-04-28 08:47:52 -03:00
Cenk Ergen
4ce1801bdf feature: Passing CustomId matches into contexts (#2136)
* add logic for passing the wild card captures into the context

* move concrete impl of IRouteSegmentMatch to internal

* Apply suggestions from code review

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

* fix build errors

* Apply suggestions from code review

Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>

Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
Co-authored-by: Armano den Boef <68127614+Rozen4334@users.noreply.github.com>
2022-04-27 11:09:30 -03:00
Armano den Boef
a744948477 feature: Global interaction post execution event. (#2213)
* Init

* Variable set to event

* Put internal above private

* Revert "Put internal above private"

This reverts commit 77784f001faa58a90edf34edc195d6942ba9b451.

* Revert "Variable set to event"

This reverts commit 2b0cb81d76e2150a8d692028486aa1d402efe8a3.

* Revert "Init"

This reverts commit 9892ce7b51d8cf2952d4ae5b67f4a2e4c7917ae2.

* Potentially improved approach
2022-04-04 18:14:36 -03:00
Cenk Ergen
d2118f02fb Adds a action delegate parameter to RespondWithModalAsync<T>() for modifying the modal (#2226)
* add modifyModal deleagate parameter to RespondWithModalAsync extension method

* change the position of the new parameter to avoid introducing a breaking change
2022-04-04 18:11:54 -03:00
Cenk Ergen
1c680db2ba add respondwithmodal methods to restinteractinmodulebase (#2227) 2022-04-04 18:11:15 -03:00
Quin Lynch
73399459ea feature: add a way to remove type readers from the interaction/command service. (#2210)
* Add remove methods

* add inline docs

Co-authored-by: Cenngo <cenk.ergen1@gmail.com>
2022-03-26 16:21:26 -03:00
KeylAmi
d656722bd9 Fix: modal response failing (#2187)
* Update bugreport.yml

* Update bugreport.yml

removed d.net reference. fixed spelling.

* Update bugreport.yml

Adjusted verbiage for clarity

* Fix for modal response failing

Credit to @Cenggo for finding issue.
2022-03-26 09:46:33 -03:00
Cenk Ergen
fb4250b88c Feature: Component TypeConverters and CustomID TypeReaders (#2169)
* fix sharded client current user

* add custom setter to group property of module builder

* rename serilazation method

* init

* create typemap and default typereaders

* add default readers

* create typereader targetting flags

* seperate custom id readers with component typeconverters

* add typereaders

* add customid readers

* clean up component info argument parsing

* remove obsolete method

* add component typeconverters to modals

* fix build errors

* add inline docs

* bug fixes

* code cleanup and refactorings

* fix build errors

* add GenerateCustomIdString method to interaction service

* add GenerateCustomIdString method to interaction service

* add inline docs to componentparameterbuilder

* add inline docs to GenerateCustomIdStringAsync method
2022-03-09 16:10:00 -04:00
Quin Lynch
c80067425a Display name support for enum type converter (#2156)
* Display name support for enum type converter

* allow display attribute on enum type converter

* update docs/examples to include enum Display sample

* Revert "allow display attribute on enum type converter"

This reverts commit a0eec5b7555d366f9de7421f6fcf6bc71f2a4557.

* adds ChoiceDisplay for enum type converters

* Update EnumChoiceAttribute.cs

* fix renamed folder issue

* fix namespace

Co-authored-by: Xeno <eliotd@gmail.com>
2022-03-02 19:23:51 -04:00
Quin Lynch
9ba64f62d1 Interaction Service Complex Parameters (#2155)
* Interaction Service Complex Parameters

* add complex parameters

* add complex parameters

* fix build errors

* add argument parsing

* add nested complex parameter checks

* add inline docs

* add preferred constructor declaration

* fix autocompletehandlers for complex parameters

* make GetConstructor private

* use flattened params in ToProps method

* make DiscordType of SlashParameter nullable

* add docs to Flattened parameters collection and move the GetComplexParameterCtor method

* add inline docs to SlashCommandParameterBuilder.ComplexParameterFields

* add check for validating required/optinal parameter order

* implement change requests

* return internal ParseResult as ExecuteResult

Co-Authored-By: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>

* fix merge errors

Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
2022-03-02 19:23:39 -04:00
Armano den Boef
01735c82fb Fix ToString() on CommandInfo (#2094) 2022-02-11 21:45:36 -04:00
Quin Lynch
7e1b8c9db0 Fix channel being null in DMs on Interactions (#2098) 2022-02-11 21:43:32 -04:00
Quin Lynch
c8f175e11a Feature: Implement modals (#2087)
* Implement Modals (#428)

* Socket Modal Support

* fix shareded client support

* Properly use `HasResponded` instead of `_hasResponded`

* `ModalBuilder` and `TextInputBuilder` validation.

* make orginisation more consistant.

* Rest Modals.

* Docs + add missing methods

* fix message signatures and missing abstract members

* modal changes

* um?????

* update modal docs

* update docs - again for some reason

* cleanup

* fix message signatures

* add modal commands support to interaction service

* Fix _hasResponded

* update to new unsupported standard.

* Sending modals with Interaction service.

* fix spelling in ComponentBuilder

* sending IModals when responding to interactions

* interaction service modals

* fix rest modals

* spelling and minor improvements.

* improve interaction service modal proformance

* use precompiled lambda for interaction service modals

* respect user compiled lambda choice

* changes to modals in the interaction service (more)

* support compiled lambdas in modal properties.

* modal interactions tweaks

* fix inline doc

* more modal docs

* configure responce to faild modal component

* init

* solve runtime errors

* solve build errors

* add default value parsing

* make modal info caching static

* make ModalUtils static

* add inline docs

* fix build errors

* code cleanup

* Introduce Required and Label properties as seperate attributes.

* replace internal dictionary of ModalInfo with a list

* change input building logic of modals

* update RespondWithModalAsync method

* add initial value parameter back to ModalTextInput and fix optional modal field

* add missing inline docs

* dispose the reference modal instance after building

* code cleanup on modalcommandbuilder

* Update docs/guides/int_basics/message-components/text-input.md

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

* Update docs/guides/int_basics/message-components/text-input.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_basics/modals/intro.md

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

* Update docs/guides/int_framework/intro.md

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

* Update docs/guides/int_framework/intro.md

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

* Update docs/guides/int_framework/samples/intro/modal.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteractionData.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/MessageComponents/TextInputComponent.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/IModalInteraction.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs

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

* Update src/Discord.Net.Core/Entities/Interactions/Modals/ModalBuilder.cs

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

* Update src/Discord.Net.Interactions/Attributes/Commands/ModalInteractionAttribute.cs

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

* Update src/Discord.Net.Interactions/Attributes/Modals/RequiredInputAttribute.cs

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

* Update src/Discord.Net.Interactions/InteractionServiceConfig.cs

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

* Update src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs

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

* Update src/Discord.Net.WebSocket/Entities/Interaction/Modals/SocketModalData.cs

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

* update interaction service modal docs

* implements ExitOnMissingmModalField config option and adds Type field to modal info

* Add WithValue to text input builders

* Fix rare NRE on component enumeration

* Fix RequestOptions being required in some methods

* Use 'OfType' instead of 'Where'

* Remove android unsported warning

* Change publicity of properties in IInputComponeontBuilder.cs

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

* Remove complex parameter ref

Co-authored-by: CottageDwellingCat <80918250+CottageDwellingCat@users.noreply.github.com>
Co-authored-by: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com>
2022-02-09 00:17:56 -04:00
Quin Lynch
33efd8981d Add support for attachments (#2088)
* Enforce valid button styles

* support command option type 11

* missing '.'

* Added type converter.

Co-authored-by: Cat <lumitydev@gmail.com>
Co-authored-by: CottageDwellingCat <80918250+CottageDwellingCat@users.noreply.github.com>

Co-authored-by: FeroxFoxxo <feroxfoxxo@gmail.com>
Co-authored-by: Cat <lumitydev@gmail.com>
Co-authored-by: CottageDwellingCat <80918250+CottageDwellingCat@users.noreply.github.com>
2022-02-09 00:13:15 -04:00
Quin Lynch
97e54e1047 Feature: Allow modifying attachments on interactions and extend the module base (#2091) 2022-02-09 00:12:22 -04:00
Armano den Boef
b45aebf506 fix: Rest message components cannot pass through execute method (#2076)
Line 60 should be equal to line 42 here. Currently rest interactions cant execute the messagecomponent handlers.
2022-02-03 14:04:23 -04:00
Cenk Ergen
1917961ee3 Fix Channel Types Attribute (#2066)
* fix channeltypes attribute

* fix channeltypes attribute
2022-01-30 02:54:48 -04:00
Quin Lynch
9a52d05637 Add search methods to InteractionService (#2041) 2022-01-14 07:52:43 -04:00
Cenk Ergen
4ed4718e18 Add Construct Method to InteractionModuleBase and Fix NRE on User-Built Module Creation (#2016) 2022-01-11 02:52:46 -04:00
Cenk Ergen
4b7cda01a6 Fix IsTopLevelCommand (#2025)
* init

* fix IsTopLevel for ModuleInfo and CommandInfo
2022-01-08 04:34:02 -04:00
Cenk Ergen
9594ccc6d9 Remove .ToLower from group name registration (#2024) 2022-01-08 04:13:27 -04:00
Cenk Ergen
944a0def97 Fix InteractionContext.Guild (#2014)
* fix InteractionContext.Guild

* remove user parameter from InteractionContext ctor
2022-01-05 18:24:33 -04:00
Cenk Ergen
68e3bed4ff Add user-built AddCommand overloads to ModuleBuilder (#2015)
* add user-built AddCommand overloads to ModuleBuilder

* fix inline docs
2022-01-05 18:24:18 -04:00
Quin Lynch
ccc365edfd Add nullable type converter to Interaction service (#1996)
* Add nullable type converter to Interaction service

* update NullableConverter CanConvertTo body
2021-12-24 10:37:57 -04:00
Quin Lynch
cb1aad308b Make module service scopes optional (#1997)
Co-Authored-By: Cenk Ergen <57065323+Cenngo@users.noreply.github.com>
2021-12-24 10:37:47 -04:00
Quin Lynch
9f124b25ab Add before and after execute async (#1998) 2021-12-24 10:37:36 -04:00
Cenk Ergen
a2f57f8cc6 fix requireRole attribute of interaction service (#1980) 2021-12-20 12:41:55 -04:00