Update Documentation to be compatible with Beta2
this one took a while
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
// 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(IUserMessage context, Command executingCommand, object moduleInstance)
|
||||
public override Task<PreconditionResult> CheckPermissions(CommandContext context, CommandInfo command, IDependencyMap map)
|
||||
{
|
||||
// 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."));
|
||||
// Get the ID of the bot's owner
|
||||
var ownerId = (await map.Get<DiscordSocketClient>().GetApplicationInfoAsync()).Owner.Id;
|
||||
// If this command was executed by that user, return a success
|
||||
if (context.User.Id == ownerId)
|
||||
return PreconditionResult.FromSuccess();
|
||||
// Since it wasn't, fail
|
||||
else
|
||||
return PreconditionResult.FromError("You must be the owner of the bot to run this command.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user