slash commands integrated

* sample env and late version incr

* added slash command compatibility

* updated command name

* updated environment sample

* updated interaction comment
This commit is contained in:
Kevin Dang
2024-01-31 10:25:45 -08:00
committed by Kevin Dang
parent b94ff55449
commit 89c19990fa
16 changed files with 311 additions and 192 deletions

6
src/commands/index.ts Normal file
View File

@@ -0,0 +1,6 @@
import { SlashCommand } from '../utils/commands.js'
import { ThreadCreate } from './threadCreate.js'
export default [
ThreadCreate
] as SlashCommand[]

View File

@@ -0,0 +1,28 @@
import { ChannelType, Client, CommandInteraction, TextChannel } from 'discord.js'
import { SlashCommand } from '../utils/commands.js'
export const ThreadCreate: SlashCommand = {
name: 'thread',
description: 'creates a thread and mentions user',
// Query for server information
run: async (client: Client, interaction: CommandInteraction) => {
// fetch the channel
const channel = await client.channels.fetch(interaction.channelId)
if (!channel || channel.type !== ChannelType.GuildText) return
const thread = await (channel as TextChannel).threads.create({
name: `support-${Date.now()}`,
reason: `Support ticket ${Date.now()}`
})
// Send a message in the thread
thread.send(`**User:** ${interaction.user}`)
// user only reply
return interaction.reply({
content: 'I can help you in the Thread below.',
ephemeral: true
})
}
}