From d478e679db735e6aa3ec98cc8374274f7cd431b1 Mon Sep 17 00:00:00 2001 From: Dominik Koch Date: Sat, 28 Dec 2024 20:35:13 +0100 Subject: [PATCH] chore: use DISCORDENO_VERSION from utils for docs and rest manager (#4059) * docs: update header to v20 * Update to upcoming version instead * Use the new DISCORDENO_VERSION * Use the new DISCORDENO_VERSION * Update website/docs/bigbot/step-2-rest.md --------- Co-authored-by: Awesome Stickz Co-authored-by: Fleny --- packages/rest/src/manager.ts | 17 ++++++++++++----- website/docs/bigbot/step-2-rest.md | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) 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(), } }