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-birthdays

v1.1.0

Published

An NPM Module to announce users birthdays written in SQL.

Downloads

7

Readme

discord-birthdays

An NPM Module allowing you to setup birthday messages when it is a users birthday automatically!


Support


Installation

npm i discord-birthdays@latest


Check SQL Table Status

Check if the required SQL table(s) are imported

| Entry | Type | Definition | |----------------|---------------|---------------| | #1 | SQL VAR | Your SQL Connection Variable (con, db, etc)


Initialization

con, client, format, guildid, channels, header, footer, color

The nodelogger function offers a fair amount of customization.

| Entry | Type | Definition | |----------------|---------------|---------------| | #1 | SQL VAR | Your SQL Connection Variable (con, db, etc) | #2 | CLIENT VAR | Your bots "client" variable (client, bot, etc) | #3 | STRING | The format you want bdays checked as (MM-DD, DD-MM) | #4 | STRING | The guild id for the birthday | #5 | ARRAY | The channels to send the alert to | #6 | STRING | The header of the birthday embed | #7 | STRING | The footer of the birthday embed | #8 | STRING | The color of the birthday embed


Add Birthdays

Add a birthday to the database function info

| Entry | Type | Definition | |----------------|---------------|---------------| | #1 | SQL VAR | Your SQL Connection Variable (con, db, etc) | #2 | STRING | A User ID to add to the bdays table | #3 | STRING | The date of the users birthday


Remove Birthdays

Remove a birthday from the database function info

| Entry | Type | Definition | |----------------|---------------|---------------| | #1 | SQL VAR | Your SQL Connection Variable (con, db, etc) | #2 | STRING | A User ID to remove from the bdays table


Code Example

const Discord = require('discord.js') // V13
const client = new Discord.Client({
    intents: ['GUILDS', 'GUILD_MESSAGES', "GUILD_MESSAGE_REACTIONS", "DIRECT_MESSAGES", "GUILD_MEMBERS", "GUILD_BANS", "GUILD_INTEGRATIONS", "GUILD_WEBHOOKS", "GUILD_INVITES", "GUILD_VOICE_STATES", "GUILD_PRESENCES", "GUILD_MESSAGE_TYPING", "DIRECT_MESSAGE_REACTIONS", "DIRECT_MESSAGE_TYPING"],
    partials: ["CHANNEL", "MESSAGE", "REACTIONS"],
    allowedMentions: { parse: ['users', 'roles', 'everyone'], repliedUser: true }
});

let con;
const mysql = require('mysql')
client.utils = require('discord-birthdays')

client.on(`ready`, () => {
    con = mysql.createConnection({
        host: "localhost",
        user: "root",
        password: "",
        database: "dbname"
    });

    console.log(`I AM READY WOOOOO`)

    setTimeout(async () => {
        await client.utils.dbcheck(con)
        await client.utils.init(con, client, 'MM-DD', '832721829822857296', ['879012702222168064'], `HAPPY BIRTHDAY`, `Happy BDay Lol`, `#ffffff`)
    }, 3000)
});

client.on('messageCreate', message => {
    let prefix = '!'
    if (message.content.startsWith(prefix)) {
        const args = message.content.slice(prefix.length).trim().split(/ +/g);
        let command = args.shift().toLowerCase();

        if(command === 'ping') {
            message.channel.send({ content: "pong!" })
        } else if(command === 'add') {
            let check = client.utils.addbday(con, message.author.id, args[0])
            if(check) {
                message.channel.send({ content: "Bday Added!" })
            } else {
                message.channel.send({ content: "Bday Add Failed!" })
            }
        } else if(command === 'remove') {
            let check2 = client.utils.removebday(con, message.author.id)
            if(check2) {
                message.channel.send({ content: "Bday Removed!" })
            } else {
                message.channel.send({ content: "Failed to remove bday!" })
            }
        }
    }
});

client.login(`YOUR_TOKEN_HERE`)