arktn / discord-giveaway-bot Goto Github PK
View Code? Open in Web Editor NEW⚠️ Outdated ⚠️
License: MIT License
⚠️ Outdated ⚠️
License: MIT License
getting the above error. here is my code-
const ms = require('ms');
const config = require("config.json")
module.exports = {
name: 'gstart',
aliases: ['giveawaystart'],
description: 'Starts a giveaway',
execute(message, args, cmd, client, Discord) {
if (!message.member.hasPermission('MANAGE_MESSAGES') && !message.member.roles.cache.some((r) => r.name === "Giveaways")) {
return message.channel.send(':boom: You need to have the \`MANAGE_MESSAGES\` permissions to start giveaways.');
}
let giveawayChannel = message.mentions.channels.first();
if (!giveawayChannel) {
return message.channel.send(':boom: Uh oh, I couldn\'t find that channel! Try again!');
}
let giveawayDuration = args[1];
if (!giveawayDuration || isNaN(ms(giveawayDuration))) {
return message.channel.send(':boom: Hm. you haven\'t provided a duration. Can you try again?');
}
let giveawayNumberWinners = args[2];
if (isNaN(giveawayNumberWinners) || (parseInt(giveawayNumberWinners) <= 0)) {
return message.channel.send(':boom: Uh... you haven\'t provided the amount of winners.');
}
let giveawayPrize = args.slice(3).join(' ');
if (!giveawayPrize) {
return message.channel.send(':boom: Oh, it seems like you didn\'t give me a valid prize!');
}
if (!config["Giveaway_Options"].showMention && config["Giveaway_Options"].giveawayRole) {
giveawayChannel.send(`<@&${config["Giveaway_Options"].giveawayRole}>`).then((msg) => msg.delete({ timeout: 1000 }))
client.giveawaysManager.start(giveawayChannel, {
time: ms(giveawayDuration),
prize: giveawayPrize,
winnerCount: parseInt(giveawayNumberWinners),
hostedBy: config["Giveaway_Options"].hostedBy ? message.author : null,
messages: {
giveaway: ":tada: **GIVEAWAY** :tada:",
giveawayEnded: ":tada: **GIVEAWAY ENDED** :tada:",
timeRemaining: "Time remaining: **{duration}**!",
inviteToParticipate: "React with 🎉 to participate!",
winMessage: "Congratulations, {winners}! You won the **{prize}**!",
embedFooter: "Giveaways",
noWinner: "Not enough entrants to determine a winner!",
hostedBy: "Hosted by: {user}",
winners: "winner(s)",
endedAt: "Ended at",
units: {
seconds: "seconds",
minutes: "minutes",
hours: "hours",
days: "days",
pluralS: false
}
}
});
} else if (config["Giveaway_Options"].showMention && config["Giveaway_Options"].giveawayRole) {
client.giveawaysManager.start(giveawayChannel, {
time: ms(giveawayDuration),
prize: giveawayPrize,
winnerCount: parseInt(giveawayNumberWinners),
hostedBy: config["Giveaway_Options"].hostedBy ? message.author : null,
messages: {
giveaway: (config["Giveaway_Options"].showMention ? `<@&${config["Giveaway_Options"].giveawayRole}>\n\n` : "") + ":tada: **GIVEAWAY** :tada:",
giveawayEnded: (config["Giveaway_Options"].showMention ? `<@&${config["Giveaway_Options"].giveawayRole}>\n\n` : "") + ":tada: **GIVEAWAY ENDED** :tada:",
timeRemaining: "Time remaining: **{duration}**!",
inviteToParticipate: "React with 🎉 to participate!",
winMessage: "Congratulations, {winners}! You won the **{prize}**!",
embedFooter: "Giveaways",
noWinner: "Not enough entrants to determine a winner!",
hostedBy: "Hosted by: {user}",
winners: "winner(s)",
endedAt: "Ended at",
units: {
seconds: "seconds",
minutes: "minutes",
hours: "hours",
days: "days",
pluralS: false
}
}
});
} else if (!config["Giveaway_Options"].showMention && !config["Giveaway_Options"].giveawayRole) {
giveawayChannel.send(`@everyone`).then((msg) => msg.delete({ timeout: 1000 }))
client.giveawaysManager.start(giveawayChannel, {
time: ms(giveawayDuration),
prize: giveawayPrize,
winnerCount: parseInt(giveawayNumberWinners),
hostedBy: config["Giveaway_Options"].hostedBy ? message.author : null,
messages: {
giveaway: ":tada: **GIVEAWAY** :tada:",
giveawayEnded: ":tada: **GIVEAWAY ENDED** :tada:",
timeRemaining: "Time remaining: **{duration}**!",
inviteToParticipate: "React with 🎉 to participate!",
winMessage: "Congratulations, {winners}! You won the **{prize}**!",
embedFooter: "Giveaways",
noWinner: "Not enough entrants to determine a winner!",
hostedBy: "Hosted by: {user}",
winners: "winner(s)",
endedAt: "Ended at",
units: {
seconds: "seconds",
minutes: "minutes",
hours: "hours",
days: "days",
pluralS: false
}
}
});
} else if (config["Giveaway_Options"].showMention && !config["Giveaway_Options"].giveawayRole) {
client.giveawaysManager.start(giveawayChannel, {
time: ms(giveawayDuration),
prize: giveawayPrize,
winnerCount: parseInt(giveawayNumberWinners),
hostedBy: config["Giveaway_Options"].hostedBy ? message.author : null,
messages: {
giveaway: (config["Giveaway_Options"].showMention ? `@everyone\n\n` : "") + ":tada: **GIVEAWAY** :tada:",
giveawayEnded: (config["Giveaway_Options"].showMention ? `@everyone\n\n` : "") + ":tada: **GIVEAWAY ENDED** :tada:",
timeRemaining: "Time remaining: **{duration}**!",
inviteToParticipate: "React with 🎉 to participate!",
winMessage: "Congratulations, {winners}! You won the **{prize}**!",
embedFooter: "Giveaways",
noWinner: "Not enough entrants to determine a winner!",
hostedBy: "Hosted by: {user}",
winners: "winner(s)",
endedAt: "Ended at",
units: {
seconds: "seconds",
minutes: "minutes",
hours: "hours",
days: "days",
pluralS: false
}
}
});
}
message.channel.send(`:tada: Done! The giveaway for the \`${giveawayPrize}\` is starting in ${giveawayChannel}!`);
}
}
now that you've added the setup file you should add documentation for it in the readme.md
I tried cloning the repository for tests, configured everything, but when someone try reacting to the giveaway message the bot removes the reaction. Why is it ?
Hello to the creator of this project, our suggestion for this has been to add the proposed code to the project which means by preparing command on the channel you like
Here ist the "Error"
at giveaway (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\commands\giveaway.js:14:66)
at Object.execute (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\commands\giveaway.js:92:9)
at Client.<anonymous> (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\index.js:40:59)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\jo_li\Documents\Altes_Zeug\Entchen\Entchen_Dev_Folder\giveaway\node_modules\ws\lib\event-target.js:132:16)
(node:32680) 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:32680) [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.
I hope you can help me c:
if someone ask for to bot to say online 24/7 hers sum code for it
1st step
make a new file and call it server.js
in there copy this code
const express = require('express');
const server = express();
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
module.exports = keepAlive;
2nd step
in the index.js folder at the top tipe this code
const keepalive = require("./server.js")
and then go down to the botme and make a new line ontop of the token
and tipe
keepalive() then
3rd step go to https://uptimerobot.com and make a new account
after make a new moniter and make it a https
go back to the bot code and coppy the url and past it in the https link
then make the new moniter then the bot is online 24/7
Add a local database (lodash/lowdb) and do 2 functions:
I would be glad if you do it :D
In line number 69, we have the following line of code,
msg.reactions.cache.get('<a:tick:791208682607870003>').users.remove(client.user.id)
This is the error message
Cannot read property 'users' of undefined
The emojis are the only change I made in the code. Is there a bug here? How can I solve it?
// This multiplies the input by 1 minute
const actual_duration_hours = stated_duration_hours * 60000;
// Checks if the number given is less than a hour to set the correct statement
if (actual_duration_hours < 3600000) return hour_s = 'minutes'
if (actual_duration_hours > 60000) return hour_s = 'minute'
if (actual_duration_hours > 3600000) return hour_s = 'hour'
if (actual_duration_hours > 7200000) return hour_s = 'hours'
// This checks if the message with the number required has a letter (h or m) to give it the appropriate multiplication.
if (stated_duration_hours.includes("h").toLowerCase()){
stated_duration_hours.split("h");
actual_duration_hours = started_duration_hours * 3600000
}
if (stated_duration_hours.includes("m").toLowerCase()){
stated_duration_hours.split("m");
actual_duration_hours = started_duration_hours * 60000
}
If the code creates any errors i apologize as i don't have a way to test if it works 100% its just a suggestion
Also if you need any help with the code you can ask me!
in the start command I get the following error: Cannot read property 'showMention' of undefined
Would you know how to solve it?
a greeting
So, i have tried it and i set the giveaway and it does 3 giveaways instead of 1, how can this be fixed?
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: 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(). The promise rejected with the reason "options.duration is not a positive number. (val=undefined)".] {
code: 'ERR_UNHANDLED_REJECTION'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-02-03T00_38_15_533Z-debug.log
exit status 1
is the error i get when i run the full command
It would be neat if this bot had the ability to create giveaways with multiple winners like GiveawayBot.
The timer on the embed would stop. you cannnot end nor reroll the giveaway (it says giveaway not found). Sometime, the giveaway.json is cleared (just saying "[]") but usually it is still there, but the values are messed up
I change in my config the prefix to $ i do $help its work i do $giveaways a strange message show in the git cmd and my bot go offline and in the git cmd its tell like TypeError : message.member.hasPermission is not a function
The Actually Giveaway Messages does not show up Please help if you can.
How I want the bot reroll Giveaway which have 2 winner and I just want to reroll just 1?
I get this error on giveaway start, I ran the example command copy-pasted directly from the help message just to make sure I wasn't messing up but I get this error no matter what. I've downloaded the latest version of the bot & I've changed nothing but the prefix & token in config.json
OS: CentOS 8.3 x64
Node version: v14.16.0
Discord.js version: v12.5.3
discord-giveaway-bot-master\node_modules\discord-giveaways\src\Giveaway.js:302
const member = guild.member(user.id) || await guild.members.fetch(user.id).catch(() => {});
^
TypeError: Cannot read properties of undefined (reading 'id')
For giveaway times, you could just write a ms() function instead of making statements for seconds, days, hours etc.
how can i do that only the staff members can do a giveway and not the whole server?´
on line 6 in end.js you need to change "reroll" to "end"
f .
Full thing:
const stated_duration_hours2 = stated_duration_hours.toLowerCase();
^
TypeError: Cannot read property 'toLowerCase' of undefined
This issue will be used to add contributors to the README.md trough the allcontributors.org bot.
UnhandledPromiseRejectionWarning: SyntaxError: The storage file is not properly formatted (Unexpected end of JSON input).
at GiveawaysManager.getAllGiveaways (C:\Users\yasse\Documents\YasserBot\discord-giveaway-bot-master\node_modules\discord-giveaways\src\Manager.js:338:27)
at async GiveawaysManager._init (C:\Users\yasse\Documents\YasserBot\discord-giveaway-bot-master\node_modules\discord-giveaways\src\Manager.js:447:30)
(Use node --trace-warnings ...
to show where the warning was created)
(node:2028) 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:2028) [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.
Hello fekt, I tried your giveaway command on my DiscordJS bot (in V12) and I have an error that I don't understand: "TypeError: Cannot read property 'start' of undefined". Thank you for answering me :)
Thanks, Spooky
When i edit my config file and everything done i run the code by the start-me file thing but when i check the bot its still on invisible
I really think there should be commands like reroll and end.
node:26576) UnhandledPromiseRejectionWarning: ReferenceError: duration is not defined
Add a bat file to install the packages needed to run the bot
I have tried doing the help command but the bot won't do anything
If i rerun the bot the giveaway stops
it doest find the module "discord.js"
how can i change that the bot is not pinging @everyone? i want that he is pinging a another role
Change this line:
if (message.content.split(' ')[1] === '') return messages.channel.send('Please enter a duration for the giveaway (in hours).');
[line 10 in giveaway.js]
to this:
if (!message.content.split(' ')[1]) return messages.channel.send('Please enter a duration for the giveaway (in hours).');
In the previous case, the first if statement [if (message.content.split(' ')[1] === '')] is not considered and the if (isNaN(stated_duration_hours))
statement is run instead [line 14 in giveaway.js]
idk why this happens
hi my friend, i am setting up a special raffle bot for myself. I want to use this infrastructure, but I have a question. After the draw is over, I don't want the name of the winner to be included in the final embed message, just displaying the winner with a plain message is sufficient. how can i remove winner name from embed message
The preview image on the readme (https://github.com/fekt/discord-giveaway-bot/blob/master/README.md) uses an example Bot account that is using GiveawayBot#2381's copyrighted profile image. This is misleading, as you were not given permission to use this image to represent your project. I am opening this issue as a courtesy, so that you have an opportunity to rectify this yourself.
I want to troll my friends with a fake giveaway, thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.