Skip to content

Commit

Permalink
refactor(Utils): use enum
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
  • Loading branch information
ckohen and vladfrangu committed Oct 25, 2021
1 parent 7971f86 commit 7e3e1b4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/rest/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { RESTPatchAPIChannelJSONBody } from 'discord-api-types/v9';
import type { Response } from 'node-fetch';
import { RequestMethod } from '../RequestManager';

/**
* Converts the response to usable data
Expand All @@ -26,8 +27,8 @@ export function hasSublimit(bucketRoute: string, body?: unknown, method?: string
// Editing channel `name` or `topic`
if (bucketRoute === '/channels/:id') {
if (typeof body !== 'object' || body === null) return false;
if (method !== 'patch') return false;
// This could be a POST body, but due to the sequencing of requests, it should never be checked on POST
// This should never be a POST body, but just in case
if (method !== RequestMethod.Patch) return false;
const castedBody = body as RESTPatchAPIChannelJSONBody;
return ['name', 'topic'].some((key) => Reflect.has(castedBody, key));
}
Expand Down

0 comments on commit 7e3e1b4

Please sign in to comment.