Skip to content

Commit

Permalink
status + optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
JustYuuto committed Jun 16, 2023
1 parent 33e031f commit a124fb5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/utils/DiscordWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ wsURLParams.append('v', '10');
wsURLParams.append('encoding', 'json');
const wsURL = `wss://gateway.discord.gg/?${wsURLParams}`;

export function connect(token: string, resumeUrl?: string) {
export async function connect(token: string, resumeUrl?: string) {
status = (await axios.get('https://discord.com/api/v10/users/@me/settings', {
headers: { Authorization: token, 'User-Agent': userAgents.discordApp }
})).data.status;

This comment has been minimized.

Copy link
@JustYuuto

JustYuuto Jun 16, 2023

Author Owner

forgot to say that putting the axios request here fixes #7


return new Promise<void>(async (resolve, reject) => {
if (!await checkToken(token)) throw new Error('Invalid token provided');
const socket = new WebSocket(resumeUrl ? resumeUrl : wsURL, {
headers: {
'User-Agent': userAgents.discordApp,
Origin: 'https://discord.com'
}
});
status = (await axios.get('https://discord.com/api/v10/users/@me/settings', {
headers: { Authorization: token, 'User-Agent': userAgents.discordApp }
})).data.status;

const socket = new WebSocket(resumeUrl || wsURL);
const payload = {
op: 2,
d: {
Expand All @@ -46,7 +43,7 @@ export function connect(token: string, resumeUrl?: string) {
system_locale: 'en',
},
presence: {
status, activities: []
status: 'dnd', since: 0, afk: false, activities: []
}
}
};
Expand Down

0 comments on commit a124fb5

Please sign in to comment.