Listeners and Index.js
Hello, I basically made a Giveaway System, but I have a code that needs to be in index.js and 1 that needs to be as event, but right now I am clueless as where to put the index.js to put it into perspective of normal discord.js framework, 1 code ness to be in the inde.js and the other in the events folder but I don't know where to put these code using the sapphire framework.
When I put the code that's supposed to be in my index.js file, i get this error:
The code that's supposed to go into index.js:
https://sourceb.in/ANt8LGRFiM
The code that's supposed to go into the events folder aka listener:
https://sourceb.in/GD3Cbxbg5y
Here is my current index.js and listener code with the giveaway code included:
Index.js - https://sourceb.in/9NXZs3iBfO Event - https://sourceb.in/bODqOfaqBX
Solution:Jump to solution
I can already tell that your event code is invalid btw. You cannot module.exports inside a run method. Nor would you even want to. Also sapphire already implements messageRun for handling commands, that's the whole point of using sapphire.
Anyway I have no idea about your problem but it's not sapphire related. The error is saying that Giveaways manager is not a constructable class. Why that is, I don't know.
Sidenote that giveaway bot exists and no offense but realistically no one is gonna use your bot over it, so unless you're just code practising, don't expect another giveaway bot to grow much. You're very unlikely to have a killer niche feature that giveaway bot doesn't cover. This is the problem will all discord bots, if you don't touch a niche yours won't grow much....
Discord GiveawayBot
GiveawayBot - Discord Giveaway Bot
Hold giveaways on your Discord server quickly and easily!
6 Replies
Solution
I can already tell that your event code is invalid btw. You cannot module.exports inside a run method. Nor would you even want to. Also sapphire already implements messageRun for handling commands, that's the whole point of using sapphire.
Anyway I have no idea about your problem but it's not sapphire related. The error is saying that Giveaways manager is not a constructable class. Why that is, I don't know.
Sidenote that giveaway bot exists and no offense but realistically no one is gonna use your bot over it, so unless you're just code practising, don't expect another giveaway bot to grow much. You're very unlikely to have a killer niche feature that giveaway bot doesn't cover. This is the problem will all discord bots, if you don't touch a niche yours won't grow much.
Discord GiveawayBot
GiveawayBot - Discord Giveaway Bot
Hold giveaways on your Discord server quickly and easily!
My niche is a rpg system and the rest are just for multipurpose
Also, hooi hoe gaat het
ik ging jou description gwn aankijken en zag dat je van nederland bent en nederlands kan spreken
Can you dump the whole code base on GitHub? I'm a bit stumped on the error tbh.
That's true but I try to keep it at English online because it doesn't alienate other readers. I also prefer it for coding talk anyway.
Anyway I'm fine.
Hey Malik, idk why youre exporting a class everytime a message is created in your event, but i think its probably because youre are importing the class from
const GiveawaysManager = require("./events/giveaway")
which is a file where you arent exporting it in (atleast validly). You should really just make a structures folder in your lib directory and add your helper classes in there, and you can add the code to instantiate the class in a ready
listener instead of in index.jsI changed that path to the correct one, it still didn't work
Also, I appreciate you both for trying to help but I have given up on the Giveaway System as I took @fanny's advise on focusing more on my bot's niche.
unrelated to the issue but it also means everyone else with the same issue can understand what the problem was if its in a "universal language"