diff --git a/docs/configuration.md b/docs/configuration.md index ad29ce8..8c77988 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -272,6 +272,10 @@ The bot's "Playing" text **Default:** `on` If enabled, channel permissions for the thread are synchronized with the category when using `!move`. Requires `allowMove` to be enabled. +#### threadOnMention +**Default:** `off` +If enabled, the bot will automatically create a new thread for a user who pings it. + #### threadTimestamps **Default:** `off` If enabled, modmail threads will show accurate UTC timestamps for each message, in addition to Discord's own timestamps. diff --git a/src/data/cfg.schema.json b/src/data/cfg.schema.json index 94738a3..8955f84 100644 --- a/src/data/cfg.schema.json +++ b/src/data/cfg.schema.json @@ -254,6 +254,11 @@ "default": "\uD83D\uDCE8" }, + "threadOnMention": { + "$ref": "#/definitions/customBoolean", + "default": false + }, + "port": { "type": "number", "maximum": 65535, diff --git a/src/main.js b/src/main.js index 9f0ff4c..7d65fa6 100644 --- a/src/main.js +++ b/src/main.js @@ -223,7 +223,6 @@ function initBaseMessageHandlers() { content = `${staffMention}Bot mentioned in ${msg.channel.mention} (${msg.channel.guild.name}) by **${msg.author.username}#${msg.author.discriminator}(${msg.author.id})**: "${msg.cleanContent}"\n\n`; } - bot.createMessage(utils.getLogChannel().id, { content, disableEveryone: false, @@ -234,6 +233,15 @@ function initBaseMessageHandlers() { const botMentionResponse = utils.readMultilineConfigValue(config.botMentionResponse); bot.createMessage(msg.channel.id, botMentionResponse.replace(/{userMention}/g, `<@${msg.author.id}>`)); } + + // If configured, automatically open a new thread with a user who has pinged it + if (config.threadOnMention) { + const existingThread = await threads.findOpenThreadByUserId(msg.author.id); + if (! existingThread) { + // Only open a thread if we don't already have one + await threads.createNewThreadForUser(msg.author, { quiet: true }); + } + } }); }