【发布时间】:2021-01-20 23:44:10
【问题描述】:
我为我的音乐机器人制作了这段代码,但是我知道当机器人不在语音频道中时机器人如何检查,机器人会自动连接回特定的频道,如 id。但是当机器人在另一个语音通道中使用时,机器人不会回到我制作的特定语音通道。了解如何用语音编码间隔、循环或检查机器人。
client.on("ready", () => {
console.log(`Hello ${client.user.username} is now online!`);
let channel = client.channels.cache.get("720137811587629119");
if (!channel) return console.error("The channel does not exist!");
setInterval(function() {
channel.join()
.then(connection => console.log('Connected'))
.catch(console.error);
}, 30000)
let botStatus = [
`${client.guilds.cache.size} servers!`,
"s,help or s,h",
`Over ${client.users.cache.size} users!`,
`Over ${client.channels.cache.size} channels!`
]
setInterval(function() {
let status = botStatus[Math.floor(Math.random() * botStatus.length)];
client.user.setActivity(status, {type: "PLAYING"});
}, 5000)
});
【问题讨论】:
标签: discord.js