aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moulberry-bush/solved.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-05 23:15:04 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-05 23:15:04 -0400
commit904ee80b50148317c0edaf71395a86138833ed7e (patch)
treefc5ac8cd745e079bb000675835f426ee8c24959a /src/commands/moulberry-bush/solved.ts
parent341565e2c30bfdc60e174c6abfb9f6bacbb1d5e3 (diff)
downloadtanzanite-904ee80b50148317c0edaf71395a86138833ed7e.tar.gz
tanzanite-904ee80b50148317c0edaf71395a86138833ed7e.tar.bz2
tanzanite-904ee80b50148317c0edaf71395a86138833ed7e.zip
add support thread solved command
Diffstat (limited to 'src/commands/moulberry-bush/solved.ts')
-rw-r--r--src/commands/moulberry-bush/solved.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/commands/moulberry-bush/solved.ts b/src/commands/moulberry-bush/solved.ts
new file mode 100644
index 0000000..836d575
--- /dev/null
+++ b/src/commands/moulberry-bush/solved.ts
@@ -0,0 +1,44 @@
+import { BushCommand, clientSendAndPermCheck, emojis, mappings, type CommandMessage, type SlashMessage } from '#lib';
+import assert from 'assert';
+
+export default class Solved extends BushCommand {
+ public constructor() {
+ super('solved', {
+ aliases: ['solved'],
+ category: "Moulberry's Bush",
+ description: 'A command to mark a support threads as solved.',
+ usage: ['solved'],
+ examples: ['solved'],
+ slash: true,
+ channel: 'guild',
+ clientPermissions: (m) => clientSendAndPermCheck(m),
+ userPermissions: [],
+ slashGuilds: [mappings.guilds["Moulberry's Bush"]],
+ restrictedGuilds: [mappings.guilds["Moulberry's Bush"]]
+ });
+ }
+
+ public override async exec(message: CommandMessage | SlashMessage) {
+ assert(message.inGuild());
+ assert(message.channel);
+
+ if (!message.channel.isThread()) return message.util.reply(`${emojis.error} This command can only be used in threads.`);
+
+ if (message.channel.parentId !== mappings.channels['neu-support'])
+ return message.util.reply(
+ `${emojis.error} This command can only be used in thread that are created in <#${mappings.channels['neu-support']}>.`
+ );
+
+ if (message.channel.name.startsWith('[Solved]')) return message.util.reply(`${emojis.error} This thread is already solved.`);
+
+ if (!message.channel.name.startsWith('Support'))
+ return message.util.reply(`${emojis.error} This thread is not a support thread.`);
+
+ const newName = `[Solved] ${message.channel.name}`;
+
+ await message.channel.setName(newName);
+ await message.util.reply(`${emojis.success} This thread has been marked as solved.`);
+
+ await message.channel.setArchived(true, `${message.author.tag} (${message.author.id}) marked this support thread as solved.`);
+ }
+}