mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
structures made async to be overrideable
This commit is contained in:
@@ -91,7 +91,7 @@ export async function getMessages(
|
||||
endpoints.CHANNEL_MESSAGES(channelID),
|
||||
options,
|
||||
)) as MessageCreateOptions[];
|
||||
return result.map((res) => structures.createMessage(res));
|
||||
return Promise.all(result.map((res) => structures.createMessage(res)));
|
||||
}
|
||||
|
||||
/** Get pinned messages in this channel. */
|
||||
@@ -99,7 +99,7 @@ export async function getPins(channelID: string) {
|
||||
const result = (await RequestManager.get(
|
||||
endpoints.CHANNEL_PINS(channelID),
|
||||
)) as MessageCreateOptions[];
|
||||
return result.map((res) => structures.createMessage(res));
|
||||
return Promise.all(result.map((res) => structures.createMessage(res)));
|
||||
}
|
||||
|
||||
/** Send a message to the channel. Requires SEND_MESSAGES permission. */
|
||||
|
||||
@@ -110,7 +110,7 @@ export async function createGuildChannel(
|
||||
type: options?.type || ChannelTypes.GUILD_TEXT,
|
||||
})) as ChannelCreatePayload;
|
||||
|
||||
const channel = structures.createChannel(result);
|
||||
const channel = await structures.createChannel(result);
|
||||
guild.channels.set(result.id, channel);
|
||||
return channel;
|
||||
}
|
||||
@@ -136,13 +136,13 @@ export async function getChannels(guildID: string, addToCache = true) {
|
||||
const result = await RequestManager.get(
|
||||
endpoints.GUILD_CHANNELS(guildID),
|
||||
) as ChannelCreatePayload[];
|
||||
return result.map((res) => {
|
||||
const channel = structures.createChannel(res, guildID);
|
||||
return Promise.all(result.map(async (res) => {
|
||||
const channel = await structures.createChannel(res, guildID);
|
||||
if (addToCache) {
|
||||
cacheHandlers.set("channels", channel.id, channel);
|
||||
}
|
||||
return channel;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
/** Fetches a single channel object from the api.
|
||||
@@ -153,7 +153,7 @@ export async function getChannel(channelID: string, addToCache = true) {
|
||||
const result = await RequestManager.get(
|
||||
endpoints.GUILD_CHANNEL(channelID),
|
||||
) as ChannelCreatePayload;
|
||||
const channel = structures.createChannel(result, result.guild_id);
|
||||
const channel = await structures.createChannel(result, result.guild_id);
|
||||
if (addToCache) cacheHandlers.set("channels", channel.id, channel);
|
||||
return channel;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ export async function getMember(guildID: string, id: string) {
|
||||
endpoints.GUILD_MEMBER(guildID, id),
|
||||
) as MemberCreatePayload;
|
||||
|
||||
const member = structures.createMember(data, guild.id);
|
||||
const member = await structures.createMember(data, guild.id);
|
||||
guild.members.set(id, member);
|
||||
return member;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ export async function createGuildRole(
|
||||
);
|
||||
|
||||
const roleData = result as RoleData;
|
||||
const role = structures.createRole(roleData);
|
||||
const role = await structures.createRole(roleData);
|
||||
const guild = await cacheHandlers.get("guilds", guildID);
|
||||
guild?.roles.set(role.id, role);
|
||||
return role;
|
||||
|
||||
@@ -108,7 +108,7 @@ export async function sendDirectMessage(
|
||||
) as DMChannelCreatePayload;
|
||||
// Channel create event will have added this channel to the cache
|
||||
cacheHandlers.delete("channels", dmChannelData.id);
|
||||
const channel = structures.createChannel(dmChannelData);
|
||||
const channel = await structures.createChannel(dmChannelData);
|
||||
// Recreate the channel and add it undert he users id
|
||||
cacheHandlers.set("channels", memberID, channel);
|
||||
dmChannel = channel;
|
||||
|
||||
Reference in New Issue
Block a user