![]() Interaction service complex parameter constructors are prioritized in the following order: Public async Task CreateVector(int x, int y, int z) Public async Task CreateVector(Vector3 vector3) Both of the commands below are displayed to the users identically. ![]() TypeConverter pattern is used to parse the constructor methods objects. If nothing is specified, the InteractionService defaults to the only public constructor of the type. Preferred constructor of a Type can be specified either by passing a Type to the or tagging a type constructor with the. This allows users to create slash command options using an object's constructor allowing complex objects to be created which cannot be infered from only one input value.Ĭonstructor methods support every attribute type that can be used with the regular slash commands (, etc. You can specify the permitted max/min value for a number type parameter using the MaxValueAttribute and MinValueAttribute. In this case, user can only input Stage Channels and Text Channels to this parameter. Public async Task Command( IChannel channel) Channel TypesĬhannel types for an IChannel parameter can also be restricted using the ChannelTypesAttribute. This Slash Command will be displayed exactly the same as the previous example. You can also use the ChoiceDisplay attribute to change how they appear in the choice menu. In most cases, you can use an enum to replace the separate choice attributes in a command. Parameter Summaryīy using the SummaryAttribute you can customize the displayed name and description of a parameter string inputĬhoiceAttribute can be used to add choices to a parameter. int count = 0) will be displayed as optional parameters on Discord Client. *You can use more specialized implementations of IChannel to restrict the allowed channel types for a channel type option. Use the attribute on enum values to prevent them from getting registered.) enum (Values are registered as multiple choice options and are enforced by Discord.Pascal casing into Discord compliant parameter names('parameterName' => 'parameter-name').īy default, your methods can feature the following parameter types: InteractionService also features a pascal casing seperator for formatting parameter names with You must name your parameters in accordance with Slash Commands can have up to 25 method parameters. You can check Discords Application Command Naming Guidelines here. Slash Commands are created using the SlashCommandAttribute.Įvery Slash Command must declare a name and a description. You should avoid using long running code in your command module.ĭepending on your setup, long running code may block the Gateway thread of your bot, interrupting its connection to Discord. Valid Interaction Commands must comply with the following requirements:Ī TypeConverter that is capable of parsing type in question must be registered to the InteractionService instance. DeleteOriginalResponseAsync() => Delete the original interaction response.ReplyAsync() => Send a message to the origin channel of the interaction.FollowupAsync() => Create a followup message for an interaction.RespondAsync() => Respond to the interaction. ![]() Methods to configure the modules behaviour.Įvery command module exposes a set of helper methods, namely: AfterExecute (executed after a command execution concludes).BeforeExecute (executed before a command execution starts).OnModuleBuilding (executed after the module is built).Optionally you can override the included : Var _interactionService = new InteractionService(_client.Rest) Īttribute based Interaction handlers must be defined within a command module class.Ĭommand modules are responsible for executing the Interaction handlers and providing them with the necessary execution info and helper functions.Ī new module instance is created before a command execution starts then it will be disposed right after the method returns. A different approach to passing in a restclient is also possible. InteractionServiceConfig to change the services behaviour to suit your needs. Optionally you can provide the InteractionService constructor with a To start using the Interaction Service, you need to create a service instance. The Interaction Service provides an attribute based framework for creating Discord Interaction handlers. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |