set for 911/911 feature/debugging
This commit is contained in:
5 files changed
+421
-62
No files matched your search
+164
@@ -0,0 +1,164 @@
|
||||
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: "911",
|
||||
debug: false,
|
||||
description: "Call the emergency hotline",
|
||||
usage: "[name] [service] [location] [nature]",
|
||||
permissions: {
|
||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||
member: [],
|
||||
},
|
||||
SlashCommand: {
|
||||
options: [
|
||||
{
|
||||
name: "name",
|
||||
description: "Caller name",
|
||||
value: "name",
|
||||
type: 3,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: "service",
|
||||
description: "What emergency service you require",
|
||||
value: "service",
|
||||
type: 3,
|
||||
required: true,
|
||||
choices: [
|
||||
{ name: "Fire Dept.", value: "Fire Dept." }, { name: "Law Enforcement", value: "Law Enforcement" },
|
||||
{ name: "EMS (Medical)", value: "EMS" }, { name: "All Dept.", value: "All Dept." }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "location",
|
||||
description: "The location of your emergency",
|
||||
value: "location",
|
||||
type: 3,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "nature",
|
||||
description: "The nature fo your emergency",
|
||||
value: "nature",
|
||||
type: 3,
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {import("discord.js").MessageCreate} 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.`);
|
||||
}
|
||||
|
||||
const missing = !GuildDB.dispatchChannel && !GuildDB.dispatcherRole
|
||||
? 3
|
||||
: !GuildDB.dispatchChannel
|
||||
? 2
|
||||
: !GuildDB.dispatcherRole
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
if (missing > 0) {
|
||||
const configure = missing = 1
|
||||
? '1. `dispatcher_role`'
|
||||
: missing = 2
|
||||
? '1. `dispatcher_channel`'
|
||||
: missing = 3
|
||||
? '1. `dispatcher_role`\n2. `dispatcher_channel`'
|
||||
: 'Error';
|
||||
|
||||
const errorEmbed = new MessageEmbed()
|
||||
.setColor("RED")
|
||||
.setTitle("Notice:")
|
||||
.setDescription(`An admin needs to configure the following:\n${configure}`)
|
||||
|
||||
return interaction.send({ embeds: [errorEmbed] });
|
||||
}
|
||||
|
||||
const ID = Math.floor(100000 + Math.random() * 900000);
|
||||
let status = 'Open';
|
||||
let Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
|
||||
|
||||
let embed911 = new MessageEmbed()
|
||||
.setColor(client.config.EmbedColor)
|
||||
.setTitle('911 Call Alert')
|
||||
.setTimestamp()
|
||||
.setDescription(Description)
|
||||
|
||||
let opt = new MessageActionRow()
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
.setCustomId(`close-${GuildDB.dispatcherRole}`)
|
||||
.setLabel("Close")
|
||||
.setStyle("PRIMARY"),
|
||||
)
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
.setCustomId(`delete-${GuildDB.dispatcherRole}`)
|
||||
.setLabel("Delete")
|
||||
.setStyle("DANGER"),
|
||||
)
|
||||
|
||||
client.on("interactionCreate", ButtonInteraction => {
|
||||
if(!ButtonInteraction.isButton()) return;
|
||||
const queryString = ButtonInteraction.customId;
|
||||
if (!ButtonInteraction.member._roles.includes(GuildDB.dispatcherRole)) {
|
||||
return ButtonInteraction.reply({
|
||||
content: "This button is not for you",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
if (queryString.startsWith('close')) {
|
||||
status = 'Closed';
|
||||
Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
|
||||
|
||||
} else if (queryString.startsWith('open')) {
|
||||
status = 'Open';
|
||||
Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
|
||||
} else if (queryString.startsWith('delete')) {
|
||||
const closedEmbed = new MessageEmbed().setTitle('Deleted Call').setColor(client.config.EmbedColor);
|
||||
return ButtonInteraction.update({ embeds: [closedEmbed], components: [] });
|
||||
}
|
||||
|
||||
embed911 = new MessageEmbed()
|
||||
.setColor(client.config.EmbedColor)
|
||||
.setTitle('911 Call Alert')
|
||||
.setTimestamp()
|
||||
.setDescription(Description)
|
||||
|
||||
opt = new MessageActionRow()
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
.setCustomId(`${queryString.startsWith('close')?'Open':'Close'}-${GuildDB.dispatcherRole}`)
|
||||
.setLabel(queryString.startsWith('close')?'Open':'Close')
|
||||
.setStyle("PRIMARY"),
|
||||
)
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
.setCustomId(`delete-${GuildDB.dispatcherRole}`)
|
||||
.setLabel("Delete")
|
||||
.setStyle("DANGER"),
|
||||
)
|
||||
|
||||
return ButtonInteraction.update({ embeds: [embed911], components: [opt] });
|
||||
})
|
||||
|
||||
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel);
|
||||
if (!channel) {
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nThe channel may have been deleted\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
channel.send({ embeds: [embed911], components: [opt] });
|
||||
return interaction.send('911 Alerted');
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user