mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
Use atob instead of node:buffer for getBotIdFromToken (#3893)
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
import { Buffer } from 'node:buffer'
|
||||
|
||||
export const fakeToken = `${Buffer.from('1033452747380494366', 'base64').toString()}.zawsxedcrftvgybhu`
|
||||
export const fakeToken = `${Buffer.from('1033452747380494366').toString('base64')}.zawsxedcrftvgybhu`
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Buffer } from 'node:buffer'
|
||||
|
||||
const validTokenPrefixes = ['Bot', 'Bearer']
|
||||
|
||||
/** 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. */
|
||||
export function getBotIdFromToken(token: string): bigint {
|
||||
return BigInt(Buffer.from(token.split('.')[0], 'base64').toString())
|
||||
return BigInt(atob(token.split('.')[0]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user