TypeScript

Discordjs SlashCommand execute 안 변수가 처음 값으로 고정되는데 어떻게 해야하나요?

ru

ruma0607
답변 대기중
30 XP
import { ChannelType, CommandInteraction, SlashCommandBuilder } from 'discord.js'
import { client } from '../index'
import Command from '../structures/Command'

export default class ChannelCommand implements Command {
    command() {
        return new SlashCommandBuilder()
            .addChannelOption(option =>
                option
                    .setName("chatting")
                    .setDescription("Select a chat channel to read the text.")
                    .addChannelTypes(ChannelType.GuildText)
            )
            .setName('channel')
            .setDescription('Activate nomic bot.')
    }

    execute(interaction: CommandInteraction) {
        if (interaction.guild?.id) {
            const inputchannel = (interaction.options.get("chatting")?.channel || interaction.channel);
            const outputchannel = (client.guilds.cache.get(interaction.guild.id)?.members.cache.get(interaction.user.id)?.voice.channel || "")
            if (outputchannel != "") {
                interaction.reply(`Input and output channels are set.\nInput : ${inputchannel}, Output : ${outputchannel}`);
            } else {
                interaction.reply(`<@${interaction.user.id}> You are not connected to a voice channel.`)
            }
        } else {
            interaction.reply("guild id is not found")
        }
    }
}

음성 채널에 들어간 채로 /channel 하면 Input and output channels are set. 가 뜨는데
음성 채널 나가고 다시 /channel 해도 Input and output channels are set. 가 뜹니다.
변수가 처음 호출했을때의 값으로 고정되있는것 같은데 어떻게 해야하나요?


불러오는 중...