mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
Prettified Code!
This commit is contained in:
@@ -7,23 +7,14 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { sendMessage } from "../messages/send_message.ts";
|
||||
|
||||
/** Send a message to a users DM. Note: this takes 2 API calls. 1 is to fetch the users dm channel. 2 is to send a message to that channel. */
|
||||
export async function sendDirectMessage(
|
||||
memberId: bigint,
|
||||
content: string | CreateMessage
|
||||
) {
|
||||
export async function sendDirectMessage(memberId: bigint, content: string | CreateMessage) {
|
||||
let dmChannel = await cacheHandlers.get("channels", memberId);
|
||||
if (!dmChannel) {
|
||||
// If not available in cache create a new one.
|
||||
const dmChannelData = await rest.runMethod<Channel>(
|
||||
"post",
|
||||
endpoints.USER_DM,
|
||||
{
|
||||
recipient_id: memberId,
|
||||
}
|
||||
);
|
||||
const discordenoChannel = await structures.createDiscordenoChannel(
|
||||
dmChannelData
|
||||
);
|
||||
const dmChannelData = await rest.runMethod<Channel>("post", endpoints.USER_DM, {
|
||||
recipient_id: memberId,
|
||||
});
|
||||
const discordenoChannel = await structures.createDiscordenoChannel(dmChannelData);
|
||||
// Recreate the channel and add it undert he users id
|
||||
await cacheHandlers.set("channels", memberId, discordenoChannel);
|
||||
dmChannel = discordenoChannel;
|
||||
|
||||
Reference in New Issue
Block a user