Javascript 如何制作多词辩论?

Javascript 如何制作多词辩论?,javascript,discord,discord.js,Javascript,Discord,Discord.js,如何制作多词辩论。例如,禁用或禁用的原因。如果我使用args[2]、args[3]、args[4]、args[5]。。。所以它仍然是有限的,如果没有写任何东西,它将写“未定义”。因此,如果你知道怎么做,我将非常高兴得到答案。:) const{ReactionCollector}=require(“discord.js”); module.exports={ 名称:"禁令",, 描述:“Dočasnězabanuječlena”, 异步执行(消息、参数、不一致、客户端、粉笔、ms){ 等待mess

如何制作多词辩论。例如,禁用或禁用的原因。如果我使用args[2]、args[3]、args[4]、args[5]。。。所以它仍然是有限的,如果没有写任何东西,它将写“未定义”。因此,如果你知道怎么做,我将非常高兴得到答案。:)

const{ReactionCollector}=require(“discord.js”);
module.exports={
名称:"禁令",,
描述:“Dočasnězabanuječlena”,
异步执行(消息、参数、不一致、客户端、粉笔、ms){
等待message.channel.messages.fetch({limit:1})。然后(messages=>{
message.channel.bulkDelete(消息);
});
const channelId=client.channels.cache.get('80264949418087530537');
const author=message.author;
const userName=message.indications.users.first();
如果(!message.member.permissions.has(“禁止成员”)){
消息。回复('Nemášpotřebnépermisse!')
。然后(msg=>{
msg.delete({timeout:5000})
});
返回;
}如果(!args[1]){
message.reply(“!ban()”)
。然后(msg=>{
msg.delete({timeout:5000})
});
console.log(chalk.red('[ERROR]缺少参数[1]');
返回;
}
如果(用户名){
const userId=message.guild.members.cache.get(userName.id);
const botId='799652033509457940';
userId.ban();
const banEmbed=new Discord.MessageEmbed()
.setColor(“#a81919”)
.setTitle(“禁止”)
addFields先生(
{name:'ch len:',value:`${userId}`},
{name:'Udělil:',value:`${author}`,
{name:'Délka:',value:`${ms(ms(args[1]))}`,
{name:'Důvod:',value:`${args[2]}`},
)
.setTimestamp()文件
channelId.send(banEmbed)
setTimeout(函数(){
message.guild.members.unban(userId);
const unbanEmbed=new Discord.MessageEmbed()
.setColor(“#25a819”)
.setTitle('Unban')
addFields先生(
{name:'ch len:',value:`${userId}`},
{名称:'Udělil:',值:``},
{name:'Důvod:',value:'Ban vypršel.`},
)
.setTimestamp()文件
channelId.send(未绑定)
},ms(args[1]);
log(chalk.green(`INFO]/ban/${userId.user.username},${ms(ms(args[1]))}`);
}否则{
message.channel.send('Nemůůšešzabanovat tohotočlena');
log(chalk.red(`[ERROR]/ban/找不到目标`));
}
}
}

我假设您正确定义了
args
。然后你可以简单地使用

args.join(“”);
用空格分隔每个单词。

您可以使用
.shift()
,这样您就可以
args.shift()
,然后它将删除数组中的第一个元素,然后您就可以用一个空格连接每个单词,如
args.join(“”)
const { ReactionCollector } = require("discord.js");

module.exports = {
    name: 'ban',
    description: "Dočasně zabanuje člena.",
    async execute(message, args, Discord, client, chalk, ms){
        await message.channel.messages.fetch({limit: 1}).then(messages =>{
            message.channel.bulkDelete(messages);
        });

        const channelId = client.channels.cache.get('802649418087530537');
        const author = message.author;
        const userName = message.mentions.users.first();
        
        if(!message.member.permissions.has("BAN_MEMBERS")){
            message.reply('Nemáš potřebné permisse!')
            .then(msg => {
                msg.delete({ timeout: 5000 })
            });
            return;
        } else if(!args[1]){
            message.reply('!ban <člen> <délka> (<důvod>)')
            .then(msg => {
                msg.delete({ timeout: 5000 })
            });
            console.log(chalk.red('[ERROR] Missing args[1]'));
            return;
        }
        if(userName){
            const userId = message.guild.members.cache.get(userName.id);
            const botId = '799652033509457940';
            userId.ban();
            
            const banEmbed = new Discord.MessageEmbed()
            .setColor('#a81919')
            .setTitle('Ban')
            .addFields(
                {name:'Člen:', value:`${userId}`},
                {name:'Udělil:', value:`${author}`},
                {name:'Délka:', value:`${ms(ms(args[1]))}`},
                {name:'Důvod:', value:`${args[2]}`},
            )
            .setTimestamp()
            channelId.send(banEmbed)

            setTimeout(function () {
                message.guild.members.unban(userId);

                const unbanEmbed = new Discord.MessageEmbed()
            .setColor('#25a819')
            .setTitle('Unban')
            .addFields(
                {name:'Člen:', value:`${userId}`},
                {name:'Udělil:', value:`<@${botId}>`},
                {name:'Důvod:', value:`Ban vypršel.`},
            )
            .setTimestamp()
            channelId.send(unbanEmbed)
            }, ms(args[1]));

            console.log(chalk.green(`[INFO] /ban/ ${userId.user.username}, ${ms(ms(args[1]))}`));
        }else{
            message.channel.send('Nemůžeš zabanovat tohoto člena');
            console.log(chalk.red(`[ERROR] /ban/ Can not find target`));
        }
    }
}