Add useNicknames config option to use mod nicknames in replies. Post log lists in chunks to avoid hitting the message length limit.

master
Miikka Virtanen 2017-05-18 05:28:11 +03:00
parent ab7c1e8611
commit ad3417c827
1 changed files with 15 additions and 2 deletions

View File

@ -226,7 +226,8 @@ function reply(msg, text, anonymous = false) {
modUsername = (mainRole ? mainRole.name : 'Moderator'); modUsername = (mainRole ? mainRole.name : 'Moderator');
logModUsername = `(Anonymous) (${msg.author.username}) ${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); const name = (config.useNicknames ? msg.member.nick || msg.author.username : msg.author.username);
modUsername = (mainRole ? `(${mainRole.name}) ${name}` : name);
logModUsername = modUsername; logModUsername = modUsername;
} }
@ -390,7 +391,19 @@ bot.registerCommand('logs', (msg, args) => {
return `\`${formattedDate}\`: <${info.url}>`; return `\`${formattedDate}\`: <${info.url}>`;
}).join('\n'); }).join('\n');
msg.channel.createMessage(message); // Send list of logs in chunks of 15 lines per message
const lines = message.split('\n');
const chunks = [];
const chunkSize = 15;
for (let i = 0; i < lines.length; i += chunkSize) {
chunks.push(lines.slice(i, i + chunkSize).join('\n'));
}
let root = Promise.resolve();
chunks.forEach(chunk => {
root = root.then(() => msg.channel.createMessage(chunk));
});
}); });
} }