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 876 B

123456789101112131415161718
  1. // (Note: This precondition is obsolete, it is recommended to use the RequireOwnerAttribute that is bundled with Discord.Commands)
  2. // Inherit from PreconditionAttribute
  3. public class RequireOwnerAttribute : PreconditionAttribute
  4. {
  5. // Override the CheckPermissions method
  6. public async override Task<PreconditionResult> CheckPermissions(CommandContext context, CommandInfo command, IDependencyMap map)
  7. {
  8. // Get the ID of the bot's owner
  9. var ownerId = (await map.Get<DiscordSocketClient>().GetApplicationInfoAsync()).Owner.Id;
  10. // If this command was executed by that user, return a success
  11. if (context.User.Id == ownerId)
  12. return PreconditionResult.FromSuccess();
  13. // Since it wasn't, fail
  14. else
  15. return PreconditionResult.FromError("You must be the owner of the bot to run this command.");
  16. }
  17. }