swc/bundler/tests/.cache/deno/4b1fcd9155cc51bb4552609aea3626fefc66b92a.ts
강동윤 d60c3242af
fix(swc): Fix bugs (#1739)
swc_bundler:
 - Fix cycle detection for complex circular imports. (denoland/deno#10752)

swc_ecma_transforms_typescript:
 - Allow using large values for an enum variant.
2021-05-25 14:30:17 +09:00

23 lines
954 B
TypeScript

// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/helpers/messages/delete_message.ts
import { botId } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
import { delay } from "../../util/utils.ts";
/** Delete a message with the channel id and message id only. */
export async function deleteMessage(channelId: bigint, messageId: bigint, reason?: string, delayMilliseconds = 0) {
const message = await cacheHandlers.get("messages", messageId);
if (message && message.authorId !== botId) {
await requireBotChannelPermissions(message.channelId, ["MANAGE_MESSAGES"]);
}
if (delayMilliseconds) await delay(delayMilliseconds);
return await rest.runMethod<undefined>("delete", endpoints.CHANNEL_MESSAGE(channelId, messageId), { reason });
}