Class ModuleBuilder
- Namespace
- Discord.Interactions.Builders
- Assembly
- Discord.Net.Interactions.dll
Represents a builder for creating ModuleInfo.
public class ModuleBuilder
- Inheritance
-
ModuleBuilder
- Inherited Members
Constructors
ModuleBuilder(InteractionService, string, ModuleBuilder)
Initializes a new ModuleBuilder.
public ModuleBuilder(InteractionService interactionService, string name, ModuleBuilder parent = null)
Parameters
interactionService
InteractionServiceThe underlying Interaction Service.
name
stringName of this module.
parent
ModuleBuilderParent module of this sub-module.
Properties
Attributes
Gets a collection of the attributes of this module.
public IReadOnlyList<Attribute> Attributes { get; }
Property Value
AutocompleteCommands
Gets a collection of the Autocomplete Commands of this module.
public IReadOnlyList<AutocompleteCommandBuilder> AutocompleteCommands { get; }
Property Value
ComponentCommands
Gets a collection of the Component Commands of this module.
public IReadOnlyList<ComponentCommandBuilder> ComponentCommands { get; }
Property Value
ContextCommands
Gets a collection of the Context Commands of this module.
public IReadOnlyList<ContextCommandBuilder> ContextCommands { get; }
Property Value
ContextTypes
Gets or sets the context types this command can be executed in.
public HashSet<InteractionContextType> ContextTypes { get; set; }
Property Value
DefaultMemberPermissions
Gets the default permissions needed for executing this command.
public GuildPermission? DefaultMemberPermissions { get; set; }
Property Value
DefaultPermission
Gets and sets the default permission of this module.
[Obsolete("To be deprecated soon, use ContextTypes and DefaultMemberPermissions instead.")]
public bool DefaultPermission { get; set; }
Property Value
Description
Gets and sets the description of this module.
public string Description { get; set; }
Property Value
DontAutoRegister
Gets and sets whether this has a DontAutoRegisterAttribute.
public bool DontAutoRegister { get; set; }
Property Value
IntegrationTypes
Gets or sets the install method for this command.
public HashSet<ApplicationIntegrationType> IntegrationTypes { get; set; }
Property Value
InteractionService
Gets the underlying Interaction Service.
public InteractionService InteractionService { get; }
Property Value
IsEnabledInDm
Gets whether this command can be used in DMs.
[Obsolete("This property will be deprecated soon. Use ContextTypes instead.")]
public bool IsEnabledInDm { get; set; }
Property Value
IsNsfw
Gets whether this command is age restricted.
public bool IsNsfw { get; set; }
Property Value
IsSlashGroup
Gets whether this has a GroupAttribute.
public bool IsSlashGroup { get; }
Property Value
ModalCommands
Gets a collection of the Modal Commands of this module.
public IReadOnlyList<ModalCommandBuilder> ModalCommands { get; }
Property Value
Name
Gets the name of this module.
public string Name { get; }
Property Value
Parent
Gets the parent module if this module is a sub-module.
public ModuleBuilder Parent { get; }
Property Value
Preconditions
Gets a collection of the preconditions of this module.
public IReadOnlyCollection<PreconditionAttribute> Preconditions { get; }
Property Value
SlashCommands
Gets a collection of the Slash Commands of this module.
public IReadOnlyList<SlashCommandBuilder> SlashCommands { get; }
Property Value
SlashGroupName
Gets and sets the group name of this module.
public string SlashGroupName { get; set; }
Property Value
SubModules
Gets a collection of the sub-modules of this module.
public IReadOnlyList<ModuleBuilder> SubModules { get; }
Property Value
Methods
AddAttributes(params Attribute[])
Adds attributes to Attributes.
public ModuleBuilder AddAttributes(params Attribute[] attributes)
Parameters
attributes
Attribute[]New attributes to be added to Attributes.
Returns
- ModuleBuilder
The builder instance.
AddAutocompleteCommand(Action<AutocompleteCommandBuilder>)
Adds autocomplete command builder to AutocompleteCommands.
public ModuleBuilder AddAutocompleteCommand(Action<AutocompleteCommandBuilder> configure)
Parameters
configure
Action<AutocompleteCommandBuilder>AutocompleteCommands factory.
Returns
- ModuleBuilder
The builder instance.
AddComponentCommand(Action<ComponentCommandBuilder>)
Adds component command builder to ComponentCommands.
public ModuleBuilder AddComponentCommand(Action<ComponentCommandBuilder> configure)
Parameters
configure
Action<ComponentCommandBuilder>ComponentCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddComponentCommand(string, ExecuteCallback, Action<ComponentCommandBuilder>)
Adds component command builder to ComponentCommands.
public ModuleBuilder AddComponentCommand(string name, ExecuteCallback callback, Action<ComponentCommandBuilder> configure)
Parameters
name
stringName of the command.
callback
ExecuteCallbackCommand callback to be executed.
configure
Action<ComponentCommandBuilder>ComponentCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddContextCommand(Action<ContextCommandBuilder>)
Adds context command builder to ContextCommands.
public ModuleBuilder AddContextCommand(Action<ContextCommandBuilder> configure)
Parameters
configure
Action<ContextCommandBuilder>ContextCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddContextCommand(string, ExecuteCallback, Action<ContextCommandBuilder>)
Adds context command builder to ContextCommands.
public ModuleBuilder AddContextCommand(string name, ExecuteCallback callback, Action<ContextCommandBuilder> configure)
Parameters
name
stringName of the command.
callback
ExecuteCallbackCommand callback to be executed.
configure
Action<ContextCommandBuilder>ContextCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddModalCommand(Action<ModalCommandBuilder>)
Adds a modal command builder to ModalCommands.
public ModuleBuilder AddModalCommand(Action<ModalCommandBuilder> configure)
Parameters
configure
Action<ModalCommandBuilder>ModalCommands factory.
Returns
- ModuleBuilder
The builder instance.
AddModalCommand(string, ExecuteCallback, Action<ModalCommandBuilder>)
Adds a modal command builder to ModalCommands.
public ModuleBuilder AddModalCommand(string name, ExecuteCallback callback, Action<ModalCommandBuilder> configure)
Parameters
name
stringName of the command.
callback
ExecuteCallbackCommand callback to be executed.
configure
Action<ModalCommandBuilder>ModalCommands factory.
Returns
- ModuleBuilder
The builder instance.
AddModule(Action<ModuleBuilder>)
Adds sub-module builder to SubModules.
public ModuleBuilder AddModule(Action<ModuleBuilder> configure)
Parameters
configure
Action<ModuleBuilder>ModuleBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddPreconditions(params PreconditionAttribute[])
Adds preconditions to Preconditions.
public ModuleBuilder AddPreconditions(params PreconditionAttribute[] preconditions)
Parameters
preconditions
PreconditionAttribute[]New preconditions to be added to Preconditions.
Returns
- ModuleBuilder
The builder instance.
AddSlashCommand(Action<SlashCommandBuilder>)
Adds slash command builder to SlashCommands.
public ModuleBuilder AddSlashCommand(Action<SlashCommandBuilder> configure)
Parameters
configure
Action<SlashCommandBuilder>SlashCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddSlashCommand(string, ExecuteCallback, Action<AutocompleteCommandBuilder>)
Adds autocomplete command builder to AutocompleteCommands.
public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action<AutocompleteCommandBuilder> configure)
Parameters
name
stringName of the command.
callback
ExecuteCallbackCommand callback to be executed.
configure
Action<AutocompleteCommandBuilder>AutocompleteCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
AddSlashCommand(string, ExecuteCallback, Action<SlashCommandBuilder>)
Adds slash command builder to SlashCommands.
public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action<SlashCommandBuilder> configure)
Parameters
name
stringName of the command.
callback
ExecuteCallbackCommand callback to be executed.
configure
Action<SlashCommandBuilder>SlashCommandBuilder factory.
Returns
- ModuleBuilder
The builder instance.
SetEnabledInDm(bool)
Sets IsEnabledInDm.
[Obsolete("This method will be deprecated soon. Use WithContextTypes instead.")]
public ModuleBuilder SetEnabledInDm(bool isEnabled)
Parameters
isEnabled
boolNew value of the IsEnabledInDm.
Returns
- ModuleBuilder
The builder instance.
SetNsfw(bool)
Sets IsNsfw.
public ModuleBuilder SetNsfw(bool isNsfw)
Parameters
Returns
- ModuleBuilder
The builder instance.
WithContextTypes(params InteractionContextType[])
Sets the ContextTypes on this ModuleBuilder.
public ModuleBuilder WithContextTypes(params InteractionContextType[] contextTypes)
Parameters
contextTypes
InteractionContextType[]Context types the command can be executed in.
Returns
- ModuleBuilder
The builder instance.
WithDefaultMemberPermissions(GuildPermission)
Sets DefaultMemberPermissions.
public ModuleBuilder WithDefaultMemberPermissions(GuildPermission permissions)
Parameters
permissions
GuildPermissionNew value of the DefaultMemberPermissions.
Returns
- ModuleBuilder
The builder instance.
WithDefaultPermission(bool)
Sets DefaultPermission.
[Obsolete("To be deprecated soon, use SetEnabledInDm and WithDefaultMemberPermissions instead.")]
public ModuleBuilder WithDefaultPermission(bool permission)
Parameters
permission
boolNew value of the DefaultPermission.
Returns
- ModuleBuilder
The builder instance.
WithDescription(string)
Sets Description.
public ModuleBuilder WithDescription(string description)
Parameters
description
stringNew value of the Description.
Returns
- ModuleBuilder
The builder instance.
WithGroupName(string)
Sets SlashGroupName.
public ModuleBuilder WithGroupName(string name)
Parameters
name
stringNew value of the SlashGroupName.
Returns
- ModuleBuilder
The builder instance.
WithIntegrationTypes(params ApplicationIntegrationType[])
Sets the IntegrationTypes on this ModuleBuilder.
public ModuleBuilder WithIntegrationTypes(params ApplicationIntegrationType[] integrationTypes)
Parameters
integrationTypes
ApplicationIntegrationType[]Install types for this command.
Returns
- ModuleBuilder
The builder instance.