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",
|
||||
description: "Set the starting balance",
|
||||
@@ -105,6 +130,16 @@ module.exports = {
|
||||
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: "role",
|
||||
description: "Role for this income",
|
||||
@@ -117,24 +152,59 @@ module.exports = {
|
||||
description: "The amount to earn in 1 day of work",
|
||||
value: 120.00,
|
||||
type: 10,
|
||||
required: true,
|
||||
required: false,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "remove_income_role",
|
||||
description: "Remove a role from earning income",
|
||||
value: "remove_income_role",
|
||||
name: "commercial_role",
|
||||
description: "Set/remove commercial role",
|
||||
value: "commercial_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 remove",
|
||||
description: "Role to set or remove",
|
||||
value: "role",
|
||||
type: 8,
|
||||
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",
|
||||
@@ -360,7 +430,7 @@ module.exports = {
|
||||
|
||||
const successEmbed = new MessageEmbed()
|
||||
.setColor("GREEN")
|
||||
.setTitle(`Successfully set <#${channelid}> for actions.`)
|
||||
.setTitle(`Successfully set <#${channelid}> for tweets.`)
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
} else if (args[0].options[0].value == 'remove') {
|
||||
@@ -415,6 +485,86 @@ module.exports = {
|
||||
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') {
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {"server.startingBalance":args[0].options[0].value}, function(err, res) {
|
||||
if (err) {
|
||||
@@ -434,7 +584,16 @@ module.exports = {
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
|
||||
} 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()
|
||||
.setDescriptions('**Error Notice:** Amount cannot be $0 or less than $0.')
|
||||
.setColor("RED");
|
||||
@@ -442,11 +601,11 @@ module.exports = {
|
||||
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) {
|
||||
const newIncome = {
|
||||
role: args[0].options[0].value,
|
||||
income: args[0].options[1].value,
|
||||
role: 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) {
|
||||
@@ -460,8 +619,8 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":Guild.serverID, "server.incomeRoles.role": args[0].options[0].value},
|
||||
{$set: {"server.incomeRoles.$.income": args[0].options[1].value}}, function(err, res) {
|
||||
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) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -472,15 +631,16 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
}
|
||||
const perform = searchIndex = -1 ? 'set' : 'updated';
|
||||
|
||||
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');
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
|
||||
} else if (args[0].name == 'remove_income_role') {
|
||||
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[0].value);
|
||||
} else if (args[0].options[0].value == 'remove') {
|
||||
const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==args[0].options[1].value);
|
||||
if (searchIndex == -1) {
|
||||
const errorEmbed = new MessageEmbed()
|
||||
.setDescription('**Error Notice:** Role not found')
|
||||
@@ -488,7 +648,37 @@ module.exports = {
|
||||
|
||||
return interaction.send({ embeds: [errorEmbed] });
|
||||
} 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) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
@@ -498,24 +688,177 @@ module.exports = {
|
||||
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()
|
||||
.setTitle('Success')
|
||||
.setDescription(`Successfully remoed <@&${args[0].options[0].value}> from income roles.`)
|
||||
} else if (args[0].name == 'commercial_role') {
|
||||
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) {
|
||||
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');
|
||||
|
||||
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') {
|
||||
const tweetChannel = client.exists(GuildDB.tweetChannel) ? `\n╚➤ <#${GuildDB.tweetChannel}>` : '';
|
||||
const tweetColor = client.exists(GuildDB.tweetChannel) ? '+ ' : '- ';
|
||||
const actionChannel = client.exists(GuildDB.actionChannel) ? `\n╚➤ <#${GuildDB.actionChannel}>` : '';
|
||||
const actionColor = client.exists(GuildDB.actionChannel) ? '+ ' : '- ';
|
||||
const tweetChannel = GuildDB.tweetChannel ? `\n╚➤ <#${GuildDB.tweetChannel}>` : '';
|
||||
const tweetColor = GuildDB.tweetChannel ? '+ ' : '- ';
|
||||
const actionChannel = GuildDB.actionChannel ? `\n╚➤ <#${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 channelColor = GuildDB.customChannelStatus ? '+ ' : '- ';
|
||||
const incomeInfo = GuildDB.incomeRoleStatus ? '\n╚➤ \`/work-roles\` to view' : '';
|
||||
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()
|
||||
.setColor(client.config.EmbedColor)
|
||||
.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 Action Channel?', value: `\`\`\`diff\n${actionColor}${client.exists(GuildDB.actionChannel)}\`\`\`${actionChannel}`, 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] });
|
||||
|
||||
+19
-49
@@ -136,72 +136,42 @@ class QuarksBot extends Client {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// If guild not found, generate guild default
|
||||
if (!guild) {
|
||||
let newGuild = {
|
||||
guild = {
|
||||
server: {
|
||||
serverID: GuildId,
|
||||
hasCustomChannels: false,
|
||||
allowedChannels: [],
|
||||
actionChannel: null,
|
||||
tweetChannel: null,
|
||||
advertsChannel: null,
|
||||
startingBalance: 1000.00,
|
||||
hasIncomeRoles: false,
|
||||
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;
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
This command is to verify a user
|
||||
has the correct role to use a
|
||||
command ie. has cop role to use
|
||||
name-search
|
||||
*/
|
||||
async verifyUseCommand(serverID, rolesCache, isList) {
|
||||
let { customRoleStatus } = await this.GetGuild(serverID)
|
||||
if (customRoleStatus) {
|
||||
let hasRole = await this.checkRoleStatus(rolesCache, serverID, isList);
|
||||
if (hasRole) {
|
||||
return true // User has role, can use command
|
||||
} else return false // User does not have role, can't use command
|
||||
} else return true // There is no role limits
|
||||
let guildData = {
|
||||
serverID: GuildID,
|
||||
customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false,
|
||||
allowedChannels: guild.server.allowedChannels,
|
||||
actionChannel: guild.server.actionChannel,
|
||||
tweetChannel: guild.server.tweetChannel,
|
||||
advertsChannel: guild.server.advertsChannel,
|
||||
startingBalance: guild.server.startingBalance,
|
||||
incomeRoleStatus: guild.server.incomeRoles.length > 0 ? true : false,
|
||||
incomeRoles: guild.server.incomeRoles,
|
||||
commercialRole: guild.server.commercialRole,
|
||||
officerRole: guild.server.officerRole,
|
||||
}
|
||||
return guildData;
|
||||
}
|
||||
|
||||
log(Text) {
|
||||
|
||||
Reference in new issue
Block a user