【问题标题】:(node:10124) DeprecationWarning: Collection#find: pass a function instead(node:10124) DeprecationWarning: Collection#find: 传递一个函数
【发布时间】:2019-04-24 13:54:54
【问题描述】:

当我执行 !x 命令时,它说

(node:10124) DeprecationWarning: Collection#find: pass a function instead

(node:10124) DeprecationWarning: Collection#find: pass a function instead

如控制台日志所述,问题出在...let channe.. ..downchan...

exports.startScrim = function(guild,host,type,time){ const embed = new RichEmbed() .setColor(0x91bbff) .addField("message x","another message"+exports.one(time),false) .addField("Mode",type.toUpperCase(),true) .addField("Host",host,true) .addField("Instructions","message x",false)

let channel = guild.channels.find("name",guilds[guild.id].digitchan);
let channel2 = guild.channels.find("name",guilds[guild.id].countdownchan);
if (channel && channel2) {
    channel.send(embed)`

并且下一行channel.send(embed) 甚至没有执行。帮忙!

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    这看起来像以下内容的副本: Collection#find: pass a function instead

    听起来你需要这样做:

    let channel = guild.channels.find(channel => channel.name === guilds[guild.id].digitchan);
    let channel2 = guild.channels.find(channel => channel.name === guilds[guild.id].countdownchan);
    

    【讨论】:

    • 非常感谢!但现在没有错误显示但仍然没有执行脚本的其余部分
    • 我会假设 channelchannel2 都没有设置。您需要在继续下一个代码之前找到它们。您确定您的两个finds 确实在寻找频道吗?
    • 加油!如果您觉得这个问题已经得到解答,您应该点击我的答案旁边的复选标记图标,接受它作为问题的答案。
    • 好吧,在此期间,尝试添加console.log(channel)console.log(channel2),看看它们是否是假的。
    • Guild asdasfasf Members 4 null // 这些是日志
    猜你喜欢
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    • 2019-02-14
    • 2019-10-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-01
    • 1970-01-01
    相关资源
    最近更新 更多