1
0
Fork 0
out-of-your-element-fork-th.../m2d/actions/send-message.js

24 lines
859 B
JavaScript
Raw Normal View History

2023-06-30 03:15:34 +00:00
// @ts-check
const assert = require("assert").strict
const DiscordTypes = require("discord-api-types/v10")
const passthrough = require("../../passthrough")
const {sync, discord, db} = passthrough
/** @type {import("./register-webhook")} */
const registerWebhook = sync.require("./register-webhook")
/**
* @param {string} channelID
* @param {DiscordTypes.RESTPostAPIWebhookWithTokenJSONBody & {name: string, file: Buffer}[]} data
*/
// param {DiscordTypes.RESTPostAPIWebhookWithTokenQuery & {wait: true, disableEveryone?: boolean}} options
async function sendMessage(channelID, data) {
const result = await registerWebhook.withWebhook(channelID, async webhook => {
return discord.snow.webhook.executeWebhook(webhook.id, webhook.token, data, {wait: true, disableEveryone: true})
})
return result
}
module.exports.sendMessage = sendMessage