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
+421 -62

No files matched your search

+229 -52
View File
@@ -27,6 +27,7 @@ module.exports = {
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}]
},
{
@@ -39,6 +40,7 @@ module.exports = {
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}]
},
]
@@ -59,6 +61,7 @@ module.exports = {
description: "The channel to configure",
value: "channel",
type: 7,
required: true,
}]
},
{
@@ -66,12 +69,6 @@ module.exports = {
description: "Remove channel",
value: "remove",
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",
value: "channel",
type: 7,
required: true,
}]
},
{
@@ -98,12 +96,6 @@ module.exports = {
description: "Remove channel",
value: "remove",
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",
value: "channel",
type: 7,
required: true,
}]
},
{
@@ -130,13 +123,34 @@ module.exports = {
description: "Remove channel",
value: "remove",
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: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
required: true
}]
},
{
name: "remove",
description: "Remove channel",
value: "remove",
type: 1,
},
]
},
{
@@ -219,13 +233,6 @@ module.exports = {
description: "Remove role",
value: "remove",
type: 1,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: 8,
required: true,
}]
},
]
},
@@ -253,13 +260,33 @@ module.exports = {
description: "Remove role",
value: "remove",
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: [{
name: "role",
description: "Role to remove",
description: "Role to set",
value: "role",
type: 8,
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.`);
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()
.setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`)
@@ -385,9 +412,8 @@ module.exports = {
}
} else if (args[0].name == 'action_channel') {
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.actionChannel;
const presetEmbed = new MessageEmbed()
@@ -411,7 +437,7 @@ module.exports = {
.setDescription(`**Success:** Set <#${channelid}> as the action channel.`);
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()
.setTitle(`Are you sure you want to stop using this channel for actions?`)
.setColor(client.config.EmbedColor)
@@ -464,9 +490,8 @@ module.exports = {
}
} else if (args[0].name == 'tweet_channel') {
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.tweetChannel;
const presetEmbed = new MessageEmbed()
@@ -490,7 +515,7 @@ module.exports = {
.setDescription(`**Success:** Set <#${channelid}> as the tweet channel.`);
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()
.setTitle(`Are you sure you want to stop using this channel for tweets?`)
.setColor(client.config.EmbedColor)
@@ -543,9 +568,8 @@ module.exports = {
}
} else if (args[0].name == 'adverts_channel') {
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
if (args[0].options[0].name== 'set') {
const channelid = args[0].options[0].options[0].value;
const channelSetting = GuildDB.advertsChannel;
const presetEmbed = new MessageEmbed()
@@ -566,10 +590,10 @@ module.exports = {
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully set <#${channelid}> for advertisements.`)
.setDescription(`**Success:** Set <#${channelid}> for advertisements.`)
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()
.setTitle(`Are you sure you want to stop using this channel for advertisements?`)
.setColor(client.config.EmbedColor)
@@ -621,6 +645,85 @@ module.exports = {
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') {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, function(err, res) {
if (err) {
@@ -640,8 +743,8 @@ module.exports = {
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'income_role') {
const roleId = args[0].options[0].options[0].value
if (args[0].options[0].value == 'set') {
if (args[0].options[0].name== 'set') {
const roleId = args[0].options[0].options[0].value
if (args[0].options[0].options[1].value <= 0) {
let embed = new MessageEmbed()
@@ -669,7 +772,7 @@ module.exports = {
}
});
} 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) {
if (err) {
client.log(err);
@@ -689,7 +792,7 @@ module.exports = {
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);
if (searchIndex == -1) {
const errorEmbed = new MessageEmbed()
@@ -728,7 +831,7 @@ module.exports = {
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
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) {
client.log(err);
const embed = new MessageEmbed()
@@ -751,10 +854,10 @@ module.exports = {
}
} else if (args[0].name == 'commercial_role') {
const roleId = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
if (args[0].options[0].name== 'set') {
const roleId = args[0].options[0].options[0].value;
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) {
client.log(err);
const embed = new MessageEmbed()
@@ -766,12 +869,12 @@ module.exports = {
});
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');
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()
.setTitle(`Are you sure you want to remove this role as commercial role?`)
.setColor(client.config.EmbedColor)
@@ -802,7 +905,7 @@ module.exports = {
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
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) {
client.log(err);
const embed = new MessageEmbed()
@@ -826,9 +929,9 @@ module.exports = {
} else if (args[0].name == 'officer_role') {
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) {
client.log(err);
const embed = new MessageEmbed()
@@ -840,12 +943,12 @@ module.exports = {
});
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');
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()
.setTitle(`Are you sure you want to remove this role as officer role?`)
.setColor(client.config.EmbedColor)
@@ -876,7 +979,7 @@ module.exports = {
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
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) {
client.log(err);
const embed = new MessageEmbed()
@@ -897,9 +1000,83 @@ module.exports = {
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') {
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) {
client.log(err);
const embed = new MessageEmbed()