update/add panic control
This commit is contained in:
1 parent
76467288f5
commit
441bb0672c
4 files changed
+157
-3
No files matched your search
@@ -0,0 +1,118 @@
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const io = require('socket.io-client');
|
||||
|
||||
module.exports = {
|
||||
name: "panic",
|
||||
description: "Enables users panic button",
|
||||
permissions: {
|
||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||
member: [],
|
||||
},
|
||||
aliases: ["enablepanic"],
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
*/
|
||||
run: async (client, message) => {
|
||||
let user = await client.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
|
||||
if (!user) return message.channel.send(`You are not logged in.`);
|
||||
if (user.user.activeCommunity==null) return message.channel.send(`You must join a community to use this command.`);
|
||||
const socket = io.connect(client.config.socket);
|
||||
// If panic is enabled, disable panic
|
||||
if (user.user.dispatchStatus=='Panic') {
|
||||
let myReq = {
|
||||
userID: user._id,
|
||||
communityID: user.user.activeCommunity
|
||||
};
|
||||
socket.emit('clear_panic', myReq);
|
||||
|
||||
let myUpdateReq = {
|
||||
userID: user._id,
|
||||
status: '10-8',
|
||||
setBy: 'System',
|
||||
onDuty: null,
|
||||
updateDuty: false
|
||||
};
|
||||
socket.emit('bot_update_status', myUpdateReq);
|
||||
socket.on('bot_updated_status', (res) => {
|
||||
message.channel.send(`Disabled Panic ${message.author} and set status to \`10-8\`.`);
|
||||
socket.disconnect();
|
||||
});
|
||||
return;
|
||||
|
||||
// If panic is disabled, enable panic
|
||||
} else {
|
||||
client.forceUpdateStatus(message.channel, message.author.id, 'Panic');
|
||||
|
||||
let req = {
|
||||
userID: user._id,
|
||||
userUsername: user.user.username,
|
||||
activeCommunity: user.user.activeCommunity
|
||||
}
|
||||
socket.emit('panic_button_update', req);
|
||||
socket.disconnect();
|
||||
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
|
||||
if (guild.server.pingOnPanic) return message.channel.send(`Attention <@&${guild.server.pingRole}>! \`${user.user.username}\` has activated panic`);
|
||||
return;
|
||||
}
|
||||
},
|
||||
SlashCommand: {
|
||||
options: [],
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
*/
|
||||
run: async (client, interaction, args, { GuildDB }) => {
|
||||
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
|
||||
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||
}
|
||||
|
||||
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
|
||||
if (!user) return interaction.send(`You are not logged in.`);
|
||||
if (user.user.activeCommunity==null) return interaction.send(`You must join a community to use this command.`);
|
||||
const socket = io.connect(client.config.socket);
|
||||
// If panic is enabled, disable panic
|
||||
if (user.user.dispatchStatus=='Panic') {
|
||||
let myReq = {
|
||||
userID: user._id,
|
||||
communityID: user.user.activeCommunity
|
||||
};
|
||||
socket.emit('clear_panic', myReq);
|
||||
|
||||
let myUpdateReq = {
|
||||
userID: user._id,
|
||||
status: '10-8',
|
||||
setBy: 'System',
|
||||
onDuty: null,
|
||||
updateDuty: false
|
||||
};
|
||||
socket.emit('bot_update_status', myUpdateReq);
|
||||
socket.on('bot_updated_status', (res) => {
|
||||
interaction.send(`Disabled Panic <@${interaction.member.user.id}> and set status to \`10-8\`.`);
|
||||
socket.disconnect();
|
||||
});
|
||||
return;
|
||||
// If panic is disabled, enable panic
|
||||
} else {
|
||||
client.forceUpdateStatus(interaction, interaction.member.user.id, 'Panic');
|
||||
|
||||
let req = {
|
||||
userID: user._id,
|
||||
userUsername: user.user.username,
|
||||
activeCommunity: user.user.activeCommunity
|
||||
}
|
||||
socket.emit('panic_button_update', req);
|
||||
socket.disconnect();
|
||||
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":GuildDB.serverID}).then(guild => guild);
|
||||
if (guild.server.pingOnPanic) return message.channel.send(`Attention <@&${guild.server.pingRole}>! \`${user.user.username}\` has activated panic`);
|
||||
return;
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
* @param {*} param3
|
||||
*/
|
||||
run: async (client, message, args) => {
|
||||
let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80', 'Panic', '10-41', '10-42'];
|
||||
let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80', '10-41', '10-42'];
|
||||
let user = await client.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
|
||||
if (!user) return message.channel.send(`You are not logged in ${message.author}`);
|
||||
if (user.user.activeCommunity==null) return message.channel.send(`You must join a community to use this command.`);
|
||||
@@ -63,7 +63,7 @@ module.exports = {
|
||||
{ name: '10-8 (In Service)', value: '10-8', }, { name: '10-7 (Out of Service)', value: '10-7', }, { name: '10-6 (Busy)', value: '10-6', },
|
||||
{ name: '10-11 (Traffic Stop)', value: '10-11', }, { name: '10-23 (Arrive on Scene', value: '10-23', }, { name: '10-97 (In Route)', value: '10-97' },
|
||||
{ name: '10-15 (Subject in Custody)', value: '10-15', }, { name: '10-70 (Foot Pursuit)', value: '10-70', }, { name: '10-80 (Vehicle Pursuit)', value: '10-80' },
|
||||
{ name: 'Panic', value: 'Panic', }, { name: '10-41 (Log in to CAD)', value: '10-41', }, { name: '10-42 (Log out of CAD)', value: '10-42' },
|
||||
{ name: '10-41 (Log in to CAD)', value: '10-41', }, { name: '10-42 (Log out of CAD)', value: '10-42' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user