Androz2091 / discord-giveaways-bot

🎁Giveways Bot using the discord-giveaways package
ISC License
202 stars 167 forks source link

Cannot read property 'start' of undefined #57

Closed HDProduction010 closed 3 years ago

HDProduction010 commented 3 years ago

This is the error that I am getting

(node:18101) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'start' of undefined at Object.module.exports.run (/home/Aresentic/commands/Fun/gstart.js:39:31) at Client. (/home/Aresentic/handlers/JoinAndLeaves/message.js:21:18) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ... to show where the warning was created) (node:18101) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:18101) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

needhamgary commented 3 years ago

Sounds like you are missing a required file possibly... Can you show your code?

HDProduction010 commented 3 years ago

Ok so I'm isolating the commands and using a command handler to implement it into my bot

HDProduction010 commented 3 years ago

But here it is

needhamgary commented 3 years ago

You either didn't post the code itself or no one else can see it. Try using a code block instead of posting a link??

HDProduction010 commented 3 years ago

Sorry about that give me a second

HDProduction010 commented 3 years ago

let Discord = require('discord.js'); const ms = require('ms'); const { GiveawaysManager } = require("discord-giveaways"); module.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}!`);

};

module.exports.help = { name: "create", description: "This command module creates a Giveaway", usage: <prefix>create, accessableby: "Members", aliases: [""] };

needhamgary commented 3 years ago

You may also need to check the handler that's pulling in your cmd

HDProduction010 commented 3 years ago

it is

HDProduction010 commented 3 years ago

I can tell because it will trigger the "error" send messages to the channel where there isnt the full command

needhamgary commented 3 years ago

Okay do you have client giveaway manager defined in your file?

HDProduction010 commented 3 years ago

const { GiveawaysManager } = require("discord-giveaways");

HDProduction010 commented 3 years ago

Where else would I define it

HDProduction010 commented 3 years ago

Add me on discord and lets talk over there. HD#1817

needhamgary commented 3 years ago

You need to define client.giveawaysManager after that

HDProduction010 commented 3 years ago

so

let or const

HDProduction010 commented 3 years ago

What one should I use

needhamgary commented 3 years ago

I have to get back to work.

On Wed, Sep 16, 2020, 8:47 PM HDProduction010 notifications@github.com wrote:

Add me on discord and lets talk over there. HD#1817

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Androz2091/giveaways-bot/issues/57#issuecomment-693758336, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFSTU26SFJW5FT3JU72HDPLSGFTEVANCNFSM4RPG5MUQ .

HDProduction010 commented 3 years ago

Dang ok let me know what I need to do when you are available

needhamgary commented 3 years ago

I added you on discord

ghost commented 3 years ago

Sorry to revive, but was the fix ever posted publicly?