From 2cbeab682b715e268f4cc65d269b0b13ea7b3c1c Mon Sep 17 00:00:00 2001 From: Mov Date: Sat, 7 Jun 2025 11:22:23 -0400 Subject: [PATCH 1/2] Re-add /pingmods --- src/index.js | 4 ++++ src/modules/ping-mods.js | 32 ++++++++++++++++++++++++++++++++ src/register-commands.js | 10 +++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/modules/ping-mods.js diff --git a/src/index.js b/src/index.js index c8cbe9e..01cb249 100644 --- a/src/index.js +++ b/src/index.js @@ -22,6 +22,7 @@ const tryRequire = (path) => { const starBoard = require('./modules/star-board'); const contactMods = require('./modules/contact-mods'); +const pingMods = require('./modules/ping-mods'); const purgeMessages = require('./modules/purge-messages'); const thread = require('./modules/thread'); const logging = require('./modules/logging'); @@ -92,6 +93,9 @@ client.on(Events.InteractionCreate, async (interaction) => { case 'contactmods': await contactMods.contactMods(interaction); break; + case 'pingmods': + await pingMods.pingMods(interaction); + break; case 'purge': await purgeMessages.purgeMessages(interaction); break; diff --git a/src/modules/ping-mods.js b/src/modules/ping-mods.js new file mode 100644 index 0000000..ae99a00 --- /dev/null +++ b/src/modules/ping-mods.js @@ -0,0 +1,32 @@ +const client = require('../client'); +const config = require('../../config'); + +const pingMods = async (interaction) => { + const reason = interaction.options.getString('reason'); + const recentMessages = await interaction.channel.messages.fetch({ + limit: 1 + }); + const mostRecentMessage = recentMessages.first(); + const modRole = await interaction.guild.roles.fetch(config.modRoleId); + const modChannel = await client.channels.fetch(config.modChannelId); + + let pingMessage = `${modRole}: ${interaction.user} pinged mods in ${interaction.channel}`; + if (mostRecentMessage) { + pingMessage += ` at ${mostRecentMessage.url}`; + } + if (reason) { + pingMessage += ' because:\n\`\`\`'; + pingMessage += reason.replace(/```/g, '[escaped code block]'); + pingMessage += '\n\`\`\`'; + } + await modChannel.send(pingMessage); + + await interaction.reply({ + content: 'Mods have been pinged. Be patient. Pinging again does not help.', + ephemeral: true + }); +}; + +module.exports = { + pingMods +}; \ No newline at end of file diff --git a/src/register-commands.js b/src/register-commands.js index cd6fde3..5835afb 100644 --- a/src/register-commands.js +++ b/src/register-commands.js @@ -14,7 +14,7 @@ const { const commands = [ new SlashCommandBuilder() .setName('contactmods') - .setDescription('Contact moderators without posting a public message (previously /pingmods)') + .setDescription('Contact moderators without posting a public message') .addStringOption(option => option .setName('topic') .setDescription('What are you contacting us about?') @@ -27,6 +27,14 @@ const commands = [ .setMaxLength(1000) .setRequired(true) ), + new SlashCommandBuilder() + .setName('pingmods') + .setDescription('Ping moderators without posting a public message') + .addStringOption(option => option + .setName('reason') + .setDescription('Message will be provided to moderators.') + .setMaxLength(1000) + ), new SlashCommandBuilder() .setName('purge') .setDescription('Purge messages in the current channel') From 98012978f3ef0a17bf87a2d18cc33ce887fa15fc Mon Sep 17 00:00:00 2001 From: Mov Date: Sat, 7 Jun 2025 14:54:55 -0400 Subject: [PATCH 2/2] Move the pingMods function into the contact-mods file with the rest of the reporting functions --- src/index.js | 3 +-- src/modules/contact-mods.js | 29 ++++++++++++++++++++++++++++- src/modules/ping-mods.js | 32 -------------------------------- 3 files changed, 29 insertions(+), 35 deletions(-) delete mode 100644 src/modules/ping-mods.js diff --git a/src/index.js b/src/index.js index 01cb249..1db7620 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,6 @@ const tryRequire = (path) => { const starBoard = require('./modules/star-board'); const contactMods = require('./modules/contact-mods'); -const pingMods = require('./modules/ping-mods'); const purgeMessages = require('./modules/purge-messages'); const thread = require('./modules/thread'); const logging = require('./modules/logging'); @@ -94,7 +93,7 @@ client.on(Events.InteractionCreate, async (interaction) => { await contactMods.contactMods(interaction); break; case 'pingmods': - await pingMods.pingMods(interaction); + await contactMods.pingMods(interaction); break; case 'purge': await purgeMessages.purgeMessages(interaction); diff --git a/src/modules/contact-mods.js b/src/modules/contact-mods.js index abcd8cf..d2cc0dd 100644 --- a/src/modules/contact-mods.js +++ b/src/modules/contact-mods.js @@ -229,9 +229,36 @@ const reportUser = async (interaction) => { } }; +const pingMods = async (interaction) => { + const reason = interaction.options.getString('reason'); + const recentMessages = await interaction.channel.messages.fetch({ + limit: 1 + }); + const mostRecentMessage = recentMessages.first(); + const modRole = await interaction.guild.roles.fetch(config.modRoleId); + const modChannel = await client.channels.fetch(config.modChannelId); + + let pingMessage = `${modRole}: ${interaction.user} pinged mods in ${interaction.channel}`; + if (mostRecentMessage) { + pingMessage += ` at ${mostRecentMessage.url}`; + } + if (reason) { + pingMessage += ' because:\n\`\`\`'; + pingMessage += reason.replace(/```/g, '[escaped code block]'); + pingMessage += '\n\`\`\`'; + } + await modChannel.send(pingMessage); + + await interaction.reply({ + content: 'Mods have been pinged. Be patient. Pinging again does not help.', + ephemeral: true + }); +}; + module.exports = { ticketActivity, contactMods, reportMessage, - reportUser + reportUser, + pingMods }; diff --git a/src/modules/ping-mods.js b/src/modules/ping-mods.js deleted file mode 100644 index ae99a00..0000000 --- a/src/modules/ping-mods.js +++ /dev/null @@ -1,32 +0,0 @@ -const client = require('../client'); -const config = require('../../config'); - -const pingMods = async (interaction) => { - const reason = interaction.options.getString('reason'); - const recentMessages = await interaction.channel.messages.fetch({ - limit: 1 - }); - const mostRecentMessage = recentMessages.first(); - const modRole = await interaction.guild.roles.fetch(config.modRoleId); - const modChannel = await client.channels.fetch(config.modChannelId); - - let pingMessage = `${modRole}: ${interaction.user} pinged mods in ${interaction.channel}`; - if (mostRecentMessage) { - pingMessage += ` at ${mostRecentMessage.url}`; - } - if (reason) { - pingMessage += ' because:\n\`\`\`'; - pingMessage += reason.replace(/```/g, '[escaped code block]'); - pingMessage += '\n\`\`\`'; - } - await modChannel.send(pingMessage); - - await interaction.reply({ - content: 'Mods have been pinged. Be patient. Pinging again does not help.', - ephemeral: true - }); -}; - -module.exports = { - pingMods -}; \ No newline at end of file