寻找向用户的错误消息是Notinvoice

发布于 2025-02-06 18:09:25 字数 2099 浏览 1 评论 0原文

          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);
                  });
            }

任何人都可以帮忙..我想要用户在玩游戏时键入前缀时。我希望用户收到一条错误消息,如果他不在某个频道中,他将无法播放该歌曲。此代码确实如此不执行它可以将其修复给我

          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);
                  });
            }

anyone can help please .. I want the user when he types the prefix while he play.. I want the user to get a error message that he can't play that song if he is not in the some channel.. this code does not execute it can someone fix it to me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木槿暧夏七纪年 2025-02-13 18:09:25

您可以使用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'})

我建议使用第一选择

You can use an if () statement:

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'})

Or you can use .some() method to return a boolean, like:

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'})

I recommend using the first choice though

无边思念无边月 2025-02-13 18:09:25
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);
                 });
           }
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);
                 });
           }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文