add more settings/revamp some settings
This commit is contained in:
2 files changed
+389
-73
No files matched your search
+370
-24
@@ -86,6 +86,31 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "adverts_channel",
|
||||||
|
description: "Set the channel for users to send commercial adverts",
|
||||||
|
value: "adverts_channel",
|
||||||
|
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: "channel",
|
||||||
|
description: "The channel to configure",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "starting_balance",
|
name: "starting_balance",
|
||||||
description: "Set the starting balance",
|
description: "Set the starting balance",
|
||||||
@@ -105,6 +130,16 @@ module.exports = {
|
|||||||
value: "set_income_role",
|
value: "set_income_role",
|
||||||
type: 1,
|
type: 1,
|
||||||
options: [
|
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: "role",
|
name: "role",
|
||||||
description: "Role for this income",
|
description: "Role for this income",
|
||||||
@@ -117,24 +152,59 @@ module.exports = {
|
|||||||
description: "The amount to earn in 1 day of work",
|
description: "The amount to earn in 1 day of work",
|
||||||
value: 120.00,
|
value: 120.00,
|
||||||
type: 10,
|
type: 10,
|
||||||
required: true,
|
required: false,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove_income_role",
|
name: "commercial_role",
|
||||||
description: "Remove a role from earning income",
|
description: "Set/remove commercial role",
|
||||||
value: "remove_income_role",
|
value: "commercial_role",
|
||||||
type: 1,
|
type: 1,
|
||||||
options: [
|
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: "role",
|
name: "role",
|
||||||
description: "Role to remove",
|
description: "Role to set or remove",
|
||||||
value: "role",
|
value: "role",
|
||||||
type: 8,
|
type: 8,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "officer_role",
|
||||||
|
description: "Set/remove officer role",
|
||||||
|
value: "officer_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: "role",
|
||||||
|
description: "Role to set or remove",
|
||||||
|
value: "role",
|
||||||
|
type: 8,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "view",
|
name: "view",
|
||||||
@@ -360,7 +430,7 @@ module.exports = {
|
|||||||
|
|
||||||
const successEmbed = new MessageEmbed()
|
const successEmbed = new MessageEmbed()
|
||||||
.setColor("GREEN")
|
.setColor("GREEN")
|
||||||
.setTitle(`Successfully set <#${channelid}> for actions.`)
|
.setTitle(`Successfully set <#${channelid}> for tweets.`)
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
} else if (args[0].options[0].value == 'remove') {
|
} else if (args[0].options[0].value == 'remove') {
|
||||||
@@ -415,6 +485,86 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (args[0].name == 'adverts_channel') {
|
||||||
|
const channelid = args[0].options[1].value;
|
||||||
|
|
||||||
|
if (args[0].options[0].value == 'set') {
|
||||||
|
const guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
|
const channelSetting = guild.server.tweetChannel;
|
||||||
|
|
||||||
|
const presetEmbed = new MessageEmbed()
|
||||||
|
.setColor(client.config.EmbedColor)
|
||||||
|
.setDescription(`The channel <#${channelid}> has already been set for advertisements.`)
|
||||||
|
|
||||||
|
if (channelSetting == channelid) return interaction.send({ embeds: [presetEmbed] });
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.advertsChannel":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")
|
||||||
|
.setTitle(`Successfully set <#${channelid}> for advertisements.`)
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
} else if (args[0].options[0].value == '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] });
|
||||||
|
|
||||||
|
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.advertsChannel": 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} 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) {
|
||||||
@@ -434,7 +584,16 @@ module.exports = {
|
|||||||
return interaction.send({ embeds: [successEmbed] });
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
|
||||||
} else if (args[0].name == 'set_income_role') {
|
} else if (args[0].name == 'set_income_role') {
|
||||||
if (args[0].options[1].value <= 0) {
|
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) {
|
||||||
let embed = new MessageEmbed()
|
let embed = new MessageEmbed()
|
||||||
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
|
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
|
||||||
.setColor("RED");
|
.setColor("RED");
|
||||||
@@ -442,11 +601,11 @@ module.exports = {
|
|||||||
return interaction.send({ embeds: [embed] });
|
return interaction.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[0].value);
|
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
|
||||||
if (searchIndex == -1) {
|
if (searchIndex == -1) {
|
||||||
const newIncome = {
|
const newIncome = {
|
||||||
role: args[0].options[0].value,
|
role: args[0].options[1].value,
|
||||||
income: args[0].options[1].value,
|
income: args[0].options[2].value,
|
||||||
}
|
}
|
||||||
|
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
|
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
|
||||||
@@ -460,8 +619,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].options[0].value},
|
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].options[1].value},
|
||||||
{$set: {"server.incomeRoles.$.income": args[0].options[1].value}}, function(err, res) {
|
{$set: {"server.incomeRoles.$.income": args[0].options[2].value}}, function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
client.log(err);
|
client.log(err);
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
@@ -472,15 +631,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const perform = searchIndex = -1 ? 'set' : 'updated';
|
||||||
|
|
||||||
const successEmbed = new MessageEmbed()
|
const successEmbed = new MessageEmbed()
|
||||||
.setDescription(`Successfully updated <@&${args[0].options[0].value}>'s income to $${args[0].options[1].value}`)
|
.setDescription(`Successfully ${perform} <@&${args[0].options[1].value}>'s income to $${args[0].options[2].value}`)
|
||||||
.setColor('GREEN');
|
.setColor('GREEN');
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
|
||||||
} else if (args[0].name == 'remove_income_role') {
|
} else if (args[0].options[0].value == 'remove') {
|
||||||
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[0].value);
|
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
|
||||||
if (searchIndex == -1) {
|
if (searchIndex == -1) {
|
||||||
const errorEmbed = new MessageEmbed()
|
const errorEmbed = new MessageEmbed()
|
||||||
.setDescription('**Error Notice:** Role not found')
|
.setDescription('**Error Notice:** Role not found')
|
||||||
@@ -488,7 +648,37 @@ module.exports = {
|
|||||||
|
|
||||||
return interaction.send({ embeds: [errorEmbed] });
|
return interaction.send({ embeds: [errorEmbed] });
|
||||||
} else {
|
} else {
|
||||||
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID}, {$pull: {"server.incomeRoles": args[0].options[0].value}}, function(err, res) {
|
const prompt = new MessageEmbed()
|
||||||
|
.setTitle(`Are you sure you want to remove this role as an income?`)
|
||||||
|
.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] });
|
||||||
|
|
||||||
|
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":Guild.serverID}, {$pull: {"server.incomeRoles": args[0].options[1].value}}, function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
client.log(err);
|
client.log(err);
|
||||||
let embed = new MessageEmbed()
|
let embed = new MessageEmbed()
|
||||||
@@ -498,24 +688,177 @@ module.exports = {
|
|||||||
return interaction.send({ embeds: [embed] });
|
return interaction.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
|
||||||
|
|
||||||
|
const successEmbed = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(`Successfully ${action} <@&${args[0].options[0].value}> from income roles.`)
|
||||||
|
|
||||||
|
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let successEmbed = new MessageEmbed()
|
} else if (args[0].name == 'commercial_role') {
|
||||||
.setTitle('Success')
|
if (args[0].options[0].value == 'set') {
|
||||||
.setDescription(`Successfully remoed <@&${args[0].options[0].value}> from income roles.`)
|
|
||||||
|
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID},{$set:{"server.commercialRole": args[0].options[1].value}}, 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 <@&${args[0].options[1].value}>'s as commercial role.\nUsers with this role can now create invoices and send advertisements.`)
|
||||||
.setColor('GREEN');
|
.setColor('GREEN');
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
return interaction.send({ embeds: [successEmbed] });
|
||||||
|
|
||||||
|
} else if (args[0].options[0].value == 'remove') {
|
||||||
|
const prompt = new MessageEmbed()
|
||||||
|
.setTitle(`Are you sure you want to remove this role as commercial 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] });
|
||||||
|
|
||||||
|
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":Guild.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setTitle(err)
|
||||||
|
.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} <@&${args[0].options[0].value}> as commercial role.`)
|
||||||
|
|
||||||
|
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (args[0].name == 'officer_role') {
|
||||||
|
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) {
|
||||||
|
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 <@&${args[0].options[1].value}>'s 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') {
|
||||||
|
const prompt = new MessageEmbed()
|
||||||
|
.setTitle(`Are you sure you want to remove this role as officer 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] });
|
||||||
|
|
||||||
|
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":Guild.serverID}, {$set: {"server.officerRole": null}}, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
client.log(err);
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setTitle(err)
|
||||||
|
.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} <@&${args[0].options[0].value}> as officer role.`)
|
||||||
|
|
||||||
|
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (args[0].name == 'view') {
|
} else if (args[0].name == 'view') {
|
||||||
const tweetChannel = client.exists(GuildDB.tweetChannel) ? `\n╚➤ <#${GuildDB.tweetChannel}>` : '';
|
const tweetChannel = GuildDB.tweetChannel ? `\n╚➤ <#${GuildDB.tweetChannel}>` : '';
|
||||||
const tweetColor = client.exists(GuildDB.tweetChannel) ? '+ ' : '- ';
|
const tweetColor = GuildDB.tweetChannel ? '+ ' : '- ';
|
||||||
const actionChannel = client.exists(GuildDB.actionChannel) ? `\n╚➤ <#${GuildDB.actionChannel}>` : '';
|
const actionChannel = GuildDB.actionChannel ? `\n╚➤ <#${GuildDB.actionChannel}>` : '';
|
||||||
const actionColor = client.exists(GuildDB.actionChannel) ? '+ ' : '- ';
|
const actionColor = GuildDB.actionChannel ? '+ ' : '- ';
|
||||||
|
const advertsChannel = GuildDB.advertsChannel ? `\n╚➤ <#${GuildDB.advertsChannel}>` : ''
|
||||||
|
const advertsColor = GuildDB.advertsChannel ? '+ ' : '- ';
|
||||||
const channelsInfo = GuildDB.customChannelStatus ? '\n╚➤ \`/channels\` to view' : '';
|
const channelsInfo = GuildDB.customChannelStatus ? '\n╚➤ \`/channels\` to view' : '';
|
||||||
const channelColor = GuildDB.customChannelStatus ? '+ ' : '- ';
|
const channelColor = GuildDB.customChannelStatus ? '+ ' : '- ';
|
||||||
const incomeInfo = GuildDB.incomeRoleStatus ? '\n╚➤ \`/work-roles\` to view' : '';
|
const incomeInfo = GuildDB.incomeRoleStatus ? '\n╚➤ \`/work-roles\` to view' : '';
|
||||||
const incomeColor = GuildDB.incomeRoleStatus ? '+ ' : '- ';
|
const incomeColor = GuildDB.incomeRoleStatus ? '+ ' : '- ';
|
||||||
|
const commercialRole = GuildDB.commercialRole ? `\n╚➤ <@&${GuildDB.commercialRole}>` : '';
|
||||||
|
const commercialRoleColor = GuildDB.commercialRole ? '+ ' : '- ';
|
||||||
|
const officerRole = GuildDB.officerRole ? `\n╚➤ <@&${GuildDB.officerRole}>` : '';
|
||||||
|
const officerRoleColor = GuildDB.officerRole ? '+ ' : '- ';
|
||||||
const settingsEmbed = new MessageEmbed()
|
const settingsEmbed = new MessageEmbed()
|
||||||
.setColor(client.config.EmbedColor)
|
.setColor(client.config.EmbedColor)
|
||||||
.setTitle('Current Guild Configurations')
|
.setTitle('Current Guild Configurations')
|
||||||
@@ -526,6 +869,9 @@ module.exports = {
|
|||||||
{ name: 'Has Tweet Channel?', value: `\`\`\`diff\n${tweetColor}${client.exists(GuildDB.tweetChannel)}\`\`\`${tweetChannel}`, inline: true },
|
{ name: 'Has Tweet Channel?', value: `\`\`\`diff\n${tweetColor}${client.exists(GuildDB.tweetChannel)}\`\`\`${tweetChannel}`, inline: true },
|
||||||
{ name: 'Has Action Channel?', value: `\`\`\`diff\n${actionColor}${client.exists(GuildDB.actionChannel)}\`\`\`${actionChannel}`, inline: true },
|
{ name: 'Has Action Channel?', value: `\`\`\`diff\n${actionColor}${client.exists(GuildDB.actionChannel)}\`\`\`${actionChannel}`, inline: true },
|
||||||
{ name: 'Starting Balance', value: `\`\`\`arm\n$${GuildDB.startingBalance}\`\`\``, inline: true },
|
{ name: 'Starting Balance', value: `\`\`\`arm\n$${GuildDB.startingBalance}\`\`\``, inline: true },
|
||||||
|
{ name: 'Has Adverts Channel?', value: `\`\`\`diff${advertsColor}${client.exists(GuildDB.advertsChannel)}\`\`\`${advertsChannel}`, inline: true },
|
||||||
|
{ name: 'Has Commercial Role?', value: `\`\`\`diff${commercialRoleColor}${client.exists(GuildDB.commercialRole)}\`\`\`${commercialRole}`, inline: true },
|
||||||
|
{ name: 'Has Officer Role?', value: `\`\`\`diff${officerRoleColor}${client.exists(GuildDB.officerRole)}\`\`\`${officerRole}`, inline: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
return interaction.send({ embeds: [settingsEmbed] });
|
return interaction.send({ embeds: [settingsEmbed] });
|
||||||
|
|||||||
+19
-49
@@ -136,72 +136,42 @@ class QuarksBot extends Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async GetGuild(GuildId) {
|
async GetGuild(GuildId) {
|
||||||
let serverID = GuildId;
|
|
||||||
let customChannelStatus, allowedChannels;
|
|
||||||
let actionChannel, tweetChannel;
|
|
||||||
let startingBalance, incomeRoles, incomeRoleStatus;
|
|
||||||
let guild = await this.dbo.collection("guilds").findOne({"server.serverID":GuildId}).then(guild => guild);
|
let guild = await this.dbo.collection("guilds").findOne({"server.serverID":GuildId}).then(guild => guild);
|
||||||
|
|
||||||
// If guild not found, generate guild default
|
// If guild not found, generate guild default
|
||||||
if (!guild) {
|
if (!guild) {
|
||||||
let newGuild = {
|
guild = {
|
||||||
server: {
|
server: {
|
||||||
serverID: GuildId,
|
serverID: GuildId,
|
||||||
hasCustomChannels: false,
|
|
||||||
allowedChannels: [],
|
allowedChannels: [],
|
||||||
actionChannel: null,
|
actionChannel: null,
|
||||||
tweetChannel: null,
|
tweetChannel: null,
|
||||||
|
advertsChannel: null,
|
||||||
startingBalance: 1000.00,
|
startingBalance: 1000.00,
|
||||||
hasIncomeRoles: false,
|
|
||||||
incomeRoles: [],
|
incomeRoles: [],
|
||||||
|
commercialRole: null,
|
||||||
|
officerRole: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.dbo.collection("guilds").insertOne(newGuild, function(err, res) {
|
this.dbo.collection("guilds").insertOne(guild, function(err, res) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
customChannelStatus = false;
|
|
||||||
allowedChannels = newGuild.server.allowedChannels;
|
|
||||||
actionChannel = newGuild.server.actionChannel;
|
|
||||||
tweetChannel = newGuild.server.tweetChannel;
|
|
||||||
startingBalance = newGuild.server.startingBalance;
|
|
||||||
incomeRoleStatus = newGuild.server.hasIncomeRoles
|
|
||||||
incomeRoles = newGuild.server.incomeRoles;
|
|
||||||
} else {
|
|
||||||
customChannelStatus = guild.server.allowedChannels.length > 0 ? true : false;
|
|
||||||
allowedChannels = guild.server.allowedChannels;
|
|
||||||
actionChannel = guild.server.actionChannel;
|
|
||||||
tweetChannel = guild.server.tweetChannel;
|
|
||||||
startingBalance = guild.server.startingBalance;
|
|
||||||
incomeRoleStatus = guild.server.incomeRoles.length > 0 ? true : false;
|
|
||||||
incomeRoles = guild.server.incomeRoles;
|
|
||||||
}
|
|
||||||
let guildData = {
|
|
||||||
serverID: serverID,
|
|
||||||
customChannelStatus: customChannelStatus,
|
|
||||||
allowedChannels: allowedChannels,
|
|
||||||
actionChannel: actionChannel,
|
|
||||||
tweetChannel: tweetChannel,
|
|
||||||
startingBalance: startingBalance,
|
|
||||||
incomeRoleStatus: incomeRoleStatus,
|
|
||||||
incomeRoles: incomeRoles,
|
|
||||||
}
|
|
||||||
return guildData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
let guildData = {
|
||||||
This command is to verify a user
|
serverID: GuildID,
|
||||||
has the correct role to use a
|
customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false,
|
||||||
command ie. has cop role to use
|
allowedChannels: guild.server.allowedChannels,
|
||||||
name-search
|
actionChannel: guild.server.actionChannel,
|
||||||
*/
|
tweetChannel: guild.server.tweetChannel,
|
||||||
async verifyUseCommand(serverID, rolesCache, isList) {
|
advertsChannel: guild.server.advertsChannel,
|
||||||
let { customRoleStatus } = await this.GetGuild(serverID)
|
startingBalance: guild.server.startingBalance,
|
||||||
if (customRoleStatus) {
|
incomeRoleStatus: guild.server.incomeRoles.length > 0 ? true : false,
|
||||||
let hasRole = await this.checkRoleStatus(rolesCache, serverID, isList);
|
incomeRoles: guild.server.incomeRoles,
|
||||||
if (hasRole) {
|
commercialRole: guild.server.commercialRole,
|
||||||
return true // User has role, can use command
|
officerRole: guild.server.officerRole,
|
||||||
} else return false // User does not have role, can't use command
|
}
|
||||||
} else return true // There is no role limits
|
return guildData;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(Text) {
|
log(Text) {
|
||||||
|
|||||||
Reference in new issue
Block a user