change: prettier code

This commit is contained in:
TriForMine
2021-10-21 16:07:35 +00:00
committed by GitHub Action
parent fe22c5ea73
commit 9a1f8f41a5
14 changed files with 112 additions and 68 deletions
+10 -5
View File
@@ -1,7 +1,7 @@
import type { Channel } from "../../types/channels/channel.ts";
import type { CreateMessage } from "../../types/messages/create_message.ts";
import type {Bot} from "../../bot.ts";
import type {SnakeCasedPropertiesDeep} from "../../types/util.ts";
import type { Bot } from "../../bot.ts";
import type { SnakeCasedPropertiesDeep } from "../../types/util.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(bot: Bot, memberId: bigint, content: string | CreateMessage) {
@@ -10,9 +10,14 @@ export async function sendDirectMessage(bot: Bot, memberId: bigint, content: str
let dmChannel = await bot.cache.channels.get(memberId);
if (!dmChannel) {
// If not available in cache create a new one.
const dmChannelData = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Channel>>(bot.rest,"post", bot.constants.endpoints.USER_DM, {
recipient_id: memberId,
});
const dmChannelData = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Channel>>(
bot.rest,
"post",
bot.constants.endpoints.USER_DM,
{
recipient_id: memberId,
}
);
const discordenoChannel = await bot.transformers.channel(bot, dmChannelData);
// Recreate the channel and add it under the users id
await bot.cache.channels.set(memberId, discordenoChannel);