diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index 12f8e3d29..f1f79a495 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -55,15 +55,22 @@ import { type MfaLevels, type ModifyGuildTemplate, } from '@discordeno/types' -import { calculateBits, camelToSnakeCase, camelize, delay, getBotIdFromToken, logger, processReactionString, urlToBase64 } from '@discordeno/utils' +import { + DISCORDENO_VERSION, + calculateBits, + camelToSnakeCase, + camelize, + delay, + getBotIdFromToken, + logger, + processReactionString, + urlToBase64 +} from '@discordeno/utils' import { createInvalidRequestBucket } from './invalidBucket.js' import { Queue } from './queue.js' import { createRoutes } from './routes.js' import type { CreateRequestBodyOptions, CreateRestManagerOptions, MakeRequestOptions, RestManager, SendRequestOptions } from './types.js' -// TODO: make dynamic based on package.json file -const version = '19.0.0' - export const DISCORD_API_VERSION = 10 export const DISCORD_API_URL = 'https://discord.com/api' @@ -102,7 +109,7 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage createBaseHeaders() { return { - 'user-agent': `DiscordBot (https://github.com/discordeno/discordeno, v${version})`, + 'user-agent': `DiscordBot (https://github.com/discordeno/discordeno, v${DISCORDENO_VERSION})`, } }, diff --git a/website/docs/bigbot/step-2-rest.md b/website/docs/bigbot/step-2-rest.md index ed3345001..3acc74c97 100644 --- a/website/docs/bigbot/step-2-rest.md +++ b/website/docs/bigbot/step-2-rest.md @@ -240,13 +240,15 @@ Having multiple bots sending requests from one source will impact your global ra In order to send the bot id inside of the request headers we first have to override the `createBaseHeaders()` function in our `services/bot/bot.ts` file. ```ts +import { DISCORDENO_VERSION } from '@discordeno/utils' + BOT.rest = createRestManager({ token: process.env.PUBLIC_BOT_TOKEN as string, }) BOT.rest.createBaseHeaders = () => { return { - 'user-agent': `DiscordBot (https://github.com/discordeno/discordeno, v19.0.0)`, + 'user-agent': `DiscordBot (https://github.com/discordeno/discordeno, v${DISCORDENO_VERSION})`, bot_id: BOT.rest.applicationId.toString(), } }