Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@the-convocation/venat-core

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@the-convocation/venat-core - npm Package Compare versions

Comparing version 0.1.4 to 0.1.7

4

CHANGELOG.md

@@ -6,2 +6,6 @@ # Change Log

## [0.1.7](https://github.com/the-convocation/venat/compare/v0.1.6...v0.1.7) (2022-05-16)
**Note:** Version bump only for package @the-convocation/venat-core
## [0.1.4](https://github.com/the-convocation/venat/compare/v0.1.3...v0.1.4) (2022-05-16)

@@ -8,0 +12,0 @@

@@ -22,4 +22,8 @@ "use strict";

createDiscordOptions() {
const token = this.config.get('TOKEN');
if (token == null) {
throw new Error(`Missing TOKEN configuration key.`);
}
return {
token: this.config.get('TOKEN'),
token,
discordClientOptions: {

@@ -26,0 +30,0 @@ intents: [discord_js_1.Intents.FLAGS.GUILDS, discord_js_1.Intents.FLAGS.GUILD_MESSAGES],

30

dist/src/module-system/module.loader.js

@@ -25,2 +25,5 @@ "use strict";

let checkPath = resolvePackagePath('@the-convocation/venat-core', __dirname);
if (checkPath == null) {
throw new Error(`Failed to resolve own package path.`);
}
let modulesPath;

@@ -41,7 +44,7 @@ do {

}
static async resolveModules(rootPath, prefix = null) {
static async resolveModules(rootPath, prefix) {
const nodeModules = await fs.readdir(rootPath);
const resolvedModules = [];
for (const nodeModule of nodeModules) {
if (nodeModule.startsWith('@') && !prefix) {
if (nodeModule.startsWith('@') && prefix == null) {
resolvedModules.push(...(await this.resolveModules(path.join(rootPath, nodeModule), nodeModule + '/')));

@@ -53,20 +56,17 @@ continue;

const modulePath = (prefix ?? '') + nodeModule;
let module = await Promise.resolve().then(() => require(modulePath));
let metadata;
for (const exp of Object.values(module)) {
if (Reflect.hasMetadata(venat_module_decorator_1.METADATA_KEY, exp)) {
module = exp;
metadata = Reflect.getMetadata(venat_module_decorator_1.METADATA_KEY, exp);
break;
}
}
if (!metadata) {
const module = await Promise.resolve().then(() => require(modulePath));
const nestModule = Object.values(module).find((item) => Reflect.hasMetadata(venat_module_decorator_1.METADATA_KEY, item));
if (nestModule == null) {
throw new Error(`Module ${module} does not have @VenatModule decorator`);
}
const metadata = Reflect.getMetadata(venat_module_decorator_1.METADATA_KEY, nestModule);
ModuleLoader_1.logger.log(`Found module: ${metadata.name} (${modulePath})`);
resolvedModules.push(module);
resolvedModules.push(nestModule);
ModuleLoader_1.loadedModuleInfo.push(metadata);
}
catch (e) {
ModuleLoader_1.logger.error(`Failed to load module ${nodeModule}: ${e.message}`);
catch (error) {
if (!(error instanceof Error)) {
throw error;
}
ModuleLoader_1.logger.error(`Failed to load module ${nodeModule}: ${error.message}`);
}

@@ -73,0 +73,0 @@ }

@@ -1,2 +0,2 @@

import { DiscordGuard, EventType } from '@discord-nestjs/core';
import { DiscordGuard } from '@discord-nestjs/core';
import { UsersService } from '../users.service';

@@ -7,3 +7,3 @@ import { Message, User } from 'discord.js';

constructor(usersService: UsersService);
canActive(event: EventType, [message, user]: [Message, User]): Promise<boolean>;
canActive(event: string | undefined, [message, user]: [Message, User]): Promise<boolean>;
}

@@ -1,2 +0,2 @@

import { DiscordGuard, EventType } from '@discord-nestjs/core';
import { DiscordGuard } from '@discord-nestjs/core';
import { UsersService } from '../users.service';

@@ -7,3 +7,3 @@ import { Message, User } from 'discord.js';

constructor(usersService: UsersService);
canActive(event: EventType, [message, user]: [Message, User]): Promise<boolean>;
canActive(event: string | undefined, [message, user]: [Message, User]): Promise<boolean>;
}

@@ -22,3 +22,3 @@ "use strict";

const userEntity = await this.usersService.find(user);
return userEntity && userEntity.isAdmin;
return userEntity?.isAdmin ?? false;
}

@@ -25,0 +25,0 @@ };

@@ -1,5 +0,7 @@

export interface LookupResult<TValue> {
export declare type LookupResult<TValue> = {
success: true;
value: TValue;
success: boolean;
err?: Error;
}
} | {
success: false;
err: Error;
};
{
"name": "@the-convocation/venat-core",
"version": "0.1.4",
"version": "0.1.7",
"description": "open source ffxiv community discord bot that's incredibly easy to self-host",

@@ -43,3 +43,3 @@ "author": "The Convocation contributors",

},
"gitHead": "520c73c0ce8eca2129ba98d0e9bf9039c85c2f4b"
"gitHead": "ed5d2c3f91ee44b382ee41aac4a774cfcefc5c62"
}

@@ -14,4 +14,9 @@ import { Injectable } from '@nestjs/common';

public createDiscordOptions(): DiscordModuleOption {
const token = this.config.get('TOKEN');
if (token == null) {
throw new Error(`Missing TOKEN configuration key.`);
}
return {
token: this.config.get('TOKEN'),
token,
discordClientOptions: {

@@ -18,0 +23,0 @@ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],

@@ -12,3 +12,3 @@ import { Param } from '@discord-nestjs/core';

})
song: string;
song!: string;
}

@@ -24,2 +24,6 @@ import { DynamicModule, Logger, Module } from '@nestjs/common';

if (checkPath == null) {
throw new Error(`Failed to resolve own package path.`);
}
let modulesPath;

@@ -45,8 +49,8 @@

rootPath: string,
prefix: string = null,
prefix?: string,
): Promise<DynamicModule[]> {
const nodeModules = await fs.readdir(rootPath);
const resolvedModules = [];
const resolvedModules: DynamicModule[] = [];
for (const nodeModule of nodeModules) {
if (nodeModule.startsWith('@') && !prefix) {
if (nodeModule.startsWith('@') && prefix == null) {
resolvedModules.push(

@@ -65,13 +69,10 @@ ...(await this.resolveModules(

const modulePath = (prefix ?? '') + nodeModule;
let module = await import(modulePath);
let metadata: VenatModuleMetadata;
for (const exp of Object.values(module)) {
if (Reflect.hasMetadata(METADATA_KEY, exp)) {
module = exp;
metadata = Reflect.getMetadata(METADATA_KEY, exp);
break;
}
}
const module: { [key: string]: object } = await import(modulePath);
if (!metadata) {
const nestModule = Object.values(module).find(
(item): item is DynamicModule =>
Reflect.hasMetadata(METADATA_KEY, item),
);
if (nestModule == null) {
throw new Error(

@@ -82,10 +83,18 @@ `Module ${module} does not have @VenatModule decorator`,

const metadata: VenatModuleMetadata = Reflect.getMetadata(
METADATA_KEY,
nestModule,
);
ModuleLoader.logger.log(
`Found module: ${metadata.name} (${modulePath})`,
);
resolvedModules.push(module);
resolvedModules.push(nestModule);
ModuleLoader.loadedModuleInfo.push(metadata);
} catch (e) {
} catch (error) {
if (!(error instanceof Error)) {
throw error;
}
ModuleLoader.logger.error(
`Failed to load module ${nodeModule}: ${e.message}`,
`Failed to load module ${nodeModule}: ${error.message}`,
);

@@ -92,0 +101,0 @@ }

@@ -9,3 +9,3 @@ import { Column, Entity, PrimaryColumn } from 'typeorm';

@PrimaryColumn()
id: number;
id!: number;

@@ -17,3 +17,3 @@ /**

@Column()
isAdmin: boolean;
isAdmin!: boolean;

@@ -24,3 +24,3 @@ /**

@Column()
isBanned: boolean;
isBanned!: boolean;
}

@@ -15,4 +15,4 @@ import { DiscordGuard, EventType } from '@discord-nestjs/core';

const userEntity = await this.usersService.find(user);
return userEntity && userEntity.isAdmin;
return userEntity?.isAdmin ?? false;
}
}

@@ -1,5 +0,3 @@

export interface LookupResult<TValue> {
value: TValue;
success: boolean;
err?: Error;
}
export type LookupResult<TValue> =
| { success: true; value: TValue }
| { success: false; err: Error };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc