Modifying internal functions

Is it safe to modify any Discord.js function to add my own code before and after the execution. Example:
const defaultInteractionReply = interaction.reply;
//I have a better way to handle args but this is just for eg
interaction.reply = async (args) => {
console.log(`I executed before`);
const returnValue = await defaultInteractionReply(args);
console.log(`I executed after`);
return returnValue;
}
const defaultInteractionReply = interaction.reply;
//I have a better way to handle args but this is just for eg
interaction.reply = async (args) => {
console.log(`I executed before`);
const returnValue = await defaultInteractionReply(args);
console.log(`I executed after`);
return returnValue;
}
3 Replies
d.js toolkit
d.js toolkit2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers.
duck
duck2y ago
depends on whether you know what you're doing (the code you've shown will have issues) but also this should be considered unsupported (especially if when you say 'any djs function' you mean any)
Ashu
AshuOP2y ago
Yeah, I think you are right, I just think its a bad idea. I wanted to add some debugging code some functions globally but ig I will just make my own functions and call them.
Want results from more Discord servers?
Add your server