Bot
Enviar uma mensagem
Exemplo com Node.js 18 ou superior, sem bibliotecas externas.
const token = process.env.WEBON_BOT_TOKEN;
const channelId = "ID_DO_CANAL";
const response = await fetch(
`https://webon.gg/api/v1/channels/${channelId}/messages`,
{
method: "POST",
headers: {
"Authorization": `Bot ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ content: "Olá pelo WEBON!" })
}
);
if (!response.ok) {
throw new Error(`${response.status}: ${await response.text()}`);
}