2020-08-20 15:21:03 -05:00
|
|
|
import { COPYRIGHT_MESSAGE } from 'core/constants';
|
2020-06-13 09:33:44 -05:00
|
|
|
import {
|
|
|
|
LOG_PARSER_PLAYER_POSSESS,
|
|
|
|
LOG_PARSER_PLAYER_UNPOSSESS
|
|
|
|
} from 'squad-server/events/log-parser';
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
export default {
|
|
|
|
name: 'discord-admin-cam-logs',
|
2020-08-22 08:32:39 -05:00
|
|
|
description:
|
|
|
|
'The `discord-admin-cam-logs` plugin will log in game admin camera usage to a Discord channel.',
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-22 10:54:05 -05:00
|
|
|
defaultEnabled: true,
|
2020-08-20 15:21:03 -05:00
|
|
|
optionsSpec: {
|
|
|
|
discordClient: {
|
|
|
|
type: 'DiscordConnector',
|
|
|
|
required: true,
|
|
|
|
default: 'discord',
|
|
|
|
description: 'The name of the Discord Connector to use.'
|
|
|
|
},
|
|
|
|
channelID: {
|
|
|
|
type: 'Discord Channel ID',
|
|
|
|
required: true,
|
|
|
|
default: 'Discord Channel ID',
|
|
|
|
description: 'The ID of the channel to log admin cam usage to.'
|
|
|
|
},
|
|
|
|
color: {
|
|
|
|
type: 'Discord Color Code',
|
|
|
|
required: false,
|
|
|
|
default: 16761867,
|
|
|
|
description: 'The color of the embed.'
|
|
|
|
}
|
|
|
|
},
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
init: async (server, options) => {
|
|
|
|
const channel = await options.discordClient.channels.fetch(options.channelID);
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
const adminsInCam = {};
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
server.on(LOG_PARSER_PLAYER_POSSESS, (info) => {
|
|
|
|
if (info.player === null || info.possessClassname !== 'CameraMan') return;
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
adminsInCam[info.player.steamID] = info.time;
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
channel.send({
|
|
|
|
embed: {
|
|
|
|
title: `Admin Entered Admin Camera`,
|
|
|
|
color: options.color,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: "Admin's Name",
|
|
|
|
value: info.player.name,
|
|
|
|
inline: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Admin's SteamID",
|
|
|
|
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
|
|
|
|
inline: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
timestamp: info.time.toISOString(),
|
|
|
|
footer: {
|
|
|
|
text: COPYRIGHT_MESSAGE
|
2020-05-15 12:42:39 -05:00
|
|
|
}
|
|
|
|
}
|
2020-08-20 15:21:03 -05:00
|
|
|
});
|
2020-05-15 14:23:16 -05:00
|
|
|
});
|
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
server.on(LOG_PARSER_PLAYER_UNPOSSESS, (info) => {
|
|
|
|
if (info.switchPossess === true || !(info.player.steamID in adminsInCam)) return;
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
channel.send({
|
|
|
|
embed: {
|
|
|
|
title: `Admin Left Admin Camera`,
|
|
|
|
color: options.color,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: "Admin's Name",
|
|
|
|
value: info.player.name,
|
|
|
|
inline: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Admin's SteamID",
|
|
|
|
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
|
|
|
|
inline: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Time in Admin Camera',
|
|
|
|
value: `${Math.round(
|
|
|
|
(info.time.getTime() - adminsInCam[info.player.steamID].getTime()) / 60000
|
|
|
|
)} mins`
|
|
|
|
}
|
|
|
|
],
|
|
|
|
timestamp: info.time.toISOString(),
|
|
|
|
footer: {
|
|
|
|
text: COPYRIGHT_MESSAGE
|
2020-05-15 12:42:39 -05:00
|
|
|
}
|
|
|
|
}
|
2020-08-20 15:21:03 -05:00
|
|
|
});
|
2020-05-15 12:42:39 -05:00
|
|
|
|
2020-08-20 15:21:03 -05:00
|
|
|
delete adminsInCam[info.player.steamID];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|