From 2a4d8b8c7b30511a717697caea415610173f3345 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Thu, 27 Jan 2022 01:12:18 +0200 Subject: [PATCH] wrapper stuff --- src/structure/client/wrappers/GuildWrapper.js | 24 +++++++++++++++++++ .../client/wrappers/InteractionWrapper.js | 16 +++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/structure/client/wrappers/GuildWrapper.js b/src/structure/client/wrappers/GuildWrapper.js index a70a42d..5459f63 100644 --- a/src/structure/client/wrappers/GuildWrapper.js +++ b/src/structure/client/wrappers/GuildWrapper.js @@ -197,6 +197,30 @@ class GuildWrapper { return this.guild.roles; } + // Primarily used by the API + toJSON() { + const json = this.guild.toJSON(); + // json.members = await Promise.all(json.members.map(async (id) => { + // const member = await this.guild.resolveMember(id); + // return { id: member.id, tag: member.user.tag }; + // })); + json.channels = this.guild.channels.cache.map((channel) => { + return { + id: channel.id, + type: channel.type, + name: channel.name, + parent: channel.parentId + }; + }); + json.roles = this.guild.roles.cache.map((role) => { + return { + id: role.id, + name: role.name + }; + }); + return json; + } + } module.exports = GuildWrapper; \ No newline at end of file diff --git a/src/structure/client/wrappers/InteractionWrapper.js b/src/structure/client/wrappers/InteractionWrapper.js index 10f0176..163ccc2 100644 --- a/src/structure/client/wrappers/InteractionWrapper.js +++ b/src/structure/client/wrappers/InteractionWrapper.js @@ -4,7 +4,7 @@ const { Emojis } = require('../../../constants'); class InteractionWrapper { - constructor(client, command, interaction, guildWrapper) { + constructor(client, interaction, guildWrapper) { if (guildWrapper && !(guildWrapper instanceof GuildWrapper)) { if (!(guildWrapper instanceof Guild)) throw new Error(`The guild-like must be a Guild or a GuildWrapper`); @@ -13,7 +13,7 @@ class InteractionWrapper { this.client = client; this.interaction = interaction; - this.command = command; + this.command = null; this.guild = guildWrapper; // this.options = []; @@ -158,6 +158,10 @@ class InteractionWrapper { return this.interaction.type; } + get commandName() { + return this.interaction.commandName; + } + get options() { return this.interaction.options; } @@ -200,6 +204,14 @@ class InteractionWrapper { return this.interaction.deferred; } + isCommand() { + return this.interaction.isCommand(); + } + + isContextMenu() { + return this.interaction.isContextMenu(); + } + } module.exports = InteractionWrapper; \ No newline at end of file