const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); module.exports = { name: "911", debug: false, global: false, description: "Call the emergency hotline", 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(`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 EmbedBuilder() .setColor(client.config.Colors.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 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 embed911 = new EmbedBuilder() .setColor(client.config.Colors.Default) .setTitle('911 Call Alert') .setTimestamp() .setDescription(Description) const opt = new ActionRowBuilder() .addComponents( new ButtonBuilder() .setCustomId(`911-delete`) .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 911 call!`, embeds: [embed911], components: [opt] }); } catch (err) { return interaction.send(`<@${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('911 Alerted!'); }, }, }