I have a Giveaway command and it says that start is undefined when I am doing the command. my code:
const ms = require('ms');
exports.run = async (client, message, args) => {
// If the member doesn't have enough permissions
if(!message.member.hasPermission('MANAGE_MESSAGES') && !message.member.roles.cache.some((r) => r.name === "Giveaways")){
return message.channel.send(':x: You need to have the manage messages permissions to start giveaways.');
}
// Giveaway channel
let giveawayChannel = message.mentions.channels.first();
// If no channel is mentionned
if(!giveawayChannel){
return message.channel.send(':x: You have to mention a valid channel!');
}
// Giveaway duration
let giveawayDuration = args[1];
// If the duration isn't valid
if(!giveawayDuration || isNaN(ms(giveawayDuration))){
return message.channel.send(':x: You have to specify a valid duration!');
}
// Number of winners
let giveawayNumberWinners = args[2];
// If the specified number of winners is not a number
if(isNaN(giveawayNumberWinners) || (parseInt(giveawayNumberWinners) <= 0)){
return message.channel.send(':x: You have to specify a valid number of winners!');
}
// Giveaway prize
let giveawayPrize = args.slice(3).join(' ');
// If no prize is specified
if(!giveawayPrize){
return message.channel.send(':x: You have to specify a valid prize!');
}
// Start the giveaway
client.giveawaysManager.start(giveawayChannel, {
// The giveaway duration
time: ms(giveawayDuration),
// The giveaway prize
prize: giveawayPrize,
// The giveaway winner count
winnerCount: giveawayNumberWinners,
// Who hosts this giveaway
hostedBy: client.config.hostedBy ? message.author : null,
// Messages
messages: {
giveaway: (client.config.everyoneMention ? "@everyone\n\n" : "")+"???????? **GIVEAWAY** ????????",
giveawayEnded: (client.config.everyoneMention ? "@everyone\n\n" : "")+"???????? **GIVEAWAY ENDED** ????????",
timeRemaining: "Time remaining: **{duration}**!",
inviteToParticipate: "React with ???? to participate!",
winMessage: "Congratulations, {winners}! You won **{prize}**!",
embedFooter: "Giveaways",
noWinner: "Giveaway cancelled, no valid participations.",
hostedBy: "Hosted by: {user}",
winners: "winner(s)",
endedAt: "Ended at",
units: {
seconds: "seconds",
minutes: "minutes",
hours: "hours",
days: "days",
pluralS: false // Not needed, because units end with a S so it will automatically removed if the unit value is lower than 2
}
}
});
message.channel.send(`Giveaway started in ${giveawayChannel}!`);
};
exports.conf = {
enabled: true,
guildOnly: true,
aliases: ["defaults"],
permLevel: "modarater"
};
exports.help = {
name: "start-giveaway",
category: "misc",
description: "well start the giveaway.",
usage: "~start-giveaway (may not work)"
};
the error in the console: TypeError: Cannot read property 'start' of undefined at Object.exports.run (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\commands\start-giveaway.js:39:29) at module.exports (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\events\message.js:69:7) at Client.emit (events.js:314:20) at MessageCreateAction.handle (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31) at WebSocketShard.onPacket (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22) at WebSocketShard.onMessage (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) at WebSocket.onMessage (C:\Users\Tanner Terrio\Desktop\FBP\guidebot\node_modules\ws\lib\event-target.js:125:16) at WebSocket.emit (events.js:314:20)>
client.giveawaysManageris not working properly. You should look into that since it says it cannot find anything which is a children of client.giveawaysManager because it doesnt exist. - julianYaman