Skip to content

Commit

Permalink
add more voice settings
Browse files Browse the repository at this point in the history
  • Loading branch information
FaiThiX committed Feb 21, 2024
1 parent ee8170c commit 6307771
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/discordTools/SetupSettingsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
55 changes: 55 additions & 0 deletions src/discordTools/discordButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}))];
},
}
154 changes: 154 additions & 0 deletions src/handlers/buttonHandler.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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];
Expand Down
10 changes: 10 additions & 0 deletions src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion src/templates/generalSettingsTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 6307771

Please sign in to comment.