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

discord-deleted-users-message-remover

v1.0.3

Published

Remove messages of deleted discord users from text channels

Downloads

23

Readme

Discord Deleted Users Message Remover

In Discord if a user get's deleted (or the account is closed) the messages of the user won't get deleted from the server.

This script uses Discord.js to search through all text channels configured in the config.json and deletes all messages where the user is a "Deleted User".

Use in existing discord.js project

To use the "Deleted Users Messages" server cleaner run npm i discord-deleted-users-message-remover and import the serverCleanerBot function into your code. Then add the function to your client ready function.

import { serverCleanerBot } from 'discord-deleted-users-message-remover';

// Configuration
const cleanChannelNames = [];
const excludeChannelNames = ["mods", "welcome"];

// Add the serverCleanerBot function to your client ready function
client.on(Events.ClientReady, async bot => {
    await serverCleanerBot(bot, cleanChannelNames, excludeChannelNames);
});

Standalone usage

Install Node.js® if you haven't already, then clone or download and unzip this repository. After that run npm i in the directory containing the files using a shell.

Now create a discord bot and add the bot to your server.

Rename the config.example.json to config.json and set the Discord API token of your bot in token.

Then configure the list of text channels that you want to clean in cleanChannelNames.

Example:

{
    "token": "ThIsIsYouRsecret.disCorD.apI-ToKendoNotShareIt",
    "cleanChannelNames": [
        "welcome",
        "news",
        "memes"
    ],
    "excludeChannelNames": []
}

If you want the script to delete the messages of deleted users in all text channels leave the cleanChannelNames array empty. You can configure channels to exclude from the run, or leave the excludeChannelNames array empty.

Example:

{
    "token": "ThIsIsYouRsecret.disCorD.apI-ToKendoNotShareIt",
    "cleanChannelNames": [],
    "excludeChannelNames": [
        "mods",
        "admins"
    ]
}

After the configuration just run the script with node (node main or npm start). The console output will tell you what is happening.

Limitations

Currently only text channels can be cleaned. Maybe I will change that in the next version. Just create an issue if you need improvements.

Discords API rate limits

The Discord API has rate limitations so the script will be slow and pause from time to time if the rate limit is reached. The script will continue after the rate limit is gone. Be patient!

Why no bulk delete

The script only deletes single messages and does not use a bulk delete feature by design. Bulk deletion of messages is only possible for messages that are not older than 2 weeks (Discord API limitation).