Skip to content

Commit

Permalink
🐛 bug: bug typeof id database
Browse files Browse the repository at this point in the history
  • Loading branch information
skillzl committed Nov 16, 2023
1 parent edf487f commit ce848cc
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions database/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = class Manager {
}

static async findServer(id) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
const result = await serverModel.findOne({ serverId: id });
Expand All @@ -23,7 +23,7 @@ module.exports = class Manager {
}

static async getPrefix(id) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
const result = await serverModel.findOne({ serverId: id });
Expand All @@ -32,7 +32,7 @@ module.exports = class Manager {
}

static async updateServerPrefix(id, prefix) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
const result = await serverModel.findOne({ serverId: id });
Expand All @@ -46,7 +46,7 @@ module.exports = class Manager {
}

static async createUser(id) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
const user = new userModel({
Expand All @@ -58,7 +58,7 @@ module.exports = class Manager {
}

static async getUserById(id) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
let user = await userModel.findOne({ userId: id });
Expand All @@ -67,7 +67,7 @@ module.exports = class Manager {
}

static async updateUserById(id, data) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
if (typeof data !== 'object') { throw Error('\'data\' must be an object'); }
Expand All @@ -78,14 +78,14 @@ module.exports = class Manager {
}

static async removeUser(id) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
await userModel.findOneAndDelete({ userId: id });
}

static async updateServerById(id, settings) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
if (typeof settings !== 'object') { throw Error('\'settings\' must be an object'); }
Expand All @@ -98,7 +98,7 @@ module.exports = class Manager {
}

static async removeServer(id) {
if (typeof id !== 'string' || id.length !== 24) {
if (typeof id !== 'string') {
throw new Error('Invalid ID');
}
await serverModel.findOneAndDelete({ guildId: id });
Expand Down

0 comments on commit ce848cc

Please sign in to comment.