Use atob instead of node:buffer for getBotIdFromToken (#3893)

This commit is contained in:
Fleny
2024-09-02 15:12:09 +02:00
committed by GitHub
parent 6a5f446c06
commit b1bfe94b7d
2 changed files with 2 additions and 4 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
import { Buffer } from 'node:buffer' import { Buffer } from 'node:buffer'
export const fakeToken = `${Buffer.from('1033452747380494366', 'base64').toString()}.zawsxedcrftvgybhu` export const fakeToken = `${Buffer.from('1033452747380494366').toString('base64')}.zawsxedcrftvgybhu`
+1 -3
View File
@@ -1,5 +1,3 @@
import { Buffer } from 'node:buffer'
const validTokenPrefixes = ['Bot', 'Bearer'] const validTokenPrefixes = ['Bot', 'Bearer']
/** Removes the Bot/Bearer before the token. */ /** Removes the Bot/Bearer before the token. */
@@ -19,5 +17,5 @@ export function removeTokenPrefix(token?: string, type: 'GATEWAY' | 'REST' = 'RE
/** Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken. */ /** Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken. */
export function getBotIdFromToken(token: string): bigint { export function getBotIdFromToken(token: string): bigint {
return BigInt(Buffer.from(token.split('.')[0], 'base64').toString()) return BigInt(atob(token.split('.')[0]))
} }