【发布时间】:2021-11-10 21:22:13
【问题描述】:
我的代码:
// not very relevant stuff
const {
SlashCommandBuilder
} = require('@discordjs/builders');
const {
MessageEmbed
} = require('discord.js');
const tip = require('../../tips/randomtip')
const fs = require('fs')
{
const status = require('./status')
if(status.inUsed = true){
status.inUsed = false
fs.writeFileSync( './commands/music/status.json', JSON.stringify(status,null,2))
}
}
// very relevant stuff
module.exports = {
data: new SlashCommandBuilder()
.setName('join')
.setDescription('Join the voice channel you are in'),
async execute(interaction) {
const voice = interaction.member.voice
// console.log(voice)
console.log(voice.channel)
},
};
问题是 voice.channel 保持不变(我没有检查它们是否完全相同相同,但频道名称和频道是相同的,因为这很重要)
我正在使用discord.js v13 最新版本,所以请不要质疑我
【问题讨论】:
-
你的代码的哪一部分应该改变频道的信息?
-
const voice = interaction.member.voice应该为用户当前所在的频道设置常量voice实际发生的情况是它显示了机器人启动时用户所在的语音频道并且永远不会改变 -
在命令函数里面,每次调用命令都会更新
-
没错,但发生的事情是它永远不会更新
-
鉴于您显示的代码它应该考虑到用户更改语音通道。
标签: javascript node.js discord discord.js