Merge pull request #198 from ect0s/test

Added Squad Created event binding to server object
This commit is contained in:
Thomas Smyth 2021-07-02 17:06:43 +01:00 committed by GitHub
commit 4e0dc392c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -288,6 +288,16 @@ export default class SquadServer extends EventEmitter {
this.logParser.on('TICK_RATE', (data) => { this.logParser.on('TICK_RATE', (data) => {
this.emit('TICK_RATE', data); this.emit('TICK_RATE', data);
}); });
this.logParser.on('SQUAD_CREATED', (data) => {
data.player = await this.getPlayerBySteamID(data.playerSteamID, true)
delete data.playerName
delete data.playerSteamID
delete data.squadID
this.emit('SQUAD_CREATED', data);
});
} }
async restartLogParser() { async restartLogParser() {

View File

@ -56,7 +56,7 @@ export default class DiscordSquadCreated extends DiscordBasePlugin {
fields: [ fields: [
{ {
name: 'Player', name: 'Player',
value: info.playerName, value: info.player.name,
inline: true inline: true
}, },
{ {
@ -66,7 +66,7 @@ export default class DiscordSquadCreated extends DiscordBasePlugin {
}, },
{ {
name: 'Squad Number & Squad Name', name: 'Squad Number & Squad Name',
value: `${info.squadID} : ${info.squadName}` value: `${info.player.squadID} : ${info.squadName}`
} }
], ],
timestamp: info.time.toISOString() timestamp: info.time.toISOString()
@ -75,7 +75,7 @@ export default class DiscordSquadCreated extends DiscordBasePlugin {
} else { } else {
await this.sendDiscordMessage(` \`\`\`Player: ${info.playerName}\n created Squad ${info.squadID} : ${info.squadName}\n on ${info.teamName}\`\`\` `) await this.sendDiscordMessage(` \`\`\`Player: ${info.player.name}\n created Squad ${info.player.squadID} : ${info.squadName}\n on ${info.teamName}\`\`\` `)
} }
} }
} }