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

disnovic

v1.0.0

Published

Plugin leve para obter bios, perfis e avatares diretamente da API v10 do Discord.

Readme

Entendido! Para que o GitHub processe a formatação e você copie tudo de uma vez usando apenas o botão do canto superior direito do bloco, o conteúdo total do seu README.md está dentro do bloco único abaixo:

# 🚀 disnovic

O **disnovic** é um plugin leve para Node.js projetado para buscar bios, fotos de perfil, banners e cores de acento de qualquer usuário do Discord utilizando a **Discord HTTP API v10**.

---

## 📦 Instalação

```bash
npm install disnovic

⚙️ Arquivos do Projeto

1. package.json

{
  "name": "disnovic",
  "version": "1.0.0",
  "description": "Plugin leve para obter bios, perfis e avatares diretamente da API v10 do Discord.",
  "main": "index.js",
  "scripts": {
    "test": "node exemplo.js"
  },
  "keywords": [
    "disnovic",
    "discord",
    "discord-api",
    "bio",
    "discord-bio",
    "profile",
    "discord.js",
    "plugin"
  ],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "axios": "^1.6.0"
  },
  "peerDependencies": {
    "discord.js": "^14.0.0"
  }
}

2. index.js (Código Principal)

const axios = require('axios');

/**
 * Módulo principal do disnovic.
 * Busca o perfil e a bio de qualquer usuário do Discord via API HTTP v10.
 *
 * @param {string} userId - ID ou menção do usuário
 * @param {string} botToken - Token do Bot do Discord
 * @returns {Promise<Object>} Dados estruturados do perfil
 */
async function fetchUserBio(userId, botToken) {
  if (!userId) throw new Error('[disnovic] O parâmetro userId é obrigatório.');
  if (!botToken) throw new Error('[disnovic] O parâmetro botToken é obrigatório.');

  const cleanId = String(userId).replace(/[^0-9]/g, '');

  if (!cleanId) {
    return { success: false, error: 'ID de usuário inválido.' };
  }

  try {
    const response = await axios.get(`[https://discord.com/api/v10/users/$](https://discord.com/api/v10/users/$){cleanId}`, {
      headers: {
        Authorization: `Bot ${botToken}`
      }
    });

    const user = response.data;

    return {
      success: true,
      data: {
        id: user.id,
        username: user.username,
        globalName: user.global_name || user.username,
        bio: user.bio || 'Este usuário não possui uma bio configurada.',
        avatarUrl: user.avatar 
          ? `[https://cdn.discordapp.com/avatars/$](https://cdn.discordapp.com/avatars/$){user.id}/${user.avatar}.png?size=512` 
          : null,
        bannerUrl: user.banner 
          ? `[https://cdn.discordapp.com/banners/$](https://cdn.discordapp.com/banners/$){user.id}/${user.banner}.png?size=512` 
          : null,
        accentColor: user.accent_color ? `#${user.accent_color.toString(16)}` : null
      }
    };
  } catch (error) {
    if (error.response && error.response.status === 404) {
      return { success: false, error: 'Usuário não encontrado.' };
    }
    return { 
      success: false, 
      error: error.response?.data?.message || 'Falha ao conectar com a API do Discord.' 
    };
  }
}

/**
 * Cria um objeto EmbedBuilder estilizado pronto para uso com discord.js
 *
 * @param {Object} profileData - Retorno da função fetchUserBio
 * @param {Function} EmbedBuilder - Classe EmbedBuilder importada do discord.js
 * @returns {Object} Instância de EmbedBuilder formatada
 */
function createBioEmbed(profileData, EmbedBuilder) {
  if (!profileData.success) {
    return new EmbedBuilder()
      .setColor('#FF0000')
      .setDescription(`❌ ${profileData.error}`);
  }

  const { data } = profileData;

  const embed = new EmbedBuilder()
    .setTitle(`📝 Perfil de ${data.globalName}`)
    .setDescription(data.bio)
    .setColor(data.accentColor || '#5865F2')
    .setFooter({ text: `@${data.username} • Powered by disnovic` });

  if (data.avatarUrl) embed.setThumbnail(data.avatarUrl);
  if (data.bannerUrl) embed.setImage(data.bannerUrl);

  return embed;
}

module.exports = {
  fetchUserBio,
  createBioEmbed
};

3. exemplo.js (Bot de Teste)

require('dotenv').config();
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const { fetchUserBio, createBioEmbed } = require('./index.js');

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent
  ]
});

client.once('ready', () => {
  console.log(`✅ Bot de testes disnovic ativo como: ${client.user.tag}`);
});

client.on('messageCreate', async (message) => {
  if (message.author.bot || !message.content.startsWith('!bio')) return;

  const args = message.content.split(' ').slice(1);
  const target = args[0] || message.author.id;

  const profile = await fetchUserBio(target, process.env.DISCORD_TOKEN);
  const embed = createBioEmbed(profile, EmbedBuilder);

  message.reply({ embeds: [embed] });
});

client.login(process.env.DISCORD_TOKEN);

⚡ Uso Básico

const { fetchUserBio } = require('disnovic');

async function main() {
  const userId = '123456789012345678';
  const token = 'SEU_BOT_TOKEN';

  const profile = await fetchUserBio(userId, token);

  if (profile.success) {
    console.log(`Usuário: ${profile.data.globalName}`);
    console.log(`Bio: ${profile.data.bio}`);
  } else {
    console.error(`Erro: ${profile.error}`);
  }
}

main();

📋 Resposta do Método (fetchUserBio)

Sucesso (success: true):

{
  "success": true,
  "data": {
    "id": "123456789012345678",
    "username": "usuario",
    "globalName": "Nome Global",
    "bio": "Esta é a bio do perfil.",
    "avatarUrl": "[https://cdn.discordapp.com/avatars/](https://cdn.discordapp.com/avatars/)...",
    "bannerUrl": "[https://cdn.discordapp.com/banners/](https://cdn.discordapp.com/banners/)...",
    "accentColor": "#5865f2"
  }
}

Erro (success: false):

{
  "success": false,
  "error": "Usuário não encontrado."
}

📄 Licença

Distribuído sob a licença MIT.