Fix missing here ping on new threads. Add threadTimestamps option to revert removal of thread timestamps.
parent
92ac21aa33
commit
adce3e0cbb
|
@ -67,3 +67,4 @@ These go in `config.json`. See also `config.example.json`.
|
||||||
|logChannelId|Server's default channel|Channel where to post links to closed threads and other alerts|
|
|logChannelId|Server's default channel|Channel where to post links to closed threads and other alerts|
|
||||||
|newThreadCategoryId|None|ID of the category where new modmail thread channels should be placed|
|
|newThreadCategoryId|None|ID of the category where new modmail thread channels should be placed|
|
||||||
|relaySmallAttachmentsAsAttachments|false|Whether to relay small (<2MB) attachments from users as attachments rather than links in modmail threads|
|
|relaySmallAttachmentsAsAttachments|false|Whether to relay small (<2MB) attachments from users as attachments rather than links in modmail threads|
|
||||||
|
|threadTimestamps|false|Whether to show custom timestamps in threads, in addition to Discord's own timestamps. Logs always have accurate timestamps, regardless of this setting.|
|
||||||
|
|
|
@ -27,6 +27,7 @@ const defaultConfig = {
|
||||||
"alwaysReplyAnon": false,
|
"alwaysReplyAnon": false,
|
||||||
"useNicknames": false,
|
"useNicknames": false,
|
||||||
"ignoreAccidentalThreads": false,
|
"ignoreAccidentalThreads": false,
|
||||||
|
"threadTimestamps": false,
|
||||||
|
|
||||||
"enableGreeting": false,
|
"enableGreeting": false,
|
||||||
"greetingMessage": null,
|
"greetingMessage": null,
|
||||||
|
|
|
@ -47,14 +47,18 @@ class Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the reply message
|
// Build the reply message
|
||||||
const timestamp = utils.getTimestamp();
|
|
||||||
let dmContent = `**${modUsername}:** ${text}`;
|
let dmContent = `**${modUsername}:** ${text}`;
|
||||||
let threadContent = `**${logModUsername}:** ${text}`;
|
let threadContent = `**${logModUsername}:** ${text}`;
|
||||||
let logContent = text;
|
let logContent = text;
|
||||||
|
|
||||||
let files = [];
|
if (config.threadTimestamps) {
|
||||||
|
const timestamp = utils.getTimestamp();
|
||||||
|
threadContent = `[${timestamp}] » ${threadContent}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare attachments, if any
|
// Prepare attachments, if any
|
||||||
|
let files = [];
|
||||||
|
|
||||||
if (replyAttachments.length > 0) {
|
if (replyAttachments.length > 0) {
|
||||||
for (const attachment of replyAttachments) {
|
for (const attachment of replyAttachments) {
|
||||||
files.push(await attachments.attachmentToFile(attachment));
|
files.push(await attachments.attachmentToFile(attachment));
|
||||||
|
@ -99,6 +103,13 @@ class Thread {
|
||||||
|
|
||||||
let threadContent = `**${msg.author.username}#${msg.author.discriminator}:** ${content}`;
|
let threadContent = `**${msg.author.username}#${msg.author.discriminator}:** ${content}`;
|
||||||
let logContent = msg.content;
|
let logContent = msg.content;
|
||||||
|
|
||||||
|
if (config.threadTimestamps) {
|
||||||
|
const timestamp = utils.getTimestamp(msg.timestamp, 'x');
|
||||||
|
threadContent = `[${timestamp}] « ${threadContent}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare attachments, if any
|
||||||
let attachmentFiles = [];
|
let attachmentFiles = [];
|
||||||
|
|
||||||
for (const attachment of msg.attachments) {
|
for (const attachment of msg.attachments) {
|
||||||
|
@ -145,13 +156,11 @@ class Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} text
|
|
||||||
* @param {Eris~MessageFile|Eris~MessageFile[]} file
|
|
||||||
* @returns {Promise<Eris~Message>}
|
* @returns {Promise<Eris~Message>}
|
||||||
*/
|
*/
|
||||||
async postToThreadChannel(text, file = null) {
|
async postToThreadChannel(...args) {
|
||||||
try {
|
try {
|
||||||
return await bot.createMessage(this.channel_id, text, file);
|
return await bot.createMessage(this.channel_id, ...args);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Channel not found
|
// Channel not found
|
||||||
if (e.code === 10003) {
|
if (e.code === 10003) {
|
||||||
|
@ -183,8 +192,8 @@ class Thread {
|
||||||
* @param {String} text
|
* @param {String} text
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async postNonLogMessage(text) {
|
async postNonLogMessage(...args) {
|
||||||
await this.postToThreadChannel(text);
|
await this.postToThreadChannel(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -79,6 +79,12 @@ async function createNewThreadForUser(user) {
|
||||||
|
|
||||||
const newThread = await findById(newThreadId);
|
const newThread = await findById(newThreadId);
|
||||||
|
|
||||||
|
// Ping moderators of the new thread
|
||||||
|
await newThread.postNonLogMessage({
|
||||||
|
content: `@here New modmail thread (${newThread.user_name})`,
|
||||||
|
disableEveryone: false
|
||||||
|
});
|
||||||
|
|
||||||
// Post the log link to the beginning (but don't save it in thread messages)
|
// Post the log link to the beginning (but don't save it in thread messages)
|
||||||
const logUrl = await newThread.getLogUrl();
|
const logUrl = await newThread.getLogUrl();
|
||||||
await newThread.postNonLogMessage(`Log URL: <${logUrl}>`);
|
await newThread.postNonLogMessage(`Log URL: <${logUrl}>`);
|
||||||
|
|
|
@ -128,11 +128,10 @@ function getUserMention(str) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current timestamp in an easily readable form
|
* Returns the current timestamp in an easily readable form
|
||||||
* @param {String|Date|undefined} date
|
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
function getTimestamp(date) {
|
function getTimestamp(...momentArgs) {
|
||||||
return moment.utc(date).format('HH:mm');
|
return moment.utc(...momentArgs).format('HH:mm');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue