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

rich-presence-builder

v0.1.1

Published

Easily create a Discord Rich Presence.

Downloads

8

Readme

Rich Presence Builder

Easily build and create a Discord Rich Presence that can also be dynamic and update on an interval, with buttons!

Step 1

Install rich-presence-builder: npm i rich-presence-builder

And that's it! You can now start making cool presences with ease

Example

How to use

First create a file and import the package.

const RichPresence = require("rich-presence-builder")

Then, create a new rich presence and add what you need. Use .go() when complete

new RichPresence()
  .setState("I am in a state of panic")
  .setDetails("Made with rich-presence-builder")
  .addButton("discord home", "https://discord.com")
  .go()

After running the file, it should look something like this:

Example

  • You can also use then/await:
await new RichPresence().setDetails("I have awaited B)")
// or
new RichPresence()
  .setDetails("then what?")
  .then(rpc => console.log(rpc.details)) // "then what?"
  • You can also use the constructor to define values:
await new RichPresence({
  state: "I am in a state of panic",
  details: "yes",
  timeLeft: 60000,
  buttons: [{ label: "click me", url: "https://discord.com" }]
})
  • Everything can also be dynamic:
const rp = new RichPresence()
await rp.setState(() => `${Date.now().toLocaleTimeString()}: staying alive`)
  • You can use intervals:
// updates every 15s
await new RichPresence().setState(() => `${Date.now().toLocaleTimeString()}: staying alive`).interval()

even with a limit

// stops updating after 10 updates
await new RichPresence().setState(() => `${Date.now().toLocaleTimeString()}: staying alive`).interval(10)
  • You can use timestamps:
await new RichPresence().setElapsedTime(60) // 00:01:00 elapsed
// or
await new RichPresence().setTimeLeft(60) // 00:01:00 left

// or you can do it the old-fashioned way:
await new RichPresence().setStartTimestamp(Date.now()) // 00:00:00 elapsed
// or
await new RichPresence().setEndTimestamp(Date.now()) // 00:00:00 left
  • You can even reuse the same RichPresence:
const rp = new RichPresence
await rp.setState("saying hello")
// soon
await rp.setState("saying goodbye").setDetails("it's time to go").addButton("say goodbye")
  • You can also clear your presence if you need to:
await rp.clear()
// clear() doesn't have to remove your presence, it can also be used to clear data:
await rp.clear().setState("clean presence")

Images

If you wish to use images, please use your own application:

new RichPresence({ clientID: "383226320970055681" })
  .setLargeImage("js", "JavaScript")
  .setSmallImage("python", "Python")
  .go()

You can create an application on Discord's Developer Portal.