简体   繁体   English

多重前缀 Discord.js

[英]Multiple Prefix Discord.js

How to use multi prefix in this code?如何在此代码中使用多前缀? I have tried various ways but nothing works.我尝试了各种方法,但没有任何效果。

let prefix = [ 'e', 'E' ];
        if (message.guild) {
            client.prefixes.ensure(message.guild.id, { prefix: 'e' });
            let guildPrefix = client.prefixes.get(message.guild.id, "e");

            prefix = guildPrefix ? guildPrefix : 'e';
        }   
        
        if(!(message.content.startsWith(prefix[0])||message.content.startsWith(prefix[1]))) { return; }

        const args = message.content.slice(prefix.length).trim().split(/ +/);

This is the code, its not work, i dont know why?这是代码,它不起作用,我不知道为什么? can u help me guys?你能帮帮我吗? i use discord.js v13我使用 discord.js v13

if(!(message.content.startsWith(prefix[0])||message.content.startsWith(prefix[1]))) { return; }

It will not start with an array, so you have to split the condition.它不会以数组开头,因此您必须拆分条件。 However there might be a more elegant solution to this.但是,对此可能有更优雅的解决方案。

Edit: The elegant solution is in the comments.编辑:优雅的解决方案在评论中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM