why Vencord's MessageLatency plugin sucks ass and how i broke it
this shit sucks ASS!!!!
its a plugin that tells you how long your message took to reach discord, wtf is the usage? NOTHING! ABSOLUTELY FUCKING NOTHING
i guess cyberbullying? thats a good usage.
eitherway, lets break this horrid plugin down:
this plugin works with reading the nonce. nonce is basically a random ass number that can only be used once
im not smart and if you’re here for detailed programming lessons you’ve come to the wrong place. we’re not gonna focus on wtf nonce is, important part is, this is how a nonce is created:
let epoch = 1420070400000 // Milliseconds since Discord Epoch, the first second of 2015 or 1420070400000.
let increment = 0
function timestamp_to_snowflake (timestamp = new Date().getTime()) {
let str = ''
// timestamp
str += ((timestamp - epoch)).toString(2).padStart(42, '0')
// worker id
str += '00001'
// process id
str += '00000'
// increment
str += (increment++ % 2**12).toString(2).padStart(12, '0')
return parseInt(str, 2)
}
(i didnt steal discord’s code. this is a reimplementation by funlennysub)
we got 3 values: worker id, process id, and my behatred, current time
since the nonce is created client side, you can subtract the time when the nonce hit the server with the value stored in the nonce to get the difference in the time, aka the user’s ping
now, what happens if we just shitpost in the nonce?
thats a great question! the answer is:
tada!!!!!!!
now, it wasnt easy to get here. turns out, fucking with the nonce has a lot of problems, for example:
lets figure out whats happening here together:
nonce has uses other than being used for a shitty ass plugin, for example: deduplication!
imagine this: im an annoying piece of shit and im spamming the same message over and over in a channel, now imagine you’re my discord client, and you have to figure out which message is which. you cant depend on the content of the message, because im spamming the same thing, and you cant depend on the time of the sent message, because since im spamming its all getting sent back out of order
this is where nonce comes into play. imagine it as a tag. since no nonces can be the same you wont have any problems
now, why did i just tell you allat? because when we were breaking MessageLatency, we broke discord itself in the process too!
and thats how i gave up using shelter
my approach was interrupting the message and replacing the nonce, but as i just said, that breaks discord. and because of shelter’s core design decisions, i simply dont have the tools for another approach
at the same time, i dont want to use vencord, because using something else to break vencord is funnier than using vencord to break vencord
here comes moonlight, yet another discord mod that has the tools for me to break the nonce! and would you look at that, they accepted antinonce into their main repo
this was a very fun project. i really enjoyed fucking MessageLatency over. and also thank you for reading this garbage :)
-amy