Skip to content

voctal/plume-api.js

Repository files navigation

Plume API.js

Discord server npm version npm downloads Last commit

About

@voctal/plume-api is a module that allows you to easily use Plume API. See the module docs, and the API docs to understand how to use it.

Installation

Node.js 22 or newer is required.

npm install @voctal/plume-api

Example usage

If you are developing a Discord bot using discord.js, here is how to use Plume API:

const { Client } = require("discord.js");
const { PlumeAPI } = require("@voctal/plume-api");

// Your discord.js client
const client = new Client({
    /* ... */
});

// Attach PlumeAPI to your client
client.plumeAPI = new PlumeAPI();

You can now use Plume API anywhere in your bot.
For example, in a slash command:

async execute(interaction) {
    const client = interaction.client;

    // Query the API
    const joke = await client.plumeAPI.joke();

    // Show the response
    await interaction.reply(
        `Question: ${joke.question}`
        + `\nAnswer: ||${joke.answer}||`
    );
}

To send an image received from the API, you can use the AttachmentBuilder class from discord.js:

const { AttachmentBuilder } = require("discord.js");

async execute(interaction) {
    const client = interaction.client;

    // Since downloading the image can take some time
    // depending on your connection speed, you should defer.
    await interaction.deferReply();

    const buffer = await client.plumeAPI.facts("PlumeAPI is the best API");
    const attachment = new AttachmentBuilder(buffer, { name: "image.png" });

    await interaction.editReply({ files: [attachment] });
}

Documentation

Plume API provides two main resources for documentation:

  • API Reference:
    Plume API Documentation
    This documentation covers all available endpoints, types, and detailed comments for the API.

  • Module Reference:
    Module Documentation
    This documentation explains how to use the @voctal/plume-api npm package, with all available methods and types.

For most use cases, you'll want to refer to the PlumeAPI class page, which lists all available methods for interacting with the API through this module.

Links

Help

Need help with the module? Ask on our support server!

About

The official Plume API JavaScript wrapper

Topics

Resources

License

Stars

Watchers

Forks

Contributors