Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

discord-buttons

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-buttons

Discord.js buttons

  • 2.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
807
decreased by-35.75%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version NPM downloads

NPM Banner



Install

$ npm i discord-buttons

Setup

const discord = require('discord.js'); //Define the discord.js module
const client = new discord.Client(); //Creating discord.js client (constructor)
const disbut = require('discord-buttons')(client);

For more examples check our Documentation


Example

let button = new disbut.MessageButton()
  .setStyle('red') //default: blurple
  .setLabel('My First Button!') //default: NO_LABEL_PROVIDED
  .setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
  .setDisabled(); //disables the button | default: false

message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', button);

Multiple Buttons

let button = new disbut.MessageButton()
  .setStyle('red') //default: blurple
  .setLabel('My First Button!') //default: NO_LABEL_PROVIDED
  .setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
  .setDisabled(); //disables the button | default: false

let button2 = new disbut.MessageButton()
  .setStyle('url') //default: blurple
  .setLabel('My Second Button!') //default: NO_LABEL_PROVIDED
  .setURL('[click_to_function](https://npmjs.com/discord-buttons)') //note: if you use other style you must provide id using .setID('myid')

message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', {
  buttons: [
    button, button2
  ]
});

With embed

let myembed = new discord.MessageEmbed()
  .setDescription('Hi!');

let btn = new disbut.MessageButton()
  .setStyle('red') //default: blurple
  .setLabel('My First Button!') //default: NO_LABEL_PROVIDED
  .setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
  .setDisabled(); //disables the button | default: false

message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', { button: btn, embed: myembed });

Using command handler?

const { MessageButton } = require('discord-buttons');

module.exports = {
    name: 'test',
    run: async (client, message, args) => {
        let button = new disbut.MessageButton()
          .setStyle('red') //default: blurple
          .setLabel('My First Button!') //default: NO_LABEL_PROVIDED
          .setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com')
          .setDisabled(); //disables the button | default: false

        await message.channel.send('Hey, i am powered by https://npmjs.com/discord-buttons', button);
    }
}

Handle Button

client.on('clickButton', async (button) => {
  if (button.id === 'click_to_function') {
    button.channel.send(`${button.clicker.user.tag} clicked button!`);
  }
});

Note: don't forgot to put require('discord-buttons')(client) after your client


Documentation

Checkout more examples on our docs


Don't see the buttons?

The buttons are beta, so to see them you have to be a discord-tester or just wait for the update


For any questions or errors, join in our server and report the bug on the #errors channel https://discord.gg/5JtyYqW


Contact

Youtube, Discord

Keywords

FAQs

Package last updated on 24 May 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc