首页 > 解决方案 > args.join 不是函数

问题描述

const axios = require('axios');
const Discord = require('discord.js');

exports.exec = async (message, args) => {
    const text = args.join(" "); /* RIGHT HERE IS THE PROBLEM */
    const url = `https://public-api.tracker.gg/apex/v1/standard/profile/5/${text}`;
    const options = {
        headers: {
            'TRN-Api-Key': `${credentials.apexAPIKey}`
        }
    };

    if (args[0] != 'set')
        axios
            .get(url, options)
            .then(stats => {
                stats.data.data.stats.map(stat => {
                    const embed = new Discord.RichEmbed()
                        .setColor(0)
                        .setTitle(`Apex Legends Stats For ${stats.data.data.metadata.platformUserHandle}`)
                        .addField(stat.metadata.name, `${stat.value} ${stat.percentile ? '(Top ' + stat.percentile + '%)' : ''}`)
                    return message.channel.send({ embed });
                })
            })

};

我知道这个问题在这里出现过多次,我试图通过它们并尝试其他方法,但都失败了。所以我自己问这个问题,第 2 行是问题所在。

TypeError: args.join is not a function

at Object.module.exports.exec (C:\Users\goose\Downloads\Peeps\commands\player-stats\apexlegends.js:5:23)

我不知道,我讨厌在这里问,但我很难过。基本上使用相同的设置在其他命令中愉快地工作,在这个命令中,它讨厌我。目前只有 2 个命令会返回此错误,而其他命令args.join (" ");则过着幸福的生活。

任何帮助表示赞赏。

标签: javascriptdiscorddiscord.js

解决方案


推荐阅读