Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ client.on(Events.InteractionCreate, async (interaction) => {
case 'contactmods':
await contactMods.contactMods(interaction);
break;
case 'pingmods':
await contactMods.pingMods(interaction);
break;
case 'purge':
await purgeMessages.purgeMessages(interaction);
break;
Expand Down
29 changes: 28 additions & 1 deletion src/modules/contact-mods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
10 changes: 9 additions & 1 deletion src/register-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?')
Expand All @@ -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')
Expand Down