-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
263 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
/src | ||
/build | ||
/scripts | ||
/examples | ||
.eslintrc.json | ||
.gitignore | ||
tsconfig.json | ||
|
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
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,64 @@ | ||
import { Client, MessageEmbed, MessageButton, MessageActionRow } from 'discord.js'; | ||
import { PagesBuilder } from 'discord.js-pages'; | ||
|
||
const client = new Client({ | ||
intents: [ | ||
'GUILDS' | ||
] | ||
}); | ||
|
||
client.on('interactionCreate', (interaction) => { | ||
// Custom buttons & select | ||
new PagesBuilder(interaction) | ||
.setTitle('Global title') | ||
.setPages([ | ||
new MessageEmbed() | ||
.setDescription('First page'), | ||
new MessageEmbed() | ||
.setDescription('Second page') | ||
]) | ||
.setComponents([ | ||
new MessageActionRow() | ||
.setComponents( | ||
new MessageButton() | ||
.setCustomId('custom') | ||
.setLabel('Custom button') | ||
.setStyle('PRIMARY') | ||
) | ||
]) | ||
// You can add buttons/selects to the end of the list. | ||
// The library itself will find the component in which there is a place or create new for the element and add it. | ||
// Support array. | ||
.addComponents( | ||
new MessageButton() | ||
.setCustomId('awesome') | ||
.setLabel('Awesome button') | ||
.setStyle('SECONDARY') | ||
) | ||
// Add triggers for handling interactions with buttons/selects. | ||
// Support array. | ||
.setTriggers({ | ||
name: 'custom', | ||
callback(interactionCallback, button) { | ||
button.setDisabled(true); | ||
|
||
interaction.followUp({ | ||
content: 'Custom button callback!' | ||
}); | ||
} | ||
}) | ||
.addTriggers({ | ||
name: 'awesome', | ||
callback(interactionCallback, button) { | ||
button.setDisabled(true) | ||
.setLabel('¯\\_(ツ)_/¯'); | ||
|
||
interaction.followUp({ | ||
content: 'Awesome button callback!' | ||
}); | ||
} | ||
}) | ||
.build(); | ||
}); | ||
|
||
client.login(process.env.TOKEN); |
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,45 @@ | ||
import { Client, MessageEmbed, MessageButton, MessageActionRow } from 'discord.js'; | ||
import { PagesBuilder } from 'discord.js-pages'; | ||
|
||
const client = new Client({ | ||
intents: [ | ||
'GUILDS' | ||
] | ||
}); | ||
|
||
client.on('interactionCreate', (interaction) => { | ||
const link = new MessageButton() | ||
.setLabel('Dynamic link') | ||
.setStyle('LINK'); | ||
|
||
// Dynamic buttons update | ||
const builder = new PagesBuilder(interaction) | ||
.setTitle('Global title'); | ||
|
||
builder.setPages([ | ||
() => { | ||
link.setURL('https://google.com/'); | ||
|
||
builder.setComponents( | ||
new MessageActionRow() | ||
.addComponents(link) | ||
); | ||
|
||
return new MessageEmbed() | ||
.setDescription('First page'); | ||
}, | ||
() => { | ||
link.setURL('https://discord.com/'); | ||
|
||
builder.setComponents( | ||
new MessageActionRow() | ||
.addComponents(link) | ||
); | ||
|
||
return new MessageEmbed() | ||
.setDescription('Second page'); | ||
} | ||
]); | ||
}); | ||
|
||
client.login(process.env.TOKEN); |
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,30 @@ | ||
import { Client, MessageEmbed, MessageButton } from 'discord.js'; | ||
import { PagesBuilder } from 'discord.js-pages'; | ||
|
||
const client = new Client({ | ||
intents: [ | ||
'GUILDS' | ||
] | ||
}); | ||
|
||
client.on('interactionCreate', (interaction) => { | ||
// Quick actions | ||
new PagesBuilder(interaction) | ||
.setTitle('Global title') | ||
.setPages([ | ||
new MessageEmbed() | ||
.setDescription('First page'), | ||
new MessageEmbed() | ||
.setDescription('Second page') | ||
]) | ||
// Add buttons with quick pagination actions, also you can customize it. | ||
// There is no need to set customId, the library does it for you. | ||
.setDefaultButtons(['first', { | ||
stop: new MessageButton() | ||
.setLabel('Stop') | ||
.setStyle('PRIMARY') | ||
}]) | ||
.build(); | ||
}); | ||
|
||
client.login(process.env.TOKEN); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.