Skip to content

Instantly share code, notes, and snippets.

@RussDev7
Forked from aamiaa/CompleteDiscordQuest.md
Created April 26, 2024 21:23
Show Gist options
  • Save RussDev7/4744bd50dd65db27f9fd162e911fd936 to your computer and use it in GitHub Desktop.
Save RussDev7/4744bd50dd65db27f9fd162e911fd936 to your computer and use it in GitHub Desktop.
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser! If you absolutely need to use browser instead of desktop app, use an extension to add the string Electron/ anywhere in your user-agent.

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
  2. Join a vc
  3. Stream any window (can be notepad or something)
  4. Press Ctrl+Shift+I to open DevTools
  5. Go to the Console tab
  6. Paste the following code and hit enter:
let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);

let api = Object.values(wpRequire.c).find(x => x?.exports?.getAPIBaseURL).exports.HTTP;
let ApplicationStreamingStore = Object.values(wpRequire.c).find(x => x?.exports?.default?.getStreamerActiveStreamMetadata).exports.default;
let QuestsStore = Object.values(wpRequire.c).find(x => x?.exports?.default?.getQuest).exports.default;
let encodeStreamKey = Object.values(wpRequire.c).find(x => x?.exports?.encodeStreamKey).exports.encodeStreamKey;
let sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

let quest = [...QuestsStore.quests.values()].find(x => x.userStatus?.enrolledAt && !x.userStatus?.completedAt)
if(!quest) {
	console.log("You don't have any uncompleted quests!")
} else {
	let streamId = encodeStreamKey(ApplicationStreamingStore.getCurrentUserActiveStream())
	let secondsNeeded = quest.config.streamDurationRequirementMinutes * 60
	let heartbeat = async function() {
		console.log("Completing quest", quest.config.messages.gameTitle, "-", quest.config.messages.questName)
		while(true) {
			let res = await api.post({url: `/quests/${quest.id}/heartbeat`, body: {stream_key: streamId}})
			let progress = res.body.stream_progress_seconds
			
			console.log(`Quest progress: ${progress}/${secondsNeeded}`)
			
			if(progress >= secondsNeeded) break;
			await sleep(30 * 1000)
		}
		
		console.log("Quest completed!")
	}
	heartbeat()
}
  1. Keep the stream running for 15 minutes
  2. 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. The progress should update every 30s.

You do NOT need anybody watching your stream for this to work. You can be alone in vc just fine.

FAQ

Q: Ctrl + Shift + I doesn't work

A: Either download the canary 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

Q: I get a different error

A: Make sure you've started streaming before running the script

@GoOfficial
Copy link

This code works but aamiaa's didn't. Thanks.

@Siddh-Sama
Copy link

This one worked for me, i tried amia's one several time but it kept on showing " undefined " and this worked in the first go
thank you buddy~

@VinJ712
Copy link

VinJ712 commented May 26, 2024

This one worked for me, i tried amia's one several time but it kept on showing " undefined " and this worked in the first go thank you buddy~

Hi, Can you teach me? Im kinda new, My quest is to stream PUBG

@VinJ712
Copy link

VinJ712 commented May 26, 2024

This one worked for me, i tried amia's one several time but it kept on showing " undefined " and this worked in the first go thank you buddy~

Hi, Can you teach me? Im kinda new, My quest is to stream PUBG

When I copy, and pasted it, this shows up
image

@withyoubetterplace
Copy link

WHY I GOT ERROR?

@0zul
Copy link

0zul commented May 27, 2024

This one worked for me, i tried amia's one several time but it kept on showing " undefined " and this worked in the first go thank you buddy~

Hi, Can you teach me? Im kinda new, My quest is to stream PUBG

When I copy, and pasted it, this shows up image

You probably did not accept the quest. You can use the code after you accept the quest, join a voice call with someone and stream anything you want. Soon your progress should start working

@cykorr
Copy link

cykorr commented Jun 4, 2024

image

@Siddh-Sama
Copy link

This one worked for me, i tried amia's one several time but it kept on showing " undefined " and this worked in the first go thank you buddy~

Hi, Can you teach me? Im kinda new, My quest is to stream PUBG

bro follow the same process, open your discord pc app and press ctrl + shift + i, then the same process, just make sure that you have one person in vc watching your stream

@Siddh-Sama
Copy link

image
it worked for me properly, watch youtube video and copy the same procedure as for others

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