Closed HDProduction010 closed 3 years ago
Sounds like you are missing a required file possibly... Can you show your code?
Ok so I'm isolating the commands and using a command handler to implement it into my bot
But here it is
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??
Sorry about that give me a second
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: [""]
};
You may also need to check the handler that's pulling in your cmd
it is
I can tell because it will trigger the "error" send messages to the channel where there isnt the full command
Okay do you have client giveaway manager defined in your
const { GiveawaysManager } = require("discord-giveaways");
Where else would I define it
Add me on discord and lets talk over there. HD#1817
You need to define client.giveawaysManager
after that
so
let or const
What one should I use
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 .
Dang ok let me know what I need to do when you are available
I added you on discord
Sorry to revive, but was the fix ever posted publicly?
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.