Пример #1
0
        public static async Task <bool> CheckPermission(this BaseCommandModule module, IPermissionService permissionService, Type t, string methodName, DiscordMember member)
        {
            if (member.IsOwner)
            {
                return(true);
            }

            var method = t.GetMethod(methodName);
            PermissionNodeAttribute attribute = method.GetCustomAttribute <PermissionNodeAttribute>();

            if (attribute == null)
            {
                throw new PermissionNodeAttributeNullException();
            }

            var node = attribute.Node;

            return(await permissionService.CheckPermissionsAsync(node, member.Guild.Id, member.Id, member.Roles.Select(r => r.Id).ToList()));
        }
Пример #2
0
 /// <summary>
 /// Creates a new singleton module, and instantiates it.
 /// </summary>
 /// <param name="t">Type of the module to create.</param>
 /// <param name="services">Services to instantiate the module with.</param>
 internal SingletonCommandModule(Type t, IServiceProvider services)
 {
     this.ModuleType = t;
     this.Instance   = t.CreateInstance(services) as BaseCommandModule;
 }
Пример #3
0
 private CommandModule castModule(BaseCommandModule mod) => mod as CommandModule;