Skip to content

Commit

Permalink
upgraded handler release notif for the discord bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Snailedlt committed Aug 15, 2021
1 parent 43a967e commit 546d7f4
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions imports/modules/server/discord-logging.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';

const adminLogging_webhookUrl = Meteor.settings.private.DISCORD_ADMIN_LOGGING_WEBHOOK || "";
const releaseLogging_webhookUrl = Meteor.settings.private.DISCORD_RELEASE_LOGGING_WEBHOOK || "";
const generalLogging_webhookUrl = Meteor.settings.private.DISCORD_GENERAL_LOGGING_WEBHOOK || "";
const adminLogging_webhookUrl = Meteor.settings.private.DISCORD_ADMIN_LOGGING_WEBHOOK || '';
const releaseLogging_webhookUrl = Meteor.settings.private.DISCORD_RELEASE_LOGGING_WEBHOOK || '';
const generalLogging_webhookUrl = Meteor.settings.private.DISCORD_GENERAL_LOGGING_WEBHOOK || '';

// Discord Admin Logging :
const d_aLog = (title, description) => {
if(adminLogging_webhookUrl.length > 0){
if (adminLogging_webhookUrl.length > 0) {
HTTP.call('POST', adminLogging_webhookUrl, {
data: { content: `**${title}** - \`${description}\`` }
})
}else{
data: { content: `**${title}** - \`${description}\`` },
});
} else {
console.log(`[Discord Admin Logging] ${title} - ${description}`);
}
};
// Discord Release Logging :
const d_rLog = handler => {
const discordData = {
content: "**New handler release!**",
embeds: [{
color: 3447003,
title: handler.gameName,
url: `https://hub.splitscreen.me/handler/${handler._id}`,
thumbnail: {
url: `https://images.igdb.com/igdb/image/upload/t_cover_big/${handler.gameCover}.jpg`,
},
fields: [
{
name: 'Author',
inline: true,
value: handler.ownerName,
content: '**New handler release!**',
embeds: [
{
color: 3447003,
title: handler.gameName,
url: `https://hub.splitscreen.me/handler/${handler._id}`,
thumbnail: {
url: `https://images.igdb.com/igdb/image/upload/t_cover_big/${handler.gameCover}.jpg`,
},
fields: [
{
name: 'Author',
inline: true,
value: `[${handler.ownerName}](https://hub.splitscreen.me/user/${handler.owner})`,
},
{
name: `Download`,
inline: true,
value: `[Download Handler (v${handler.currentVersion})](https://hub.splitscreen.me/cdn/storage/packages/${handler.currentPackage}/original/handler-${handler._id}-v${handler.currentVersion}.nc?download=true)`,
},
],
timestamp: new Date(),
footer: {
icon_url: 'https://www.splitscreen.me/img/splitscreen-me-logo.png',
text: '© SplitScreen.Me',
},
],
timestamp: new Date(),
footer: {
icon_url: "https://www.splitscreen.me/img/splitscreen-me-logo.png",
text: '© SplitScreen.Me',
},
}],
],
};

if(releaseLogging_webhookUrl.length > 0 && generalLogging_webhookUrl){
if (releaseLogging_webhookUrl.length > 0 && generalLogging_webhookUrl) {
HTTP.call('POST', releaseLogging_webhookUrl, {
data: {...discordData, content: "**New handler release!**\n<@&696472181093171300>"}
data: { ...discordData, content: '**New handler release!**\n<@&696472181093171300>' },
});
HTTP.call('POST', generalLogging_webhookUrl, {
data: discordData
data: discordData,
});
}else{
} else {
console.log(`[Discord Release Logging] ${handler.title} by ${handler.ownerName}`);
}
};

export {d_aLog, d_rLog};
export { d_aLog, d_rLog };

0 comments on commit 546d7f4

Please sign in to comment.