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

spacebar

v13.1.1-dev

Published

A powerful library for interacting with the Discord API

Downloads

2

Readme

About

fosscord.js is a fork of discord.js that allows you to easily interact with the Fosscord API and is backwards compatible to discord.js.

Fosscord.js

  • Object-oriented
  • Predictable abstractions
  • Performant
  • 100% coverage of the Fosscord API

Additions

  • User only features (video/screenshare)
  • Voice support for browser

Installation

Node.js 16.6.0 or newer is required.

npm install fosscord.js
yarn add fosscord.js
pnpm add fosscord.js

Without voice support: npm install fosscord.js
With voice support (@discordjs/opus): npm install fosscord.js @discordjs/opus
With voice support (opusscript): npm install fosscord.js opusscript

Audio engines

The preferred audio engine is @discordjs/opus, as it performs significantly better than opusscript. When both are available, fosscord.js will automatically choose @discordjs/opus. Using opusscript is only recommended for development environments where @discordjs/opus is tough to get working. For production bots, using @discordjs/opus should be considered a necessity, especially if they're going to be running on multiple servers.

Optional packages

  • zlib-sync for WebSocket data compression and inflation (npm install zlib-sync)
  • erlpack for significantly faster WebSocket data (de)serialisation (npm install discord/erlpack)
  • bufferutil for a much faster WebSocket connection (npm install bufferutil)
  • utf-8-validate in combination with bufferutil for much faster WebSocket processing (npm install utf-8-validate)
  • @discordjs/voice for interacting with the Discord Voice API

Example usage

Install all required dependencies:

npm install fosscord.js @discordjs/rest discord-api-types
yarn add fosscord.js @discordjs/rest discord-api-types
pnpm add fosscord.js @discordjs/rest discord-api-types

Register a slash command against the Discord API:

const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');

const commands = [
  {
    name: 'ping',
    description: 'Replies with Pong!',
  },
];

const rest = new REST({ version: '9' }).setToken('token');

(async () => {
  try {
    console.log('Started refreshing application (/) commands.');

    await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands });

    console.log('Successfully reloaded application (/) commands.');
  } catch (error) {
    console.error(error);
  }
})();

Afterwards we can create a quite simple example bot:

const { Client, Intents } = require('fosscord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;

  if (interaction.commandName === 'ping') {
    await interaction.reply('Pong!');
  }
});

client.login('token');

Links

Extensions

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.
See the contribution guide if you'd like to submit a PR.

Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official fossccord.js Server.