honocord 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +11 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -278,6 +278,7 @@ var Fetcher = class {
|
|
|
278
278
|
}
|
|
279
279
|
users = { get: (userId) => this.fetchAndCache(() => this.cache?.users.get(userId) ?? Promise.resolve(null), (user) => this.cache.users.set(user), () => this.api.users.get(userId)) };
|
|
280
280
|
channels = { get: (channelId) => this.fetchAndCache(() => this.cache?.channels.get(channelId) ?? Promise.resolve(null), (channel) => this.cache.channels.set(channel), () => this.api.channels.get(channelId)) };
|
|
281
|
+
dmChannels = { get: (userId) => this.fetchAndCache(() => this.cache?.getDMChannel(userId) ?? Promise.resolve(null), (channel) => this.cache.setDMChannel(userId, channel), () => this.api.users.createDM(userId)) };
|
|
281
282
|
guilds = { get: (guildId) => this.fetchAndCache(() => this.cache?.guilds.get(guildId) ?? Promise.resolve(null), (guild) => this.cache.guilds.set(guild), () => this.api.guilds.get(guildId)) };
|
|
282
283
|
roles = {
|
|
283
284
|
get: (guildId, roleId) => this.fetchAndCache(() => this.cache?.roles.get(roleId) ?? Promise.resolve(null), (role) => this.cache.roles.set(role), async () => {
|
|
@@ -1604,6 +1605,15 @@ var CacheManager = class {
|
|
|
1604
1605
|
if (!roleIds) return [];
|
|
1605
1606
|
return (await Promise.all(roleIds.map((roleId) => this.roles.get(roleId)))).filter(Boolean);
|
|
1606
1607
|
}
|
|
1608
|
+
async getDMChannel(userId) {
|
|
1609
|
+
const channelId = await this.adapter.get(key("dm-channel", userId));
|
|
1610
|
+
const cachedChannel = channelId ? await this.channels.get(channelId) : void 0;
|
|
1611
|
+
if (cachedChannel && (cachedChannel.type === discord_api_types_v10.ChannelType.DM || cachedChannel.type === discord_api_types_v10.ChannelType.GroupDM)) return cachedChannel;
|
|
1612
|
+
}
|
|
1613
|
+
async setDMChannel(userId, channel, ttlMs) {
|
|
1614
|
+
await this.channels.set(channel, ttlMs);
|
|
1615
|
+
await this.adapter.set(key("dm-channel", userId), channel.id, ttlMs ?? this.defaultTtlMs);
|
|
1616
|
+
}
|
|
1607
1617
|
async addRolesToGuild(guildId, roleIds) {
|
|
1608
1618
|
if (!roleIds.length) return;
|
|
1609
1619
|
const existing = await this.adapter.get(key("guild-roles", guildId)) ?? [];
|