【发布时间】: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(`\`\`\`${joinnametot}Joined 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"]
}
【问题讨论】:
标签: javascript discord.js quick.db