wrapper stuff

This commit is contained in:
Erik 2022-01-27 01:12:18 +02:00
parent c85d58511e
commit 2a4d8b8c7b
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
2 changed files with 38 additions and 2 deletions

View File

@ -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;

View File

@ -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;