set for 911/911 feature/debugging

This commit is contained in:
SowinskiBraeden committed 2022-08-05 15:26:00 -07:00
1 parent 1325a1f80c
commit 7fd292650d
5 files changed
+406 -47

No files matched your search

+164
View File
@@ -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');
},
},
}
+7
View File
@@ -39,6 +39,13 @@ module.exports = {
if (client.exists(GuildDB.actionChannel)) { if (client.exists(GuildDB.actionChannel)) {
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.actionChannel); const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.actionChannel);
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: [actionEmbed] }); channel.send({ embeds: [actionEmbed] });
return interaction.send('Action performed'); return interaction.send('Action performed');
} else { } else {
+224 -47
View File
@@ -27,6 +27,7 @@ module.exports = {
description: "The channel to configure", description: "The channel to configure",
value: "channel", value: "channel",
type: 7, type: 7,
required: true,
}] }]
}, },
{ {
@@ -39,6 +40,7 @@ module.exports = {
description: "The channel to configure", description: "The channel to configure",
value: "channel", value: "channel",
type: 7, type: 7,
required: true,
}] }]
}, },
] ]
@@ -59,6 +61,7 @@ module.exports = {
description: "The channel to configure", description: "The channel to configure",
value: "channel", value: "channel",
type: 7, type: 7,
required: true,
}] }]
}, },
{ {
@@ -66,12 +69,6 @@ module.exports = {
description: "Remove channel", description: "Remove channel",
value: "remove", value: "remove",
type: 1, type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
}]
}, },
] ]
}, },
@@ -91,6 +88,7 @@ module.exports = {
description: "The channel to configure", description: "The channel to configure",
value: "channel", value: "channel",
type: 7, type: 7,
required: true,
}] }]
}, },
{ {
@@ -98,12 +96,6 @@ module.exports = {
description: "Remove channel", description: "Remove channel",
value: "remove", value: "remove",
type: 1, type: 1,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
}]
}, },
] ]
}, },
@@ -123,6 +115,7 @@ module.exports = {
description: "The channel to configure", description: "The channel to configure",
value: "channel", value: "channel",
type: 7, type: 7,
required: true,
}] }]
}, },
{ {
@@ -130,13 +123,34 @@ module.exports = {
description: "Remove channel", description: "Remove channel",
value: "remove", value: "remove",
type: 1, type: 1,
},
]
},
{
name: "dispatcher_channel",
description: "Set the channel for dispatchers to recieve notifications.",
value: "adverts_channel",
type: 2,
options: [
{
name: "set",
description: "Set channel",
value: "set",
type: 1,
options: [{ options: [{
name: "channel", name: "channel",
description: "The channel to configure", description: "The channel to configure",
value: "channel", value: "channel",
type: 7, type: 7,
required: true
}] }]
}, },
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
},
] ]
}, },
{ {
@@ -219,13 +233,6 @@ module.exports = {
description: "Remove role", description: "Remove role",
value: "remove", value: "remove",
type: 1, type: 1,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: 8,
required: true,
}]
}, },
] ]
}, },
@@ -253,13 +260,33 @@ module.exports = {
description: "Remove role", description: "Remove role",
value: "remove", value: "remove",
type: 1, type: 1,
},
]
},
{
name: "dispatcher_role",
description: "Set/remove dispatcher role",
value: "officer_role",
type: 2,
options: [
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [{ options: [{
name: "role", name: "role",
description: "Role to remove", description: "Role to set",
value: "role", value: "role",
type: 8, type: 8,
required: true, required: true,
}] }],
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
}, },
] ]
}, },
@@ -325,7 +352,7 @@ module.exports = {
.setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`); .setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`);
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const embed = new MessageEmbed() const embed = new MessageEmbed()
.setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`) .setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`)
@@ -385,9 +412,8 @@ module.exports = {
} }
} else if (args[0].name == 'action_channel') { } else if (args[0].name == 'action_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value; const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
const channelSetting = GuildDB.actionChannel; const channelSetting = GuildDB.actionChannel;
const presetEmbed = new MessageEmbed() const presetEmbed = new MessageEmbed()
@@ -411,7 +437,7 @@ module.exports = {
.setDescription(`**Success:** Set <#${channelid}> as the action channel.`); .setDescription(`**Success:** Set <#${channelid}> as the action channel.`);
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed() const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for actions?`) .setTitle(`Are you sure you want to stop using this channel for actions?`)
.setColor(client.config.EmbedColor) .setColor(client.config.EmbedColor)
@@ -464,9 +490,8 @@ module.exports = {
} }
} else if (args[0].name == 'tweet_channel') { } else if (args[0].name == 'tweet_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value; const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
const channelSetting = GuildDB.tweetChannel; const channelSetting = GuildDB.tweetChannel;
const presetEmbed = new MessageEmbed() const presetEmbed = new MessageEmbed()
@@ -490,7 +515,7 @@ module.exports = {
.setDescription(`**Success:** Set <#${channelid}> as the tweet channel.`); .setDescription(`**Success:** Set <#${channelid}> as the tweet channel.`);
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed() const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for tweets?`) .setTitle(`Are you sure you want to stop using this channel for tweets?`)
.setColor(client.config.EmbedColor) .setColor(client.config.EmbedColor)
@@ -543,9 +568,8 @@ module.exports = {
} }
} else if (args[0].name == 'adverts_channel') { } else if (args[0].name == 'adverts_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value; const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
const channelSetting = GuildDB.advertsChannel; const channelSetting = GuildDB.advertsChannel;
const presetEmbed = new MessageEmbed() const presetEmbed = new MessageEmbed()
@@ -566,10 +590,10 @@ module.exports = {
const successEmbed = new MessageEmbed() const successEmbed = new MessageEmbed()
.setColor("GREEN") .setColor("GREEN")
.setTitle(`Successfully set <#${channelid}> for advertisements.`) .setDescription(`**Success:** Set <#${channelid}> for advertisements.`)
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed() const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for advertisements?`) .setTitle(`Are you sure you want to stop using this channel for advertisements?`)
.setColor(client.config.EmbedColor) .setColor(client.config.EmbedColor)
@@ -621,6 +645,85 @@ module.exports = {
return; return;
} }
} else if (args[0].name == 'dispatcher_channel') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.advertsChannel;
const presetEmbed = new MessageEmbed()
.setColor(client.config.EmbedColor)
.setDescription(`The channel <#${channelid}> has already been set for dispatchers.`)
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.dispatchChannel":channelid}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setDescription(`**Success:** Set <#${channelid}> for dispatchers.`)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to stop using this channel for advertisements?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt], ephemeral: true });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.dispatchChannel": null}},function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Success: You ${action} the channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'starting_balance') { } else if (args[0].name == 'starting_balance') {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, function(err, res) {
if (err) { if (err) {
@@ -640,8 +743,8 @@ module.exports = {
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'income_role') { } else if (args[0].name == 'income_role') {
if (args[0].options[0].name== 'set') {
const roleId = args[0].options[0].options[0].value const roleId = args[0].options[0].options[0].value
if (args[0].options[0].value == 'set') {
if (args[0].options[0].options[1].value <= 0) { if (args[0].options[0].options[1].value <= 0) {
let embed = new MessageEmbed() let embed = new MessageEmbed()
@@ -669,7 +772,7 @@ module.exports = {
} }
}); });
} else { } else {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": roleId}, client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID, "server.incomeRoles.role": roleId},
{$set: {"server.incomeRoles.$.income": args[0].options[0].options[1].value}}, function(err, res) { {$set: {"server.incomeRoles.$.income": args[0].options[0].options[1].value}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
@@ -689,7 +792,7 @@ module.exports = {
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==roleId); const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==roleId);
if (searchIndex == -1) { if (searchIndex == -1) {
const errorEmbed = new MessageEmbed() const errorEmbed = new MessageEmbed()
@@ -728,7 +831,7 @@ module.exports = {
let action = ''; let action = '';
if (queryString==`yes-${interaction.member.user.id}`) { if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed'; action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
const embed = new MessageEmbed() const embed = new MessageEmbed()
@@ -751,10 +854,10 @@ module.exports = {
} }
} else if (args[0].name == 'commercial_role') { } else if (args[0].name == 'commercial_role') {
if (args[0].options[0].name== 'set') {
const roleId = args[0].options[0].options[0].value; const roleId = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.commercialRole": roleId}}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.commercialRole": roleId}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
const embed = new MessageEmbed() const embed = new MessageEmbed()
@@ -766,12 +869,12 @@ module.exports = {
}); });
const successEmbed = new MessageEmbed() const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${roleId}>'s as commercial role.\nUsers with this role can now use business commands.`) .setDescription(`Successfully set <@&${roleId}> as commercial role.\nUsers with this role can now use business commands.`)
.setColor('GREEN'); .setColor('GREEN');
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed() const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this role as commercial role?`) .setTitle(`Are you sure you want to remove this role as commercial role?`)
.setColor(client.config.EmbedColor) .setColor(client.config.EmbedColor)
@@ -802,7 +905,7 @@ module.exports = {
let action = ''; let action = '';
if (queryString==`yes-${interaction.member.user.id}`) { if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed'; action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
const embed = new MessageEmbed() const embed = new MessageEmbed()
@@ -826,9 +929,9 @@ module.exports = {
} else if (args[0].name == 'officer_role') { } else if (args[0].name == 'officer_role') {
const roleId = args[0].options[0].options[0].value; const roleId = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') { if (args[0].options[0].name== 'set') {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.officerRole": roleId}}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.officerRole": roleId}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
const embed = new MessageEmbed() const embed = new MessageEmbed()
@@ -840,12 +943,12 @@ module.exports = {
}); });
const successEmbed = new MessageEmbed() const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${roleId}>'s as officer role.\nUsers with this role can now fine other users.`) .setDescription(`Successfully set <@&${roleId}> as officer role.\nUsers with this role can now fine other users.`)
.setColor('GREEN'); .setColor('GREEN');
return interaction.send({ embeds: [successEmbed] }); return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') { } else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed() const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this role as officer role?`) .setTitle(`Are you sure you want to remove this role as officer role?`)
.setColor(client.config.EmbedColor) .setColor(client.config.EmbedColor)
@@ -876,7 +979,7 @@ module.exports = {
let action = ''; let action = '';
if (queryString==`yes-${interaction.member.user.id}`) { if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed'; action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$set: {"server.officerRole": null}}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
const embed = new MessageEmbed() const embed = new MessageEmbed()
@@ -897,9 +1000,83 @@ module.exports = {
return; return;
} }
} else if (args[0].name == 'dispatcher_role') {
if (args[0].options[0].name == 'set') {
const roleId = args[0].options[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatcherRole": roleId}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${roleId}> as dispatcher role.\nUsers with this role can now receive 911/311 notifications.`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].name== 'remove') {
const prompt = new MessageEmbed()
.setTitle(`Are you sure you want to remove this role as dispatcher role?`)
.setColor(client.config.EmbedColor)
const opt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [prompt], components: [opt], ephemeral: true });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
ephemeral: true
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
return;
}
} else if (args[0].name == 'only_officers_search') { } else if (args[0].name == 'only_officers_search') {
const setting = args[0].options[0]; const setting = args[0].options[0];
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$set: {"server.onlyOfficersSearch": setting}}, function(err, res) { client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.onlyOfficersSearch": setting}}, function(err, res) {
if (err) { if (err) {
client.log(err); client.log(err);
const embed = new MessageEmbed() const embed = new MessageEmbed()
+7
View File
@@ -44,6 +44,13 @@ module.exports = {
if (client.exists(GuildDB.tweetChannel)) { if (client.exists(GuildDB.tweetChannel)) {
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.tweetChannel); const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.tweetChannel);
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: [tweetEmbed] }); channel.send({ embeds: [tweetEmbed] });
return interaction.send('Tweeted!'); return interaction.send('Tweeted!');
} else { } else {
+4
View File
@@ -147,10 +147,12 @@ class QuarksBot extends Client {
actionChannel: null, actionChannel: null,
tweetChannel: null, tweetChannel: null,
advertsChannel: null, advertsChannel: null,
dispatchChannel: null,
startingBalance: 1000.00, startingBalance: 1000.00,
incomeRoles: [], incomeRoles: [],
commercialRole: null, commercialRole: null,
officerRole: null, officerRole: null,
dispatcherRole: null,
onlyOfficersSearch: false, onlyOfficersSearch: false,
} }
} }
@@ -166,11 +168,13 @@ class QuarksBot extends Client {
actionChannel: guild.server.actionChannel, actionChannel: guild.server.actionChannel,
tweetChannel: guild.server.tweetChannel, tweetChannel: guild.server.tweetChannel,
advertsChannel: guild.server.advertsChannel, advertsChannel: guild.server.advertsChannel,
dispatchChannel: guild.server.dispatchChannel,
startingBalance: guild.server.startingBalance, startingBalance: guild.server.startingBalance,
incomeRoleStatus: guild.server.incomeRoles.length > 0 ? true : false, incomeRoleStatus: guild.server.incomeRoles.length > 0 ? true : false,
incomeRoles: guild.server.incomeRoles, incomeRoles: guild.server.incomeRoles,
commercialRole: guild.server.commercialRole, commercialRole: guild.server.commercialRole,
officerRole: guild.server.officerRole, officerRole: guild.server.officerRole,
dispatcherRole: guild.server.dispatcherRole,
onlyOfficersSearch: guild.server.onlyOfficersSearch, onlyOfficersSearch: guild.server.onlyOfficersSearch,
} }
return guildData; return guildData;