Finish message helpers

This commit is contained in:
TriForMine
2021-10-15 15:17:19 +02:00
parent 597f061581
commit a97b01846d
10 changed files with 58 additions and 74 deletions
+9 -15
View File
@@ -1,26 +1,20 @@
import { botId } from "../../bot.ts";
import type { Bot } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import { EditMessage } from "../../types/messages/edit_message.ts";
import type { Message } from "../../types/messages/message.ts";
import type { PermissionStrings } from "../../types/permissions/permission_strings.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
import { snakelize, validateComponents } from "../../util/utils.ts";
import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Suppress all the embeds in this message */
export async function suppressEmbeds(channelId: bigint, messageId: bigint) {
export async function suppressEmbeds(bot: Bot, channelId: bigint, messageId: bigint) {
const message = await cacheHandlers.get("messages", messageId);
await requireBotChannelPermissions(channelId, message ? ["MANAGE_MESSAGES"] : ["SEND_MESSAGES"]);
await bot.utils.requireBotChannelPermissions(bot, channelId, message ? ["MANAGE_MESSAGES"] : ["SEND_MESSAGES"]);
const result = await rest.runMethod<Message>(
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(
bot.rest,
"patch",
endpoints.CHANNEL_MESSAGE(channelId, messageId),
snakelize({ flags: 4 })
bot.constants.endpoints.CHANNEL_MESSAGE(channelId, messageId),
bot.utils.snakelize({ flags: 4 })
);
return await structures.createDiscordenoMessage(result);
return await bot.transformers.message(bot, result);
}