-
Hello everyone, I'm a beginner on discord-js, especially in bot creation. Below is the code for a slash command called 'join': data: new SlashCommandBuilder()
.setName('join')
.setDescription('Join a channel')
.addChannelOption(option => option.setName('channel')
.setDescription('The channel to join')
.addChannelTypes(ChannelType.GuildVoice)
.setRequired(true)
),
async execute(interaction: CommandInteraction) {
const voiceChannel = (interaction.options as CommandInteractionOptionResolver).getChannel('channel');
// ...
} Here I'm forced to cast the type, which I don't find very clean. export abstract class CommandInteraction<Cached extends CacheType = CacheType> extends BaseInteraction<Cached> {
public type: InteractionType.ApplicationCommand;
public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
public options: Omit<
CommandInteractionOptionResolver<Cached>,
| 'getMessage'
| 'getFocused'
| 'getMentionable'
| 'getRole'
| 'getAttachment'
| 'getNumber'
| 'getInteger'
| 'getString'
| 'getChannel'
| 'getBoolean'
| 'getSubcommandGroup'
| 'getSubcommand'
>;
// ... So my question is why? thank you in advance for your reply 🙏🏻 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
didn't read just saw the code sample but try typing it as |
Beta Was this translation helpful? Give feedback.
-
It is omitted because |
Beta Was this translation helpful? Give feedback.
didn't read just saw the code sample but try typing it as
ChatInputCommandInteraction