Skip to content

Commit

Permalink
Add raid alarm plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexemanuelol committed Aug 26, 2022
1 parent 77f2484 commit 59cdffc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/util/FcmListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ module.exports = async (client, guild) => {
} break;

default: {
if (data.title === 'You\'re getting raided!') {
/* Custom alarm from plugin: https://umod.org/plugins/raid-alarm */
client.log('FCM', `${guild.id} alarm: raid-alarm plugin`);
alarmRaidAlarm(client, guild, full, data, body);
break;
}
client.log('FCM', `${guild.id} alarm: other\n${JSON.stringify(full)}`);
} break;
}
Expand Down Expand Up @@ -368,6 +374,32 @@ async function alarmAlarm(client, guild, full, data, body) {
}
}

async function alarmRaidAlarm(client, guild, full, data, body) {
let instance = client.readInstanceFile(guild.id);
let serverId = `${body.ip}-${body.port}`;
let rustplus = client.rustplusInstances[guild.id];
let channel = DiscordTools.getTextChannelById(guild.id, instance.channelId.activity);

if (channel !== undefined) {
await client.messageSend(channel, {
embeds: [DiscordEmbeds.getEmbed({
color: '#00ff40',
timestamp: true,
footer: { text: body.name },
title: data.title,
description: data.message,
thumbnail: body.img
})],
});
}

if (rustplus && (serverId === rustplus.serverId)) {
rustplus.sendTeamMessageAsync(`${data.title}: ${data.message}`);
}

client.log('INFO', `${data.title} ${data.message}`);
}

async function playerDeath(client, guild, full, data, body, ownerId) {
let member = await DiscordTools.getMemberById(guild.id, ownerId);

Expand Down

0 comments on commit 59cdffc

Please sign in to comment.