close: use native options for -s, add -silent/-cancel/-c options
parent
ff5707c40f
commit
cd500f06dd
|
@ -92,8 +92,9 @@ module.exports = ({ bot, knex, config, commands }) => {
|
|||
thread = await threads.findOpenThreadByChannelId(msg.channel.id);
|
||||
if (! thread) return;
|
||||
|
||||
if (args.opts && args.opts.length) {
|
||||
if (args.opts.includes("cancel") || args.opts.includes("c")) {
|
||||
const opts = args.opts || [];
|
||||
|
||||
if (args.cancel || opts.includes("cancel") || opts.includes("c")) {
|
||||
// Cancel timed close
|
||||
if (thread.scheduled_close_at) {
|
||||
await thread.cancelScheduledClose();
|
||||
|
@ -104,12 +105,12 @@ module.exports = ({ bot, knex, config, commands }) => {
|
|||
}
|
||||
|
||||
// Silent close (= no close message)
|
||||
if (args.opts.includes("silent") || args.opts.includes("s") || args.opts.includes("-s")) {
|
||||
if (args.silent || opts.includes("silent") || opts.includes("s")) {
|
||||
silentClose = true;
|
||||
}
|
||||
|
||||
// Timed close
|
||||
const delayStringArg = args.opts.find(arg => utils.delayStringRegex.test(arg));
|
||||
const delayStringArg = opts.find(arg => utils.delayStringRegex.test(arg));
|
||||
if (delayStringArg) {
|
||||
const delay = utils.convertDelayStringToMS(delayStringArg);
|
||||
if (delay === 0 || delay === null) {
|
||||
|
@ -131,7 +132,6 @@ module.exports = ({ bot, knex, config, commands }) => {
|
|||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Regular close
|
||||
closedBy = msg.author.username;
|
||||
|
@ -146,6 +146,11 @@ module.exports = ({ bot, knex, config, commands }) => {
|
|||
await thread.close(suppressSystemMessages, silentClose);
|
||||
|
||||
await sendCloseNotification(thread, `Modmail thread #${thread.thread_number} with ${thread.user_name} (${thread.user_id}) was closed by ${closedBy}`);
|
||||
}, {
|
||||
options: [
|
||||
{ name: "silent", shortcut: "s", isSwitch: true },
|
||||
{ name: "cancel", shortcut: "c", isSwitch: true },
|
||||
],
|
||||
});
|
||||
|
||||
// Auto-close threads if their channel is deleted
|
||||
|
|
Loading…
Reference in New Issue