Discord.js 语音 connection.destroy() 错误
Discord.js Voice connection.destroy() error
我想创建一个“无线电”命令。我使用一个名为 @discordjs/voice 的包。我希望用户键入 quit
,机器人将离开机器人所在的频道。我正在使用此代码:
async function stop(message) {
try {
if (!message.member.voice.channelId)
return message.reply("You are not in a voice channel!");
if (
message.guild.me.voice.channelId &&
message.member.voice.channelId !== message.guild.me.voice.channelId
)
return message.reply("You are not in my voice channel!");
if (!message.guild.me.voice.channelId)
return message.reply("I'm not playing anything!");
let embed = new MessageEmbed()
.setColor(color.warn)
.setDescription(
`**⏹️ | Stopped playing in <#${message.guild.me.voice.channelId}>**`
);
const connection = await getVoiceConnection(message.guildId);
if (!connection)
return message.reply(`There aren't any active radio in this Server`);
message.reply({ embeds: [embed] });
return await connection.destroy();
} catch (err) {}
}
这是错误:
reject Promise { { ip: '34.136.228.183', port: 51364 } } Error: Cannot perform IP discovery - socket closed
at Socket.<anonymous> (/home/runner/disbot/node_modules/@discordjs/voice/dist/index.js:1:6361)
at Object.onceWrapper (node:events:509:28)
at Socket.emit (node:events:402:35)
at socketCloseNT (node:dgram:755:8)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Note: The bots is leave the voice channel. But the bot return an error in the console.
Thanks for answering!
我有解决办法:
在 index.js(或主文件)中,您可以输入:
process.on("multipleResolves", (type, promise, reason) => {
if (reason.toLocaleString() === "Error: Cannot perform IP discovery - socket closed") return;
});
错误被取消以显示错误process.on("multipleResolves")
我想创建一个“无线电”命令。我使用一个名为 @discordjs/voice 的包。我希望用户键入 quit
,机器人将离开机器人所在的频道。我正在使用此代码:
async function stop(message) {
try {
if (!message.member.voice.channelId)
return message.reply("You are not in a voice channel!");
if (
message.guild.me.voice.channelId &&
message.member.voice.channelId !== message.guild.me.voice.channelId
)
return message.reply("You are not in my voice channel!");
if (!message.guild.me.voice.channelId)
return message.reply("I'm not playing anything!");
let embed = new MessageEmbed()
.setColor(color.warn)
.setDescription(
`**⏹️ | Stopped playing in <#${message.guild.me.voice.channelId}>**`
);
const connection = await getVoiceConnection(message.guildId);
if (!connection)
return message.reply(`There aren't any active radio in this Server`);
message.reply({ embeds: [embed] });
return await connection.destroy();
} catch (err) {}
}
这是错误:
reject Promise { { ip: '34.136.228.183', port: 51364 } } Error: Cannot perform IP discovery - socket closed
at Socket.<anonymous> (/home/runner/disbot/node_modules/@discordjs/voice/dist/index.js:1:6361)
at Object.onceWrapper (node:events:509:28)
at Socket.emit (node:events:402:35)
at socketCloseNT (node:dgram:755:8)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Note: The bots is leave the voice channel. But the bot return an error in the console.
Thanks for answering!
我有解决办法:
在 index.js(或主文件)中,您可以输入:
process.on("multipleResolves", (type, promise, reason) => {
if (reason.toLocaleString() === "Error: Cannot perform IP discovery - socket closed") return;
});
错误被取消以显示错误process.on("multipleResolves")