add more settings/revamp some settings

This commit is contained in:
SowinskiBraeden committed 2022-08-02 22:41:18 -07:00
1 parent 10df5324d0
commit 9d8350f569
2 files changed
+443 -127

No files matched your search

+29 -59
View File
@@ -136,74 +136,44 @@ 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 = {
server: {
serverID: GuildId,
hasCustomChannels: false,
allowedChannels: [],
actionChannel: null,
tweetChannel: null,
startingBalance: 1000.00,
hasIncomeRoles: false,
incomeRoles: [],
}
// If guild not found, generate guild default
if (!guild) {
guild = {
server: {
serverID: GuildId,
allowedChannels: [],
actionChannel: null,
tweetChannel: null,
advertsChannel: null,
startingBalance: 1000.00,
incomeRoles: [],
commercialRole: null,
officerRole: null,
}
this.dbo.collection("guilds").insertOne(newGuild, 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;
}
this.dbo.collection("guilds").insertOne(guild, function(err, res) {
if (err) throw err;
});
}
let guildData = {
serverID: serverID,
customChannelStatus: customChannelStatus,
allowedChannels: allowedChannels,
actionChannel: actionChannel,
tweetChannel: tweetChannel,
startingBalance: startingBalance,
incomeRoleStatus: incomeRoleStatus,
incomeRoles: incomeRoles,
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;
}
/*
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
}
log(Text) {
this.logger.log(Text);
}