diff --git a/src/middleware/ApiClientUtil.js b/src/middleware/ApiClientUtil.js index 7ab9e7e..f55c381 100644 --- a/src/middleware/ApiClientUtil.js +++ b/src/middleware/ApiClientUtil.js @@ -1,16 +1,21 @@ class ApiClientUtil { constructor(client) { - this.client = client; + this.client = client; this.cache = {}; } + get apiManager() { + return this.client.api; + } + async handleMessage(shard, message) { const { type, id } = message; let response = null; + try { switch (type) { case 'guild-live': @@ -25,6 +30,9 @@ class ApiClientUtil { case 'settings': response = await this.settings(message); break; + case 'restart': + response = await this.restartAPIShards(message); + break; default: return shard.send({ id, failure: true, error: '[IPC] No such type' }); } @@ -41,10 +49,7 @@ class ApiClientUtil { async settings({ guildId }) { const evalFunc = async (client, { guildId }) => { - const guild = client.guilds.resolve(guildId); - if (!guild) return null; - - const wrapper = new client.wrapperClasses.GuildWrapper(client, guild); + const wrapper = client.getGuildWrapper(guildId); const settings = await wrapper.settings(); return settings; }; @@ -102,6 +107,11 @@ class ApiClientUtil { } + async restartAPIShards(message) { + const { shards } = message; + await this.apiManager.restartShards(shards); + } + } module.exports = ApiClientUtil; \ No newline at end of file diff --git a/src/structure/client/Intercom.js b/src/structure/client/Intercom.js index ae8f77e..768f1cc 100644 --- a/src/structure/client/Intercom.js +++ b/src/structure/client/Intercom.js @@ -13,7 +13,7 @@ class Intercom { } send(type, message = {}) { - if (typeof message !== 'object') return false; + if (typeof message !== 'object') throw new Error('Invalid message object'); if (!process.send) return; // Nowhere to send, the client was not spawned as a shard return process.send({ [`_${type}`]: true, diff --git a/src/structure/components/commands/moderation/Nickname.js b/src/structure/components/commands/moderation/Nickname.js index 332bfd1..5d52dc5 100644 --- a/src/structure/components/commands/moderation/Nickname.js +++ b/src/structure/components/commands/moderation/Nickname.js @@ -11,7 +11,8 @@ class NicknameCommand extends ModerationCommand { options: [{ name: 'name', description: 'The new nickname to give', - type: 'STRING' + type: 'STRING', + required: true }], memberPermissions: ['ManageNicknames'], clientPermissions: ['ManageNicknames'],