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 🙏

© 2026 – Pkg Stats / Ryan Hefner

discord-prevnames

v1.0.2

Published

Unofficial Discord module to track and retrieve users' previous usernames and display names by ID .

Readme

🎮 Discord PrevNames

Track Discord username & display name changes in real-time with this unofficial module

License Version Platform Node Database Documentation

📚 Documentation

Full documentation available at: https://docs.discprev.xyz

🚀 Overview

Discord PrevNames is an unofficial module that allows you to track and retrieve Discord users' previous usernames and display names. Using Server-Sent Events (SSE), it provides real-time notifications when users change their names and maintains a historical record of these changes. With over 5 million previous names stored in our database, we offer one of the largest Discord name history tracking services available.

✨ Key Features

  • Real-time Monitoring - Get instant notifications when users change their names
  • Display Name Tracking - Track display name changes in real-time
  • Event-Driven Architecture - Built with EventEmitter for easy event handling
  • Automatic Reconnection - Maintains stable connection with automatic retry mechanism
  • Simple API - Easy-to-use methods for retrieving user history

📦 Installation

npm install discord-prevnames

🎯 Quick Start

const PrevNames = require('discord-prevnames');

async function main() {
    const prevnames = new PrevNames();

    // Listen for name changes
    prevnames.on('prevnamesadd', (data) => {
        console.log('Name change detected:', {
            userId: data.userId,
            type: data.type,
            previousName: data.name,
            changedAt: data.changedAt
        });
    });

    // Get user's name history
    try {
        const history = await prevnames.getUserPrevnames('USER_ID');
        console.log('User history:', history);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

main().catch(console.error);

📊 Event Data Structure

interface NameChangeEvent {
    userId: string;          // Discord User ID
    type: 'displayname';     // Type of name change
    name: string;           // Previous name
    changedAt: string;      // Timestamp of change
}

🔧 API Reference

For complete API documentation, visit https://docs.discprev.xyz

Below is a quick overview of the main features:

Class: PrevNames

Constructor

const prevnames = new PrevNames();

Methods

.on(eventName, callback)

  • Listen for name change events
  • Returns an unsubscribe function
const unsubscribe = prevnames.on('prevnamesadd', (data) => {
    console.log('New name change:', data);
});

// Later, to stop listening
unsubscribe();

.getUserPrevnames(userId)

  • Retrieve user's name history
  • Throws error if userId is invalid
async function getUserHistory() {
    try {
        const history = await prevnames.getUserPrevnames('123456789');
        console.log('History:', history);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

.stop()

  • Stop listening to name change events
  • Removes all event listeners
prevnames.stop();

🌐 API Endpoints

The module interacts with the following endpoints:

GET  /api/users/:userId/prevnames    # Get user's name history
GET  /api/webhooks/prevnames/listen  # Stream real-time name changes

🔐 Error Handling

The module includes built-in error handling for:

  • Invalid user IDs
  • Network connection issues
  • API response errors
  • Event stream disruptions
async function handleUserHistory() {
    try {
        const history = await prevnames.getUserPrevnames('invalid_id');
    } catch (error) {
        console.error('Error:', error.message); // "User ID invalid"
    }
}

📈 Advanced Usage

Handling Different Name Change Types

async function trackNameChanges() {
    const prevnames = new PrevNames();
    
    prevnames.on('prevnamesadd', (data) => {
        if (data.type === 'displayname') {
            console.log(`Display name change for user ${data.userId}`);
            console.log(`Previous name: ${data.name}`);
            console.log(`Changed at: ${new Date(data.changedAt).toLocaleString()}`);
        }
    });
    
    // Example of fetching history alongside listening to changes
    try {
        const history = await prevnames.getUserPrevnames('123456789');
        console.log('Initial history:', history);
    } catch (error) {
        console.error('Error fetching history:', error.message);
    }
}

trackNameChanges().catch(console.error);

Auto-Reconnection Handling

The module automatically handles disconnections and reconnects with a 3-second delay:

// The module will automatically:
// 1. Detect disconnections
// 2. Wait 3 seconds
// 3. Attempt to reconnect
// 4. Resume event streaming

🛠️ Future Features

  • [ ] Username change tracking
  • [ ] Bulk history retrieval
  • [ ] Customizable retry intervals
  • [ ] Rate limiting protection
  • [ ] Filtered event listening
  • [ ] Historical data analysis

🤝 Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

📝 License

ISC © Discord Prevnames