mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
fix: remove structure automatic caching (#517)
* fix: remove structure automatic caching * Update src/api/controllers/interactions.ts * Update src/api/controllers/interactions.ts * Update src/api/controllers/interactions.ts * memb -> member * rename shit * Update src/api/controllers/misc.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * idk * Update src/api/handlers/guild.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * fmt Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
This commit is contained in:
@@ -137,7 +137,11 @@ export async function createGuildChannel(
|
||||
type: options?.type || ChannelTypes.GUILD_TEXT,
|
||||
})) as ChannelCreatePayload;
|
||||
|
||||
return structures.createChannel(result);
|
||||
const channelStruct = await structures.createChannel(result);
|
||||
|
||||
await cacheHandlers.set("channels", channelStruct.id, channelStruct);
|
||||
|
||||
return channelStruct;
|
||||
}
|
||||
|
||||
/** Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
|
||||
@@ -183,11 +187,12 @@ export async function getChannels(guildID: string, addToCache = true) {
|
||||
) as ChannelCreatePayload[];
|
||||
|
||||
return Promise.all(result.map(async (res) => {
|
||||
const channel = await structures.createChannel(res, guildID);
|
||||
const channelStruct = await structures.createChannel(res, guildID);
|
||||
if (addToCache) {
|
||||
await cacheHandlers.set("channels", channel.id, channel);
|
||||
await cacheHandlers.set("channels", channelStruct.id, channelStruct);
|
||||
}
|
||||
return channel;
|
||||
|
||||
return channelStruct;
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -200,10 +205,12 @@ export async function getChannel(channelID: string, addToCache = true) {
|
||||
endpoints.CHANNEL_BASE(channelID),
|
||||
) as ChannelCreatePayload;
|
||||
|
||||
const channel = await structures.createChannel(result, result.guild_id);
|
||||
if (addToCache) await cacheHandlers.set("channels", channel.id, channel);
|
||||
const channelStruct = await structures.createChannel(result, result.guild_id);
|
||||
if (addToCache) {
|
||||
await cacheHandlers.set("channels", channelStruct.id, channelStruct);
|
||||
}
|
||||
|
||||
return channel;
|
||||
return channelStruct;
|
||||
}
|
||||
|
||||
/** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permisison. */
|
||||
@@ -287,7 +294,11 @@ export async function getMember(
|
||||
endpoints.GUILD_MEMBER(guildID, id),
|
||||
) as MemberCreatePayload;
|
||||
|
||||
return structures.createMember(data, guildID);
|
||||
const memberStruct = await structures.createMember(data, guildID);
|
||||
|
||||
await cacheHandlers.set("members", memberStruct.id, memberStruct);
|
||||
|
||||
return memberStruct;
|
||||
}
|
||||
|
||||
/** Returns guild member objects for the specified user by their nickname/username.
|
||||
@@ -620,7 +631,13 @@ export async function getMembers(
|
||||
) as MemberCreatePayload[];
|
||||
|
||||
const memberStructures = await Promise.all(
|
||||
result.map((member) => structures.createMember(member, guildID)),
|
||||
result.map(async (member) => {
|
||||
const memberStruct = await structures.createMember(member, guildID);
|
||||
|
||||
await cacheHandlers.set("members", memberStruct.id, memberStruct);
|
||||
|
||||
return memberStruct;
|
||||
}),
|
||||
) as Member[];
|
||||
|
||||
if (!memberStructures.length) break;
|
||||
|
||||
@@ -133,12 +133,12 @@ export async function sendDirectMessage(
|
||||
) as DMChannelCreatePayload;
|
||||
// Channel create event will have added this channel to the cache
|
||||
await cacheHandlers.delete("channels", dmChannelData.id);
|
||||
const channel = await structures.createChannel(
|
||||
const channelStruct = await structures.createChannel(
|
||||
dmChannelData as unknown as ChannelCreatePayload,
|
||||
);
|
||||
// Recreate the channel and add it undert he users id
|
||||
await cacheHandlers.set("channels", memberID, channel);
|
||||
dmChannel = channel;
|
||||
await cacheHandlers.set("channels", memberID, channelStruct);
|
||||
dmChannel = channelStruct;
|
||||
}
|
||||
|
||||
// If it does exist try sending a message to this user
|
||||
|
||||
Reference in New Issue
Block a user