diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index f820f566c..d0d8227d9 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -1215,6 +1215,32 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage async upsertGuildApplicationCommands(guildId, body) { return await rest.put(rest.routes.interactions.commands.guilds.all(rest.applicationId, guildId), { body }) }, + + preferSnakeCase(enabled: boolean) { + const camelizer = enabled ? (x: any) => x : camelize + + rest.get = async (url, options) => { + return camelizer(await rest.makeRequest('GET', url, options)) + } + + rest.post = async (url: string, options?: Omit) => { + return camelizer(await rest.makeRequest('POST', url, options)) + } + + rest.delete = async (url: string, options?: Omit) => { + camelizer(await rest.makeRequest('DELETE', url, options)) + } + + rest.patch = async (url: string, options?: Omit) => { + return camelizer(await rest.makeRequest('PATCH', url, options)) + } + + rest.put = async (url: string, options?: Omit) => { + return camelizer(await rest.makeRequest('PUT', url, options)) + } + + return rest + }, } return rest diff --git a/packages/rest/src/types.ts b/packages/rest/src/types.ts index 895b013e7..b66cb484a 100644 --- a/packages/rest/src/types.ts +++ b/packages/rest/src/types.ts @@ -160,6 +160,8 @@ export interface RestManager { invalidBucket: InvalidRequestBucket /** The routes that are available for this manager. */ routes: RestRoutes + /** Whether or not the rest manager should keep objects in raw snake case from discord. */ + preferSnakeCase: (enabled: boolean) => RestManager; /** Check the rate limits for a url or a bucket. */ checkRateLimits: (url: string) => number | false /** Reshapes and modifies the obj as needed to make it ready for discords api. */