Skip to content

Commit

Permalink
start adding validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Aug 22, 2024
1 parent d8520e3 commit b5d819f
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/managers/BaseCacheManager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashjs from "hash.js";
import { GLUON_VERSION, NAME, TO_JSON_TYPES_ENUM } from "../constants.js";
import Client from "../Client.js";

/**
* The base cache manager for all cache managers.
Expand All @@ -20,6 +21,11 @@ class BaseCacheManager {
* @constructor
*/
constructor(client, { structureType } = {}) {
if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be an instance of Client.");
if (!structureType)
throw new TypeError("GLUON: Structure type must be provided.");

/**
* The cache for this manager.
* @type {Map<String, Object>}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/ChannelMessageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class ChannelMessageManager extends BaseCacheManager {
*/
constructor(client, guild, channel) {
super(client, { structureType: ChannelMessageManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/GuildChannelsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class GuildChannelsManager extends BaseCacheManager {
*/
constructor(client, guild) {
super(client, { structureType: GuildChannelsManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
5 changes: 5 additions & 0 deletions src/managers/GuildEmojisManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import Emoji from "../structures/Emoji.js";
import BaseCacheManager from "./BaseCacheManager.js";

Expand All @@ -15,6 +16,10 @@ class GuildEmojisManager extends BaseCacheManager {
*/
constructor(client, guild) {
super(client, { structureType: GuildEmojisManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
5 changes: 5 additions & 0 deletions src/managers/GuildInviteManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import { PERMISSIONS } from "../constants.js";
import Invite from "../structures/Invite.js";
import checkPermission from "../util/discord/checkPermission.js";
Expand All @@ -17,6 +18,10 @@ class GuildInviteManager extends BaseCacheManager {
*/
constructor(client, guild) {
super(client, { structureType: GuildInviteManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/GuildManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class GuildManager extends BaseCacheManager {
*/
constructor(client) {
super(client, { structureType: GuildManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/GuildMemberManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class GuildMemberManager extends BaseCacheManager {
*/
constructor(client, guild) {
super(client, { structureType: GuildMemberManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/GuildRoleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class GuildRoleManager extends BaseCacheManager {
*/
constructor(client, guild) {
super(client, { structureType: GuildRoleManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
5 changes: 5 additions & 0 deletions src/managers/GuildScheduledEventManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import ScheduledEvent from "../structures/ScheduledEvent.js";
import BaseCacheManager from "./BaseCacheManager.js";

Expand All @@ -7,6 +8,10 @@ class GuildScheduledEventManager extends BaseCacheManager {
static identifier = "events";
constructor(client, guild) {
super(client, { structureType: GuildScheduledEventManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/GuildVoiceStatesManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import VoiceState from "../structures/VoiceState.js";
import BaseCacheManager from "./BaseCacheManager.js";

Expand All @@ -8,6 +9,9 @@ class GuildVoiceStatesManager extends BaseCacheManager {
static identifier = "voicestates";
constructor(client) {
super(client, { structureType: GuildVoiceStatesManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");
}
/**
* Adds a voice state to the cache.
Expand Down
4 changes: 4 additions & 0 deletions src/managers/MessagePollManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import { TO_JSON_TYPES_ENUM } from "../constants.js";

/**
Expand All @@ -11,6 +12,9 @@ class MessagePollManager {
* @param {Object} existingResponses Existing responses for a poll.
*/
constructor(client, existingResponses = {}) {
if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be an instance of Client.");

/**
* The client instance.
* @type {Client}
Expand Down
4 changes: 4 additions & 0 deletions src/managers/MessageReactionManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import { TO_JSON_TYPES_ENUM } from "../constants.js";
import Reaction from "../structures/Reaction.js";

Expand All @@ -13,6 +14,9 @@ class MessageReactionManager {
* @param {Object} existingReactions Existing reactions for a message.
*/
constructor(client, guild, existingReactions = {}) {
if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be an instance of Client.");

/**
* The client instance.
* @type {Client}
Expand Down
5 changes: 5 additions & 0 deletions src/managers/UserManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Client from "../Client.js";
import User from "../structures/User.js";
import BaseCacheManager from "./BaseCacheManager.js";

Expand All @@ -13,6 +14,10 @@ class UserManager extends BaseCacheManager {
*/
constructor(client) {
super(client, { structureType: UserManager });

if (!(client instanceof Client))
throw new TypeError("GLUON: Client must be a Client instance.");

/**
* The client instance.
* @type {Client}
Expand Down

0 comments on commit b5d819f

Please sign in to comment.