Table of Contents

Class RequireTeamAttribute

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

Requires the command to be invoked by a member of the team that owns the bot.

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

Remarks

This precondition will restrict the access of the command or module to the a member of the team of the Discord application, narrowed to specific team roles if specified. If the precondition fails to be met, an erroneous PreconditionResult will be returned with the message "Command can only be run by a member of the bot's team."

note

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

Constructors

RequireTeamAttribute(params string[])

Requires that the user invoking the command to have a specific team role.

public RequireTeamAttribute(params string[] teamRoles)

Parameters

teamRoles string[]

The team roles to require. Valid values: "*", "admin", "developer", or "read_only"

Properties

TeamRoles

The team roles to require. Valid values: "*", "admin", "developer", or "read_only"

public string[] TeamRoles { get; }

Property Value

string[]

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>