Table of Contents

Class RequireOwnerAttribute

Namespace
Fluxer.Net.Commands
Assembly
Fluxer.Net.dll

Requires the command to be invoked by the owner of the bot.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class RequireOwnerAttribute : PreconditionAttribute
Inheritance
object
Attribute
RequireOwnerAttribute
Inherited Members

Examples

The following example restricts the command to a set of sensitive commands that only the owner of the bot application should be able to access.

[RequireOwner]
[Group("admin")]
public class AdminModule : ModuleBase
{
    [Command("exit")]
    public async Task ExitAsync()
    {
        Environment.Exit(0);
    }
}

Remarks

This precondition will restrict the access of the command or module to the owner of the StoatSharp bot. If the precondition fails to be met, an erroneous PreconditionResult will be returned with the message "Command can only be run by the owner of the bot."

Methods

CheckPermissionsAsync(ICommandContext, CommandInfo, IServiceProvider)

Checks if the command has the sufficient permission to be executed.

public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)

Parameters

context ICommandContext

The context of the command.

command CommandInfo

The command being executed.

services IServiceProvider

The service collection used for dependency injection.

Returns

Task<PreconditionResult>