TypeError: Function.prototype.apply 在#<Object> 上被调用,这是一个对象而不是函数
Posted
技术标签:
【中文标题】TypeError: Function.prototype.apply 在#<Object> 上被调用,这是一个对象而不是函数【英文标题】:TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function 【发布时间】:2021-07-21 18:22:51 【问题描述】:我正在为我的机器人处理抢劫命令,但我尝试了它却收到此错误
(node:2253) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function
我的代码是这个,我不知道它是从哪里来的
const Discord = require('discord.js');
const db = require('quick.db')
module.exports.run = async (bot, message, args) =>
let member = message.mentions.members.first()
if (!member) return message.reply(`You you wanna hiest`)
let user = message.author;
let money = await db.fetch(`mon_$user.id`)
if(money < 2000) return message.reply(`You need atleast 2000 coins to try and rob someone!`)
let money2 = await db.fetch(`b_$member.id`)
if (money2 < 3000) return message.reply(`This fella does not have atleast 3000 coins in his bank not worth it!`)
message.channel.send(`$user.username Is Starting a heist on $member\nType \`GG JOIN\` To join them!`).then(() =>
message.channel.awaitMessages( max: 7, time: 70000, errors: ['time'] )
.then(message =>
message = message.first()
if (message.content.toUpperCase() == 'GG JOIN' || message.content.toUpperCase() == 'JOIN HEIST')
message.react("????")
db.fetch(`heistname_$message.guild.id`)
db.push(`heistname_$message.guild.id`, -user.username)
db.fetch(`heist_$message.guild.id`)
db.push(`heist_$message.guild.id`, -user.id)
db.fetch(`heistmem_$message.guild.id`)
db.add(`heistmem_$message.guild.id`, 1)
else
return;
)
.catch(collected =>
message.channel.send('Allirght These Many Users Are joining the hesit.The Result will be given shortly!');
);
)
setTimeout( async function()
let memjoined = await db.fetch(`heistmem_$message.guild.id`)
let userbank = await db.fetch(`b_$member.id`)
let bankdev = (userbank / memjoined)
let joined = await db.fetch(`heist_$message.guild.id`)
let join2 = joined.split('-')
let jointot = join2.join('\n')
let joinname = await db.fetch(`heistname_$message.guild.id`)
let joinnamesp = joinname.split('-')
let joinnametot = joinnamesp.join('\n')
db.add(`mon_$join2[0]`, bankdev)
db.add(`mon_$join2[1]`, bankdev)
db.add(`mon_$join2[2]`, bankdev)
db.add(`mon_$join2[3]`, bankdev)
db.add(`mon_$join2[4]`, bankdev)
db.add(`mon_$join2[5]`, bankdev)
db.add(`mon_$join2[6]`, bankdev)
message.channel.send(`\`\`\`$joinnametotJoined the heist and everyone came out with a total of $bankdev Money!\`\`\``)
, 100000);
setTimeout( async function()
await db.delete(`heistmem_$message.guild.id`)
await db.delete(`heistname_$message.guild.id`)
await db.delete(`heist_$message.guild.id`)
, 10000);
module.exports.help =
name: "bankrob",
aliases: ["heist"]
【问题讨论】:
【参考方案1】:TextChannel#awaitMessages
的第一个参数应该是过滤函数,而不是对象。该过滤器函数将传入的消息作为参数访问,并决定是否让它通过。此函数的一个常见用途是确保消息作者是原始命令的作者:
message.channel.awaitMessages(
(m) => m.author.id === message.author.id,
/* options */
)
如果你不需要任何过滤器,你可以使用() => true
。
【讨论】:
以上是关于TypeError: Function.prototype.apply 在#<Object> 上被调用,这是一个对象而不是函数的主要内容,如果未能解决你的问题,请参考以下文章
TypeError:“TypeError:函数名称不是 HTMLButtonElement.onclick (/:2:54) 处的函数”
反应本机获取多标记[未处理的承诺拒绝:TypeError:TypeError:未定义不是对象(评估'this.state.markers.map
Django TypeError - TypeError: issubclass() arg 1 必须是一个类
pyspark:TypeError:'float'对象不可迭代
Python 3.8 TypeError: can't concat str to bytes - TypeError: a bytes-like object is required, not 's