Skip to content

Instantly share code, notes, and snippets.

@Hacksore
Created January 24, 2024 23:44
Show Gist options
  • Save Hacksore/37e6848431e12bc9ea59cc50eefddab5 to your computer and use it in GitHub Desktop.
Save Hacksore/37e6848431e12bc9ea59cc50eefddab5 to your computer and use it in GitHub Desktop.
message-troll-discord.js
const ws = new WebSocket("wss://gateway.discord.gg/?encoding=json&v=9")
const token = ""
const myUsername = ""
const channelId = ""
const messageId = ""
const randomMessages = [
"Pranks are the spice of life, just be sure it's not too spicy!",
"Life's a stage, and pranks are the improv.",
"Pranking: the art of surprise with a side of laughter.",
"In the world of pranks, every day is April Fools' Day.",
"A well-timed prank is like a punchline to the comedy of life.",
"Pranks are the secret handshake of mischief-makers.",
"When in doubt, prank it out!",
"Prank responsibly – laughter is the best medicine, not revenge.",
"The real magic is turning everyday moments into hilarious memories with a clever prank.",
"Pranksters: turning ordinary days into extraordinary stories since [your birth year].",
"Prank like no one is watching, but always check for hidden cameras.",
"Life is short, pranks make it memorable.",
"Pranking is an art form; consider yourself the Picasso of mischief.",
"In the prankiverse, every setup is a potential punchline.",
"Why be serious when you can be seriously funny with a well-executed prank?",
"The secret to happiness: a dash of humor and a sprinkle of pranks.",
"Pranksters: the unsung heroes of laughter in a mundane world.",
"Pranks: because adulthood needs a touch of childhood mischief.",
"If life gives you lemons, turn them into squirt guns for a water balloon prank.",
"Prank well, laugh often, and never take yourself too seriously.",
"In the prank playbook of life, spontaneity is the winning strategy.",
"Pranks are the emojis of real life – adding a splash of humor to every situation.",
"Laughter is timeless, imagination has no age, and pranks are the key to unlocking both.",
"The best pranks are the ones that leave everyone smiling, not scratching their heads.",
"Pranking is a language everyone understands; let your actions speak volumes.",
"Elevate your mood, elevate your pranks – the higher, the funnier.",
"Behind every great laugh, there's a prank waiting to be revealed.",
"Pranks are the fireworks of daily life – unexpected, dazzling, and best enjoyed with friends.",
"If life's a joke, make sure you're the one telling it with a clever prank.",
"Don't just go with the flow; redirect it with a well-placed prank.",
"The golden rule of pranking: leave no trace, just smiles.",
"In a world full of seriousness, be the prankster that breaks the monotony.",
"Prank responsibly: no harm, all charm.",
"Pranks are the wrinkles of laughter on the face of life.",
"Why frown when you can turn it upside down with a goofy prank?",
"Laughter is contagious; unleash the prank epidemic.",
"Pranks: the unexpected plot twists in the novel of life.",
"Life's too short to be serious; add some levity with a playful prank.",
"Prank like you mean it, but make sure everyone's in on the joke.",
"A well-crafted prank is a masterpiece; become the prank Picasso.",
"Pranks: the glue that binds friendships with laughter.",
"Why be normal when you can be abnormally hilarious with a clever prank?",
"Pranking is the sweet melody in the symphony of life; play it well.",
"Humor is the seasoning of life, and pranks are the spicy surprises.",
"Pranks are the souvenirs of unforgettable moments.",
"Dance like nobody's watching; prank like everyone is laughing.",
"Laughter is the universal language; pranks are the dialects.",
"Pranksters: turning mundane situations into comedy gold since forever.",
"Why be a spectator when you can be the star of the prank show?",
"Pranks are the punctuation marks in the sentence of life; use them wisely.",
"The funniest moments are the unplanned pranks that catch us by surprise.",
"Prank responsibly: never cross the line, just draw it with laughter.",
"Life's a playground, and pranks are the ultimate recess activity.",
"Pranking etiquette: never spoil the punchline before the big reveal.",
"In the school of life, pranks are the extracurricular activities of joy.",
"Why settle for dull when you can sparkle with the glitter of clever pranks?",
"Pranks: the magical spells that turn seriousness into smiles.",
"Don't just dream; turn your imagination into a prank-tastic reality.",
"Prank like a ninja: stealthy, unexpected, and always leaving a mark.",
"In the comedy club of life, pranks are the stand-up routines that steal the show.",
"Laughter is the applause of a well-executed prank.",
"Why fear the unknown when you can prank it into familiarity?",
"Pranks are the unexpected gifts that keep on giving – in laughs.",
"Life's a canvas; paint it with the vibrant colors of playful pranks.",
"Pranksters: the architects of laughter in the building of life.",
"Why be ordinary when you can be extraordinarily funny with a clever prank?",
"Pranks: the spark plugs that ignite the engine of joy.",
"In the grand symphony of life, pranks are the notes that make everyone dance.",
"Laughter is the destination; pranks are the thrilling journey.",
"Prank responsibly: no harm, just charm.",
"Why be serious when you can be seriously hilarious with a well-placed prank?",
"Pranks are the love language of mischief-makers.",
"Life's too short for boring stories; add a twist with a memorable prank.",
"Prank like it's your job; the laughter is your paycheck.",
"In the comedy of errors, pranks are the plot twists that make it unforgettable.",
"Why follow the rules when you can rewrite them with a clever prank?",
"Pranksters: the alchemists turning ordinary moments into golden memories.",
"Pranks: the seasoning that makes life's soup tastier.",
"Laughter is the best medicine, but pranks are the magical potions.",
"Prank responsibly: the only rule you need in the book of mischief.",
"Why be a spectator when you can be the director of the prank movie?",
"Pranks: the side dishes that make the main course of life more flavorful.",
"Life's a game, and pranks are the unexpected power-ups.",
"Prank like there's no tomorrow, but make sure everyone gets the joke today.",
"In the play of life, pranks are the scene-stealing performances.",
"Why whisper when you can shout 'surprise' with a clever prank?",
"Pranks are the spice in the recipe of joy; don't be afraid to add more.",
"Laughter is the music; pranks are the dance moves.",
"Prank responsibly: where mischief meets mindfulness.",
"Why be average when you can be above average in pranking?",
"Pranks: the secret ingredients that turn moments",
]
function messageTroll(channelId, token, nonce = null) {
const randomMessage = randomMessages[Math.floor(Math.random() * randomMessages.length)];
const res = fetch(`https://discord.com/api/v9/channels/${channelId}/messages`, {
"headers": {
"accept": "*/*",
"authorization": token,
"content-type": "application/json"
},
"body": `{\"mobile_network_type\":\"unknown\",\"content\":\"# ${randomMessage}\",\"nonce\":\"${nonce}\",\"tts\":false,\"flags\":0}`,
"method": "POST",
"mode": "cors",
"credentials": "include"
}).then(res => res.json())
}
ws.onopen = function(e) {
console.log("Connected to Discord")
ws.send(JSON.stringify({
"op": 2, "d": {
"token": token,
"capabilities": 509,
"properties": { "os": "Windows", "browser": "Chrome", "device": "", "system_locale": "en-US", "browser_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36", "browser_version": "102.0.0.0", "os_version": "10", "referrer": "https://www.google.com/", "referring_domain": "www.google.com", "search_engine": "google", "referrer_current": "", "referring_domain_current": "", "release_channel": "stable", "client_build_number": 131860, "client_event_source": null }, "presence": { "status": "online", "since": 0, "activities": [], "afk": false }, "compress": false, "client_state": { "guild_hashes": {}, "highest_last_message_id": "0", "read_state_version": 0, "user_guild_settings_version": -1, "user_settings_version": -1 }
}
}))
}
ws.onmessage = function(e) {
const { d, t } = JSON.parse(e.data)
if (t === "READY_SUPPLEMENTAL") {
messageTroll(channelId, token, messageId)
}
if (d?.author?.username !== myUsername || t !== "MESSAGE_CREATE") return
setTimeout(() => {
const { id } = d
console.log("updating id", id)
messageTroll(channelId, token, id)
}, 1000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment