Table of Contents

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 InteractionService

The underlying Interaction Service.

name string

Name of this module.

parent ModuleBuilder

Parent module of this sub-module.

Properties

Attributes

Gets a collection of the attributes of this module.

public IReadOnlyList<Attribute> Attributes { get; }

Property Value

IReadOnlyList<Attribute>

AutocompleteCommands

Gets a collection of the Autocomplete Commands of this module.

public IReadOnlyList<AutocompleteCommandBuilder> AutocompleteCommands { get; }

Property Value

IReadOnlyList<AutocompleteCommandBuilder>

ComponentCommands

Gets a collection of the Component Commands of this module.

public IReadOnlyList<ComponentCommandBuilder> ComponentCommands { get; }

Property Value

IReadOnlyList<ComponentCommandBuilder>

ContextCommands

Gets a collection of the Context Commands of this module.

public IReadOnlyList<ContextCommandBuilder> ContextCommands { get; }

Property Value

IReadOnlyList<ContextCommandBuilder>

ContextTypes

Gets or sets the context types this command can be executed in.

public HashSet<InteractionContextType> ContextTypes { get; set; }

Property Value

HashSet<InteractionContextType>

DefaultMemberPermissions

Gets the default permissions needed for executing this command.

public GuildPermission? DefaultMemberPermissions { get; set; }

Property Value

GuildPermission?

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

bool

Description

Gets and sets the description of this module.

public string Description { get; set; }

Property Value

string

DontAutoRegister

Gets and sets whether this has a DontAutoRegisterAttribute.

public bool DontAutoRegister { get; set; }

Property Value

bool

IntegrationTypes

Gets or sets the install method for this command.

public HashSet<ApplicationIntegrationType> IntegrationTypes { get; set; }

Property Value

HashSet<ApplicationIntegrationType>

InteractionService

Gets the underlying Interaction Service.

public InteractionService InteractionService { get; }

Property Value

InteractionService

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

bool

IsNsfw

Gets whether this command is age restricted.

public bool IsNsfw { get; set; }

Property Value

bool

IsSlashGroup

Gets whether this has a GroupAttribute.

public bool IsSlashGroup { get; }

Property Value

bool

ModalCommands

Gets a collection of the Modal Commands of this module.

public IReadOnlyList<ModalCommandBuilder> ModalCommands { get; }

Property Value

IReadOnlyList<ModalCommandBuilder>

Name

Gets the name of this module.

public string Name { get; }

Property Value

string

Parent

Gets the parent module if this module is a sub-module.

public ModuleBuilder Parent { get; }

Property Value

ModuleBuilder

Preconditions

Gets a collection of the preconditions of this module.

public IReadOnlyCollection<PreconditionAttribute> Preconditions { get; }

Property Value

IReadOnlyCollection<PreconditionAttribute>

SlashCommands

Gets a collection of the Slash Commands of this module.

public IReadOnlyList<SlashCommandBuilder> SlashCommands { get; }

Property Value

IReadOnlyList<SlashCommandBuilder>

SlashGroupName

Gets and sets the group name of this module.

public string SlashGroupName { get; set; }

Property Value

string

SubModules

Gets a collection of the sub-modules of this module.

public IReadOnlyList<ModuleBuilder> SubModules { get; }

Property Value

IReadOnlyList<ModuleBuilder>

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 string

Name of the command.

callback ExecuteCallback

Command 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 string

Name of the command.

callback ExecuteCallback

Command 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 string

Name of the command.

callback ExecuteCallback

Command 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 string

Name of the command.

callback ExecuteCallback

Command 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 string

Name of the command.

callback ExecuteCallback

Command callback to be executed.

configure Action<SlashCommandBuilder>

SlashCommandBuilder factory.

Returns

ModuleBuilder

The builder instance.

SetEnabledInDm(bool)

[Obsolete("This method will be deprecated soon. Use WithContextTypes instead.")]
public ModuleBuilder SetEnabledInDm(bool isEnabled)

Parameters

isEnabled bool

New value of the IsEnabledInDm.

Returns

ModuleBuilder

The builder instance.

SetNsfw(bool)

Sets IsNsfw.

public ModuleBuilder SetNsfw(bool isNsfw)

Parameters

isNsfw bool

New value of the IsNsfw.

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)

public ModuleBuilder WithDefaultMemberPermissions(GuildPermission permissions)

Parameters

permissions GuildPermission

New value of the DefaultMemberPermissions.

Returns

ModuleBuilder

The builder instance.

WithDefaultPermission(bool)

[Obsolete("To be deprecated soon, use SetEnabledInDm and WithDefaultMemberPermissions instead.")]
public ModuleBuilder WithDefaultPermission(bool permission)

Parameters

permission bool

New value of the DefaultPermission.

Returns

ModuleBuilder

The builder instance.

WithDescription(string)

public ModuleBuilder WithDescription(string description)

Parameters

description string

New value of the Description.

Returns

ModuleBuilder

The builder instance.

WithGroupName(string)

public ModuleBuilder WithGroupName(string name)

Parameters

name string

New 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.