Skip to content

Commit

Permalink
feat: attachment support
Browse files Browse the repository at this point in the history
  • Loading branch information
paring-chan committed Mar 9, 2024
1 parent f3e7b0d commit 16e5ff0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/applicationCommand/ApplicationCommandExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
Snowflake,
ApplicationCommandOptionData,
} from 'discord.js'
import { ChatInputCommandInteraction, Collection, CommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'
import { Attachment, ChatInputCommandInteraction, Collection, CommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'
import { ApplicationCommandOptionType, ApplicationCommandType } from 'discord-api-types/v10'
import { ApplicationCommandComponent } from './ApplicationCommand'
import { ApplicationCommandOption } from './ApplicationCommandOption'
Expand Down Expand Up @@ -118,7 +118,15 @@ export class ApplicationCommandExtension extends CTSExtension {
}
}

value = i.options.get(decorator.options.name, false)?.value
switch (decorator.options.type) {
case ApplicationCommandOptionType.Attachment:
value = i.options.getAttachment(decorator.options.name, decorator.options.required)
break
default:
value = i.options.get(decorator.options.name)?.value
break
}

break
}
}
Expand Down Expand Up @@ -373,4 +381,10 @@ export class ApplicationCommandExtension extends CTSExtension {
async commandInteraction(i: UserContextMenuCommandInteraction) {
return i
}

@argConverter({
component: ApplicationCommandComponent,
type: Attachment,
})
async attachment() {}
}

0 comments on commit 16e5ff0

Please sign in to comment.