fix/free unused armbands
This commit is contained in:
2 files changed
+4
-4
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "13.3.14",
|
"version": "13.3.15",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
+3
-3
@@ -99,15 +99,15 @@ class DayzRBot extends Client {
|
|||||||
// Free unused armbands for related commands
|
// Free unused armbands for related commands
|
||||||
if (['armbands', 'claim', 'factions'].includes(command)) {
|
if (['armbands', 'claim', 'factions'].includes(command)) {
|
||||||
for (const [factionID, data] of Object.entries(GuildDB.factionArmbands)) {
|
for (const [factionID, data] of Object.entries(GuildDB.factionArmbands)) {
|
||||||
const guild = client.guilds.cache.get(GuildDB.serverID);
|
const guild = this.guilds.cache.get(GuildDB.serverID);
|
||||||
const role = guild.roles.cache.find(role => role.id == factionID);
|
const role = guild.roles.cache.find(role => role.id == factionID);
|
||||||
if (!role) {
|
if (!role) {
|
||||||
let query = {
|
let query = {
|
||||||
$pull: { 'server.usedArmbands': data.armband },
|
$pull: { 'server.usedArmbands': data.armband },
|
||||||
$unset: { [`server.factionArmbands.${factionID}`]: "" },
|
$unset: { [`server.factionArmbands.${factionID}`]: "" },
|
||||||
};
|
};
|
||||||
await client.dbo.collection("guilds").updateOne({ 'server.serverID': GuildDB.serverID }, query, (err, res) => {
|
this.dbo.collection("guilds").updateOne({ 'server.serverID': GuildDB.serverID }, query, (err, res) => {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return this.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user