Easily create Discord.js embed menus with reactions and unlimited customisable pages.
Need help? Join the support server! https://discord.gg/VBDhRc8
Project Summary
Create flexible, understandable and performant Discord reaction menus with ease. This package is an addon for Discord.js that automates all aspects of a reaction-based navigation menu.
Besides creating it, of course. It'd be pretty useless if you couldn't create the menus yourself.
Here's a fast, fully-featured demo of Discord.js-menu. With one read-through of this demo, you should have all you need to create your own menus from scratch.
All values have TypeScript / TSDoc types, so if you use an editor like VSCode, you should get real-time code suggestions and tooltips where appropriate.
const { Client, MessageEmbed } = require('discord.js')
const { Menu } = require('discord.js-menu')
const client = new Client()
client.on('message', message => {
if (message.content === "!help") {
let helpMenu = new Menu(message.channel, message.author.id, [
{
name: 'main',
content: new MessageEmbed({
title: 'Help Menu',
description: 'This is some helpful info!',
fields: [
{
name: "Command: Ban",
value: "This command bans people.",
inline: true
}
]
}),
reactions: {
'😳': 'extra',
'😀': async () => {
let res = await message.channel.send("Hey-")
setTimeout(() => {
return res.edit("listen!")
}, 1000)
}
}
},
{
name: 'extra',
content: new MessageEmbed({
title: 'Extra menu',
description: 'This is another page.'
}),
reactions: {
'711632156497019021': 'main',
'711840938303847401': 'delete',
}
}
], 300000)
helpMenu.start()
helpMenu.on('pageChange', destination => {
destination.content.title = "Hey, " + message.author.username
})
}
})
client.login("Get your bot's oauth token at https://discord.com/developers/applications")
You get the idea.
Special Destinations
You may have noticed I mentioned "special destinations" above.
Discord.js-menu comes with 6 pre-defined destinations with specific uses.
Destination | Function |
---|
first | Goes to the first page in the array. |
last | Goes to the last page in the array. |
previous | Goes to the previous page in the array. |
next | Goes to the next page in the array. |
stop | Removes reactions from the embed and stops updating the menu. |
delete | Stops the menu and deletes the message. |
Note that whilst calling a page one of these wouldn't break anything (the page would still be accessible using, ironically, the special destinations) you wouldn't be able to directly link to it.
Contributing
Right now, the development pipeline is super simple. The Standard code style is used to keep styling consistent, but besides that, there's not much going on.
Feel free to PR anything you think others would find useful. I'll gladly approve new contributions!
Acknowledgements
Some parts of this project were inspired by Juby210's discord.js-reaction-menu.
Thank you to Juby210 for releasing their code to the public and thus inspiring me to create my own implementation!