Files
discordeno/helpers/messages/deleteMessage.ts
T
Skillz4Killz 3a5bdce32d feat: helpers support strings in args (#2478)
* fix: helpers support strings in args

* fix: fmt
2022-09-15 20:59:02 -05:00

37 lines
1007 B
TypeScript

import type { Bot } from "../../bot.ts";
import { BigString } from "../../types/shared.ts";
// TODO: Remove `delayMilliseconds` parameter.
/**
* Deletes a message from a channel.
*
* @param bot - The bot instance to use to make the request.
* @param channelId - The ID of the channel to delete the message from.
* @param messageId - The ID of the message to delete from the channel.
*
* @remarks
* If not deleting own message:
* - Requires the `MANAGE_MESSAGES` permission.
*
* Fires a _Message Delete_ gateway event.
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-message}
*/
export async function deleteMessage(
bot: Bot,
channelId: BigString,
messageId: BigString,
reason?: string,
delayMilliseconds = 0,
): Promise<void> {
if (delayMilliseconds) await bot.utils.delay(delayMilliseconds);
return await bot.rest.runMethod<void>(
bot.rest,
"DELETE",
bot.constants.routes.CHANNEL_MESSAGE(channelId, messageId),
{ reason },
);
}