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

enerthya.dev-pudding

v1.0.0

Published

Database abstraction layer for Enerthya — wraps all Mongoose schemas into a single injectable PuddingClient

Readme

enerthya.dev-pudding

Camada de abstração de banco de dados para a Enerthya. Inspirado em pudding:client (MrPowerGamerBR / LorittaBot).

Encapsula todos os schemas Mongoose em um único PuddingClient injetável. Comandos e handlers chamam métodos do pudding em vez de importar schemas diretamente — mantendo a lógica de negócio desacoplada da camada de banco.

Zero dependências externas. Os schemas Mongoose são injetados na construção.


Por que usar

Sem pudding, um comando faz:

const { getSettings }  = require("@schemas/Guild");
const { getMember }    = require("@schemas/Member");
const { addModLogToDb } = require("@schemas/ModLog");

Com pudding, qualquer handler recebe um único objeto:

const settings = await pudding.getGuild(guild);
const member   = await pudding.getMember(guildId, memberId);
await pudding.addModLog(admin, target, reason, "BAN");

Vantagens: testável com mocks, sem imports espalhados, método incrementXP agrega a lógica de XP + level-up em uma chamada só.


Uso básico

const { PuddingClient } = require("enerthya.dev-pudding");

// bot.js — criar uma vez após conectar ao banco
const pudding = new PuddingClient(EnerthyaCore.schemas);
pudding.enableXpCooldown(); // ativa o cache de cooldown de XP

// Em qualquer handler ou comando:
const settings = await pudding.getGuild(guild);
const member   = await pudding.getMember(guildId, memberId);
const { leveledUp, newLevel } = await pudding.incrementXP(guildId, memberId, xpAmount);
await pudding.addModLog(admin, target, reason, "BAN");

API completa

Guild

| Método | Parâmetros | Retorno | |--------|-----------|---------| | getGuild(guild) | Discord Guild | Promise<doc> | | clearGuildCache(guildId) | string | void |

User

| Método | Parâmetros | Retorno | |--------|-----------|---------| | getUser(user) | Discord User | Promise<doc> | | getReputationLb(limit?) | number | Promise<doc[]> | | getEconomyGlobalLb(limit?) | number | Promise<doc[]> | | getEconomyLocalLb(memberIds, limit?) | string[], number | Promise<doc[]> |

Member (invites, strikes)

| Método | Parâmetros | Retorno | |--------|-----------|---------| | getMember(guildId, memberId) | string, string | Promise<doc> | | getInvitesLb(guildId, limit?) | string, number | Promise<doc[]> |

MemberStats (XP, level, atividade)

| Método | Parâmetros | Retorno | |--------|-----------|---------| | getMemberStats(guildId, memberId) | string, string | Promise<doc> | | getXpLb(guildId, limit?) | string, number | Promise<doc[]> | | incrementXP(guildId, memberId, amount, options?) | string, string, number, object | Promise<{ doc, leveledUp, newLevel }> | | enableXpCooldown() | — | void |

ModLog

| Método | Parâmetros | Retorno | |--------|-----------|---------| | addModLog(admin, target, reason, type) | GuildMember, GuildMember|User, string, string | Promise<doc> | | getWarnings(guildId, targetId) | string, string | Promise<doc[]> | | clearWarnings(guildId, targetId) | string, string | Promise<object> | | getAllWarnings(guildId) | string | Promise<doc[]> | | deleteWarn(guildId, warnId) | string, string | Promise<doc\|null> |

ReactionRoles

| Método | Parâmetros | Retorno | |--------|-----------|---------| | cacheReactionRoles(client) | Discord Client | Promise<void> | | getReactionRoles(guildId, channelId, messageId) | string, string, string | { emote, role_id }[] | | addReactionRole(guildId, channelId, messageId, emote, roleId) | strings | Promise<void> | | removeReactionRole(guildId, channelId, messageId) | string, string, string | Promise<void> |

Suggestions

| Método | Parâmetros | Retorno | |--------|-----------|---------| | addSuggestion(message, userId, suggestion) | Message, string, string | Promise<doc> | | findSuggestion(guildId, messageId) | string, string | Promise<doc\|null> | | deleteSuggestion(guildId, messageId, memberId, reason) | strings | Promise<doc> |

Partnerships

| Método | Parâmetros | Retorno | |--------|-----------|---------| | addPartnership(messageId, guildId, data) | string, string, object | Promise<doc> | | getPartnerships(guildId) | string | Promise<doc[]> | | getPartnership(messageId) | string | Promise<doc\|null> | | removePartnership(messageId, guildId) | string, string | Promise<doc\|null> | | removePartnershipsByRep(guildId, repId) | string, string | Promise<string[]> | | countPromoterPartnerships(guildId, promoterId) | string, string | Promise<number> | | getPartnershipRank(guildId) | string | Promise<{ _id, total }[]> |

Starboard

| Método | Parâmetros | Retorno | |--------|-----------|---------| | findStarboardEntry(guildId, messageId) | string, string | Promise<doc\|null> | | upsertStarboardEntry(guildId, messageId, channelId, starMsgId, starCount, authorId?) | strings, number | Promise<doc> | | updateStarCount(guildId, messageId, starCount) | string, string, number | Promise<doc> | | deleteStarboardEntry(guildId, messageId) | string, string | Promise<doc> |

SavedEmbeds

| Método | Parâmetros | Retorno | |--------|-----------|---------| | saveEmbed(guildId, name, embedData, componentsData) | string, string, object, array | Promise<doc> | | loadEmbed(guildId, name) | string, string | Promise<doc\|null> | | listEmbeds(guildId) | string | Promise<{ name, created_at }[]> | | deleteEmbed(guildId, name) | string, string | Promise<boolean> |

AutomodLogs

| Método | Parâmetros | Retorno | |--------|-----------|---------| | addAutoModLog(member, content, reason, strikes) | GuildMember, string, string, number | Promise<void> |

TranslateLog

| Método | Parâmetros | Retorno | |--------|-----------|---------| | isTranslated(message, code) | Message, string | Promise<doc\|null> | | logTranslation(message, code) | Message, string | Promise<doc> |

Giveaways

| Getter | Retorno | |--------|---------| | giveawayModel | Mongoose model (gerenciado pelo discord-giveaways) |


SCHEMA_KEYS

const { SCHEMA_KEYS } = require("enerthya.dev-pudding");

// Constantes para evitar typos:
SCHEMA_KEYS.GUILD          // "Guild"
SCHEMA_KEYS.MEMBER_STATS   // "MemberStats"
SCHEMA_KEYS.TRANSLATE_LOG  // "TranslateLog"

// Validação antes de inicializar:
SCHEMA_KEYS.REQUIRED.forEach(key => {
  if (!schemas[key]) throw new Error(`Schema obrigatório ausente: ${key}`);
});

Como o bot inicializa

// src/structures/EnerthyaCore.js
const { PuddingClient } = require("enerthya.dev-pudding");

// Após conectar ao banco:
const pudding = new PuddingClient(EnerthyaCore.schemas);
pudding.enableXpCooldown();

// Exponha no client para uso nos handlers:
client.pudding = pudding;

Estrutura

src/
├── index.js                      ← Exporta PuddingClient e SCHEMA_KEYS
├── structures/
│   └── PuddingClient.js          ← Classe principal — 13 schemas cobertos
└── constants/
    └── schemaKeys.js             ← Constantes de chave + REQUIRED + OPTIONAL
test.js                           ← 64 testes — node test.js (0 falhas)

Testes

node test.js
# Results: 64 passed, 0 failed

Todos os schemas são testados com mocks em memória — sem Mongoose, sem conexão de banco.