Oscar
Oscar
DIAdiscord.js - Imagine an app
Created by Nixxxxxx on 6/28/2023 in #djs-questions
Bot seems to be uploading the same media file multiple times?
dunno sorry
21 replies
DIAdiscord.js - Imagine an app
Created by Nixxxxxx on 6/28/2023 in #djs-questions
Bot seems to be uploading the same media file multiple times?
maybe when the bot sends the file, it triggers the event again?
21 replies
DIAdiscord.js - Imagine an app
Created by Nixxxxxx on 6/28/2023 in #djs-questions
Bot seems to be uploading the same media file multiple times?
What event are you responding to?
21 replies
DIAdiscord.js - Imagine an app
Created by Tecrubeli Armut on 6/24/2023 in #djs-questions
commands
anyway, this is more of a server for Discord JS help than a general JS help server
10 replies
DIAdiscord.js - Imagine an app
Created by Tecrubeli Armut on 6/24/2023 in #djs-questions
commands
if that makes sense
10 replies
DIAdiscord.js - Imagine an app
Created by Tecrubeli Armut on 6/24/2023 in #djs-questions
commands
No the require bit is importing the code from another file the exports bit is exporting a thing to a file this thing must be an object, it could be an array, an object, a function, etc so if I wanted to export a function to a file, I'd first have to make the function in a file and then export it it then in my main file I'd import it
10 replies
DIAdiscord.js - Imagine an app
Created by Tecrubeli Armut on 6/24/2023 in #djs-questions
commands
So CommonJS works like this: You have your main folder (index.js), this is the folder you run. Any code you put here is executed without hassle. Now, if I wanted to call a function in another file, say the function is called sendHelloWorld, simply putting sendHelloWorld(); in the index.js folder won't work. Instead, you must go to your sendHelloWorld.js file and write the following code: module.exports = { sendHelloWorld } What this does is it essientially exports your function saying "hey other files, you can use this function". Now, the way to import this function is to do this: const { sendHelloWorld } = require('./sendHelloWorld.js'); Final code for index.js file:
const { sendHelloWorld } = require('./sendHelloWorld.js');
sendHelloWorld();
const { sendHelloWorld } = require('./sendHelloWorld.js');
sendHelloWorld();
Final code for sendHelloWorld.js:
function sendHelloWorld() {
console.log("Hello, world!");
}

module.exports = { sendHelloWorld }
function sendHelloWorld() {
console.log("Hello, world!");
}

module.exports = { sendHelloWorld }
10 replies
DIAdiscord.js - Imagine an app
Created by Oscar on 8/13/2022 in #djs-questions
Add an event listener to variable change
Nevermind, didn't know that voiceStateUpdate existed lol
3 replies