2.4.4 • Published 4 years ago

weird-ds-buttons v2.4.4

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 years ago

Install

$ npm i weird-ds-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('weird-ds-buttons')(client);

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/weird-ds-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/weird-ds-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/weird-ds-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/weird-ds-buttons', { button: btn, embed: myembed });

Using command handler?

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

module.exports = {
    name: 'test',
    run: async (client, message, args) => {
        let button = new 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/weird-ds-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('weird-ds-buttons')(client) after your client

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 #bug channel https://discord.gg/MynKf9VsTt

Contact

Discord