javascript - 类型错误:args.slice(...).join 不是函数
问题描述
我正在开发我的 discord 机器人,当我尝试运行 ban 命令时,出现了这个错误。我是新手,所以任何人都可以帮助我。
在不和谐上联系对我有更多帮助:
我的不和谐:AlanITD#0630
let args = message.content.slice(prefix.length).split(' ');
let cont = args.shift().toLowerCase();
module.exports.run = async (bot, message) => {
const user = message.mentions.users.first().id // returns the user object if an user mention exists
const banReason = args.slice(1).join(' '); // Reason of the ban (Everything behind the mention)
// Check if an user mention exists in this message
if (!user) {
try {
// Check if a valid userID has been entered instead of a Discord user mention
if (!message.guild.members.get(args.slice(0, 1).join(' '))) throw new Error('Couldn\' get a Discord user with this userID!');
// If the client (bot) can get a user with this userID, it overwrites the current user variable to the user object that the client fetched
user = message.guild.members.get(args.slice(0, 1).join(' '));
user = user.user;
} catch (error) {
return message.reply('Couldn\'t get a Discord user with this userID!');
}
}
if (user === message.author) return message.channel.send('You can\'t ban yourself, stupid '); // Check if the user mention or the entered userID is the message author himsmelf
if (!reason) return message.reply('You forgot to enter a reason for this ban!'); // Check if a reason has been given by the message author
if (!message.guild.member(user).bannable) return message.reply('You can\'t ban this user because you the bot has not sufficient permissions, lmao '); // Check if the user is bannable with the bot's perms
const banConfirmationEmbedModlog = new Discord.RichEmbed()
.setAuthor(`Banned by **${msg.author.username}#${msg.author.discriminator}**`, msg.author.displayAvatarURL)
.setThumbnail(user.displayAvatarURL)
.setColor('RED')
.setTimestamp()
.setDescription(`**Action**: Ban
**User**: ${user.username}#${user.discriminator} (${user.id})
**Reason**: ${reason}`);
message.channel.send(banConfirmationEmbedModlog)
}
module.exports.config = {
name: "ban",
description: "Ban those naughty folks",
usage: ">ban",
accessableby: "Moderators and Admins",
}
我非常感谢您的支持
解决方案
推荐阅读
- c - 如何使用 libmcrypt 在 C 中解密 twofish CBC?
- .net-core - System.OperationCanceledException:dotnet Core 2.1
- sql - SQL如何获取逗号分隔列表(字符串格式)并对其进行排序
- javascript - 我想在按下按钮时打开一个页面
- apache-spark - java.lang.ClassNotFoundException: org.apache.spark.examples.SparkPi
- php - 生成一个数组的随机两个值的数组
- r - 使用 trunc 函数时的问题
- python - 如何使用来自另一个文件的匹配值替换使用熊猫的列?
- php - 获取对象 xml 中的数组(simplexml_load_string)
- python - pip WeasyPrint 安装后如何解决 Cairo 和 Pango 版本问题?