mirror of
https://gitdab.com/cadence/out-of-your-element.git
synced 2025-09-10 12:22:50 +02:00
add webhook creation utility
This commit is contained in:
parent
cc1210729f
commit
5bd1bc9a5b
4 changed files with 79 additions and 0 deletions
23
m2d/actions/send-message.js
Normal file
23
m2d/actions/send-message.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
// @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
|
Loading…
Add table
Add a link
Reference in a new issue