Class InteractionService
Provides the framework for building and registering Discord Application Commands.
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public class InteractionService : IDisposable
Constructors
| Improve this Doc View SourceInteractionService(DiscordRestClient, InteractionServiceConfig)
Initialize a InteractionService with provided configurations.
Declaration
public InteractionService(DiscordRestClient discord, InteractionServiceConfig config = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordRestClient | discord | The discord client. |
InteractionServiceConfig | config | The configuration class. |
InteractionService(BaseSocketClient, InteractionServiceConfig)
Initialize a InteractionService with provided configurations.
Declaration
public InteractionService(BaseSocketClient discord, InteractionServiceConfig config = null)
Parameters
Type | Name | Description |
---|---|---|
BaseSocketClient | discord | The discord client. |
InteractionServiceConfig | config | The configuration class. |
InteractionService(DiscordShardedClient, InteractionServiceConfig)
Initialize a InteractionService with provided configurations.
Declaration
public InteractionService(DiscordShardedClient discord, InteractionServiceConfig config = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordShardedClient | discord | The discord client. |
InteractionServiceConfig | config | The configuration class. |
InteractionService(DiscordSocketClient, InteractionServiceConfig)
Initialize a InteractionService with provided configurations.
Declaration
public InteractionService(DiscordSocketClient discord, InteractionServiceConfig config = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordSocketClient | discord | The discord client. |
InteractionServiceConfig | config | The configuration class. |
Properties
| Improve this Doc View SourceComponentCommands
Represents all Component Commands loaded within InteractionService.
Declaration
public IReadOnlyCollection<ComponentCommandInfo> ComponentCommands { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<ComponentCommandInfo> |
ContextCommands
Represents all Context Commands loaded within InteractionService.
Declaration
public IReadOnlyList<ContextCommandInfo> ContextCommands { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<ContextCommandInfo> |
LocalizationManager
Get the ILocalizationManager used by this Interaction Service instance to localize strings.
Declaration
public ILocalizationManager LocalizationManager { get; set; }
Property Value
Type | Description |
---|---|
ILocalizationManager |
ModalCommands
Represents all Modal Commands loaded within InteractionService.
Declaration
public IReadOnlyCollection<ModalCommandInfo> ModalCommands { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<ModalCommandInfo> |
Modals
Gets a collection of the cached ModalInfo classes that are referenced in registered ModalCommandInfos.
Declaration
public IReadOnlyCollection<ModalInfo> Modals { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<ModalInfo> |
Modules
Represents all modules loaded within InteractionService.
Declaration
public IReadOnlyList<ModuleInfo> Modules { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<ModuleInfo> |
RestClient
Rest client to be used to register application commands.
Declaration
public DiscordRestClient RestClient { get; }
Property Value
Type | Description |
---|---|
DiscordRestClient |
SlashCommands
Represents all Slash Commands loaded within InteractionService.
Declaration
public IReadOnlyList<SlashCommandInfo> SlashCommands { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<SlashCommandInfo> |
Methods
| Improve this Doc View SourceAddCommandsGloballyAsync(Boolean, IApplicationCommandInfo[])
Register Application Commands from commands
as global commands.
Declaration
public async Task<IReadOnlyCollection<RestGlobalCommand>> AddCommandsGloballyAsync(bool deleteMissing = false, params IApplicationCommandInfo[] commands)
Parameters
Type | Name | Description |
---|---|---|
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
IApplicationCommandInfo[] | commands | Commands to be registered to Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGlobalCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
Remarks
Commands will be registered as standalone commands, if you want the GroupAttribute to take effect, use AddModulesToGuildAsync(IGuild, Boolean, ModuleInfo[]). Registering a commands without group names might cause the command traversal to fail.
AddCommandsToGuildAsync(IGuild, Boolean, ICommandInfo[])
Register Application Commands from commands
to a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> AddCommandsToGuildAsync(IGuild guild, bool deleteMissing = false, params ICommandInfo[] commands)
Parameters
Type | Name | Description |
---|---|---|
IGuild | guild | The target guild. |
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
ICommandInfo[] | commands | Commands to be registered to Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
Remarks
Commands will be registered as standalone commands, if you want the GroupAttribute to take effect, use AddModulesToGuildAsync(IGuild, Boolean, ModuleInfo[]). Registering a commands without group names might cause the command traversal to fail.
AddCommandsToGuildAsync(UInt64, Boolean, ICommandInfo[])
Register Application Commands from commands
to a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> AddCommandsToGuildAsync(ulong guildId, bool deleteMissing = false, params ICommandInfo[] commands)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | guildId | The target guild ID. |
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
ICommandInfo[] | commands | Commands to be registered to Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
Remarks
Commands will be registered as standalone commands, if you want the GroupAttribute to take effect, use AddModulesToGuildAsync(UInt64, Boolean, ModuleInfo[]). Registering a commands without group names might cause the command traversal to fail.
AddComponentTypeConverter(Type, ComponentTypeConverter)
Add a concrete type ComponentTypeConverter.
Declaration
public void AddComponentTypeConverter(Type type, ComponentTypeConverter converter)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Primary target |
ComponentTypeConverter | converter | The ComponentTypeConverter instance. |
AddComponentTypeConverter<T>(ComponentTypeConverter)
Add a concrete type ComponentTypeConverter.
Declaration
public void AddComponentTypeConverter<T>(ComponentTypeConverter converter)
Parameters
Type | Name | Description |
---|---|---|
ComponentTypeConverter | converter | The ComponentTypeConverter instance. |
Type Parameters
Name | Description |
---|---|
T | Primary target |
AddGenericComponentTypeConverter(Type, Type)
Add a generic type ComponentTypeConverter<T>.
Declaration
public void AddGenericComponentTypeConverter(Type targetType, Type converterType)
Parameters
Type | Name | Description |
---|---|---|
Type | targetType | Generic Type constraint of the |
Type | converterType | Type of the ComponentTypeConverter<T>. |
AddGenericComponentTypeConverter<T>(Type)
Add a generic type ComponentTypeConverter<T>.
Declaration
public void AddGenericComponentTypeConverter<T>(Type converterType)
Parameters
Type | Name | Description |
---|---|---|
Type | converterType | Type of the ComponentTypeConverter<T>. |
Type Parameters
Name | Description |
---|---|
T | Generic Type constraint of the |
AddGenericTypeConverter(Type, Type)
Add a generic type TypeConverter<T>.
Declaration
public void AddGenericTypeConverter(Type targetType, Type converterType)
Parameters
Type | Name | Description |
---|---|---|
Type | targetType | Generic Type constraint of the |
Type | converterType | Type of the TypeConverter<T>. |
AddGenericTypeConverter<T>(Type)
Add a generic type TypeConverter<T>.
Declaration
public void AddGenericTypeConverter<T>(Type converterType)
Parameters
Type | Name | Description |
---|---|---|
Type | converterType | Type of the TypeConverter<T>. |
Type Parameters
Name | Description |
---|---|
T | Generic Type constraint of the |
AddGenericTypeReader(Type, Type)
Add a generic type TypeReader<T>.
Declaration
public void AddGenericTypeReader(Type targetType, Type readerType)
Parameters
Type | Name | Description |
---|---|---|
Type | targetType | Generic Type constraint of the |
Type | readerType | Type of the TypeReader<T>. |
AddGenericTypeReader<T>(Type)
Add a generic type TypeReader<T>.
Declaration
public void AddGenericTypeReader<T>(Type readerType)
Parameters
Type | Name | Description |
---|---|---|
Type | readerType | Type of the TypeReader<T>. |
Type Parameters
Name | Description |
---|---|
T | Generic Type constraint of the |
AddModalInfo<T>()
Declaration
public ModalInfo AddModalInfo<T>()
where T : class, IModal
Returns
Type | Description |
---|---|
ModalInfo | The built ModalInfo instance. |
Type Parameters
Name | Description |
---|---|
T | Type of IModal to be loaded. |
AddModuleAsync(Type, IServiceProvider)
Add a command module from a
Declaration
public async Task<ModuleInfo> AddModuleAsync(Type type, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the module. |
IServiceProvider | services | The |
Returns
Type | Description |
---|---|
Task<ModuleInfo> | A task representing the operation for adding the module. The task result contains the built module. |
AddModuleAsync<T>(IServiceProvider)
Add a command module from a
Declaration
public Task<ModuleInfo> AddModuleAsync<T>(IServiceProvider services)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | services | The |
Returns
Type | Description |
---|---|
Task<ModuleInfo> | A task representing the operation for adding the module. The task result contains the built module. |
Type Parameters
Name | Description |
---|---|
T | Type of the module. |
AddModulesAsync(Assembly, IServiceProvider)
Discover and load command modules from an
Declaration
public async Task<IEnumerable<ModuleInfo>> AddModulesAsync(Assembly assembly, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | |
IServiceProvider | services | The |
Returns
Type | Description |
---|---|
Task<IEnumerable<ModuleInfo>> | A task representing the operation for adding modules. The task result contains a collection of the modules added. |
AddModulesGloballyAsync(Boolean, ModuleInfo[])
Register Application Commands from modules provided in modules
as global commands.
Declaration
public async Task<IReadOnlyCollection<RestGlobalCommand>> AddModulesGloballyAsync(bool deleteMissing = false, params ModuleInfo[] modules)
Parameters
Type | Name | Description |
---|---|---|
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
ModuleInfo[] | modules | Modules to be registered to Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGlobalCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
AddModulesToGuildAsync(IGuild, Boolean, ModuleInfo[])
Register Application Commands from modules provided in modules
to a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> AddModulesToGuildAsync(IGuild guild, bool deleteMissing = false, params ModuleInfo[] modules)
Parameters
Type | Name | Description |
---|---|---|
IGuild | guild | The target guild. |
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
ModuleInfo[] | modules | Modules to be registered to Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
AddModulesToGuildAsync(UInt64, Boolean, ModuleInfo[])
Register Application Commands from modules provided in modules
to a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> AddModulesToGuildAsync(ulong guildId, bool deleteMissing = false, params ModuleInfo[] modules)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | guildId | The target guild ID. |
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
ModuleInfo[] | modules | Modules to be registered to Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
AddTypeConverter(Type, TypeConverter)
Add a concrete type TypeConverter.
Declaration
public void AddTypeConverter(Type type, TypeConverter converter)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Primary target |
TypeConverter | converter | The TypeConverter instance. |
AddTypeConverter<T>(TypeConverter)
Add a concrete type TypeConverter.
Declaration
public void AddTypeConverter<T>(TypeConverter converter)
Parameters
Type | Name | Description |
---|---|---|
TypeConverter | converter | The TypeConverter instance. |
Type Parameters
Name | Description |
---|---|
T | Primary target |
AddTypeReader(Type, TypeReader)
Add a concrete type TypeReader.
Declaration
public void AddTypeReader(Type type, TypeReader reader)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Primary target |
TypeReader | reader | The TypeReader instance. |
AddTypeReader<T>(TypeReader)
Add a concrete type TypeReader.
Declaration
public void AddTypeReader<T>(TypeReader reader)
Parameters
Type | Name | Description |
---|---|---|
TypeReader | reader | The TypeReader instance. |
Type Parameters
Name | Description |
---|---|
T | Primary target |
CreateModuleAsync(String, IServiceProvider, Action<ModuleBuilder>)
Create and loads a ModuleInfo using a builder factory.
Declaration
public async Task<ModuleInfo> CreateModuleAsync(string name, IServiceProvider services, Action<ModuleBuilder> buildFunc)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the module. |
IServiceProvider | services | The |
Action<ModuleBuilder> | buildFunc | Module builder factory. |
Returns
Type | Description |
---|---|
Task<ModuleInfo> | A task representing the operation for adding modules. The task result contains the built module instance. |
Dispose()
Declaration
public void Dispose()
ExecuteCommandAsync(IInteractionContext, IServiceProvider)
Execute a Command from a given IInteractionContext.
Declaration
public async Task<IResult> ExecuteCommandAsync(IInteractionContext context, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | Name context of the command. |
IServiceProvider | services | The service to be used in the command's dependency injection. |
Returns
Type | Description |
---|---|
Task<IResult> | A task representing the command execution process. The task result contains the result of the execution. |
GenerateCustomIdStringAsync(String, IServiceProvider, Object[])
Serialize and format multiple objects into a Custom Id string.
Declaration
public async Task<string> GenerateCustomIdStringAsync(string format, IServiceProvider services, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | format | A composite format string. |
IServiceProvider | services |
|
Object[] | args | Objects to be serialized. |
Returns
Type | Description |
---|---|
Task<String> | A task representing the conversion process. The task result contains the result of the conversion. |
GetComponentCommandInfo<TModule>(String)
Gets a ComponentCommandInfo.
Declaration
public ComponentCommandInfo GetComponentCommandInfo<TModule>(string methodName)
where TModule : class
Parameters
Type | Name | Description |
---|---|---|
String | methodName | Method name of the handler, use of langword_csharp_nameof is recommended. |
Returns
Type | Description |
---|---|
ComponentCommandInfo | ComponentCommandInfo instance for this command. |
Type Parameters
Name | Description |
---|---|
TModule | Declaring module type of this command, must be a type of InteractionModuleBase<T>. |
GetContextCommandInfo<TModule>(String)
Gets a ContextCommandInfo.
Declaration
public ContextCommandInfo GetContextCommandInfo<TModule>(string methodName)
where TModule : class
Parameters
Type | Name | Description |
---|---|---|
String | methodName | Method name of the handler, use of langword_csharp_nameof is recommended. |
Returns
Type | Description |
---|---|
ContextCommandInfo | ContextCommandInfo instance for this command. |
Type Parameters
Name | Description |
---|---|
TModule | Declaring module type of this command, must be a type of InteractionModuleBase<T>. |
GetModuleInfo<TModule>()
Gets a built ModuleInfo.
Declaration
public ModuleInfo GetModuleInfo<TModule>()
where TModule : class
Returns
Type | Description |
---|---|
ModuleInfo | ModuleInfo instance for this module. |
Type Parameters
Name | Description |
---|---|
TModule | Type of the module, must be a type of InteractionModuleBase<T>. |
GetSlashCommandInfo<TModule>(String)
Gets a SlashCommandInfo.
Declaration
public SlashCommandInfo GetSlashCommandInfo<TModule>(string methodName)
where TModule : class
Parameters
Type | Name | Description |
---|---|---|
String | methodName | Method name of the handler, use of langword_csharp_nameof is recommended. |
Returns
Type | Description |
---|---|
SlashCommandInfo | SlashCommandInfo instance for this command. |
Type Parameters
Name | Description |
---|---|
TModule | Declaring module type of this command, must be a type of InteractionModuleBase<T>. |
ModifyContextCommandPermissionsAsync(ContextCommandInfo, IGuild, ApplicationCommandPermission[])
Modify the command permissions of the matching Discord Slash Command.
Declaration
public async Task<GuildApplicationCommandPermission> ModifyContextCommandPermissionsAsync(ContextCommandInfo command, IGuild guild, params ApplicationCommandPermission[] permissions)
Parameters
Type | Name | Description |
---|---|---|
ContextCommandInfo | command | The Context Command. |
IGuild | guild | Target guild. |
ApplicationCommandPermission[] | permissions | New permission values. |
Returns
Type | Description |
---|---|
Task<GuildApplicationCommandPermission> | The active command permissions after the modification. |
ModifyContextCommandPermissionsAsync(ContextCommandInfo, UInt64, ApplicationCommandPermission[])
Modify the command permissions of the matching Discord Slash Command.
Declaration
public async Task<GuildApplicationCommandPermission> ModifyContextCommandPermissionsAsync(ContextCommandInfo command, ulong guildId, params ApplicationCommandPermission[] permissions)
Parameters
Type | Name | Description |
---|---|---|
ContextCommandInfo | command | The Context Command. |
UInt64 | guildId | Target guild ID. |
ApplicationCommandPermission[] | permissions | New permission values. |
Returns
Type | Description |
---|---|
Task<GuildApplicationCommandPermission> | The active command permissions after the modification. |
ModifySlashCommandPermissionsAsync(ModuleInfo, IGuild, ApplicationCommandPermission[])
Modify the command permissions of the matching Discord Slash Command.
Declaration
public async Task<GuildApplicationCommandPermission> ModifySlashCommandPermissionsAsync(ModuleInfo module, IGuild guild, params ApplicationCommandPermission[] permissions)
Parameters
Type | Name | Description |
---|---|---|
ModuleInfo | module | Module representing the top level Slash Command. |
IGuild | guild | Target guild. |
ApplicationCommandPermission[] | permissions | New permission values. |
Returns
Type | Description |
---|---|
Task<GuildApplicationCommandPermission> | The active command permissions after the modification. |
ModifySlashCommandPermissionsAsync(ModuleInfo, UInt64, ApplicationCommandPermission[])
Modify the command permissions of the matching Discord Slash Command.
Declaration
public async Task<GuildApplicationCommandPermission> ModifySlashCommandPermissionsAsync(ModuleInfo module, ulong guildId, params ApplicationCommandPermission[] permissions)
Parameters
Type | Name | Description |
---|---|---|
ModuleInfo | module | Module representing the top level Slash Command. |
UInt64 | guildId | Target guild ID. |
ApplicationCommandPermission[] | permissions | New permission values. |
Returns
Type | Description |
---|---|
Task<GuildApplicationCommandPermission> | The active command permissions after the modification. |
ModifySlashCommandPermissionsAsync(SlashCommandInfo, IGuild, ApplicationCommandPermission[])
Modify the command permissions of the matching Discord Slash Command.
Declaration
public async Task<GuildApplicationCommandPermission> ModifySlashCommandPermissionsAsync(SlashCommandInfo command, IGuild guild, params ApplicationCommandPermission[] permissions)
Parameters
Type | Name | Description |
---|---|---|
SlashCommandInfo | command | The Slash Command. |
IGuild | guild | Target guild. |
ApplicationCommandPermission[] | permissions | New permission values. |
Returns
Type | Description |
---|---|
Task<GuildApplicationCommandPermission> | The active command permissions after the modification. |
ModifySlashCommandPermissionsAsync(SlashCommandInfo, UInt64, ApplicationCommandPermission[])
Modify the command permissions of the matching Discord Slash Command.
Declaration
public async Task<GuildApplicationCommandPermission> ModifySlashCommandPermissionsAsync(SlashCommandInfo command, ulong guildId, params ApplicationCommandPermission[] permissions)
Parameters
Type | Name | Description |
---|---|---|
SlashCommandInfo | command | The Slash Command. |
UInt64 | guildId | Target guild ID. |
ApplicationCommandPermission[] | permissions | New permission values. |
Returns
Type | Description |
---|---|
Task<GuildApplicationCommandPermission> | The active command permissions after the modification. |
RegisterCommandsGloballyAsync(Boolean)
Register Application Commands from ContextCommands and SlashCommands to Discord on in global scope.
Declaration
public async Task<IReadOnlyCollection<RestGlobalCommand>> RegisterCommandsGloballyAsync(bool deleteMissing = true)
Parameters
Type | Name | Description |
---|---|---|
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGlobalCommand>> | A task representing the command registration process. The task result contains the active global application commands of bot. |
RegisterCommandsToGuildAsync(UInt64, Boolean)
Register Application Commands from ContextCommands and SlashCommands to a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> RegisterCommandsToGuildAsync(ulong guildId, bool deleteMissing = true)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | guildId | Id of the target guild. |
Boolean | deleteMissing | If false, this operation will not delete the commands that are missing from InteractionService. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command registration process. The task result contains the active application commands of the target guild. |
RemoveModuleAsync(ModuleInfo)
Remove a command module.
Declaration
public async Task<bool> RemoveModuleAsync(ModuleInfo module)
Parameters
Type | Name | Description |
---|---|---|
ModuleInfo | module | The ModuleInfo to be removed from the service. |
Returns
Type | Description |
---|---|
Task<Boolean> | A task that represents the asynchronous removal operation. The task result contains a value that
indicates whether the |
RemoveModuleAsync(Type)
Remove a command module.
Declaration
public async Task<bool> RemoveModuleAsync(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The |
Returns
Type | Description |
---|---|
Task<Boolean> | A task that represents the asynchronous removal operation. The task result contains a value that indicates whether the module is successfully removed. |
RemoveModuleAsync<T>()
Remove a command module.
Declaration
public Task<bool> RemoveModuleAsync<T>()
Returns
Type | Description |
---|---|
Task<Boolean> | A task that represents the asynchronous removal operation. The task result contains a value that indicates whether the module is successfully removed. |
Type Parameters
Name | Description |
---|---|
T | The |
RemoveModulesFromGuildAsync(IGuild, ModuleInfo[])
Unregister Application Commands from modules provided in modules
from a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> RemoveModulesFromGuildAsync(IGuild guild, params ModuleInfo[] modules)
Parameters
Type | Name | Description |
---|---|---|
IGuild | guild | The target guild. |
ModuleInfo[] | modules | Modules to be deregistered from Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command de-registration process. The task result contains the active application commands of the target guild. |
RemoveModulesFromGuildAsync(UInt64, ModuleInfo[])
Unregister Application Commands from modules provided in modules
from a guild.
Declaration
public async Task<IReadOnlyCollection<RestGuildCommand>> RemoveModulesFromGuildAsync(ulong guildId, params ModuleInfo[] modules)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | guildId | The target guild ID. |
ModuleInfo[] | modules | Modules to be deregistered from Discord. |
Returns
Type | Description |
---|---|
Task<IReadOnlyCollection<RestGuildCommand>> | A task representing the command de-registration process. The task result contains the active application commands of the target guild. |
SearchAutocompleteCommand(IAutocompleteInteraction)
Search the registered slash commands using a IAutocompleteInteraction.
Declaration
public SearchResult<AutocompleteCommandInfo> SearchAutocompleteCommand(IAutocompleteInteraction autocompleteInteraction)
Parameters
Type | Name | Description |
---|---|---|
IAutocompleteInteraction | autocompleteInteraction | Interaction entity to perform the search with. |
Returns
Type | Description |
---|---|
SearchResult<AutocompleteCommandInfo> | The search result. When successful, result contains the found AutocompleteCommandInfo. |
SearchComponentCommand(IComponentInteraction)
Search the registered slash commands using a IComponentInteraction.
Declaration
public SearchResult<ComponentCommandInfo> SearchComponentCommand(IComponentInteraction componentInteraction)
Parameters
Type | Name | Description |
---|---|---|
IComponentInteraction | componentInteraction | Interaction entity to perform the search with. |
Returns
Type | Description |
---|---|
SearchResult<ComponentCommandInfo> | The search result. When successful, result contains the found ComponentCommandInfo. |
SearchMessageCommand(IMessageCommandInteraction)
Search the registered slash commands using a IMessageCommandInteraction.
Declaration
public SearchResult<ContextCommandInfo> SearchMessageCommand(IMessageCommandInteraction messageCommandInteraction)
Parameters
Type | Name | Description |
---|---|---|
IMessageCommandInteraction | messageCommandInteraction | Interaction entity to perform the search with. |
Returns
Type | Description |
---|---|
SearchResult<ContextCommandInfo> | The search result. When successful, result contains the found ContextCommandInfo. |
SearchSlashCommand(ISlashCommandInteraction)
Search the registered slash commands using a ISlashCommandInteraction.
Declaration
public SearchResult<SlashCommandInfo> SearchSlashCommand(ISlashCommandInteraction slashCommandInteraction)
Parameters
Type | Name | Description |
---|---|---|
ISlashCommandInteraction | slashCommandInteraction | Interaction entity to perform the search with. |
Returns
Type | Description |
---|---|
SearchResult<SlashCommandInfo> | The search result. When successful, result contains the found SlashCommandInfo. |
SearchUserCommand(IUserCommandInteraction)
Search the registered slash commands using a IUserCommandInteraction.
Declaration
public SearchResult<ContextCommandInfo> SearchUserCommand(IUserCommandInteraction userCommandInteraction)
Parameters
Type | Name | Description |
---|---|---|
IUserCommandInteraction | userCommandInteraction | Interaction entity to perform the search with. |
Returns
Type | Description |
---|---|
SearchResult<ContextCommandInfo> | The search result. When successful, result contains the found ContextCommandInfo. |
SerializeValueAsync<T>(T, IServiceProvider)
Serialize an object using a TypeReader into a
Declaration
public Task<string> SerializeValueAsync<T>(T obj, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
T | obj | Object to be serialized. |
IServiceProvider | services | Services that will be passed on to the TypeReader. |
Returns
Type | Description |
---|---|
Task<String> | A task representing the conversion process. The task result contains the result of the conversion. |
Type Parameters
Name | Description |
---|---|
T | Type of the object to be serialized. |
Remarks
Removing a TypeReader from the InteractionService will not dereference the TypeReader from the loaded module/command instances. You need to reload the modules for the changes to take effect.
TryRemoveGenericTypeReader(Type, out Type)
Removes a generic type reader from the given type.
Declaration
public bool TryRemoveGenericTypeReader(Type type, out Type readerType)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to remove the reader from. |
Type | readerType | The readers type if the remove operation was successful. |
Returns
Type | Description |
---|---|
Boolean | true if the remove operation was successful; otherwise false. |
Remarks
Removing a TypeReader from the InteractionService will not dereference the TypeReader from the loaded module/command instances. You need to reload the modules for the changes to take effect.
TryRemoveGenericTypeReader<T>(out Type)
Removes a generic type reader from the type T
.
Declaration
public bool TryRemoveGenericTypeReader<T>(out Type readerType)
Parameters
Type | Name | Description |
---|---|---|
Type | readerType | The removed readers type. |
Returns
Type | Description |
---|---|
Boolean | true if the remove operation was successful; otherwise false. |
Type Parameters
Name | Description |
---|---|
T | The type to remove the readers from. |
Remarks
Removing a TypeReader from the InteractionService will not dereference the TypeReader from the loaded module/command instances. You need to reload the modules for the changes to take effect.
TryRemoveTypeReader(Type, out TypeReader)
Removes a type reader for the given type.
Declaration
public bool TryRemoveTypeReader(Type type, out TypeReader reader)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to remove the reader from. |
TypeReader | reader | The reader if the resulting remove operation was successful. |
Returns
Type | Description |
---|---|
Boolean | true if the remove operation was successful; otherwise false. |
Remarks
Removing a TypeReader from the InteractionService will not dereference the TypeReader from the loaded module/command instances. You need to reload the modules for the changes to take effect.
TryRemoveTypeReader<T>(out TypeReader)
Removes a type reader for the type T
.
Declaration
public bool TryRemoveTypeReader<T>(out TypeReader reader)
Parameters
Type | Name | Description |
---|---|---|
TypeReader | reader | The reader if the resulting remove operation was successful. |
Returns
Type | Description |
---|---|
Boolean | true if the remove operation was successful; otherwise false. |
Type Parameters
Name | Description |
---|---|
T | The type to remove the readers from. |
Events
| Improve this Doc View SourceAutocompleteCommandExecuted
Occurs when a Autocomplete command is executed.
Declaration
public event Func<AutocompleteCommandInfo, IInteractionContext, IResult, Task> AutocompleteCommandExecuted
Event Type
Type | Description |
---|---|
Func<AutocompleteCommandInfo, IInteractionContext, IResult, Task> |
AutocompleteHandlerExecuted
Occurs when a AutocompleteHandler is executed.
Declaration
public event Func<IAutocompleteHandler, IInteractionContext, IResult, Task> AutocompleteHandlerExecuted
Event Type
Type | Description |
---|---|
Func<IAutocompleteHandler, IInteractionContext, IResult, Task> |
ComponentCommandExecuted
Occurs when a Message Component command is executed.
Declaration
public event Func<ComponentCommandInfo, IInteractionContext, IResult, Task> ComponentCommandExecuted
Event Type
Type | Description |
---|---|
Func<ComponentCommandInfo, IInteractionContext, IResult, Task> |
ContextCommandExecuted
Occurs when a Context Command is executed.
Declaration
public event Func<ContextCommandInfo, IInteractionContext, IResult, Task> ContextCommandExecuted
Event Type
Type | Description |
---|---|
Func<ContextCommandInfo, IInteractionContext, IResult, Task> |
InteractionExecuted
Occurs when any type of interaction is executed.
Declaration
public event Func<ICommandInfo, IInteractionContext, IResult, Task> InteractionExecuted
Event Type
Type | Description |
---|---|
Func<ICommandInfo, IInteractionContext, IResult, Task> |
Log
Occurs when a Slash Command related information is received.
Declaration
public event Func<LogMessage, Task> Log
Event Type
Type | Description |
---|---|
Func<LogMessage, Task> |
ModalCommandExecuted
Occurs when a Modal command is executed.
Declaration
public event Func<ModalCommandInfo, IInteractionContext, IResult, Task> ModalCommandExecuted
Event Type
Type | Description |
---|---|
Func<ModalCommandInfo, IInteractionContext, IResult, Task> |
SlashCommandExecuted
Occurs when a Slash Command is executed.
Declaration
public event Func<SlashCommandInfo, IInteractionContext, IResult, Task> SlashCommandExecuted
Event Type
Type | Description |
---|---|
Func<SlashCommandInfo, IInteractionContext, IResult, Task> |