hazre / songcard

A simple package to create song card when play songs using discord music bot.

Home Page:https://www.npmjs.com/package/songcard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

songcard (fork)

This is a fork of Songcard Library but modified to use ESM, instead of CommonJS


A simple package to create song card when play songs in discord.

NPM version

NPM Banner

This package was originally used only for my personal needs to generate a song card when users play songs using my Discord bot, but then I decided to make this package open source and let everyone use it.


Install

npm install songcard
# or
yarn add songcard

Example

const createCard = require("songcard"); // Import
const { AttachmentBuilder } = require("discord.js");

client.on("interactionCreate", async (message) => {
    
    const cardImage = await createCard(
        imageBg =  "https://images-ext-1.discordapp.net/external/uw_-bWFyeXnWb11wGThe2CAbTYdrxzFqMJ2trxDIYVE/https/i.scdn.co/image/ab67616d0000b2738ad8f5243d6534e03b656c8b?width=468&height=468",
        imageText = "Die For You (with Ariana Grande) - Remix",
        trackStream = false,
        trackDuration = 220000,
        trackTotalDuration = 233000,
    );

    const attachment = new AttachmentBuilder(cardImage, {
        name: "card.png",
    });

    interaction.channel.send({
        files: [attachment],
    });
});

client.login("token");

Usage

Option Type Description
imageBg String Image that will be display to the songcard.

Example: https://images-ext-1.discordapp.net/external/uw_-bWFyeXnWb11wGThe2CAbTYdrxzFqMJ2trxDIYVE/https/i.scdn.co/image/ab67616d0000b2738ad8f5243d6534e03b656c8b?width=468&height=468
File format: PNG/JPEG
imageText String Text that will be display to the songcard.
trackStream Boolean Whether to set the trackDuration and trackTotalDuration to LIVE

Example: if trackStream is true the trackDuration and totalTrackDuration will show as LIVE else it will show number.
trackDuration Integer Show current duration of the songs. If no value provide it will show 0:00.
trackTotalDuration Integer Show the songs duration.



About

A simple package to create song card when play songs using discord music bot.

https://www.npmjs.com/package/songcard

License:ISC License


Languages

Language:JavaScript 100.0%