Table of Contents

Class SectionModuleBuilder

Namespace
Kook
Assembly
Kook.Net.Core.dll

Represents a section module builder for creating a SectionModule.

public class SectionModuleBuilder : IModuleBuilder, IEquatable<SectionModuleBuilder>, IEquatable<IModuleBuilder>
Inheritance
SectionModuleBuilder
Implements
Inherited Members

Constructors

SectionModuleBuilder()

Initializes a new instance of the SectionModuleBuilder class.

public SectionModuleBuilder()

SectionModuleBuilder(IElementBuilder?, SectionAccessoryMode?, IElementBuilder?)

Initializes a new instance of the SectionModuleBuilder class.

public SectionModuleBuilder(IElementBuilder? text, SectionAccessoryMode? mode = null, IElementBuilder? accessory = null)

Parameters

text IElementBuilder
mode SectionAccessoryMode?
accessory IElementBuilder

Exceptions

ArgumentException

The text is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder; or the accessory is neither an ImageElementBuilder nor ButtonElementBuilder.

SectionModuleBuilder(string?, bool, SectionAccessoryMode?, IElementBuilder?)

Initializes a new instance of the SectionModuleBuilder class.

public SectionModuleBuilder(string? text, bool isKMarkdown = false, SectionAccessoryMode? mode = null, IElementBuilder? accessory = null)

Parameters

text string
isKMarkdown bool
mode SectionAccessoryMode?
accessory IElementBuilder

Exceptions

ArgumentException

The text is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder; or the accessory is neither an ImageElementBuilder nor ButtonElementBuilder.

Properties

Accessory

Gets or sets the accessory of the section.

public IElementBuilder? Accessory { get; set; }

Property Value

IElementBuilder

An IElementBuilder representing the accessory of the section.

Exceptions

ArgumentException

The value is neither an ImageElementBuilder nor ButtonElementBuilder.

Mode

Gets or sets how the Accessory is positioned relative to the Text.

public SectionAccessoryMode? Mode { get; set; }

Property Value

SectionAccessoryMode?

A SectionAccessoryMode representing how the Accessory is positioned relative to the Text.

Text

Gets or sets the text of the section.

public IElementBuilder? Text { get; set; }

Property Value

IElementBuilder

An IElementBuilder representing the text of the section.

Exceptions

ArgumentException

The value is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder.

Type

Specifies the module type of the IModule this builder creates.

public ModuleType Type { get; }

Property Value

ModuleType

A ModuleType representing the module type of the IModule this builder creates.

Methods

Build()

Builds this builder into a SectionModule.

public SectionModule Build()

Returns

SectionModule

A SectionModule representing the built section module object.

Exceptions

ArgumentException

The Text is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder.

ArgumentException

The Accessory is neither an ImageElementBuilder nor ButtonElementBuilder.

InvalidOperationException

The ButtonElement was not positioned to the left of the Text, which is not allowed.

Equals(SectionModuleBuilder?)

Determines whether the specified SectionModuleBuilder is equal to the current SectionModuleBuilder.

public bool Equals(SectionModuleBuilder? sectionModuleBuilder)

Parameters

sectionModuleBuilder SectionModuleBuilder

The SectionModuleBuilder to compare with the current SectionModuleBuilder.

Returns

bool

true if the specified SectionModuleBuilder is equal to the current SectionModuleBuilder; otherwise, false.

Equals(object?)

Determines whether the specified SectionModuleBuilder is equal to the current SectionModuleBuilder.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current SectionModuleBuilder.

Returns

bool

true if the specified SectionModuleBuilder is equal to the current SectionModuleBuilder; otherwise, false.

Remarks

If the object passes is an SectionModuleBuilder, Equals(SectionModuleBuilder?) will be called to compare the 2 instances.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

WithAccessory(ButtonElementBuilder)

Sets the accessory of the section.

public SectionModuleBuilder WithAccessory(ButtonElementBuilder accessory)

Parameters

accessory ButtonElementBuilder

The accessory to be set for the section.

Returns

SectionModuleBuilder

The current builder.

WithAccessory(ImageElementBuilder)

Sets the accessory of the section.

public SectionModuleBuilder WithAccessory(ImageElementBuilder accessory)

Parameters

accessory ImageElementBuilder

The accessory to be set for the section.

Returns

SectionModuleBuilder

The current builder.

WithAccessory<T>(Action<T>?)

Sets the accessory of the section.

public SectionModuleBuilder WithAccessory<T>(Action<T>? action = null) where T : IElementBuilder, new()

Parameters

action Action<T>

The action to set the accessory of the section.

Returns

SectionModuleBuilder

The current builder.

Type Parameters

T

WithMode(SectionAccessoryMode)

Sets how the Accessory is positioned relative to the Text.

public SectionModuleBuilder WithMode(SectionAccessoryMode mode)

Parameters

mode SectionAccessoryMode

How the Accessory is positioned relative to the Text.

Returns

SectionModuleBuilder

The current builder.

WithText(KMarkdownElementBuilder)

Sets the text of the section.

public SectionModuleBuilder WithText(KMarkdownElementBuilder text)

Parameters

text KMarkdownElementBuilder

The text to be set for the section.

Returns

SectionModuleBuilder

The current builder.

WithText(ParagraphStructBuilder)

Sets the text of the section.

public SectionModuleBuilder WithText(ParagraphStructBuilder text)

Parameters

text ParagraphStructBuilder

The text to be set for the section.

Returns

SectionModuleBuilder

The current builder.

WithText(PlainTextElementBuilder)

Sets the text of the section.

public SectionModuleBuilder WithText(PlainTextElementBuilder text)

Parameters

text PlainTextElementBuilder

The text to be set for the section.

Returns

SectionModuleBuilder

The current builder.

WithText(string?, bool)

Sets the text of the section.

public SectionModuleBuilder WithText(string? text, bool isKMarkdown = false)

Parameters

text string

The text to be set for the section.

isKMarkdown bool

A bool indicating whether the text is in KMarkdown format; if true, the text will be set as a KMarkdownElement; if false, the text will be set as a PlainTextElement.

Returns

SectionModuleBuilder

The current builder.

WithText<T>(Action<T>?)

Sets the text of the section.

public SectionModuleBuilder WithText<T>(Action<T>? action = null) where T : IElementBuilder, new()

Parameters

action Action<T>

The action to set the text of the section.

Returns

SectionModuleBuilder

The current builder.

Type Parameters

T

Operators

operator ==(SectionModuleBuilder?, SectionModuleBuilder?)

Determines whether the specified SectionModuleBuilder is equal to the current SectionModuleBuilder.

public static bool operator ==(SectionModuleBuilder? left, SectionModuleBuilder? right)

Parameters

left SectionModuleBuilder
right SectionModuleBuilder

Returns

bool

true if the specified SectionModuleBuilder is equal to the current SectionModuleBuilder; otherwise, false.

operator !=(SectionModuleBuilder?, SectionModuleBuilder?)

Determines whether the specified SectionModuleBuilder is not equal to the current SectionModuleBuilder.

public static bool operator !=(SectionModuleBuilder? left, SectionModuleBuilder? right)

Parameters

left SectionModuleBuilder
right SectionModuleBuilder

Returns

bool

true if the specified SectionModuleBuilder is not equal to the current SectionModuleBuilder; otherwise, false.