mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
refactor!: do not store token prefixed with Bot (#2002)
This commit is contained in:
@@ -98,7 +98,7 @@ export function createBot(options: CreateBotOptions): Bot {
|
||||
const bot = {
|
||||
id: options.botId,
|
||||
applicationId: options.applicationId || options.botId,
|
||||
token: `Bot ${options.token}`,
|
||||
token: options.token,
|
||||
events: createEventHandlers(options.events),
|
||||
intents: options.intents.reduce((bits, next) => (bits |= GatewayIntents[next]), 0),
|
||||
botGatewayData: options.botGatewayData,
|
||||
@@ -242,7 +242,7 @@ export function createRestManager(options: CreateRestManagerOptions) {
|
||||
invalidRequestFrozenAt: 0,
|
||||
invalidRequestErrorStatuses: [401, 403, 429],
|
||||
version,
|
||||
token: `${options.token.startsWith("Bot ") ? "" : "Bot "}${options.token}`,
|
||||
token: options.token,
|
||||
maxRetryCount: options.maxRetryCount || 10,
|
||||
secretKey: options.secretKey || "discordeno_best_lib_ever",
|
||||
customUrl: options.customUrl || "",
|
||||
|
||||
@@ -6,7 +6,7 @@ import { RestPayload, RestRequest } from "./rest.ts";
|
||||
/** Creates the request body and headers that are necessary to send a request. Will handle different types of methods and everything necessary for discord. */
|
||||
export function createRequestBody(rest: RestManager, queuedRequest: { request: RestRequest; payload: RestPayload }) {
|
||||
const headers: { [key: string]: string } = {
|
||||
Authorization: rest.token,
|
||||
Authorization: `Bot ${rest.token}`,
|
||||
"User-Agent": USER_AGENT,
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export function identify(gateway: GatewayManager, shardId: number, maxShards: nu
|
||||
{
|
||||
op: GatewayOpcodes.Identify,
|
||||
d: {
|
||||
token: gateway.token,
|
||||
token: `Bot ${gateway.token}`,
|
||||
compress: gateway.compress,
|
||||
properties: {
|
||||
$os: gateway.$os,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { GetGatewayBot } from "../types/gateway/getGatewayBot.ts";
|
||||
export async function resharder(gateway: GatewayManager) {
|
||||
// TODO: is it possible to route this to REST?
|
||||
const results = (await fetch(`https://discord.com/api/gateway/bot`, {
|
||||
headers: { Authorization: gateway.token },
|
||||
headers: { Authorization: `Bot ${gateway.token}` },
|
||||
}).then((res) => res.json())) as GetGatewayBot;
|
||||
|
||||
const percentage = ((results.shards - gateway.maxShards) / gateway.maxShards) * 100;
|
||||
|
||||
@@ -53,7 +53,7 @@ export function resume(gateway: GatewayManager, shardId: number) {
|
||||
{
|
||||
op: GatewayOpcodes.Resume,
|
||||
d: {
|
||||
token: gateway.token,
|
||||
token: `Bot ${gateway.token}`,
|
||||
session_id: sessionId,
|
||||
seq: previousSequenceNumber,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user