From 9efbbb77678b346a5ae746ce47808a2f2e4daaf9 Mon Sep 17 00:00:00 2001 From: Wizzard Date: Thu, 8 Feb 2024 20:17:56 -0500 Subject: [PATCH] additional features to .toggleimages --- main.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 25956eb..2dabf86 100644 --- a/main.js +++ b/main.js @@ -63,13 +63,21 @@ function logMessageToFile(channelId, message) { client.on('messageCreate', async message => { if (message.channel.id === COMMAND_CHANNEL_ID && message.content.startsWith('.toggleimages')) { const args = message.content.split(' '); - if (args.length < 2) { + if (args.length === 1) { + let response = "Image forwarding status for channels:\n"; + Object.keys(channelMappings).forEach(sourceChannelId => { + const status = channelSettings.includeImages[sourceChannelId] ? "Enabled" : "Disabled"; + response += `- <#${sourceChannelId}>: ${status}\n`; + }); + return message.channel.send(response).then(msg => setTimeout(() => msg.delete(), 10000)); + } else if (args.length === 2) { + const channelId = args[1]; + channelSettings.includeImages[channelId] = !channelSettings.includeImages[channelId]; + fs.writeFileSync(settingsFilePath, JSON.stringify(channelSettings, null, 2)); + return message.reply(`Image and link forwarding for channel <#${channelId}> is now ${channelSettings.includeImages[channelId] ? "enabled" : "disabled"}.`).then(msg => setTimeout(() => msg.delete(), 5000)); + } else { return message.reply("Usage: .toggleimages ").then(msg => setTimeout(() => msg.delete(), 5000)); } - const channelId = args[1]; - channelSettings.includeImages[channelId] = !channelSettings.includeImages[channelId]; - fs.writeFileSync(settingsFilePath, JSON.stringify(channelSettings, null, 2)); - return message.reply(`Image and link forwarding for channel ${channelId} is now ${channelSettings.includeImages[channelId] ? "enabled" : "disabled"}.`).then(msg => setTimeout(() => msg.delete(), 5000)); } if (channelMappings[message.channel.id]) {