作者:热情风吟_181 | 来源:互联网 | 2022-12-06 16:36
我是node.js的新手,我现在正在使用discord.js制作一个Discord机器人.一旦使用任何bot命令,控制台就会打印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)
NealC..
15
这是你的其他命令之一.您很可能正在使用#Collection.find('name', 'keyname')
其他命令之一.
这已更新为#Collection.find(x => x.name === "name")
.
就像它在错误中说的那样.#Collection.find()需要一个函数.所以使用一个,错误就消失了.
1> NealC..:
这是你的其他命令之一.您很可能正在使用#Collection.find('name', 'keyname')
其他命令之一.
这已更新为#Collection.find(x => x.name === "name")
.
就像它在错误中说的那样.#Collection.find()需要一个函数.所以使用一个,错误就消失了.