discord-friendly-components

0.0.1 • Public • Published

Documentation

BTW make sure your using the discord.js@dev version i have no clue if it works with discord-buttons or any other button packages.

And thats only because i've mostly done all my button coding on python 😛


I Do Have an Example Already made in the Example folder so if you need a reference you can look at that also this link should take you to the video where the example was in use.

Create Custom ID (This is how you'll save the data)

const ComponentFriend = require('../src/index');
const friend = new ComponentFriend("./save.json");

// the data you want to save
const data = {
  "hello": "world"
}

// put the data you want to save in the first argument position
// returns the custom id that the data was saved under
const id = friend.CreateCustomID(data)

Send The Button With the id

// take the id we created in the last example and put it inside the setCustomId

let button = new Discord.MessageButton()
    .setCustomId(id)
    .setLabel("Click Me")
    .setStyle("SUCCESS");

message.channel.send("buttons!", { components: [ [button] ] });

Read the Data

client.on('interactionCreate', async (interaction) => {
  // this will get the data we saved from above
  const data = friend.GetCustomID(interaction.customId);
  // now we should be able to send whatever text we saved in the "hello" property
  await interaction.reply(data.hello);
});

Edit the Data

  //lets take the doc from above and just change it a bit

client.on('interactionCreate', async (interaction) => {
  // this will get the data we saved from above
  const data = friend.GetCustomID(interaction.customId);
  // now we should be able to send whatever text we saved in the "hello" property
  await interaction.reply({ content: data.hello, ephemeral: true });

  // now when they call it again it'll change the message to say no
  friend.EditCustomID(interaction.customId, { 'hello': 'no' })
});

Package Sidebar

Install

npm i discord-friendly-components

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

7.99 kB

Total Files

4

Last publish

Collaborators

  • amashi