mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 19:54:25 -05:00
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:
commit
f182a3326c
23
README.md
23
README.md
@ -537,6 +537,29 @@ Grafana (NOT YET WORKING WITH V2):
|
|||||||
]</code></pre></ul>
|
]</code></pre></ul>
|
||||||
</details>
|
</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>
|
<details>
|
||||||
<summary>DiscordPlaceholder</summary>
|
<summary>DiscordPlaceholder</summary>
|
||||||
<h2>DiscordPlaceholder</h2>
|
<h2>DiscordPlaceholder</h2>
|
||||||
|
@ -111,6 +111,13 @@
|
|||||||
"channelID": "",
|
"channelID": "",
|
||||||
"events": []
|
"events": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"plugin": "DiscordFOBHABExplosionDamage",
|
||||||
|
"enabled": true,
|
||||||
|
"discordClient": "discord",
|
||||||
|
"channelID": "",
|
||||||
|
"color": 16761867
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"plugin": "DiscordPlaceholder",
|
"plugin": "DiscordPlaceholder",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
81
squad-server/plugins/discord-fob-hab-explosion-damage.js
Normal file
81
squad-server/plugins/discord-fob-hab-explosion-damage.js
Normal 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()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user