TomatoCake
TomatoCake
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
I was about to blame you for accepting both numbers and strings, but that's Discords fault. Nevermind then.
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
I thought about automatically calling .toString() on BigInts for nonce which would happen in djs, not returning a string as Snowflake
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
... Yea I stopped reading after kyranets reply
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
a random nonce: (use SnowflakeUtil.generate() for example)
just fyi: that function returns a BigInt which isn't accepted as nonce. Could be another feature request xD
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
Should I create a feature request for that to be added? And regardless, thank you (and all other contributors) for maintaining this lib and helping me xd
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
Yea no that's ofc not a good as default enabled, but maybe as option for the REST client?
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 6/3/2024 in #djs-questions
discord.js occasionally resending requests, causing double messages
Oh, I've searched for GH issues but apparently only with the wrong keywords, I'm sorry Nonce enforcing does sound good, is there a way (planned) of making djs able to handle that? Generating them on my end seems wrong (mainly because I use <Channel>.send() everywhere, and all of those would need two additional properties)
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 5/1/2024 in #djs-questions
Logging API response body
Made a feature request https://github.com/discordjs/discord.js/issues/10240 I'll take a look at onData, tho I recall trying onHeaders which didn't quite work
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 5/1/2024 in #djs-questions
Logging API response body
Not sure whether you noticed, but I'm aware of that interceptors thing because that user talked to me. I've been using them since, but I apparently can only log the body which is sent, not the one received (without body-already-consumed errors)
const undici = require("undici")
const logBodyInterceptor = dispatch => {
return (opts, handler) => {
if (opts.body) console.log({
path: opts.method + " " + opts.path,
body: opts.body
})
return dispatch(opts, handler)
}
}

const client = new undici.Client("https://discord.com")
.compose(logBodyInterceptor)

const Discord = require("discord.js")
bot = new Discord.Client({
rest: {
agent: client
}
})
const undici = require("undici")
const logBodyInterceptor = dispatch => {
return (opts, handler) => {
if (opts.body) console.log({
path: opts.method + " " + opts.path,
body: opts.body
})
return dispatch(opts, handler)
}
}

const client = new undici.Client("https://discord.com")
.compose(logBodyInterceptor)

const Discord = require("discord.js")
bot = new Discord.Client({
rest: {
agent: client
}
})
(simplified)
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 5/1/2024 in #djs-questions
Logging API response body
Unless someone has an idea on how to get that diagnostic channel to work, what would be the best way to request a feature like this? Should I just create a feature request on GitHub?
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 5/1/2024 in #djs-questions
Logging API response body
I've tried listening to the response REST event, while it returns a cloned Response I'm still unable to simply use response.json() (or <Response>.text(), ...)
10 replies
DIAdiscord.js - Imagine an app
Created by TomatoCake on 5/1/2024 in #djs-questions
Logging API response body
Which one would that be? I haven't been able to get that working as I want it (https://github.com/nodejs/undici/issues/1342)
10 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
oh, well nevermind then I only saw discord.js@dev some time ago and thought that's it
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
Because the dev releases are just "the" dev release, there's no version attached to it which makes things like debugging which commit (might) have caused it much harder
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
As Qjuh said it's a Git hash, which I use for referencing a specific version of the code. Though I've made my own script to load the packages from GitHub, because while you can install a npm package from a hash, you can't run any build scripts or similar with it, however they are required by djs to work
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
Looks like 95c0b1a59f3dc8f496a966e9f3e947b0cd9e81b8 doesn't leak too, testing with aad82f088b4d39f7996980f8f71bfc6e5dee5c52 now
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
Because it worked before I've updated djs, then it started leaking, and after I've changed back to 637e1a4ddb6d5810deb31c5b90400ca277218270 it stopped leaking
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
I was able to create a heap dump now using the heapdump package, I'll try creating another one once memory starts leaking again
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
Nope, that guide doesn't help me at all because the issue is not in my code xD
19 replies
DIAdiscord.js - Imagine an app
Created by Nils on 11/16/2023 in #djs-questions
Memory leak in discord js
Changes in the process management code require a full restart of the whole server which is something I don't want to do often As long as I don't have to use the latest djs version, I'll just try finding the commit which started breaking it
19 replies