Skip to content

Commit

Permalink
you
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Feb 3, 2022
1 parent 89084e5 commit 91ae0ef
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/lib/structures/Provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Logger from 'js-logger';
import { EventEmitter } from 'events';
import { Util } from '../util/Util';

Expand All @@ -21,39 +20,33 @@ export declare interface Provider {
delete(...args): Promise<any> | any;
}

const throwError = (error, name) => {
const trace = Util.resolveValidationErrorTrace([name]);

Logger.error(error, trace);
};

export class Provider extends EventEmitter {
init() {
throwError('Init method is not implemented!', this.constructor.name);
Util.throwError('Init method is not implemented!', this.constructor.name);
return;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
insert(...args) {
throwError('Insert method is not implemented!', this.constructor.name);
Util.throwError('Insert method is not implemented!', this.constructor.name);
return;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
get(...args) {
throwError('Get method is not implemented!', this.constructor.name);
Util.throwError('Get method is not implemented!', this.constructor.name);
return;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
update(...args) {
throwError('Update method is not implemented!', this.constructor.name);
Util.throwError('Update method is not implemented!', this.constructor.name);
return;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
delete(...args) {
throwError('Delete method is not implemented!', this.constructor.name);
Util.throwError('Delete method is not implemented!', this.constructor.name);
return;
}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/Boolean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Boolean {
validate() {

}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/Channel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Channel {
validate() {

}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/Integer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Integer {
validate() {

}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/Mentionable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Mentionable {
validate() {

}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/Number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Number {
validate() {

}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/Role.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Role {
validate() {

}
}
5 changes: 5 additions & 0 deletions src/lib/structures/arguments/String.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class String {
validate() {

}
}
17 changes: 17 additions & 0 deletions src/lib/structures/arguments/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Message } from 'discord.js';

export class User {
validate(message: Message) {
const content = message.content;
const matches = content.match(/([0-9]+)/);

if (!matches) return {
success: false
}

return {
success: true,
value: message.client.users.cache.get(matches[0])
}
}
}
8 changes: 8 additions & 0 deletions src/lib/util/Util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Logger from 'js-logger';

export class Util {
/**
* @deprecated We don't support arguments in object/array
Expand Down Expand Up @@ -91,4 +93,10 @@ export class Util {
array = array.filter(item => typeof item === 'string');
return `(${array.join(' -> ') || 'unknown'})`;
}

static throwError(error: any, name: string): void {
const trace = Util.resolveValidationErrorTrace([name]);

Logger.error(error, trace);
};
}

0 comments on commit 91ae0ef

Please sign in to comment.