Add documentation for Preconditions, Aliases, Command Structure
Resolves #223
This commit is contained in:
16
docs/guides/samples/require_owner.cs
Normal file
16
docs/guides/samples/require_owner.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// Defining the Precondition
|
||||
|
||||
// Specify that this precondition can target a Class (Module/Group) or Method (Command)
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
// Inherit from PreconditionAttribute
|
||||
public class RequireOwnerAttribute : PreconditionAttribute
|
||||
{
|
||||
public readonly ulong OwnerId = 66078337084162048;
|
||||
|
||||
// Override the CheckPermissions method
|
||||
public override Task<PreconditionResult> CheckPermissions(IMessage context, Command executingCommand, object moduleInstance)
|
||||
{
|
||||
// If the author of the message is '66078337084162048', return success; otherwise fail.
|
||||
return Task.FromResult(context.Author.Id == OwnerId ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("You must be the owner of the bot."));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user