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:
6
src/commands/index.ts
Normal file
6
src/commands/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { SlashCommand } from '../utils/commands.js'
|
||||
import { ThreadCreate } from './threadCreate.js'
|
||||
|
||||
export default [
|
||||
ThreadCreate
|
||||
] as SlashCommand[]
|
||||
28
src/commands/threadCreate.ts
Normal file
28
src/commands/threadCreate.ts
Normal 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
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user