javascript - 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 (" ");
则过着幸福的生活。
任何帮助表示赞赏。
解决方案
推荐阅读
- java - WebMvcTest 尝试加载每个应用程序控制器
- android - Android模拟器设置无相机选项(用于虚拟场景)
- java - 打开数据文件 ./eng.traineddata 时出错
- java - 在 Eclipse 中关闭 Scanner 对象的问题。请阅读下面的详细说明
- python - 侵蚀和扩张被交换
- python - pip 安装错误:需要 Microsoft Visual C++ 14.0 或更高版本
- django - Django 找不到模板
- php - 从 php5.2 升级到 php7.4 后 $_REQUEST 变为空
- python-3.x - 在 Python 中使用解码进行 XML 解析
- java - 我想在 For 循环运行时运行 JProgressBar,可以吗?