Socket
Socket
Sign inDemoInstall

discord.js-better-buttons

Package Overview
Dependencies
31
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    discord.js-better-buttons

A package for discord.js that makes message buttons easy to use


Version published
Weekly downloads
10
increased by400%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

PLEASE DO NOT USE THIS PACKAGE YET ITS NOT FINISHED!!!!!!!!

About

discord.js-better-buttons is a package that makes message buttons easier (and fun) to use.

Features

  • a

Installation

npm i discord.js discord.js-better-buttons

Example Comparison

If you want to create and use a button with just discord.js, here's how you currently do it:

const row = new Discord.MessageActionRow()
	.addComponents(
		new Discord.MessageButton()
			.setLabel('My button')
			.setCustomId('mybutton')
			.setStyle('PRIMARY'),
	);

await interaction.reply({ content: 'Here\'s a button!', components: [row] });

const filter = i => i.user.id == interaction.user.id;

const collector = interaction.channel.createMessageComponentCollector({ filter, time: 15000 });

collector.on('collect', async i => {
	if (i.customId == 'mybutton') {
		console.log('A button was clicked!');
	}
});

That's cool and all, but it could be better. Here's how you can create and send a button using discord.js-better-buttons:

const { Button, ButtonBundle, ButtonPackage, ButtonStyles } = require('discord.js-better-buttons');

const button = new Button({ label: 'My button', style: ButtonStyles.primary });
const bundle = new ButtonBundle([ button ]);
const package = new ButtonPackage([ bundle ], interaction.client);

button.on('click', async i =>{
	console.log('A button was clicked!');
});

await interaction.reply({ content: 'Here\'s a button!', components: package.format() });

Yes, yes, I know. It's amazing. But you know what's even more amazing? Your code, once you start using this package!

FAQs

Last updated on 03 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc