Skip to content

Commit 468b24c

Browse files
authored
Merge pull request #216 from tjjfvi/title-from-other-channel
allow running !title from another channel
2 parents c4d3f73 + 04db07d commit 468b24c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/modules/helpthread.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,19 @@ export class HelpThreadModule extends Module {
341341

342342
@command({ single: true, description: 'Help System: Rename a help thread' })
343343
async title(msg: Message, title: string) {
344-
if (!isHelpThread(msg.channel))
344+
const m = /^<#(\d+)>\s*([^]*)/.exec(title);
345+
let thread: Omit<Channel, 'partial'> | undefined = msg.channel;
346+
if (m) {
347+
thread = msg.guild?.channels.cache.get(m[1])!;
348+
title = m[2];
349+
}
350+
if (!thread || !isHelpThread(thread))
345351
return sendWithMessageOwnership(
346352
msg,
347353
':warning: This can only be run in a help thread',
348354
);
349355
if (!title)
350356
return sendWithMessageOwnership(msg, ':warning: Missing title');
351-
const thread = msg.channel;
352357
const threadData = (await HelpThread.findOne(thread.id))!;
353358
if (
354359
msg.author.id !== threadData.ownerId &&
@@ -374,8 +379,11 @@ export class HelpThreadModule extends Module {
374379
titleSetTimestamp: Date.now() + '',
375380
}),
376381
// Truncate if longer than 100, the max thread title length
377-
msg.channel.setName(`${username} - ${title}`.slice(0, 100)),
382+
thread.setName(`${username} - ${title}`.slice(0, 100)),
378383
]);
384+
if (thread !== msg.channel) {
385+
await msg.react('✅');
386+
}
379387
}
380388

381389
@command()

0 commit comments

Comments
 (0)