Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
feat: greet newly created threads
Browse files Browse the repository at this point in the history
When a message is sent, this commit will make the threadchannel hook
send a reply to the newly created thread greeting the poster and
providing some help on what is the purpose of the thread.
  • Loading branch information
danirod committed May 20, 2022
1 parent 42c8f4a commit 350dd12
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/hooks/threadchannel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { userMention } from "@discordjs/builders";
import {
GuildMember,
Message,
Expand Down Expand Up @@ -62,6 +63,15 @@ function isAcceptableUser(gm: GuildMember): boolean {
}

async function startThread(msg: Message): Promise<void> {
const name = `${msg.id}`;
await msg.startThread({ name });
const name = `${msg.author.username} - ${msg.id}`;
const thread = await msg.startThread({ name });
const template = [
`¡Hola, ${userMention(msg.author.id)}! Te he abierto un hilo para que se pueda continuar`,
`aquí una conversación sobre el mensaje que has enviado. Puedes utilizar los siguientes comandos para controlar tu hilo:\n`,
"▪ Utiliza `/renombrar` para cambiarle el título al hilo. Por ejemplo, `/renombrar javascript no funciona mi fizzbuzz`\n",
"▪ Utiliza `/archivar` si quieres archivar tu hilo en cualquier momento.",
].join(" ");
await thread.send({
content: template,
});
}

0 comments on commit 350dd12

Please sign in to comment.