delete button for alerts

This commit is contained in:
2025-11-11 14:30:33 -05:00
parent a8ea776bed
commit 7c735b91e8
4 changed files with 40 additions and 3 deletions

View File

@@ -25,8 +25,16 @@ module.exports = async (client, torn, config) => {
const then = new Date(state.itemAlertLast);
const twelveHours = 12 * 60 * 60 * 1000;
if (now.getTime() - then.getTime() > twelveHours) {
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
console.debug(`unpaidOC: Sending alert`);
channel.send(message);
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('delete_message')
.setLabel('Click when sorted')
.setStyle(ButtonStyle.Success),
);
channel.send({ content: message, components: [row] });
state.itemAlertLast = now.toISOString();
fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => {if (err) {console.error(err)}});
} else { console.debug(`noItemOC: Would send alert, but one was sent recently`); }

View File

@@ -65,8 +65,16 @@ module.exports = async (client, torn, config) => {
const then = new Date(state.ocAlertLast);
const twelveHours = 12 * 60 * 60 * 1000;
if (now.getTime() - then.getTime() > twelveHours) {
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
console.debug(`unavailableOC: Sending alert`);
channel.send({ embeds: [embed] });
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('delete_message')
.setLabel('Click when sorted')
.setStyle(ButtonStyle.Success),
);
channel.send({ embeds: [embed], components: [row] });
state.ocAlertLast = now.toISOString();
fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => {if (err) {console.error(err)}});
} else { console.debug(`unavailableOC: Would send alert, but one was sent recently`); }

View File

@@ -47,8 +47,16 @@ module.exports = async (client, torn, config) => {
const then = new Date(state.payoutAlertLast);
const twelveHours = 12 * 60 * 60 * 1000;
if (now.getTime() - then.getTime() > twelveHours) {
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
console.debug(`unpaidOC: Sending alert`);
channel.send({content: "# Unpaid Faction Crimes:", embeds: embeds });
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('delete_message')
.setLabel('Click when sorted')
.setStyle(ButtonStyle.Success),
);
channel.send({content: "# Unpaid Faction Crimes:", embeds: embeds, components: [row] });
state.payoutAlertLast = now.toISOString();
fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => {if (err) {console.error(err)}});
} else { console.debug(`unpaidOC: Would send alert, but one was sent recently`); }