135 lines
4.5 KiB
JavaScript
135 lines
4.5 KiB
JavaScript
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
|
|
|
module.exports = {
|
|
name: "311",
|
|
debug: false,
|
|
global: false,
|
|
description: "Report a non emergency",
|
|
usage: "[name] [service] [location] [nature]",
|
|
permissions: {
|
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
|
member: [],
|
|
},
|
|
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,
|
|
}
|
|
],
|
|
SlashCommand: {
|
|
/**
|
|
* @param {require("../structures/QuarksBot")} 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({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) });
|
|
}
|
|
|
|
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 EmbedBuilder()
|
|
.setColor(client.config.Colors.Yellow)
|
|
.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 Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[3].value}`
|
|
|
|
const embed311 = new EmbedBuilder()
|
|
.setColor(client.config.Colors.Default)
|
|
.setTitle('311 Call Alert')
|
|
.setTimestamp()
|
|
.setDescription(Description)
|
|
|
|
const opt = new ActionRowBuilder()
|
|
.addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId(`Delete311`)
|
|
.setLabel("Delete")
|
|
.setStyle(ButtonStyle.Danger),
|
|
)
|
|
|
|
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel);
|
|
if (!channel) {
|
|
const embed = new EmbedBuilder()
|
|
.setDescription(`**Internal Error:** ${err}\nThe channel may have been deleted\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
|
.setColor(client.config.Colors.Red)
|
|
|
|
return interaction.send({ embeds: [embed] });
|
|
}
|
|
try {
|
|
channel.send({ content: `<@&${GuildDB.dispatcherRole}> New 311 report`, embeds: [embed311], components: [opt] });
|
|
} catch (err) {
|
|
return interaction.send({ content: `<@${client.user.id}> Does not have permissions to send to the channel.\nMake sure your admins give <@${client.user.id}> access to all channels required.` })
|
|
}
|
|
return interaction.send({ content: 'A report has been sent via 311.' });
|
|
},
|
|
},
|
|
Interactions: {
|
|
|
|
Delete311: {
|
|
run: async (client, interaction, GuildDB) => {
|
|
if (!interaction.member._roles.includes(GuildDB.dispatcherRole)) {
|
|
return interaction.reply({
|
|
content: "This button is not for you",
|
|
flags: (1 << 6)
|
|
})
|
|
}
|
|
const successEmbed = new EmbedBuilder()
|
|
.setColor(client.config.Colors.Green)
|
|
.setTitle(`Successfully Deleted 311 Report.`)
|
|
|
|
return interaction.update({ embeds: [successEmbed], components: [] });
|
|
}
|
|
}
|
|
}
|
|
} |