feature/mute alarm role ping
This commit is contained in:
4 files changed
+71
-8
No files matched your search
+63
-3
@@ -125,6 +125,19 @@ module.exports = {
|
|||||||
value: "enable",
|
value: "enable",
|
||||||
type: CommandOptions.SubCommand,
|
type: CommandOptions.SubCommand,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "mute",
|
||||||
|
description: "Toggle mute on this alarm",
|
||||||
|
value: "mute",
|
||||||
|
type: CommandOptions.SubCommand,
|
||||||
|
options: [{
|
||||||
|
name: "toggle",
|
||||||
|
description: "Turn on or off role pings for this alarm",
|
||||||
|
value: false,
|
||||||
|
type: CommandOptions.Boolean,
|
||||||
|
required: true,
|
||||||
|
}]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "set-rule",
|
name: "set-rule",
|
||||||
description: "Add a Rule to an Alarm",
|
description: "Add a Rule to an Alarm",
|
||||||
@@ -350,11 +363,9 @@ module.exports = {
|
|||||||
|
|
||||||
if (GuildDB.alarms.length == 0) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Default).setDescription('**Notice:** No Existing Alarms to configure.')] });
|
if (GuildDB.alarms.length == 0) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Default).setDescription('**Notice:** No Existing Alarms to configure.')] });
|
||||||
|
|
||||||
let disable = args[0].name == 'disable' ? true : false;
|
|
||||||
|
|
||||||
let alarms = new StringSelectMenuBuilder()
|
let alarms = new StringSelectMenuBuilder()
|
||||||
.setCustomId(`MoveOrigin-${args[0].options[0].value}-${args[0].options[1].value}-${interaction.member.user.id}`)
|
.setCustomId(`MoveOrigin-${args[0].options[0].value}-${args[0].options[1].value}-${interaction.member.user.id}`)
|
||||||
.setPlaceholder(`Select an Alarm to ${disable ? 'disable' : 'enable'}.`);
|
.setPlaceholder(`Select an Alarm to move.`);
|
||||||
|
|
||||||
for (let i = 0; i < GuildDB.alarms.length; i++) {
|
for (let i = 0; i < GuildDB.alarms.length; i++) {
|
||||||
alarms.addOptions({
|
alarms.addOptions({
|
||||||
@@ -368,6 +379,25 @@ module.exports = {
|
|||||||
|
|
||||||
return interaction.send({ components: [opt], flags: (1 << 6) });
|
return interaction.send({ components: [opt], flags: (1 << 6) });
|
||||||
|
|
||||||
|
} else if (args[0].name == 'mute') {
|
||||||
|
|
||||||
|
if (GuildDB.alarms.length == 0) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Default).setDescription('**Notice:** No Existing Alarms to configure.')] });
|
||||||
|
|
||||||
|
let alarms = new StringSelectMenuBuilder()
|
||||||
|
.setCustomId(`MuteAlarm-${args[0].options[0].value ? 1 : 0}-${interaction.member.user.id}`)
|
||||||
|
.setPlaceholder(`Select an Alarm to mute.`);
|
||||||
|
|
||||||
|
for (let i = 0; i < GuildDB.alarms.length; i++) {
|
||||||
|
alarms.addOptions({
|
||||||
|
label: GuildDB.alarms[i].name,
|
||||||
|
description: `Mute the role pings of this Alarm`,
|
||||||
|
value: GuildDB.alarms[i].name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const opt = new ActionRowBuilder().addComponents(alarms);
|
||||||
|
|
||||||
|
return interaction.send({ components: [opt], flags: (1 << 6) });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -639,7 +669,37 @@ module.exports = {
|
|||||||
|
|
||||||
return interaction.update({ embeds: [successEmbed], components: [] });
|
return interaction.update({ embeds: [successEmbed], components: [] });
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
MuteAlarm: {
|
||||||
|
run: async(client, interaction, GuildDB) => {
|
||||||
|
if (!interaction.customId.endsWith(interaction.member.user.id)) {
|
||||||
|
return interaction.reply({
|
||||||
|
content: "This menu is not for you",
|
||||||
|
flags: (1 << 6)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let alarm = GuildDB.alarms.find(alarm => alarm.name == interaction.values[0]);
|
||||||
|
let alarmIndex = GuildDB.alarms.indexOf(alarm);
|
||||||
|
let mute = parseInt(interaction.customId.split('-')[1]);
|
||||||
|
alarm.mute = mute;
|
||||||
|
GuildDB.alarms[alarmIndex] = alarm
|
||||||
|
|
||||||
|
client.dbo.collection('guilds').updateOne({ 'server.serverID': GuildDB.serverID }, {
|
||||||
|
$set: {
|
||||||
|
'server.alarms': GuildDB.alarms,
|
||||||
|
}
|
||||||
|
}, (err, res) => {
|
||||||
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
|
});
|
||||||
|
|
||||||
|
let successEmbed = new EmbedBuilder()
|
||||||
|
.setColor(client.config.Colors.Green)
|
||||||
|
.setDescription(`**Success:** Successfully ${mute?'Muted':'Unmuted'} this alarm.`);
|
||||||
|
|
||||||
|
return interaction.update({ embeds: [successEmbed], components: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "10.3.8",
|
"version": "10.4.0",
|
||||||
"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": {
|
||||||
|
|||||||
@@ -158,10 +158,12 @@ class DayzRBot extends Client {
|
|||||||
if (lines[i].includes('killed by Zmb') || lines[i].includes('>) died.')) s = await UpdateLastDeathDate(this, s, lines[i]); // Updates users last death date for non PVP deaths.
|
if (lines[i].includes('killed by Zmb') || lines[i].includes('>) died.')) s = await UpdateLastDeathDate(this, s, lines[i]); // Updates users last death date for non PVP deaths.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle alarm pings
|
||||||
for (const [channel_id, data] of Object.entries(this.alarmPingQueue)) {
|
for (const [channel_id, data] of Object.entries(this.alarmPingQueue)) {
|
||||||
const channel = this.GetChannel(channel_id);
|
const channel = this.GetChannel(channel_id);
|
||||||
for (const [role, embeds] of Object.entries(data)) {
|
for (const [role, embeds] of Object.entries(data)) {
|
||||||
channel.send({ content: `<@&${role}>`, embeds: embeds });
|
if (role == '-no-role-ping-') channel.send({ embeds: embeds });
|
||||||
|
else channel.send({ content: `<@&${role}>`, embeds: embeds });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,10 +77,11 @@ module.exports = {
|
|||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
if (!client.alarmPingQueue[alarm.channel]) client.alarmPingQueue[alarm.channel] = {};
|
if (!client.alarmPingQueue[alarm.channel]) client.alarmPingQueue[alarm.channel] = {};
|
||||||
if (!client.alarmPingQueue[alarm.channel][alarm.role]) client.alarmPingQueue[alarm.channel][alarm.role] = [];
|
let route = alarm.mute ? '-no-role-ping-' : alarm.role;
|
||||||
|
if (!client.alarmPingQueue[alarm.channel][route]) client.alarmPingQueue[alarm.channel][route] = [];
|
||||||
|
|
||||||
if (alarm.rules.includes['ban_on_entry']) {
|
if (alarm.rules.includes['ban_on_entry']) {
|
||||||
client.alarmPingQueue[alarm.channel][alarm.role].push(
|
client.alarmPingQueue[alarm.channel][route].push(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default)
|
.setColor(client.config.Colors.Default)
|
||||||
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned.__`)
|
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned.__`)
|
||||||
@@ -91,7 +92,7 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.alarmPingQueue[alarm.channel][alarm.role].push(
|
client.alarmPingQueue[alarm.channel][route].push(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default)
|
.setColor(client.config.Colors.Default)
|
||||||
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}**`)
|
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}**`)
|
||||||
|
|||||||
Reference in new issue
Block a user