npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sunday.ts

v1.1.4

Published

Sunday a lavalink wrapper

Downloads

615

Readme

Status GitHub Issues GitHub Pull Requests License


📝 Table of Contents

🧐 About

Sunday a lavalink wrapper for ( NodeJS, Bun )

🏁 Getting Started

Installing

To install Sunday.ts, follow these steps:

  1. Open your terminal or command prompt.
  2. Navigate to the root directory of your project.
  3. Run the following command to install Sunday.ts:
bun i sunday.ts

This will install Sunday.ts and its dependencies.

  1. Once the installation is complete, you can import Sunday.ts into your project and start using it.

That's it! You have successfully installed Sunday.ts and are ready to start using it in your Node.js project.

Features

  • [x] SearchCache

🎈 Usage

import { Client } from "discord.js";
import { Manager } from "sunday.ts";
import "dotenv/config";

let client = new Client({
    intents: [
        "Guilds",
        "GuildMembers",
        "MessageContent",
        "GuildMessages",
        "GuildVoiceStates"
    ],
});
let manager = new Manager({
    nodes: [
        {
            host: 'localhost',
            port: 2333,
            password: 'youshallnotpass',
            resumeStatus: true,
        },
    ],
    caches: {
        enabled: true,
        time: 60000,
    },
    clientId: "1234567890",
    send(guild_id, payload) {
        const guild = client.guilds.cache.get(guild_id);
        if (guild) guild.shard.send(payload);
    },
});

manager.on("NodeConnect", (node) => {
    console.log(`Node ${node.options.host} connected`);
});
manager.on("NodeRaw", async (node) => {
    console.log(`sent raw data: ${JSON.stringify(node)}`);
});
manager.on("PlayerCreate", (player) => {
    console.log(`Player created in guild ${player.guild}`);
});
manager.on("NodeError" , (node, error) => {
    console.log(`Node ${node.options.host} has an error: ${error.message}`);
});
client.on("messageCreate", async (message) => {
    if (message.author.bot) return;
    const start = performance.now();
    const [command, ...args] = message.content.slice(0).split(/\s+/g);
    if (command === 'play') {
        if (!message.member?.voice.channel) return message.reply('you need to join a voice channel.');
        if (!args.length) return message.reply('you need to give me a URL or a search term.');
        const search = args.join(' ');
        let res;
        let end;
        try {
            // Search for tracks using a query or url, using a query searches youtube automatically and the track requester object
            res = await manager.search({query: search});
            end = `Time took: ${Math.round(performance.now() - start)}ms.`;
            // Check the load type as this command is not that advanced for basics
            if (res.loadType === 'empty') throw res;
            if (res.loadType === 'playlist') {
                throw { message: 'Playlists are not supported with this command.' };
            }
        } catch (err) {
            return message.reply(`there was an error while searching: ${err}`);
        }

        if (res.loadType === 'error') {
            return message.reply('there was no tracks found with that query.');
        }

        // Create the player
        const player = manager.create({
            guild: message.guild?.id as string,
            voiceChannel: message.member?.voice.channel.id,
            textChannel: message.channel.id,
            volume: 100,
        });

        // Connect to the voice channel and add the track to the queue
        player.connect();
        await player.queue.add(res.tracks[0]);
        // Checks if the client should play the track if it's the first one added
        if (!player.playing && !player.paused && !player.queue.size) player.play();

        return message.reply(`enqueuing ${res.tracks[0].title}. ${end}`);
    }
});
manager.on("SearchCacheClear" , (key: string,  values) => {
    console.log(`Cache cleared for ${key} with values: ${values}`);
});
client.on("raw", (data) => manager.updateVoiceState(data));
client.on("ready" , () => {
    manager.init(client.user?.id as string);
    console.log(`Logged in as ${client.user?.tag} | Memory usage: ${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`);
});
client.login(process.env.TOKEN);

Credits

Star History

Star History Chart

See also the list of contributors who participated in this project.