Merge pull request #170 from Thomas-Smyth/fob-hab-radio-explosion-damage

Add plugin to log FOB/HAB explosion damage to Discord
This commit is contained in:
Thomas Smyth 2021-03-08 19:14:55 +00:00 committed by GitHub
commit f182a3326c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 111 additions and 0 deletions

View File

@ -537,6 +537,29 @@ Grafana (NOT YET WORKING WITH V2):
]</code></pre></ul>
</details>
<details>
<summary>DiscordFOBHABExplosionDamage</summary>
<h2>DiscordFOBHABExplosionDamage</h2>
<p>The <code>DiscordFOBHABExplosionDamage</code> plugin logs damage done to FOBs and HABs by explosions to help identify engineers blowing up friendly FOBs and HABs.</p>
<h3>Options</h3>
<ul><li><h4>discordClient (Required)</h4>
<h6>Description</h6>
<p>Discord connector name.</p>
<h6>Default</h6>
<pre><code>discord</code></pre></li>
<li><h4>channelID (Required)</h4>
<h6>Description</h6>
<p>The ID of the channel to log FOB/HAB explosion damage to.</p>
<h6>Default</h6>
<pre><code></code></pre></li><h6>Example</h6>
<pre><code>667741905228136459</code></pre>
<li><h4>color</h4>
<h6>Description</h6>
<p>The color of the embeds.</p>
<h6>Default</h6>
<pre><code>16761867</code></pre></li></ul>
</details>
<details>
<summary>DiscordPlaceholder</summary>
<h2>DiscordPlaceholder</h2>

View File

@ -111,6 +111,13 @@
"channelID": "",
"events": []
},
{
"plugin": "DiscordFOBHABExplosionDamage",
"enabled": true,
"discordClient": "discord",
"channelID": "",
"color": 16761867
},
{
"plugin": "DiscordPlaceholder",
"enabled": true,

View File

@ -0,0 +1,81 @@
import DiscordBasePlugin from './discord-base-plugin.js';
export default class DiscordFOBHABExplosionDamage extends DiscordBasePlugin {
static get description() {
return (
'The <code>DiscordFOBHABExplosionDamage</code> plugin logs damage done to FOBs and HABs by ' +
'explosions to help identify engineers blowing up friendly FOBs and HABs.'
);
}
static get defaultEnabled() {
return true;
}
static get optionsSpecification() {
return {
...DiscordBasePlugin.optionsSpecification,
channelID: {
required: true,
description: 'The ID of the channel to log FOB/HAB explosion damage to.',
default: '',
example: '667741905228136459'
},
color: {
required: false,
description: 'The color of the embeds.',
default: 16761867
}
};
}
constructor(server, options, connectors) {
super(server, options, connectors);
this.onDeployableDamaged = this.onDeployableDamaged.bind(this);
}
async mount() {
this.server.on('DEPLOYABLE_DAMAGED', this.onDeployableDamaged);
}
async unmount() {
this.server.removeEventListener('DEPLOYABLE_DAMAGED', this.onDeployableDamaged);
}
async onDeployableDamaged(info) {
if (!info.deployable.match(/(?:FOBRadio|Hab)_/i)) return;
if (!info.weapon.match(/_Deployable_/i)) return;
if (!info.player) return;
const fields = [
{
name: "Player's Name",
value: info.player.name,
inline: true
},
{
name: "Player's SteamID",
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
inline: true
},
{
name: 'Deployable',
value: info.deployable
},
{
name: 'Weapon',
value: info.weapon
}
];
await this.sendDiscordMessage({
embed: {
title: `FOB/HAB Explosion Damage: ${info.player.name}`,
color: this.options.color,
fields: fields,
timestamp: info.time.toISOString()
}
});
}
}