查找给用户的错误消息是notinvoice


collector.on("collect", async (i) => {
i.deferReply({ ephemeral: true }).catch(() => {});
if (!interaction.member.voice.channel)
return i.followUp({
content:
emojis.error + ` | **You Must Join A Voice Channel**`,
ephemeral: true,
});
if (interaction.guild.me.voice.channel) {
if (
interaction.member.voice.channel?.id !==
interaction.guild.me.voice.channel?.id
)
return i.followUp({
content:
emojis.error +
` | **You Must Join <#${interaction.guild.me.voice.channel.id}> To Contolr The Panel**`,
ephemeral: true,
});
}

-----------------------------------------------------------------------------

else if (panelType == "reactions") {
if (!interaction.member.voice.channel)
return interaction.channel
.send(emojis.error + ` | **You Must Join A Voice Channel**`)
.then((m) => {
setTimeout(() => {
m.delete();
}, 1500);
});
if (interaction.guild.me.voice.channel) {
if (
interaction.member.voice.channel?.id !==
interaction.guild.me.voice.channel?.id
)
return interaction.channel
.send(
emojis.error +
` | **You Must Join <#${interaction.guild.me.voice.channel.id}> To Contolr The Panel**`
)
.then((m) => {
setTimeout(() => {
m.delete();
}, 1500);
});
}

任何人都可以帮忙…我想要用户当他键入前缀,而他玩…我希望用户得到一个错误信息,如果他不在某个频道,他就不能播放那首歌。这段代码不能执行,谁能把它修复给我

您可以使用if ()语句:

if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.reply({content: 'you must be in the same voice channel as me'})

或者您可以使用.some()方法返回布尔值,如:

const sameChan = client.voice.connections.some((c) => c.channel.id === msg.member.voice.channelID)
if (!sameChan) return message.reply({content: 'you must be in the same voice channel as me'})

我建议使用第一个选择

collector.on("collect", async (i) => {
i.deferReply({ ephemeral: true }).catch(() => {});
if (!interaction.member.voice.channel)
return i.followUp({
content:
emojis.error + ` | **You Must Join A Voice Channel**`,
ephemeral: true,
});
if (interaction.guild.me.voice.channel) {
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) 
return message.reply({content: 'you must be in the same voice channel as me'})
}});
----------------------------------------------------------------------------
else if (panelType == "reactions") {
if (!interaction.member.voice.channel)
return interaction.channel
.send(emojis.error + ` | **You Must Join A Voice Channel**`)
.then((m) => {
setTimeout(() => {
m.delete();
}, 1500);
});
if (interaction.guild.me.voice.channel) {
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.reply({content: 'you must be in the same voice channel as me'})
};
.then((m) => {
setTimeout(() => {
m.delete();
}, 1500);
});
}

最新更新