Show mod username for anonymous replies in logs
parent
51ef267f02
commit
70601f1d00
13
src/index.js
13
src/index.js
|
@ -166,23 +166,30 @@ function reply(msg, text, anonymous = false) {
|
||||||
|
|
||||||
attachments.saveAttachmentsInMessage(msg).then(() => {
|
attachments.saveAttachmentsInMessage(msg).then(() => {
|
||||||
bot.getDMChannel(thread.userId).then(dmChannel => {
|
bot.getDMChannel(thread.userId).then(dmChannel => {
|
||||||
let modUsername;
|
let modUsername, logModUsername;
|
||||||
const mainRole = utils.getMainRole(msg.member);
|
const mainRole = utils.getMainRole(msg.member);
|
||||||
|
|
||||||
if (anonymous) {
|
if (anonymous) {
|
||||||
modUsername = (mainRole ? mainRole.name : 'Moderator');
|
modUsername = (mainRole ? mainRole.name : 'Moderator');
|
||||||
|
logModUsername = `(Anonymous) (${msg.author.username}) ${mainRole ? mainRole.name : 'Moderator'}`;
|
||||||
} else {
|
} else {
|
||||||
modUsername = (mainRole ? `(${mainRole.name}) ${msg.author.username}` : msg.author.username);
|
modUsername = (mainRole ? `(${mainRole.name}) ${msg.author.username}` : msg.author.username);
|
||||||
|
logModUsername = modUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = `**${modUsername}:** ${text}`;
|
let content = `**${modUsername}:** ${text}`;
|
||||||
|
let logContent = `**${logModUsername}:** ${text}`;
|
||||||
|
|
||||||
function sendMessage(file, attachmentUrl) {
|
function sendMessage(file, attachmentUrl) {
|
||||||
dmChannel.createMessage(content, file).then(() => {
|
dmChannel.createMessage(content, file).then(() => {
|
||||||
if (attachmentUrl) content += `\n\n**Attachment:** ${attachmentUrl}`;
|
if (attachmentUrl) {
|
||||||
|
content += `\n\n**Attachment:** ${attachmentUrl}`;
|
||||||
|
logContent += `\n\n**Attachment:** ${attachmentUrl}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the message in the modmail thread as well
|
||||||
const timestamp = utils.getTimestamp();
|
const timestamp = utils.getTimestamp();
|
||||||
msg.channel.createMessage(`[${timestamp}] » ${content}`);
|
msg.channel.createMessage(`[${timestamp}] » ${logContent}`);
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
if (err.resp && err.resp.statusCode === 403) {
|
if (err.resp && err.resp.statusCode === 403) {
|
||||||
msg.channel.createMessage(`Could not send reply; the user has likely blocked the bot`);
|
msg.channel.createMessage(`Could not send reply; the user has likely blocked the bot`);
|
||||||
|
|
Loading…
Reference in New Issue