import "client" into separate function files

im creating a heat system and with this im adding automatic punishments so i want to make separate files like a "ban.js" thatll take in specific arguments and perform the ban action there to save space in other files. i have the function setup to work in other files however im not sure how to go about importing the discord client so i can actually do the ban. i cant do it the typical module.exports = (client) => {} because i have to export the BanMember function. function code here:
class BanMember {
constructor(guild, userID, banReason) {
this.guild = guild;
this.userID = userID;
this.banReason = banReason;
}

ban() {
//ban function here
}

module.explorts = BanMember;
class BanMember {
constructor(guild, userID, banReason) {
this.guild = guild;
this.userID = userID;
this.banReason = banReason;
}

ban() {
//ban function here
}

module.explorts = BanMember;
BanMember.ban(); being the function that will be used in the other files to execute the ban
8 Replies
d.js toolkit
d.js toolkitβ€’10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - βœ… Marked as resolved by OP
dez
dezOPβ€’10mo ago
please ping if you respond
NyR
NyRβ€’10mo ago
@dezπŸ¦• pass the client as a parameter in the constructor of the BanMember or the ban() method
dez
dezOPβ€’10mo ago
oh it as easy as
constructor(guild, userID, banReason, client) {
this.guild = guild;
this.userID = userID;
this.banReason = banReason;
this.client = client;
}
constructor(guild, userID, banReason, client) {
this.guild = guild;
this.userID = userID;
this.banReason = banReason;
this.client = client;
}
?
NyR
NyRβ€’10mo ago
Yep..
dez
dezOPβ€’10mo ago
somehow i didnt think of that πŸ’€
NyR
NyRβ€’10mo ago
Also this is not djs related, so make sure to utilize #other-js-ts for issues like this
dez
dezOPβ€’10mo ago
got confused what this would classify as so figured here thanks anyways
Want results from more Discord servers?
Add your server