only_officers_search setting

This commit is contained in:
SowinskiBraeden committed 2022-08-04 11:42:49 -07:00
1 parent b441ec3963
commit 46d07efc5f
2 files changed
+204 -110

No files matched your search

+202 -110
View File
@@ -15,25 +15,32 @@ module.exports = {
name: "allowed_channels",
description: "Set channels you're allowed to use the bot in",
value: "allowed_channels",
type: 1,
type: 2,
options: [
{
name: "add_or_remove",
description: "Add/remove channel",
value: "add_or_remove",
type: 3,
required: true,
choices: [
{ name: "add", value: "add" }, { name: "remove", value: "remove" },
]
},
{
name: "add",
description: "Add channel",
value: "add",
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,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
}]
},
]
},
{
@@ -43,22 +50,29 @@ module.exports = {
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove channel",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
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,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
}]
},
]
},
{
@@ -68,22 +82,29 @@ module.exports = {
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove channel",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
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,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
}]
},
]
},
{
@@ -93,22 +114,29 @@ module.exports = {
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove channel",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
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,
options: [{
name: "channel",
description: "The channel to configure",
value: "channel",
type: 7,
}]
},
]
},
{
@@ -125,24 +153,20 @@ module.exports = {
}]
},
{
name: "set_income_role",
name: "income_role",
description: "Add/update a role to earn income on /work command",
value: "set_income_role",
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove role",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [
{
name: "role",
description: "Role for this income",
description: "Role to set",
value: "role",
type: 8,
required: true,
@@ -154,6 +178,21 @@ module.exports = {
type: 10,
required: false,
}
]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: 8,
required: true,
}]
},
],
},
{
@@ -163,21 +202,30 @@ module.exports = {
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove role",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [{
name: "role",
description: "Role to set or remove",
description: "Role to set",
value: "role",
type: 8,
required: true,
}]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: 8,
required: true,
}]
},
]
},
@@ -188,24 +236,46 @@ module.exports = {
type: 1,
options: [
{
name: "set_or_remove",
description: "Set/remove role",
value: "set_or_remove",
type: 3,
required: true,
choices: [
{ name: "set", value: "set" }, { name: "remove", value: "remove" },
]
},
{
name: "set",
description: "Set role",
value: "set",
type: 1,
options: [{
name: "role",
description: "Role to set or remove",
description: "Role to set",
value: "role",
type: 8,
required: true,
}]
},
{
name: "remove",
description: "Remove role",
value: "remove",
type: 1,
options: [{
name: "role",
description: "Role to remove",
value: "role",
type: 8,
required: true,
}]
},
]
},
{
name: "only_officers_search",
description: "Determine if only officers can use /search",
value: "only_officers_search",
type: 1,
options: [{
name: "true_or_false",
description: "Enable or Disable setting",
value: false,
type: 5,
required: true,
}]
},
{
name: "view",
description: "View current settings configuration",
@@ -226,7 +296,7 @@ module.exports = {
}
if (args[0].name == 'allowed_channels') {
const channelid = args[0].options[1].value;
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'add') {
const channel = client.channels.cache.get(channelid);
@@ -315,7 +385,7 @@ module.exports = {
}
} else if (args[0].name == 'action_channel') {
const channelid = args[0].options[1].value;
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
const channelSetting = GuildDB.actionChannel;
@@ -394,7 +464,7 @@ module.exports = {
}
} else if (args[0].name == 'tweet_channel') {
const channelid = args[0].options[1].value;
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
const channelSetting = GuildDB.tweetChannel;
@@ -473,7 +543,7 @@ module.exports = {
}
} else if (args[0].name == 'adverts_channel') {
const channelid = args[0].options[1].value;
const channelid = args[0].options[0].options[0].value;
if (args[0].options[0].value == 'set') {
const channelSetting = GuildDB.advertsChannel;
@@ -569,17 +639,11 @@ module.exports = {
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'set_income_role') {
} 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[2]) {
let embed = new MessageEmbed()
.setDescriptions('**Error Notice:** Please provide an income amount.')
.setColor("RED");
return interaction.send({ embeds: [embed] });
}
if (args[0].options[2].value <= 0) {
if (args[0].options[0].options[1].value <= 0) {
let embed = new MessageEmbed()
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
.setColor("RED");
@@ -587,11 +651,11 @@ module.exports = {
return interaction.send({ embeds: [embed] });
}
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==roleId);
if (searchIndex == -1) {
const newIncome = {
role: args[0].options[1].value,
income: args[0].options[2].value,
role: roleId,
income: args[0].options[0].options[1].value,
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
@@ -605,8 +669,8 @@ module.exports = {
}
});
} else {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].options[1].value},
{$set: {"server.incomeRoles.$.income": args[0].options[2].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": roleId},
{$set: {"server.incomeRoles.$.income": args[0].options[0].options[1].value}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
@@ -620,13 +684,13 @@ module.exports = {
const perform = searchIndex = -1 ? 'set' : 'updated';
const successEmbed = new MessageEmbed()
.setDescription(`Successfully ${perform} <@&${args[0].options[1].value}>'s income to $${args[0].options[2].value}`)
.setDescription(`Successfully ${perform} <@&${roleId}>'s income to $${args[0].options[0].options[1].value}`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].options[0].value == 'remove') {
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==roleId);
if (searchIndex == -1) {
const errorEmbed = new MessageEmbed()
.setDescription('**Error Notice:** Role not found')
@@ -664,7 +728,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": args[0].options[1].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
@@ -678,7 +742,7 @@ module.exports = {
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> from income roles.`)
.setTitle(`Successfully ${action} <@&${roleId}> from income roles.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
@@ -687,9 +751,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') {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.commercialRole": args[0].options[1].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.commercialRole": roleId}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
@@ -701,7 +766,7 @@ module.exports = {
});
const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${args[0].options[1].value}>'s as commercial role.\nUsers with this role can now create invoices and send advertisements.`)
.setDescription(`Successfully set <@&${roleId}>'s as commercial role.\nUsers with this role can now use business commands.`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
@@ -751,7 +816,7 @@ module.exports = {
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> as commercial role.`)
.setTitle(`Successfully ${action} <@&${roleId}> as commercial role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
@@ -759,9 +824,11 @@ 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') {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.officerRole": args[0].options[1].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.officerRole": roleId}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()
@@ -773,7 +840,7 @@ module.exports = {
});
const successEmbed = new MessageEmbed()
.setDescription(`Successfully set <@&${args[0].options[1].value}>'s as officer role.\nUsers with this role can now fine other users.`)
.setDescription(`Successfully set <@&${roleId}>'s as officer role.\nUsers with this role can now fine other users.`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
@@ -823,13 +890,34 @@ module.exports = {
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> as officer role.`)
.setTitle(`Successfully ${action} <@&${roleId}> as officer 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) {
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 title = setting ? 'Only officers can use /search' : 'Any user can use /search';
const successEmbed = new MessageEmbed()
.setColor("GREEN")
.setTitle(title)
return interaction.send({ embeds: [successEmbed] });
} else if (args[0].name == 'view') {
const tweetChannel = GuildDB.tweetChannel ? `\n╚➤ <#${GuildDB.tweetChannel}>` : '';
const tweetColor = GuildDB.tweetChannel ? '+ ' : '- ';
@@ -845,6 +933,9 @@ module.exports = {
const commercialRoleColor = GuildDB.commercialRole ? '+ ' : '- ';
const officerRole = GuildDB.officerRole ? `\n╚➤ <@&${GuildDB.officerRole}>` : '';
const officerRoleColor = GuildDB.officerRole ? '+ ' : '- ';
const oos = GuildDB.onlyOfficersSearch; // only officers search (oos)
const oosColor = GuildDB.onlyOfficersSearch ? '+ ' : '- ';
const settingsEmbed = new MessageEmbed()
.setColor(client.config.EmbedColor)
.setTitle('Current Guild Configurations')
@@ -858,6 +949,7 @@ module.exports = {
{ name: 'Has Adverts Channel?', value: `\`\`\`diff\n${advertsColor}${client.exists(GuildDB.advertsChannel)}\`\`\`${advertsChannel}`, inline: true },
{ name: 'Has Commercial Role?', value: `\`\`\`diff\n${commercialRoleColor}${client.exists(GuildDB.commercialRole)}\`\`\`${commercialRole}`, inline: true },
{ name: 'Has Officer Role?', value: `\`\`\`diff\n${officerRoleColor}${client.exists(GuildDB.officerRole)}\`\`\`${officerRole}`, inline: true },
{ name: 'Only Officers Search?', value: `\`\`\`diff\n${oosColor}${oos}\`\`\``, inline: true },
);
return interaction.send({ embeds: [settingsEmbed] });
+2
View File
@@ -151,6 +151,7 @@ class QuarksBot extends Client {
incomeRoles: [],
commercialRole: null,
officerRole: null,
onlyOfficersSearch: false,
}
}
this.dbo.collection("guilds").insertOne(guild, function(err, res) {
@@ -170,6 +171,7 @@ class QuarksBot extends Client {
incomeRoles: guild.server.incomeRoles,
commercialRole: guild.server.commercialRole,
officerRole: guild.server.officerRole,
onlyOfficersSearch: guild.server.onlyOfficersSearch,
}
return guildData;
}