public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { if ((context as SocketCommandContext).IsPrivate) { return(Task.FromResult(PreconditionResult.FromSuccess())); } OliveGuild.GuildSetting setting = OliveGuild.Get(context.Guild.Id).Setting; if (setting.EnabledCategories.Contains(Category)) { return(Task.FromResult(PreconditionResult.FromSuccess())); } else { return(Task.FromResult(PreconditionResult.FromError($"이 커맨드를 실행하려면 {CategoryToString(Category)} 타입의 활성화가 필요해요"))); } }
public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { // whitelist if (context.User.Id == 396163884005851137) { return(Task.FromResult(PreconditionResult.FromSuccess())); } if (Permission != PermissionType.BotAdmin) { if ((context as SocketCommandContext).IsPrivate) { return(Task.FromResult(PreconditionResult.FromSuccess())); } OliveGuild.GuildSetting setting = OliveGuild.Get(context.Guild.Id).Setting; SocketGuildUser user = context.User as SocketGuildUser; if (context.Guild.OwnerId == user.Id) { return(Task.FromResult(PreconditionResult.FromSuccess())); } string perm = Permission.ToString(); if (setting.PermissionRoles.ContainsKey(perm) && context.Guild.Roles.Any(r => r.Id == setting.PermissionRoles[perm])) { if (user.Roles.Any(r => r.Position >= context.Guild.GetRole(setting.PermissionRoles[perm]).Position)) { return(Task.FromResult(PreconditionResult.FromSuccess())); } } else { if (Permission is PermissionType.UseBot or PermissionType.SpeakByBot or PermissionType.ManageCommand or PermissionType.CreateVote) { return(Task.FromResult(PreconditionResult.FromSuccess())); } } } return(Task.FromResult(PreconditionResult.FromError($"이 커맨드를 실행하려면 {PermissionToString(Permission)} 권한이 필요해요"))); }