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 <awesome@stickz.dev>
Co-authored-by: Fleny <Fleny113@outlook.com>
This commit is contained in:
Dominik Koch
2024-12-28 20:35:13 +01:00
committed by GitHub
parent 3fd075a80f
commit d478e679db
2 changed files with 15 additions and 6 deletions

View File

@@ -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})`,
}
},

View File

@@ -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(),
}
}