mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
members
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordChannel } from "../../types/channels/channel.ts";
|
||||
import { Channel } from "../../types/channels/channel.ts";
|
||||
import { CreateMessage } from "../../types/messages/create_message.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { sendMessage } from "../messages/send_message.ts";
|
||||
@@ -14,11 +14,15 @@ export async function sendDirectMessage(
|
||||
let dmChannel = await cacheHandlers.get("channels", memberId);
|
||||
if (!dmChannel) {
|
||||
// If not available in cache create a new one.
|
||||
const dmChannelData = await rest.runMethod("post", endpoints.USER_DM, {
|
||||
recipient_id: memberId,
|
||||
});
|
||||
const dmChannelData = await rest.runMethod<Channel>(
|
||||
"post",
|
||||
endpoints.USER_DM,
|
||||
{
|
||||
recipient_id: memberId,
|
||||
},
|
||||
);
|
||||
const discordenoChannel = await structures.createDiscordenoChannel(
|
||||
dmChannelData as DiscordChannel,
|
||||
dmChannelData,
|
||||
);
|
||||
// Recreate the channel and add it undert he users id
|
||||
await cacheHandlers.set("channels", memberId, discordenoChannel);
|
||||
@@ -26,5 +30,5 @@ export async function sendDirectMessage(
|
||||
}
|
||||
|
||||
// If it does exist try sending a message to this user
|
||||
return sendMessage(dmChannel.id, content);
|
||||
return await sendMessage(dmChannel.id, content);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user