Skip to content

Commit

Permalink
cache resolved data from commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Sep 23, 2024
1 parent 7b16e78 commit 0b24d80
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/structures/SlashCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Client from "../Client.js";
import { TO_JSON_TYPES_ENUM } from "../constants.js";
import Interaction from "./Interaction.js";
import util from "util";
import Member from "./Member.js";
import Role from "./Role.js";
import cacheChannel from "../util/gluon/cacheChannel.js";

/**
* Represents a slash command.
Expand Down Expand Up @@ -30,6 +33,22 @@ class SlashCommand extends Interaction {
* @private
*/
this.#data = data.data;

if (data.data.resolved?.members)
for (const [key, value] of Object.entries(data.data.resolved.members))
new Member(client, value, {
userId: key,
guildId: data.guild_id,
user: data.data.resolved.users[key],
});
if (data.data.resolved?.roles)
for (const value of Object.values(data.data.resolved.roles))
new Role(client, value, {
guildId: data.guild_id,
});
if (data.data.resolved?.channels)
for (const value of Object.values(data.data.resolved.channels))
cacheChannel(client, value, data.guild_id);
}

/**
Expand Down

0 comments on commit 0b24d80

Please sign in to comment.