我是node.js 的新手,目前正在使用discord.js 来制作Discord 机器人。一旦使用任何机器人命令,控制台就会打印 DeprecationWarning。
例如:
(node:15656) DeprecationWarning: Collection#find: pass a function instead
(node:15656)
有时是另一个数字,几乎总是在变化。
这就是我的代码的样子(只有一个命令,我有多个命令,但所有命令都出现此错误):
const botconfig = require("./botconfig.json")
const Discord = require("discord.js");
const bot = new Discord.Client();
bot.on("ready", () => {
console.log(`Launched ${bot.user.username}...`);
bot.user.setActivity("Games", { type: "PLAYING" });
});
bot.on("message", async message => {
if (message.author.bot) return;
let prefix = botconfig.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let botico = bot.user.displayAvatarURL;
if (cmd == `${prefix}help`) {
let helpEmbed = new Discord.RichEmbed()
.addField(".kick", "kick a user", true)
.addField(".ban", "ban a user", true)
.addField(".unban", "unbans a user", true)
.addField(".mute", "mutes a user over a period of time", true)
.setColor("#005b5f")
.setThumbnail(botico);
message.channel.send(helpEmbed);
console.log(`command used: help`);
};
});
bot.login(botconfig.token)
它位于您的其他命令之一中。你很可能正在使用类似的东西#Collection.find('name', 'keyname')
在其他命令之一中。
这已更新为#Collection.find(x => x.name === "name")
.
就像错误中所说的那样。 #Collection.find() 需要一个函数。因此,使用一个错误就会消失。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)