1- import { CommandInteraction , Message } from "discord.js"
1+ import { CommandInteraction , Message , Snowflake } from "discord.js"
22import log4js from "log4js"
33import config from "../../data/config.json"
44import Command from "../../utils/Command"
5- import { SendMessage } from "../../utils/Types"
5+ import { CommandSource , SendMessage } from "../../utils/Types"
66import { sendMessage } from "../../utils/Utils"
77
88
@@ -16,18 +16,24 @@ export default class ThreadCommand extends Command {
1616 help : "Create a new thread, can only be used in own Discord. Bot developer only." ,
1717 usage : "thread <name>" ,
1818 aliases : [ ] ,
19- options : [ ]
19+ options : [ {
20+ name : "name" ,
21+ description : "Name of thread" ,
22+ type : "STRING" ,
23+ required : true
24+ } ]
2025 } )
2126 }
2227
2328 async runInteraction ( source : CommandInteraction ) : Promise < SendMessage | undefined > {
24- return sendMessage ( source , "Slash command not supported" )
29+ return this . run ( source , source . user . id , source . options . getString ( "name" , true ) )
2530 }
2631
2732 async runMessage ( source : Message , args : string [ ] ) : Promise < SendMessage | undefined > {
28- const id = source . author . id
29- let name = args . join ( " " )
33+ return this . run ( source , source . author . id , args . join ( " " ) )
34+ }
3035
36+ async run ( source : CommandSource , id : Snowflake , name : string ) : Promise < SendMessage | undefined > {
3137 if ( ! config . admins . includes ( id ) )
3238 return sendMessage ( source , "This command is only for the bot developer" , undefined , true )
3339
@@ -42,11 +48,15 @@ export default class ThreadCommand extends Command {
4248 name = `[${ type } ] ${ name } `
4349
4450 Logger . info ( `Creating thread ${ name } for ${ id } in ${ channel . id } (${ channel . guild . name } )` )
45- await source . startThread ( {
51+ const msg = await channel . send ( { content : `<@${ id } >: ${ name } ` } )
52+ await msg . startThread ( {
4653 name,
4754 autoArchiveDuration : "MAX"
4855 } )
49- if ( source . pinnable )
50- await source . pin ( )
56+
57+ if ( msg . pinnable )
58+ await msg . pin ( )
59+
60+ return sendMessage ( source , "Done!" , undefined , true )
5161 }
5262}
0 commit comments