0.0.1 • Published 3 years ago

discord-friendly-components v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Documentation

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)
// 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] ] });
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);
});
  //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' })
});