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

eris-collects

v1.0.0

Published

Collect and Manage Interactions and Messages in Eris

Downloads

36

Readme

Eris Collectors

eris-collects is a package that provides utility classes for collecting interactions and messages in the Eris library. It simplifies the process of collecting and managing interactions and messages from specific channels with customizable filters and time limits.

Installation

You can install the eris-collects package using npm:

npm install eris-collects

Usage

Here is an example of how to use the eris-collects package to create an interaction collector:

const { InteractionCollector } = require('eris-collects');

// Create an instance of the collector
const collector = new InteractionCollector(client, {
  channel: channel, // The channel to collect interactions from
  filter: (interaction) => interaction.data.name === 'ping', // Optional filter function
  time: 60000 // Optional time limit in milliseconds
});

// Listen for the 'collect' event
collector.on('collect', (interaction) => {
  console.log(`Collected interaction ${interaction.id}`);
});

// Listen for the 'end' event
collector.on('end', (interactions, reason) => {
  console.log(`Collector ended. Collected ${interactions.length} interactions. Reason: ${reason}`);
});

// Stop the collector manually
collector.stop("reason");

API

new InteractionCollector(client, options)

Creates a new instance of the InteractionCollector.

  • client (required): The Eris client instance.
  • options (required): An object containing the following properties:
    • channel (optional): The channel to collect interactions from.
    • filter (optional): A function that acts as a filter for the collected interactions. Only interactions that pass the filter will be collected.
    • time (optional): The time limit in milliseconds. The collector will automatically stop after the specified time.

collector.on(event, listener)

Adds an event listener to the collector.

  • event: The name of the event to listen for. Supported events:
    • 'collect': Emitted when an interaction is collected. The listener receives the collected interaction as an argument.
    • 'end': Emitted when the collector ends. The listener receives the collected interactions and the reason for ending as arguments.
  • listener: The function to be called when the event is emitted.

collector.stop([reason])

Stops the collector manually.

  • reason (optional): The reason for stopping the collector. Defaults to "nothing".

collector.emit(event, ...args)

Emits an event with optional arguments.

  • event: The name of the event to emit.
  • args: Optional arguments to pass to the event listeners.

collector.total

A read-only property that returns the total number of collected interactions.

collector.first

A read-only property that returns the first collected interaction.

collector.last

A read-only property that returns the last collected interaction.

MessageCollector

The MessageCollector class allows you to collect messages from a specific channel.

Usage

Here is an example of how to use the MessageCollector class:

const { MessageCollector } = require('eris-collects');

// Create an instance of the collector
const collector = new MessageCollector(client, {
  channel: channel, // The channel to collect messages from
  filter: (message) => message.content.includes('hello'), // Optional filter function
  time: 60000 // Optional time limit in milliseconds
});

// Listen for the 'collect' event


collector.on('collect', (message) => {
  console.log(`Collected message ${message.id}`);
});

// Listen for the 'end' event
collector.on('end', (messages, reason) => {
  console.log(`Collector ended. Collected ${messages.length} messages. Reason: ${reason}`);
});

// Stop the collector manually
collector.stop();

API

The MessageCollector class provides the same methods and properties as the InteractionCollector class. Please refer to the InteractionCollector API documentation for more details.

Sponsors

  • Love what I do? Send me some coffee !? ☕
  • Can't send coffees? Your support will help me to continue working on open-source projects like this. 🙏😇

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 Discord Server .

License

Refer to the LICENSE file.