type DiscordBotConfiguration = {
public_key: string,
application_id: string
};
// Note: you can also send messages to channels using Discord webhooks: https://hub.windmill.dev/scripts/discord/1288/
import { RequestInit } from 'node-fetch';
export async function main(
config: DiscordBotConfiguration,
channelId: string,
message: string
): Promise<any> {
const url = `https://discord.com/api/v9/channels/${channelId}/messages`;
const payload = {
content: message
};
const requestOptions: RequestInit = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bot ${config.public_key}`
},
body: JSON.stringify(payload)
};
const response = await fetch(url, requestOptions);
return await response.json();
}
Submitted by henri186 166 days ago