55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
/*
|
|
SkeptCOM [Discord] | Pour envoyer des notifications sur un serveur Discord
|
|
|
|
exemple pour injecter depuis un routage :
|
|
routage.send({
|
|
author: "",
|
|
title: "",
|
|
url : "",
|
|
image: "",
|
|
desc: ""
|
|
})
|
|
*/
|
|
|
|
// REQUIRE, CONST, VARIABLES
|
|
const discordBot = require('../modules/discordBot')
|
|
const skeptIO = require('../modules/skeptIO')('discord')
|
|
|
|
function embed(conf, data) {
|
|
return {
|
|
embed: {
|
|
color: conf.color,
|
|
author: {name: data.author},
|
|
title: data.title,
|
|
url: data.url,
|
|
image: {url: data.image },
|
|
description: data.desc,
|
|
footer: conf.footer
|
|
}
|
|
}
|
|
}
|
|
|
|
function tinyEmbed(conf, data) {
|
|
return {
|
|
embed: {
|
|
color: conf.color,
|
|
author: {name: data.author},
|
|
title: data.title,
|
|
url: data.url,
|
|
thumbnail: {url: data.image},
|
|
description: data.desc,
|
|
footer: conf.footer
|
|
}
|
|
}
|
|
}
|
|
|
|
// INIT
|
|
skeptIO.receive( obj => {
|
|
console.log(` --> [Discord] message from [${obj.from}]`)
|
|
|
|
if (obj.conf.style === "msg") discordBot.send(obj.conf.channel, obj.data.desc)
|
|
if (obj.conf.style === "embed") discordBot.send(obj.conf.channel, embed(obj.conf, obj.data))
|
|
if (obj.conf.style === "tinyEmbed") discordBot.send(obj.conf.channel, tinyEmbed(obj.conf, obj.data))
|
|
|
|
})
|