Table of Contents

Class RequireOwnerAttribute

Namespace
Discord.Interactions
Assembly
Discord.Net.Interactions.dll

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

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

Remarks

This precondition will restrict the access of the command or module to the owner of the Discord application. 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."

note

This precondition will only work if the account has a TokenType of Bot ;otherwise, this precondition will always fail.

Methods

CheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider)

Checks if the commandInfo command to be executed meets the precondition requirements.

public override Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo command, IServiceProvider services)

Parameters

context IInteractionContext

The context of the command.

command ICommandInfo
services IServiceProvider

The service collection used for dependency injection.

Returns

Task<PreconditionResult>