Discord webhooks now mirror character log
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
import Discord from 'discord.js'
|
||||
export default function sendWebhook({webhookURL, message}){
|
||||
export default function sendWebhook({webhookURL, message, options}){
|
||||
//webhookURL = https://discordapp.com/api/webhooks/<id>/<token>
|
||||
let urlArray = webhookURL.split('/');
|
||||
let token = urlArray.pop();
|
||||
let id = urlArray.pop();
|
||||
// const hook = new Discord.WebhookClient(webhook.id, webhook.token);
|
||||
const hook = new Discord.WebhookClient(id, token);
|
||||
// Send a message using the webhook
|
||||
hook.send(message);
|
||||
hook.send(message, options)
|
||||
}
|
||||
|
||||
export function sendWebhookAsCreature({creature, content, embeds}){
|
||||
if (!creature || !creature.discordWebhook) return;
|
||||
if (!creature || !creature.settings || !creature.settings.discordWebhook) return;
|
||||
sendWebhook({
|
||||
webhookURL: creature.discordWebhook,
|
||||
message: {
|
||||
webhookURL: creature.settings.discordWebhook,
|
||||
message: content,
|
||||
options: {
|
||||
username: creature.name,
|
||||
avatar_url: creature.avatarPicture,
|
||||
content,
|
||||
avatarURL: creature.avatarPicture,
|
||||
embeds,
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user