【发布时间】:2021-11-03 20:17:23
【问题描述】:
我正在尝试检查发起命令的用户当前是否在语音频道中,并且在我运行机器人后,我的代码正常工作,如果我随后离开频道并重新获得语音频道信息,启动命令我要返回与缓存相同的语音通道信息?接收最新信息的唯一方法是完全重启我的机器人。
export const interactionListener = async (interaction, client) => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
switch (commandName) {
case 'play':
let user = await interaction.member.fetch();
let channel = await user.voice.channel;
if (!channel) {
interaction.reply('you are not in a voice channel');
} else {
interaction.channel.send('do something else');
}
}
};
并且该代码运行在一个interactionCreate here上
client.on('interactionCreate', async (interaction) => {
interactionListener(interaction, client);
});
【问题讨论】:
标签: javascript node.js discord discord.js