Skip to content

Instantly share code, notes, and snippets.

@aamiaa
Last active November 9, 2024 20:15
Show Gist options
  • Save aamiaa/204cd9d42013ded9faf646fae7f89fbb to your computer and use it in GitHub Desktop.
Save aamiaa/204cd9d42013ded9faf646fae7f89fbb to your computer and use it in GitHub Desktop.
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

This no longer works if you're alone in vc! Somebody else has to join you!

Warning

There are now two quest types ("stream" and "play")! Pay attention to the instructions!

How to use this script:

  1. Accept a quest under User Settings -> Gift Inventory
  2. Press Ctrl+Shift+I to open DevTools
  3. Go to the Console tab
  4. Paste the following code and hit enter:
Click to expand
let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);

let ApplicationStreamingStore = Object.values(wpRequire.c).find(x => x?.exports?.Z?.getStreamerActiveStreamMetadata).exports.Z;
let RunningGameStore = Object.values(wpRequire.c).find(x => x?.exports?.ZP?.getRunningGames).exports.ZP;
let QuestsStore = Object.values(wpRequire.c).find(x => x?.exports?.Z?.getQuest).exports.Z;
let ExperimentStore = Object.values(wpRequire.c).find(x => x?.exports?.Z?.getGuildExperiments).exports.Z;
let FluxDispatcher = Object.values(wpRequire.c).find(x => x?.exports?.Z?.flushWaitQueue).exports.Z;
let api = Object.values(wpRequire.c).find(x => x?.exports?.tn?.get).exports.tn;

let quest = [...QuestsStore.quests.values()].find(x => x.id !== "1248385850622869556" && x.userStatus?.enrolledAt && !x.userStatus?.completedAt && new Date(x.config.expiresAt).getTime() > Date.now())
let isApp = navigator.userAgent.includes("Electron/")
if(!isApp) {
	console.log("This no longer works in browser. Use the desktop app!")
} else if(!quest) {
	console.log("You don't have any uncompleted quests!")
} else {
	const pid = Math.floor(Math.random() * 30000) + 1000
	
	let applicationId, applicationName, secondsNeeded, secondsDone, canPlay
	if(quest.config.configVersion === 1) {
		applicationId = quest.config.applicationId
		applicationName = quest.config.applicationName
		secondsNeeded = quest.config.streamDurationRequirementMinutes * 60
		secondsDone = quest.userStatus?.streamProgressSeconds ?? 0
		canPlay = quest.config.variants.includes(2)
	} else if(quest.config.configVersion === 2) {
		applicationId = quest.config.application.id
		applicationName = quest.config.application.name
		canPlay = ExperimentStore.getUserExperimentBucket("2024-04_quest_playtime_task") > 0 && quest.config.taskConfig.tasks["PLAY_ON_DESKTOP"]
		const taskName = canPlay ? "PLAY_ON_DESKTOP" : "STREAM_ON_DESKTOP"
		secondsNeeded = quest.config.taskConfig.tasks[taskName].target
		secondsDone = quest.userStatus?.progress?.[taskName]?.value ?? 0
	}

	if(canPlay) {
		api.get({url: `/applications/public?application_ids=${applicationId}`}).then(res => {
			const appData = res.body[0]
			const exeName = appData.executables.find(x => x.os === "win32").name.replace(">","")
			
			const games = RunningGameStore.getRunningGames()
			const fakeGame = {
				cmdLine: `C:\\Program Files\\${appData.name}\\${exeName}`,
				exeName,
				exePath: `c:/program files/${appData.name.toLowerCase()}/${exeName}`,
				hidden: false,
				isLauncher: false,
				id: applicationId,
				name: appData.name,
				pid: pid,
				pidPath: [pid],
				processName: appData.name,
				start: Date.now(),
			}
			games.push(fakeGame)
			FluxDispatcher.dispatch({type: "RUNNING_GAMES_CHANGE", removed: [], added: [fakeGame], games: games})
			
			let fn = data => {
				let progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.PLAY_ON_DESKTOP.value)
				console.log(`Quest progress: ${progress}/${secondsNeeded}`)
				
				if(progress >= secondsNeeded) {
					console.log("Quest completed!")
					
					const idx = games.indexOf(fakeGame)
					if(idx > -1) {
						games.splice(idx, 1)
						FluxDispatcher.dispatch({type: "RUNNING_GAMES_CHANGE", removed: [fakeGame], added: [], games: []})
					}
					FluxDispatcher.unsubscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
				}
			}
			FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
			
			console.log(`Spoofed your game to ${applicationName}. Wait for ${Math.ceil((secondsNeeded - secondsDone) / 60)} more minutes.`)
		})
	} else {
		let realFunc = ApplicationStreamingStore.getStreamerActiveStreamMetadata
		ApplicationStreamingStore.getStreamerActiveStreamMetadata = () => ({
			id: applicationId,
			pid,
			sourceName: null
		})
		
		let fn = data => {
			let progress = quest.config.configVersion === 1 ? data.userStatus.streamProgressSeconds : Math.floor(data.userStatus.progress.STREAM_ON_DESKTOP.value)
			console.log(`Quest progress: ${progress}/${secondsNeeded}`)
			
			if(progress >= secondsNeeded) {
				console.log("Quest completed!")
				
				ApplicationStreamingStore.getStreamerActiveStreamMetadata = realFunc
				FluxDispatcher.unsubscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
			}
		}
		FluxDispatcher.subscribe("QUESTS_SEND_HEARTBEAT_SUCCESS", fn)
		
		console.log(`Spoofed your stream to ${applicationName}. Stream any window in vc for ${Math.ceil((secondsNeeded - secondsDone) / 60)} more minutes.`)
		console.log("Remember that you need at least 1 other person to be in the vc!")
	}
}
  1. Follow the printed instructions depending on what type of quest you have
    • If your quest says to "play" the game, you can just wait and do nothing
    • If your quest says to "stream" the game, join a vc with a friend or alt and stream any window
  2. Wait for 15 minutes
  3. You can now claim the reward in User Settings -> Gift Inventory!

You can track the progress by looking at the Quest progress: prints in the Console tab, or by reopening the Gift Inventory tab in settings.

FAQ

Q: Ctrl + Shift + I doesn't work

A: Either download the ptb client, or use this to enable DevTools on stable

Q: I get an error saying "Unauthorized"

A: Discord has patched the script from working in browsers. Use the desktop app, or alternatively find some extension which lets you change your User-Agent and append the string Electron/ anywhere in it.

They have also started checking how many people are in the vc, so make sure you join it on at least 1 other account.

Q: I get a syntax error/unexpected token error

A: Make sure your browser isn't auto-translating this website before copying the script. Turn off any translator extensions and try again.

Q: I get a different error

A: Make sure you're copy/pasting the script correctly and that you've have done all the steps.

Q: Can you make the script auto accept the quest/reward?

A: No. Both of those actions may show a captcha, so automating them is not a good idea. Just do the two clicks yourself.


Side note: Please don't post your "fixed" or "improved" versions of the script in the comments. It creates unnecessary confusion, often doesn't fix anything, and sometimes puts other people's accounts at risk. I might redact/delete such comments without notice. Thank you for understanding.

@s0urce-c0de
Copy link

How can I spoof the game to genshin impact or valorant so I seem like a chronically online degenerate that deserves the quests feature?

@Pearl8520
Copy link

86KE113CKCVBCHJY

@20syldev
Copy link

20syldev commented Oct 5, 2024

Here's my Throne and Liberty code for 100x Ornate Coins : 8M2AOATW69QVQJJB

@ankarakata
Copy link

Throne and Liberty 100 ornate coins : AJ9OOF70FD5HP9VS

@joblessgod
Copy link

100 ornate coins: 2WG5QM5A91EV41HJ

@Gamecoder3D
Copy link

My Throne and Liberty 100 Ornate coins code: B9Z7HR36M6BLCOV2

@h-lunah
Copy link

h-lunah commented Oct 8, 2024

How can I spoof the game to genshin impact or valorant so I seem like a chronically online degenerate that deserves the quests feature?

You can just wait for a quest to become available for Genshin / Valorant and adapt this script (this one spoofs TL)

let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);

let RunningGameStore = Object.values(wpRequire.c).find(x => x?.exports?.ZP?.getRunningGames).exports.ZP;
let FluxDispatcher = Object.values(wpRequire.c).find(x => x?.exports?.Z?.flushWaitQueue).exports.Z;
let api = Object.values(wpRequire.c).find(x => x?.exports?.tn?.get).exports.tn;

const tlData = {
    "id": "1286341455773700096",
    "name": "THRONE AND LIBERTY"
}
const pid = Math.floor(Math.random() * 30000) + 1000

api.get({url: `/applications/public?application_ids=${tlData.id}`}).then(res => {
    const appData = res.body[0];
    const exeName = appData.executables.find(x => x.os === "win32").name.replace(">","");
    
    const games = RunningGameStore.getRunningGames();
    const fakeGame = {
        cmdLine: `C:\\Program Files\\${appData.name}\\${exeName}`,
        exeName,
        exePath: `c:/program files/${appData.name.toLowerCase()}/${exeName}`,
        hidden: false,
        isLauncher: false,
        id: tlData.id,
        name: appData.name,
        pid: pid,
        pidPath: [pid],
        processName: appData.name,
        start: Date.now(),
    };

    games.push(fakeGame);
    FluxDispatcher.dispatch({type: "RUNNING_GAMES_CHANGE", removed: [], added: [fakeGame], games: games});
    console.log(`You are now playing ${tlData.name}`);        
});

@Pearl8520
Copy link

3GVD-98F3-CKW64-QGBB-VVXV

@tonyismagicly
Copy link

Celestial Ties Shader Reward Code: 7KT-ATM-4VL
Sea of Voices Weapon Bundle: 3PXW-FPH9-58KXF-LL63-B486
100x Ornate Coins: C9QEIA3DNRXHX6GE

@cxb190007
Copy link

Destiny 2: 7TJ-9XJ-C36
Throne and Liberty: C96GL63JUCE1PDTZ
Diablo IV: 3TQP-9NX8-HRCPN-8LFW-QVDJ

@cdkw2
Copy link

cdkw2 commented Oct 10, 2024

Destiny 2: 7TJ-9XJ-C36 Throne and Liberty: C96GL63JUCE1PDTZ Diablo IV: 3TQP-9NX8-HRCPN-8LFW-QVDJ

still works can confirm

@PhoenixSheppy
Copy link

Can confirm, this method / script still works. Thanks! 👍

@FortHell0
Copy link

Destiny 2: G4N-DFH-A3A

@mesalytic
Copy link

Destiny 2: G6C-X3V-PYH
Diablo IV: 4JV6-GQ4V-3KJSL-T3FQ-GVPN
Throne of Liberty: 2LFTHRLDVMQSB1BP

@Pearl8520
Copy link

destiny 2: G6L-KXV-XGR

@LoveUwUBotForeverMcBoss1999

web.5cb2778e8e954b8b496f.js:12 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'nativeModules')
at Object.requireModule (web.5cb2778e8e954b8b496f.js:12:9050198)
at Object.getDiscordUtils (web.5cb2778e8e954b8b496f.js:12:9052536)
at Object.GetWindowFullscreenTypeByPid (web.5cb2778e8e954b8b496f.js:12:9061648)
at L.update (web.5cb2778e8e954b8b496f.js:12:6054719)
at new L (web.5cb2778e8e954b8b496f.js:12:6056874)
at new D (web.5cb2778e8e954b8b496f.js:12:6062980)
at D.create (web.5cb2778e8e954b8b496f.js:12:6057344)
at y (web.5cb2778e8e954b8b496f.js:12:6063269)
at web.5cb2778e8e954b8b496f.js:12:9642019
at Set.forEach ()
at web.5cb2778e8e954b8b496f.js:12:9642008
at web.5cb2778e8e954b8b496f.js:12:9648446
at h._dispatch (web.5cb2778e8e954b8b496f.js:12:9641981)
at web.5cb2778e8e954b8b496f.js:12:9641493
at l.log (web.5cb2778e8e954b8b496f.js:12:9648388)
at h._dispatchWithLogging (web.5cb2778e8e954b8b496f.js:12:9641435)
at h._dispatchWithDevtools (web.5cb2778e8e954b8b496f.js:12:9641011)
at Object.dispatch_RUNNING_GAMES_CHANGE [as RUNNING_GAMES_CHANGE] (web.5cb2778e8e954b8b496f.js:12:9640325)
at web.5cb2778e8e954b8b496f.js:12:9640426
at h.flushWaitQueue (web.5cb2778e8e954b8b496f.js:12:9640907)
at web.5cb2778e8e954b8b496f.js:12:9640456
at new Promise ()
at h.dispatch (web.5cb2778e8e954b8b496f.js:12:9640205)
at :34:20

@Pearl8520
Copy link

marvel snap: 02UGFyyPW8y6sE7

@Pangaulin
Copy link

Winter survival pack for Once Human : tj4ecthcfx

@Bonosho
Copy link

Bonosho commented Oct 27, 2024

Hi there ! Does (by some MIRACLE) someone still have a code for the Marvel Snap quest in stock? It'd be awesome.
Happy scripting to you

@TechySkills
Copy link

TechySkills commented Oct 27, 2024 via email

@Bonosho
Copy link

Bonosho commented Oct 27, 2024

That's the point, codes expire October 30 but are no longer obtainable since October 23 so I'm trying here maybe I'll get lucky :)
Thanks for your answer !

@Joki158
Copy link

Joki158 commented Oct 28, 2024

"This no longer works in browser. Use the desktop app!"

@4uncuk
Copy link

4uncuk commented Oct 28, 2024

off-topic
I got falsely banned off of discord, cannot make another account, very annoying, tech support doesnt help
anyways, have a good day

@DePieLucca
Copy link

once human / winter survival pack code : tj67wfqrk8 🙂

@joblessgod
Copy link

Discord Quest - Winter Survival Pack - Once Human
Copy: tj6c47rep6

@tienanh109
Copy link

Yay, we have a Winter Survival Pack redeem code for Once Human, here is the redeem code if you need it:
||tj6jx3fadj||

For more, pls complete this quest!
https://discord.com/quests/1298035818769940591

Join my server if u want: https://tienanh109.github.io/dc

@godsh1ps
Copy link

do we still get the quest badge or not?

@joblessgod
Copy link

do we still get the quest badge or not?

Yes, you do receive it after finishing the quest.

@lurking2
Copy link

lurking2 commented Nov 8, 2024

HEY GUYS If you never had nitro before on your discord account, you can activate this but need a card to activate it. Please use it so it does not go to waste.
Nitro promo codes: https://discord.com/billing/promotions/pDAM7zjwXAak6fcKUKfY2QVv
https://discord.com/billing/promotions/?code=fQPV-hqya-VhSh-b3X4-DBQB-pJ55

@TechySkills
Copy link

TechySkills commented Nov 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment