-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle cases of unknown component types better
- Loading branch information
1 parent
f202d9a
commit 2d9d1d5
Showing
4 changed files
with
33 additions
and
7 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
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,23 @@ | ||
import type { | ||
APIActionRowComponent, | ||
APIMessageActionRowComponent, | ||
APITextInputComponent, | ||
APIActionRowComponentTypes, | ||
} from 'discord-api-types/v9'; | ||
import { ComponentBuilder } from './Component'; | ||
|
||
/** | ||
* This class is simply a class provided to match any future components that | ||
* may not be implemented in builders. This future-proofs by not throwing an error anytime an unknown | ||
* component type is encountered. | ||
*/ | ||
export class UnknownComponentBuilder extends ComponentBuilder { | ||
public toJSON(): | ||
| APIActionRowComponent<APIMessageActionRowComponent | APITextInputComponent> | ||
| APIActionRowComponentTypes { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
return { ...this.data } as | ||
| APIActionRowComponent<APIMessageActionRowComponent | APITextInputComponent> | ||
| APIActionRowComponentTypes; | ||
} | ||
} |
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