discord-buttons-pe

1.0.3-beta • Public • Published

NPM version NPM downloads

NPM Banner



This version is just discord-buttons but a little modified for my personnal use

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)
require('discord-buttons')(client); //Starting the discord-buttons class

Example

const discord = require('discord.js');
const client = new discord.Client();
require('discord-buttons')(client);

client.on('ready', () => console.log(client.user.tag));

client.on('message', message => {
    if (message.content.startsWith('!button')) {

        message.buttons('Hello World!', {
            buttons: [
                {
                    style: 'green',
                    label: 'Click to function!',
                    id: 'click_to_function'
                },
                {
                    style: 'url',
                    label: 'Vote for me!',
                    url: 'https://npmjs.com/top.gg-core'
                }
            ]
        })
    }
})

client.login("TOKEN");

When button is clicked

client.on('clickButton', button => {
    if (button.id === 'click_to_function') {
      button.message.channel.send(button.clicker.user.tag)
    }
});

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

Package Sidebar

Install

npm i discord-buttons-pe

Weekly Downloads

5

Version

1.0.3-beta

License

Apache-2.0

Unpacked Size

12.7 kB

Total Files

4

Last publish

Collaborators

  • gaetan20