fix/admin disableBaseDamage
This commit is contained in:
3 files changed
+12
-13
No files matched your search
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } = require('discord.js');
|
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } = require('discord.js');
|
||||||
const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes;
|
const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes;
|
||||||
const bitfieldCalculator = require('discord-bitfield-calculator');
|
const bitfieldCalculator = require('discord-bitfield-calculator');
|
||||||
const { BanPlayer, UnbanPlayer, RestartServer, CheckServerStatus, ToggleBaseDamage } = require('../util/NitradoAPI');
|
const { BanPlayer, UnbanPlayer, RestartServer, CheckServerStatus, DisableBaseDamage } = require('../util/NitradoAPI');
|
||||||
const { Armbands } = require('../config/armbandsdb.js');
|
const { Armbands } = require('../config/armbandsdb.js');
|
||||||
const { User, addUser } = require('../structures/user');
|
const { User, addUser } = require('../structures/user');
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == args[0].options[1].value );
|
let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == args[0].options[1].value );
|
||||||
if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** This gamertag \` ${args[1].value} \` cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least \` 5 minutes \`.`)] });
|
if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** This gamertag \` ${args[0].options[1].value} \` cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least \` 5 minutes \`.`)] });
|
||||||
|
|
||||||
if (client.exists(playerStat.discordID)) {
|
if (client.exists(playerStat.discordID)) {
|
||||||
const warnGTOverwrite = new EmbedBuilder()
|
const warnGTOverwrite = new EmbedBuilder()
|
||||||
@@ -478,7 +478,7 @@ module.exports = {
|
|||||||
} else if (args[0].name == 'disable-base-damage') {
|
} else if (args[0].name == 'disable-base-damage') {
|
||||||
const preference = args[0].options[0].value;
|
const preference = args[0].options[0].value;
|
||||||
|
|
||||||
const toggle = await ToggleBaseDamage(client, preference);
|
const toggle = await DisableBaseDamage(client, preference);
|
||||||
if (toggle == 1) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Red).setDescription('Failed to update ` disableBaseDamage `, try again later.')] });
|
if (toggle == 1) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Red).setDescription('Failed to update ` disableBaseDamage `, try again later.')] });
|
||||||
|
|
||||||
return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Green).setDescription(`Successfully updated \` disableBaseDamage \` to ${preference}.\nRestart the DayZ server to apply these changes.`)] });
|
return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Green).setDescription(`Successfully updated \` disableBaseDamage \` to ${preference}.\nRestart the DayZ server to apply these changes.`)] });
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "10.0.6",
|
"version": "10.0.8",
|
||||||
"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": {
|
||||||
|
|||||||
+8
-9
@@ -33,14 +33,13 @@ const UploadNitradoFile = async (client, remoteDir, remoteFilename, localFileDir
|
|||||||
token: res.data.token.token
|
token: res.data.token.token
|
||||||
},
|
},
|
||||||
body: contents,
|
body: contents,
|
||||||
});
|
})
|
||||||
if (!uploadRes.ok) {
|
if (!uploadRes.ok) {
|
||||||
const errorText = await uploadRes.text();
|
const errorText = await uploadRes.text();
|
||||||
client.error(`Failed to upload file to Nitrado (${client.config.Nitrado.ServerID}): status: ${uploadRes.status}, message: ${errorText}: UploadNitradoFile`);
|
client.error(`Failed to upload file to Nitrado (${client.config.Nitrado.ServerID}): status: ${uploadRes.status}, message: ${errorText}: UploadNitradoFile`);
|
||||||
if (retries === 2) return 1; // Return error status on the second failed status code.
|
if (retries === 2) return 1; // Return error status on the second failed status code.
|
||||||
} else {
|
} else {
|
||||||
const data = await uploadRes.json();
|
return uploadRes;
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
client.error(`UploadNitradoFile: Error connecting to server (${client.config.Nitrado.ServerID}): ${error.message}`);
|
client.error(`UploadNitradoFile: Error connecting to server (${client.config.Nitrado.ServerID}): ${error.message}`);
|
||||||
@@ -216,27 +215,27 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ToggleBaseDamage: async (client, preference) => {
|
DisableBaseDamage: async (client, preference) => {
|
||||||
const settings = await module.exports.FetchServerSettings(client, 'ToggleBaseDamage'); // Fetch server settings
|
const settings = await module.exports.FetchServerSettings(client, 'ToggleBaseDamage'); // Fetch server settings
|
||||||
if (settings == 1) return 1;
|
if (settings == 1) return 1;
|
||||||
|
|
||||||
const pref = preference ? 1 : 0;
|
const pref = preference ? '1' : '0';
|
||||||
const posted = await PostServerSettings(client, "config", "disableBaseDamage", pref);
|
const posted = await PostServerSettings(client, "config", "ToggleBaseDamage", pref);
|
||||||
if (posted == 1) return 1;
|
if (posted == 1) return 1;
|
||||||
|
|
||||||
const remoteDir = `/games/${client.config.Nitrado.UserID}/ftproot/dayzxb_missions/dayzOffline.chernarusplus`;
|
const remoteDir = `/games/${client.config.Nitrado.UserID}/ftproot/dayzxb_missions/dayzOffline.chernarusplus`;
|
||||||
const remoteFilename = 'cfggameplay.json';
|
const remoteFilename = 'cfggameplay.json';
|
||||||
|
|
||||||
const jsonDir = `../logs/${remoteFilename}`;
|
const jsonDir = `./logs/${remoteFilename}`;
|
||||||
await module.exports.DownloadNitradoFile(client, `${remoteDir}/${remoteFilename}`, jsonDir);
|
await module.exports.DownloadNitradoFile(client, `${remoteDir}/${remoteFilename}`, jsonDir);
|
||||||
|
|
||||||
let gameplay = JSON.parse(fs.readFileSync(jsonDir));
|
let gameplay = JSON.parse(fs.readFileSync(jsonDir));
|
||||||
gameplay.GeneralData.disableBaseDamage = preference;
|
gameplay.GeneralData.disableBaseDamage = preference;
|
||||||
|
|
||||||
// write JSON to file
|
// write JSON to file
|
||||||
fs.writeFileSync(jsonDir, JSON.stringify(gameplay), null, 2);
|
fs.writeFileSync(jsonDir, JSON.stringify(gameplay, null, 2));
|
||||||
|
|
||||||
const uploaded = await UploadNitradoFile(client, remoteDir, remoteFileName, jsonDir);
|
const uploaded = await UploadNitradoFile(client, remoteDir, remoteFilename, jsonDir);
|
||||||
if (uploaded == 1) return 1;
|
if (uploaded == 1) return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user