Skip to content

Commit

Permalink
feat: upgrade to discord.js v14.8
Browse files Browse the repository at this point in the history
  • Loading branch information
paring-chan committed Mar 25, 2023
1 parent 888e1e8 commit 5f15c91
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"semantic-release": "semantic-release"
},
"peerDependencies": {
"discord.js": "14",
"discord.js": "14.8",
"tslog": "*"
},
"release": {
Expand Down
16 changes: 4 additions & 12 deletions src/applicationCommand/ApplicationCommandExtension.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import chalk from 'chalk'
import type {
APIApplicationCommandSubcommandGroupOption,
APIApplicationCommandSubcommandOption,
ApplicationCommandData,
ApplicationCommandSubCommandData,
ChatInputApplicationCommandData,
Interaction,
Snowflake,
} from 'discord.js'
import type { ApplicationCommandData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, ChatInputApplicationCommandData, Interaction, Snowflake } from 'discord.js'
import {
ApplicationCommandOptionType,
ApplicationCommandType,
Expand Down Expand Up @@ -212,10 +204,10 @@ export class ApplicationCommandExtension extends CTSExtension {

if (!group.options) group.options = []

let child = group.options.find((x) => x.name === command.subcommandGroupChild?.options.name) as APIApplicationCommandSubcommandGroupOption | undefined
let child = group.options.find((x) => x.name === command.subcommandGroupChild?.options.name) as ApplicationCommandSubGroupData

if (!child) {
child = { type: ApplicationCommandOptionType.SubcommandGroup, ...(command.subcommandGroupChild.options as Omit<APIApplicationCommandSubcommandGroupOption, 'type'>) }
child = { ...(command.subcommandGroupChild.options as Omit<ApplicationCommandSubGroupData, 'type'>), type: ApplicationCommandOptionType.SubcommandGroup }
group.options.push(child)
}

Expand All @@ -231,7 +223,7 @@ export class ApplicationCommandExtension extends CTSExtension {
}
}

child.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as APIApplicationCommandSubcommandOption)
child.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as ApplicationCommandSubCommandData)

continue
}
Expand Down
4 changes: 2 additions & 2 deletions src/applicationCommand/ApplicationCommandOption.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { APIApplicationCommandOption } from 'discord.js'
import type { ApplicationCommandOptionData } from 'discord.js'
import { createArgumentDecorator, ComponentArgumentDecorator } from '../core'

type Options = APIApplicationCommandOption
type Options = ApplicationCommandOptionData

export class ApplicationCommandOption extends ComponentArgumentDecorator<Options> {}

Expand Down
10 changes: 5 additions & 5 deletions src/applicationCommand/group.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { APIApplicationCommandSubcommandOption, ChatInputApplicationCommandData } from 'discord.js'
import type { ApplicationCommandSubGroupData, ChatInputApplicationCommandData } from 'discord.js'
import { ApplicationCommandType } from 'discord.js'
import { createComponentDecorator } from '../core'
import { ApplicationCommandComponent } from './ApplicationCommand'

export class SubCommandGroup {
constructor(public options: Omit<APIApplicationCommandSubcommandOption, 'type'>, public guilds?: string[]) {}
constructor(public options: Omit<ChatInputApplicationCommandData, 'type'>, public guilds?: string[]) {}

command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {
command(options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>): MethodDecorator {
const cmd = new ApplicationCommandComponent({
type: ApplicationCommandType.ChatInput,
...options,
Expand All @@ -15,13 +15,13 @@ export class SubCommandGroup {
return createComponentDecorator(cmd)
}

createChild(options: Omit<APIApplicationCommandSubcommandOption, 'type'>) {
createChild(options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>) {
return new SubCommandGroupChild(options, this)
}
}

export class SubCommandGroupChild {
constructor(public options: Omit<APIApplicationCommandSubcommandOption, 'type'>, public parent: SubCommandGroup) {}
constructor(public options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>, public parent: SubCommandGroup) {}

command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {
const cmd = new ApplicationCommandComponent({
Expand Down

0 comments on commit 5f15c91

Please sign in to comment.