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

sdb-getall

v1.2.1

Published

A lightweight and optimized library for discord.js that simplifies retrieving objects from Discord managers

Downloads

46

Readme

sdb-getall

sdb-getall is a lightweight and optimized library for discord.js version 14 and above. It simplifies the process of retrieving various objects from manager classes in discord.js. This library is fully typed with JSDoc, making it suitable for bots of any size.

Installation

npm install sdb-getall

Dependencies

  • discord.js version 14+
  • Node.js version 16+

Usage Example

const allGet = require("sdb-getall");
const Discord = require("discord.js");
const bot = new Discord.Client({ intents: 47007 });

bot.once("ready", async (client) => {
    const guild = await allGet.getGuild(client, "785107327413911592");
    console.log(guild);

    console.log(await allGet.getUser(client, "785082790089719828"));
    console.log(await allGet.getChannel(client, "1157047546657652786"));
    console.log(await allGet.getEmoji(client, "1260198905564499990"));
    console.log(await allGet.getTextChannel(client, "1157047546657652786"));
    console.log(await allGet.getVoiceChannel(client, "1247459651436548168"));
    console.log(await allGet.getCategoryChannel(client, "1064500387995983872"));
    console.log(await allGet.getDMChannel(client, "1057686950229852251"));
    console.log(await allGet.getAnyThread(client, "1264927327951912960"));

    if (!guild) return console.log("No guild :(");

    console.log(await allGet.guildGetMember(guild, "785082790089719828"));
    console.log(await allGet.guildGetInvite(guild, "KYpE44UxCP"));
    console.log(await allGet.guildGetBan(guild, "310848622642069504"));
    console.log(await allGet.guildGetPresence(guild, "1090762494366187630"));
    console.log(await allGet.guildGetRole(guild, "1090928583482036275"));
    console.log(await allGet.guildGetSticker(guild, "1265657039728803934"));
    console.log(await allGet.guildGetVoiceState(guild, "509734900182548489"));
});

bot.login(process.env.TOKEN);

Functions

Base Functions

  • baseFetchIfCan(base, id): Attempts to fetch an object if the base has a fetch method.

    const result = await allGet.baseFetchIfCan(client.guilds, "785107327413911592");
  • getAnythingFrom(base, id, fetchOnly = false): Retrieves an object from the base, optionally bypassing the cache.

    const result = await allGet.getAnythingFrom(client.guilds, "785107327413911592", true);

Client Functions

  • getGuild(client, id): Retrieves a Guild by its ID.

    const guild = await allGet.getGuild(client, "785107327413911592");
  • getUser(client, id): Retrieves a User by its ID.

    const user = await allGet.getUser(client, "785082790089719828");
  • getChannel(client, id): Retrieves a Channel by its ID.

    const channel = await allGet.getChannel(client, "1157047546657652786");
  • getTextChannel(client, id): Retrieves a Text Channel by its ID.

    const textChannel = await allGet.getTextChannel(client, "1157047546657652786");
  • getVoiceChannel(client, id): Retrieves a Voice Channel by its ID.

    const voiceChannel = await allGet.getVoiceChannel(client, "1247459651436548168");
  • getCategoryChannel(client, id): Retrieves a Category Channel by its ID.

    const categoryChannel = await allGet.getCategoryChannel(client, "1064500387995983872");
  • getDMChannel(client, id): Retrieves a DM Channel by its ID.

    const dmChannel = await allGet.getDMChannel(client, "1057686950229852251");
  • getAnyThread(client, id): Retrieves any Thread by its ID.

    const thread = await allGet.getAnyThread(client, "1264927327951912960");
  • getEmoji(client, id): Retrieves an Emoji by its ID.

    const emoji = await allGet.getEmoji(client, "1260198905564499990");

Guild Functions

  • guildGetMember(guild, id): Retrieves a Guild Member by its ID.

    const member = await allGet.guildGetMember(guild, "785082790089719828");
  • guildGetInvite(guild, id): Retrieves an Invite by its ID.

    const invite = await allGet.guildGetInvite(guild, "KYpE44UxCP");
  • guildGetBan(guild, id): Retrieves a Ban by its ID.

    const ban = await allGet.guildGetBan(guild, "310848622642069504");
  • guildGetPresence(guild, id): Retrieves a Presence by its ID.

    const presence = await allGet.guildGetPresence(guild, "1090762494366187630");
  • guildGetRole(guild, id): Retrieves a Role by its ID.

    const role = await allGet.guildGetRole(guild, "1090928583482036275");
  • guildGetScheduledEvent(guild, id): Retrieves a Scheduled Event by its ID.

    const event = await allGet.guildGetScheduledEvent(guild, "1265657039728803934");
  • guildGetSticker(guild, id): Retrieves a Sticker by its ID.

    const sticker = await allGet.guildGetSticker(guild, "1265657039728803934");
  • guildGetVoiceState(guild, id): Retrieves a Voice State by its ID.

    const voiceState = await allGet.guildGetVoiceState(guild, "509734900182548489");

Channel Functions

  • channelGetMessage(channel, id): Retrieves a Message by its ID.
    const message = await allGet.channelGetMessage(textChannel, "1265657039728803934");

Notes

Some functions have alternative versions:

  • guildGetChannel(guild, id): Retrieves any Channel in the guild.
  • guildGetTextBasedChannel(guild, id): Retrieves any Text-based Channel in the guild.
  • guildGetVoiceChannel(guild, id): Retrieves any Voice-based Channel in the guild.

These functions are available but may not be as type-safe as their more specific counterparts.

Made with ♥