diff --git a/src/discordTools/SetupSettingsMenu.js b/src/discordTools/SetupSettingsMenu.js index 4784ddef..33c2f472 100644 --- a/src/discordTools/SetupSettingsMenu.js +++ b/src/discordTools/SetupSettingsMenu.js @@ -267,6 +267,17 @@ async function setupGeneralSettings(client, guildId, channel) { files: [new Discord.AttachmentBuilder( Path.join(__dirname, '..', 'resources/images/settings_logo.png'))] }); + + await client.messageSend(channel, { + embeds: [DiscordEmbeds.getEmbed({ + color: Constants.COLOR_SETTINGS, + title: client.intlGet(guildId, 'selectVoiceCallouts'), + thumbnail: `attachment://settings_logo.png` + })], + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId), + files: [new Discord.AttachmentBuilder( + Path.join(__dirname, '..', 'resources/images/settings_logo.png'))] + }); } async function setupNotificationSettings(client, guildId, channel) { diff --git a/src/discordTools/discordButtons.js b/src/discordTools/discordButtons.js index 7f90a106..ff146d17 100644 --- a/src/discordTools/discordButtons.js +++ b/src/discordTools/discordButtons.js @@ -564,4 +564,59 @@ module.exports = { style: instance.generalSettings.battlemetricsGlobalLogout ? SUCCESS : DANGER }))]; }, + + getSelectVoiceCalloutsButtons: function (guildId) { //TODO look for more Options + const instance = Client.client.getInstance(guildId); + + return [ + new Discord.ActionRowBuilder().addComponents( + module.exports.getButton({ + customId: 'VoicePlayerConnection', + label: Client.client.intlGet(guildId, 'voicePlayerConnectionCap'), + style: instance.generalSettings.voicePlayerConnection ? SUCCESS : DANGER + }), + module.exports.getButton({ + customId: 'VoicePlayerAfk', + label: Client.client.intlGet(guildId, 'voicePlayerAfkCap'), + style: instance.generalSettings.voicePlayerAfk ? SUCCESS : DANGER + }), + module.exports.getButton({ + customId: 'VoicePlayerDeath', + label: Client.client.intlGet(guildId, 'voicePlayerDeathCap'), + style: instance.generalSettings.voicePlayerDeath ? SUCCESS : DANGER + }), + module.exports.getButton({ + customId: 'VoiceSmartAlarm', + label: Client.client.intlGet(guildId, 'voiceSmartAlarmCap'), + style: instance.generalSettings.voiceSmartAlarm ? SUCCESS : DANGER + })), + new Discord.ActionRowBuilder().addComponents( + module.exports.getButton({ + customId: 'VoiceTeamChanges', + label: Client.client.intlGet(guildId, 'voiceTeamChangesCap'), + style: instance.generalSettings.voiceTeamChanges ? SUCCESS : DANGER + }), + module.exports.getButton({ + customId: 'VoiceServerStatus', + label: Client.client.intlGet(guildId, 'voiceServerStatusCap'), + style: instance.generalSettings.voiceServerStatus ? SUCCESS : DANGER + }), + module.exports.getButton({ + customId: 'VoiceServerWiped', + label: Client.client.intlGet(guildId, 'voiceServerWipedCap'), + style: instance.generalSettings.voiceServerWiped ? SUCCESS : DANGER + }), + module.exports.getButton({ + customId: 'VoiceSmartDevice', + label: Client.client.intlGet(guildId, 'voiceSmartDeviceCap'), + style: instance.generalSettings.voiceSmartDevice ? SUCCESS : DANGER + })), + new Discord.ActionRowBuilder().addComponents( + module.exports.getButton({ + customId: 'VoiceSayCommand', + label: Client.client.intlGet(guildId, 'voiceSayCommandCAP', + { prefix: instance.generalSettings.prefix }), + style: instance.generalSettings.voiceSayCommand ? SUCCESS : DANGER + }))]; + }, } \ No newline at end of file diff --git a/src/handlers/buttonHandler.js b/src/handlers/buttonHandler.js index f6bb724f..fce6520d 100644 --- a/src/handlers/buttonHandler.js +++ b/src/handlers/buttonHandler.js @@ -1,5 +1,6 @@ /* Copyright (C) 2022 Alexander Emanuelsson (alexemanuelol) + Edited by FaiThiX This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -425,6 +426,159 @@ module.exports = async (client, interaction) => { components: DiscordButtons.getSubscribeToChangesBattlemetricsButtons(guildId) }); } + else if (interaction.customId === 'VoicePlayerConnection') { + instance.generalSettings.voicePlayerConnection = + !instance.generalSettings.voicePlayerConnection; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voicePlayerConnection = + instance.generalSettings.voicePlayerConnection; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voicePlayerConnection}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoicePlayerAfk') { + instance.generalSettings.voicePlayerAfk = + !instance.generalSettings.voicePlayerAfk; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voicePlayerAfk = + instance.generalSettings.voicePlayerAfk; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voicePlayerAfk}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoicePlayerDeath') { + instance.generalSettings.voicePlayerDeath = + !instance.generalSettings.voicePlayerDeath; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voicePlayerDeath = + instance.generalSettings.voicePlayerDeath; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voicePlayerDeath}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoiceSmartAlarm') { + instance.generalSettings.voiceSmartAlarm = + !instance.generalSettings.voiceSmartAlarm; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voiceSmartAlarm = + instance.generalSettings.voiceSmartAlarm; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voiceSmartAlarm}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoiceTeamChanges') { + instance.generalSettings.voiceTeamChanges = + !instance.generalSettings.voiceTeamChanges; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voiceTeamChanges = + instance.generalSettings.voiceTeamChanges; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voiceTeamChanges}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoiceServerStatus') { + instance.generalSettings.voiceServerStatus = + !instance.generalSettings.voiceServerStatus; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voiceServerStatus = + instance.generalSettings.voiceServerStatus; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voiceServerStatus}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoiceServerWiped') { + instance.generalSettings.voiceServerWiped = + !instance.generalSettings.voiceServerWiped; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voiceServerWiped = + instance.generalSettings.voiceServerWiped; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voiceServerWiped}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoiceSmartDevice') { + instance.generalSettings.voiceSmartDevice = + !instance.generalSettings.voiceSmartDevice; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voiceSmartDevice = + instance.generalSettings.voiceSmartDevice; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voiceSmartDevice}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } + else if (interaction.customId === 'VoiceSayCommand') { + instance.generalSettings.voiceSayCommand = + !instance.generalSettings.voiceSayCommand; + client.setInstance(guildId, instance); + + if (rustplus) rustplus.generalSettings.voiceSayCommand = + instance.generalSettings.voiceSayCommand; + + client.log(client.intlGet(null, 'infoCap'), client.intlGet(null, 'buttonValueChange', { + id: `${verifyId}`, + value: `${instance.generalSettings.voiceSayCommand}` + })); + + await client.interactionUpdate(interaction, { + components: DiscordButtons.getSelectVoiceCalloutsButtons(guildId) + }); + } else if (interaction.customId.startsWith('ServerConnect')) { const ids = JSON.parse(interaction.customId.replace('ServerConnect', '')); const server = instance.serverList[ids.serverId]; diff --git a/src/languages/en.json b/src/languages/en.json index 974a6524..dc296bb2 100644 --- a/src/languages/en.json +++ b/src/languages/en.json @@ -609,6 +609,7 @@ "selectLanguageSetting": "Select what language the bot uses:", "selectMenuValueChange": "Select Menu Interaction - VerifyId: {id}, Value: {value}.", "selectTrademarkSetting": "Select which trademark that should be shown in every in-game message.", + "selectVoiceCallouts": "Select what the Bot should Call in Voicechat", "sell": "sell", "semicolon": "Semicolon", "sentTextToSpeech": "Sent the Text-To-Speech.", @@ -760,6 +761,15 @@ "vendingMachine": "Vending Machine", "vendingMachineDetectedSetting": "When a new Vending Machine is detected, send a notification.", "voiceCap": "VOICE", + "voicePlayerConnectionCap": "PLAYER CONNECT", + "voicePlayerAfkCap": "PLAYER AFK", + "voicePlayerDeathCap": "PLAYER DEATH", + "voiceSmartAlarmCap": "SMART ALARMS", + "voiceTeamChangesCap": "TEAM CHANGES", + "voiceServerStatusCap": "SERVER STATUS", + "voiceServerWipedCap": "SERVER WIPE", + "voiceSmartDeviceCap": "SMART DEVICES", + "voiceSayCommandCAP": "{prefix}SAY COMMAND", "warningCap": "WARNING", "waterTreatmentPlant": "Water Treatment Plant", "websiteCap": "WEBSITE", diff --git a/src/templates/generalSettingsTemplate.json b/src/templates/generalSettingsTemplate.json index cb25eed7..72675c2a 100644 --- a/src/templates/generalSettingsTemplate.json +++ b/src/templates/generalSettingsTemplate.json @@ -22,5 +22,14 @@ "battlemetricsTrackerNameChanges": true, "battlemetricsGlobalNameChanges": false, "battlemetricsGlobalLogin": false, - "battlemetricsGlobalLogout": false + "battlemetricsGlobalLogout": false, + "voicePlayerConnection": false, + "voicePlayerAfk": false, + "voicePlayerDeath": false, + "voiceSmartAlarm": false, + "voiceTeamChanges": false, + "voiceServerStatus": false, + "voiceServerWiped": false, + "voiceSmartDevice": false, + "voiceSayCommand": true } \ No newline at end of file