13.2.0 configure work limiter && better default guild settings handler
This commit is contained in:
5 files changed
+60
-38
No files matched your search
+25
-15
@@ -365,6 +365,19 @@ module.exports = {
|
||||
required: true,
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "work_limiter",
|
||||
description: "Configure the number of hours users have to wait to work again",
|
||||
value: "work_limiter",
|
||||
type: 1,
|
||||
options: [{
|
||||
name: "hours",
|
||||
description: "Set the hours to wait till a user can work again",
|
||||
value: 24,
|
||||
type: 4,
|
||||
min_value: 1,
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "reset",
|
||||
description: "Restore all settings to default configurations",
|
||||
@@ -847,6 +860,17 @@ module.exports = {
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
|
||||
} else if (arg[0].name == 'work_limiter') {
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.workLimiter": args[0].options[0].value}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
const successEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Green)
|
||||
.setDescription(`**Success:** Set work limiter to **${args[0].options[0].value}** hours. Users need to wait this set amount of time to use the \`/work\` command again.`);
|
||||
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
|
||||
} else if (args[0].name == 'reset') {
|
||||
const prompt = new EmbedBuilder()
|
||||
.setTitle(`Woah!? Hold on.`)
|
||||
@@ -1180,21 +1204,7 @@ module.exports = {
|
||||
let action = '';
|
||||
if (interaction.customId.split('-')[1]=='yes') {
|
||||
action = 'reset';
|
||||
const defaultGuildConfig = {
|
||||
serverID: GuildDB.serverID,
|
||||
allowedChannels: [],
|
||||
actionChannel: null,
|
||||
tweetChannel: null,
|
||||
advertsChannel: null,
|
||||
dispatchChannel: null,
|
||||
startingBalance: 1000.00,
|
||||
incomeRoles: [],
|
||||
botAdmin: null,
|
||||
commercialRole: null,
|
||||
officerRole: null,
|
||||
dispatcherRole: null,
|
||||
onlyOfficersSearch: false,
|
||||
}
|
||||
const defaultGuildConfig = client.getDefaultSettings(GuildDB.serverID);
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server": defaultGuildConfig}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
+2
-1
@@ -64,7 +64,8 @@ module.exports = {
|
||||
diff /= (60 * 60);
|
||||
let hoursBetweenDates = Math.abs(Math.round(diff));
|
||||
|
||||
if (hoursBetweenDates >= 24) {
|
||||
// work limiter is # of hours to wait before next time a user can use /work
|
||||
if (hoursBetweenDates >= GuildDB.workLimiter) {
|
||||
let workRoles = []
|
||||
let workPays = []
|
||||
for (let i = 0; i < GuildDB.incomeRoles.length; i++) {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ require('dotenv').config();
|
||||
|
||||
module.exports = {
|
||||
Dev: "PROD.",
|
||||
Version: "13.1.9", // (major).(feature).(revision/bug/refactoring)
|
||||
Version: "13.2.0", // (major).(feature).(revision/bug/refactoring)
|
||||
Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot
|
||||
DefaultPrefix: "?",
|
||||
ServerID: "955668596745461830",
|
||||
|
||||
@@ -124,5 +124,11 @@ module.exports = {
|
||||
This configurations allows you to customize the multiplier used to determine the winnings from casino games.
|
||||
`
|
||||
},
|
||||
{
|
||||
name: "work_limiter",
|
||||
description: `
|
||||
This configuration allows you to alter the number of hours a user has to wait between the use of the \`/work\` command. By default, users need to wait **24** hours before the can use the \`/work\` command again.
|
||||
`
|
||||
}
|
||||
]
|
||||
}
|
||||
+26
-21
@@ -191,31 +191,35 @@ class QuarksBot extends Client {
|
||||
this.guilds.cache.forEach((guild) => RegisterGuildCommands(this, guild.id));
|
||||
}
|
||||
|
||||
getDefaultSettings(GuildId) {
|
||||
return {
|
||||
serverID: GuildId,
|
||||
allowedChannels: [],
|
||||
actionChannel: null,
|
||||
tweetChannel: null,
|
||||
advertsChannel: null,
|
||||
dispatchChannel: null,
|
||||
startingBalance: 1000.00,
|
||||
incomeRoles: [],
|
||||
botAdmin: null,
|
||||
commercialRole: null,
|
||||
officerRole: null,
|
||||
dispatcherRole: null,
|
||||
onlyOfficersSearch: false,
|
||||
casinoMultiplier: 2,
|
||||
canIgnoreInvoices: true,
|
||||
workLimiter: 24,
|
||||
}
|
||||
}
|
||||
|
||||
async GetGuild(GuildId) {
|
||||
let guild = undefined;
|
||||
if (this.databaseConnected) guild = await this.dbo.collection("guilds").findOne({"server.serverID":GuildId}).then(guild => guild);
|
||||
|
||||
// If guild not found, generate guild default
|
||||
if (!guild) {
|
||||
guild = {
|
||||
server: {
|
||||
serverID: GuildId,
|
||||
allowedChannels: [],
|
||||
actionChannel: null,
|
||||
tweetChannel: null,
|
||||
advertsChannel: null,
|
||||
dispatchChannel: null,
|
||||
startingBalance: 1000.00,
|
||||
incomeRoles: [],
|
||||
botAdmin: null,
|
||||
commercialRole: null,
|
||||
officerRole: null,
|
||||
dispatcherRole: null,
|
||||
onlyOfficersSearch: false,
|
||||
casinoMultiplier: 2,
|
||||
canIgnoreInvoices: true,
|
||||
}
|
||||
}
|
||||
guild = {}
|
||||
guild.server = this.getDefaultSettings(GuildId);
|
||||
if (this.databaseConnected) {
|
||||
this.dbo.collection("guilds").insertOne(guild, function(err, res) {
|
||||
if (err) throw err;
|
||||
@@ -225,14 +229,14 @@ class QuarksBot extends Client {
|
||||
|
||||
let guildData = {
|
||||
serverID: GuildId,
|
||||
customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false,
|
||||
customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false, // not stored but calculated after
|
||||
allowedChannels: guild.server.allowedChannels,
|
||||
actionChannel: guild.server.actionChannel,
|
||||
tweetChannel: guild.server.tweetChannel,
|
||||
advertsChannel: guild.server.advertsChannel,
|
||||
dispatchChannel: guild.server.dispatchChannel,
|
||||
startingBalance: guild.server.startingBalance,
|
||||
incomeRoleStatus: guild.server.incomeRoles.length > 0 ? true : false,
|
||||
incomeRoleStatus: guild.server.incomeRoles.length > 0 ? true : false, // not stored but calculated after
|
||||
incomeRoles: guild.server.incomeRoles,
|
||||
commercialRole: guild.server.commercialRole,
|
||||
officerRole: guild.server.officerRole,
|
||||
@@ -241,6 +245,7 @@ class QuarksBot extends Client {
|
||||
botAdmin: guild.server.botAdmin,
|
||||
casinoMultiplier: guild.server.casinoMultiplier,
|
||||
canDismissInvoices: guild.server.canDismissInvoices,
|
||||
workLimiter: guild.server.workLimiter,
|
||||
}
|
||||
return guildData;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user