You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

require_owner.cs 833 B

12345678910111213141516
  1. // Defining the Precondition
  2. // Specify that this precondition can target a Class (Module/Group) or Method (Command)
  3. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
  4. // Inherit from PreconditionAttribute
  5. public class RequireOwnerAttribute : PreconditionAttribute
  6. {
  7. public readonly ulong OwnerId = 66078337084162048;
  8. // Override the CheckPermissions method
  9. public override Task<PreconditionResult> CheckPermissions(IUserMessage context, Command executingCommand, object moduleInstance)
  10. {
  11. // If the author of the message is '66078337084162048', return success; otherwise fail.
  12. return Task.FromResult(context.Author.Id == OwnerId ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("You must be the owner of the bot."));
  13. }
  14. }