-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
562 additions
and
3 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,77 @@ | ||
import { Tabs } from 'nextra/components'; | ||
|
||
# ButtonKit | ||
|
||
ButtonKit is a class that allows you to use buttons easily by extending native [ButtonBuilder](https://old.discordjs.dev/#/docs/discord.js/main/class/ButtonBuilder) features. | ||
|
||
## Usage | ||
|
||
<Tabs items={['CommonJS', 'ESM', 'TypeScript']}> | ||
<Tabs.Tab> | ||
```js filename="commands/counter.js" copy | ||
const { ButtonKit } = require('commandkit'); | ||
const { ButtonStyle } = require('discord.js'); | ||
|
||
// create a button | ||
const button = new ButtonKit() | ||
.setEmoji('👍') | ||
.setStyle(ButtonStyle.Primary) | ||
// custom id is required to use onClick | ||
.setCustomId('button'); | ||
|
||
// listen to the button interaction right away | ||
button.onClick( | ||
(interaction) => { | ||
// reply to the interaction | ||
interaction.reply('You clicked the button!'); | ||
}, | ||
{ message }, | ||
); | ||
``` | ||
</Tabs.Tab> | ||
<Tabs.Tab> | ||
```js filename="commands/counter.js" copy | ||
import { ButtonKit } from 'commandkit'; | ||
import { ButtonStyle } from 'discord.js'; | ||
|
||
// create a button | ||
const button = new ButtonKit() | ||
.setEmoji('👍') | ||
.setStyle(ButtonStyle.Primary) | ||
// custom id is required to use onClick | ||
.setCustomId('button'); | ||
|
||
// listen to the button interaction right away | ||
button.onClick( | ||
(interaction) => { | ||
// reply to the interaction | ||
interaction.reply('You clicked the button!'); | ||
}, | ||
{ message }, | ||
); | ||
``` | ||
</Tabs.Tab> | ||
<Tabs.Tab> | ||
```ts filename="commands/counter.ts" copy | ||
import { ButtonKit } from 'commandkit'; | ||
import { ButtonStyle, ButtonInteraction } from 'discord.js'; | ||
|
||
// create a button | ||
const button = new ButtonKit() | ||
.setEmoji('👍') | ||
.setStyle(ButtonStyle.Primary) | ||
// custom id is required to use onClick | ||
.setCustomId('button'); | ||
|
||
// listen to the button interaction right away | ||
button.onClick( | ||
(interaction: ButtonInteraction) => { | ||
// reply to the interaction | ||
interaction.reply('You clicked the button!'); | ||
}, | ||
{ message }, | ||
); | ||
``` | ||
</Tabs.Tab> | ||
|
||
</Tabs> |
Oops, something went wrong.