首页 > 解决方案 > (node:199408) DeprecationWarning: Collection#find: 传递一个函数

问题描述

嗨,我是编码新手,想知道我的代码会通过传递函数更改为什么,而不是这里是我已经存在的错误代码

let reportschannel = message.guild.channels.find(`name`, "reports");

标签: javascriptdiscord.js

解决方案


以下是您可能会发现有用的文档:https ://discord.js.org/#/docs/main/stable/class/Collection?scrollTo=find

因此,您的代码将变为:

let reportschannel = message.guild.channels.find(channel => channel.name === "reports");

推荐阅读