Table of Contents

Class DiscordInit

Namespace
BotManager.Discord.Expressions
Assembly
BotManager.Discord.dll

The Discord plugin will connect to the Discord api using the given Token. You can register Commands that will run an expression once a user executes them.

Return type is null.

This json example initials OpenAI and returns null:
{ "$OpenAiInit": { "TokenType": "Bot", "Token": { "$Env": "DISCORD_TOKEN" } } }
public sealed class DiscordInit : IExpression
Inheritance
DiscordInit
Implements
Inherited Members

Constructors

DiscordInit()

public DiscordInit()

Properties

Client

Gets the Discord client interface.

[JsonIgnore]
public DiscordSocketClient Client { get; }

Property Value

DiscordSocketClient

Commands

Gets and sets the slash commands.

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DiscordSlashCommand[]? Commands { get; set; }

Property Value

DiscordSlashCommand[]

Token

Gets and sets the Discord API key.

public IExpression? Token { get; set; }

Property Value

IExpression

TokenType

Gets and sets the Token type.

[JsonConverter(typeof(EnumConverter<TokenType>))]
public TokenType TokenType { get; set; }

Property Value

TokenType

Methods

ExecuteAsync(RuntimeContext, Type?)

Executes the expression in the given RuntimeContext. Please do not use this method to run an expression. Use ExecuteAsync(IExpression?) instead.

public Task<object?> ExecuteAsync(RuntimeContext context, Type? returnType)

Parameters

context RuntimeContext

The current runtime context.

returnType Type

The expected return type. Use typeof(object) for a generic result. Use null if you don't need the return value.

Returns

Task<object>

Returns the result of the expression.

GetGuild(DiscordIdentifier)

Returns the guild by the given identifier

public IGuild? GetGuild(DiscordIdentifier identifier)

Parameters

identifier DiscordIdentifier

Returns

IGuild

GetGuild(ulong)

Returns the guild by the given identifier

public IGuild? GetGuild(ulong id)

Parameters

id ulong

Returns

IGuild