Im trying to make a giveaway command based in a tutorial i saw and it says TypeError: Cannot read property 'start' of undefined

Im trying to make a giveaway command based in a tutorial i saw and it says TypeError: Cannot read property 'start' of undefined

正如我在标题中所说的那样,我遇到了这个错误,我不知道如何修复它,但是教程使用相同的东西并且不会出现这个错误。请帮助我,我不知道该怎么做。

错误:

"Cannot read property 'start' of undefined"

const ms = require('ms')
const { MessageEmbed } = require('discord.js')

module.exports = {
    name : 'giveaway',
    execute : async(message, args ,client) => {
        if(!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send('You dont have manage messages permission.')

        const channel = message.mentions.channels.first()
        if(!channel) return message.channel.send('Please specify a channel')

        const duration = args[1]
        if(!duration) return message.channel.send('please enter a valid duration')

        const winners = args[2]
        if(!winners) return message.channel.send('Please specify an amount of winners')

        const prize = args.slice(3).join(" ")
        if(!prize) return message.channel.send('Please sepcify a prize to win')

        client.giveaways.start(channel, {
            time : ms(duration),
            prize : prize,
            winnerCount: winners,
            hostedBy: message.author,
            messages: {
                giveaway:  "Giveaway \@everyone",
                giveawayEnd: "Giveaway Ended \@everyone",
                timeRemaining: "Time Remaining **{duration}**",
                inviteToParticipate: "React with  to join the giveaway",
                winMessage: "Congrats {winners}, you have  won the giveaway",
                embedFooter: "Giveaway Time!",
                noWinner: "Could not determine a winner",
                hostedBy: 'Hosted by {user}',
                winners: "winners",
                endedAt: 'Ends at',
                units: {
                    seconds: "seconds",
                    minutes: "minutes",
                    hours: 'hours',
                    days: 'days',
                    pluralS: false
                }
            },
           
        })
        message.channel.send(`Giveaway is starting in ${channel}`)
    }
}

错误行代码:client.giveaways.start(channel, {

index.js:

client.giveaways = new GiveawaysManager(client, {
    storage : './giveaways.json',
    updateCountdownEvery : 5000,
    embedColor: '#D03600',
    reaction: ''
})

giveaways.json: []

执行:

try{
    command.execute(message,args, cmd, client, Discord);
} catch (err){
    message.reply("There was an error trying to execute this command!");
    console.log(err);
}

}

在您的 command.execute() 调用中,您传入 client 作为第四个参数。但是在你导出赠品命令的命令文件中,client 是第三个参数。

module.exports = {
    name : 'giveaway',
    // Add cmd parameter here, so client is passed in correctly as the fourth parameter
    execute : async(message, args, cmd, client) => { ... }
}