Skip to content

Commit

Permalink
fixed the button create method
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Oct 27, 2024
1 parent 2e23cef commit d72c1d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/app/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface IButton {
* export type BuyButtonParams = [article: string, quantity: number]
* ```
*/
export type ButtonParams = Record<string, string | boolean | number>
export type ButtonParams = Record<string, string | boolean | number> | null

export interface ButtonOptions<Params extends ButtonParams> {
key: string
Expand All @@ -97,14 +97,16 @@ export interface ButtonOptions<Params extends ButtonParams> {
* Represents a button handler. <br>
* See the {@link https://ghom.gitbook.io/bot.ts/usage/create-a-button guide} for more information.
*/
export class Button<Params extends ButtonParams> {
export class Button<Params extends ButtonParams = null> {
filepath?: string
native = false

constructor(public options: ButtonOptions<Params>) {}

public create(params: Params): discord.ButtonBuilder {
return createButton(this, params)
public create(): discord.ButtonBuilder
public create(params: Params): discord.ButtonBuilder
public create(params?: Params): discord.ButtonBuilder {
return createButton(this, params!)
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/buttons/pagination.native.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as button from "#src/app/button.ts"
import type * as pagination from "#src/app/pagination.ts"

export type PaginationButtonParams = {
export default new button.Button<{
key: pagination.PaginatorKey
}

export default new button.Button<PaginationButtonParams>({
}>({
key: "pagination",
description: "The pagination button",
async run(interaction, { key }) {
Expand Down

0 comments on commit d72c1d3

Please sign in to comment.