Logs are posted in the log channel again
parent
ce6c0da0e2
commit
e0bd96e959
|
@ -163,7 +163,13 @@ bot.registerCommandAlias('ar', 'anonreply');
|
|||
// Close a thread. Closing a thread saves a log of the channel's contents and then deletes the channel.
|
||||
addInboxServerCommand('close', async (msg, args, thread) => {
|
||||
if (! thread) return;
|
||||
thread.close();
|
||||
await thread.close();
|
||||
|
||||
const logUrl = await thread.getLogUrl();
|
||||
utils.postLog(utils.trimAll(`
|
||||
Modmail thread with ${thread.user_name} (${thread.user_id}) was closed by ${msg.author.username}
|
||||
Logs: ${logUrl}
|
||||
`));
|
||||
});
|
||||
|
||||
addInboxServerCommand('block', (msg, args, thread) => {
|
||||
|
|
14
src/utils.js
14
src/utils.js
|
@ -52,6 +52,10 @@ function getLogChannel() {
|
|||
return logChannel;
|
||||
}
|
||||
|
||||
function postLog(...args) {
|
||||
getLogChannel().createMessage(...args);
|
||||
}
|
||||
|
||||
function postError(str) {
|
||||
getLogChannel().createMessage({
|
||||
content: `@here **Error:** ${str.trim()}`,
|
||||
|
@ -182,6 +186,13 @@ function chunk(items, chunkSize) {
|
|||
return result;
|
||||
}
|
||||
|
||||
function trimAll(str) {
|
||||
return str
|
||||
.split('\n')
|
||||
.map(str => str.trim())
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
BotError,
|
||||
|
||||
|
@ -189,6 +200,7 @@ module.exports = {
|
|||
getMainGuild,
|
||||
getLogChannel,
|
||||
postError,
|
||||
postLog,
|
||||
|
||||
isStaff,
|
||||
messageIsOnInboxServer,
|
||||
|
@ -201,5 +213,7 @@ module.exports = {
|
|||
disableLinkPreviews,
|
||||
getSelfUrl,
|
||||
getMainRole,
|
||||
|
||||
chunk,
|
||||
trimAll,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue