-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add stage instances (#9578)
* feat(core): add stage instances * chore: use one import * Apply suggestions from code review Co-authored-by: Aura Román <[email protected]> * chore: requested changes Co-authored-by: David Malchin <[email protected]> Co-authored-by: Jiralite <[email protected]> * Apply suggestions from code review Co-authored-by: David Malchin <[email protected]> Co-authored-by: Jiralite <[email protected]> --------- Co-authored-by: Aura Román <[email protected]> Co-authored-by: David Malchin <[email protected]> Co-authored-by: Jiralite <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1c4a12c
commit 985def3
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* eslint-disable jsdoc/check-param-names */ | ||
|
||
import type { RequestData, REST } from '@discordjs/rest'; | ||
import { | ||
type Snowflake, | ||
type RESTGetAPIStageInstanceResult, | ||
type RESTPatchAPIStageInstanceJSONBody, | ||
type RESTPatchAPIStageInstanceResult, | ||
type RESTPostAPIStageInstanceJSONBody, | ||
type RESTPostAPIStageInstanceResult, | ||
Routes, | ||
} from 'discord-api-types/v10'; | ||
|
||
export class StageInstancesAPI { | ||
public constructor(private readonly rest: REST) {} | ||
|
||
/** | ||
* Creates a new stage instance | ||
* | ||
* @see {@link https://discord.com/developers/docs/resources/stage-instance#get-stage-instance} | ||
* @param body - The data to use when creating the new stage instance | ||
* @param options - The options for creating the new stage instance | ||
*/ | ||
public async create( | ||
body: RESTPostAPIStageInstanceJSONBody, | ||
{ reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {}, | ||
) { | ||
return this.rest.post(Routes.stageInstances(), { | ||
body, | ||
reason, | ||
signal, | ||
}) as Promise<RESTPostAPIStageInstanceResult>; | ||
} | ||
|
||
/** | ||
* Fetches a stage instance | ||
* | ||
* @see {@link https://discord.com/developers/docs/resources/stage-instance#get-stage-instance} | ||
* @param channelId - The id of the channel | ||
* @param options - The options for fetching the stage instance | ||
*/ | ||
public async get(channelId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) { | ||
return this.rest.get(Routes.stageInstance(channelId), { signal }) as Promise<RESTGetAPIStageInstanceResult>; | ||
} | ||
|
||
/** | ||
* Edits a stage instance | ||
* | ||
* @see {@link https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance} | ||
* @param channelId - The id of the channel | ||
* @param body - The new stage instance data | ||
* @param options - The options for editing the stage instance | ||
*/ | ||
public async edit( | ||
channelId: Snowflake, | ||
body: RESTPatchAPIStageInstanceJSONBody, | ||
{ reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {}, | ||
) { | ||
return this.rest.patch(Routes.stageInstance(channelId), { | ||
body, | ||
reason, | ||
signal, | ||
}) as Promise<RESTPatchAPIStageInstanceResult>; | ||
} | ||
|
||
/** | ||
* Deletes a stage instance | ||
* | ||
* @see {@link https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance} | ||
* @param channelId - The id of the channel | ||
* @param options - The options for deleting the stage instance | ||
*/ | ||
public async delete(channelId: Snowflake, { reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {}) { | ||
await this.rest.delete(Routes.stageInstance(channelId), { reason, signal }); | ||
} | ||
} |