Add 'silent' option to !close when closeMessage is specified
parent
f4a295c00e
commit
5e1a1e7e15
|
@ -326,8 +326,8 @@ class Thread {
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async close(silent = false) {
|
async close(noSystemMessage = false) {
|
||||||
if (! silent) {
|
if (! noSystemMessage) {
|
||||||
console.log(`Closing thread ${this.id}`);
|
console.log(`Closing thread ${this.id}`);
|
||||||
await this.postSystemMessage('Closing thread...');
|
await this.postSystemMessage('Closing thread...');
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ module.exports = bot => {
|
||||||
bot.registerCommand('close', async (msg, args) => {
|
bot.registerCommand('close', async (msg, args) => {
|
||||||
let thread, closedBy;
|
let thread, closedBy;
|
||||||
|
|
||||||
|
let sendCloseMessage = !! config.closeMessage;
|
||||||
|
|
||||||
if (msg.channel instanceof Eris.PrivateChannel) {
|
if (msg.channel instanceof Eris.PrivateChannel) {
|
||||||
// User is closing the thread by themselves (if enabled)
|
// User is closing the thread by themselves (if enabled)
|
||||||
if (! config.allowUserClose) return;
|
if (! config.allowUserClose) return;
|
||||||
|
@ -67,7 +69,7 @@ module.exports = bot => {
|
||||||
|
|
||||||
// Timed close
|
// Timed close
|
||||||
if (args.length) {
|
if (args.length) {
|
||||||
if (args[0].startsWith('c')) {
|
if (args.includes('cancel') || args.includes('c')) {
|
||||||
// Cancel timed close
|
// Cancel timed close
|
||||||
if (thread.scheduled_close_at) {
|
if (thread.scheduled_close_at) {
|
||||||
await thread.cancelScheduledClose();
|
await thread.cancelScheduledClose();
|
||||||
|
@ -75,8 +77,9 @@ module.exports = bot => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else if (args.includes('silent') || args.includes('s')) {
|
||||||
|
sendCloseMessage = false;
|
||||||
|
} else {
|
||||||
// Set a timed close
|
// Set a timed close
|
||||||
const delay = utils.convertDelayStringToMS(args.join(' '));
|
const delay = utils.convertDelayStringToMS(args.join(' '));
|
||||||
if (delay === 0 || delay === null) {
|
if (delay === 0 || delay === null) {
|
||||||
|
@ -90,13 +93,14 @@ module.exports = bot => {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Regular close
|
// Regular close
|
||||||
await thread.close();
|
await thread.close();
|
||||||
closedBy = msg.author.username;
|
closedBy = msg.author.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.closeMessage) {
|
if (sendCloseMessage) {
|
||||||
await thread.postToUser(config.closeMessage).catch(() => {});
|
await thread.postToUser(config.closeMessage).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue