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

boton-luxz

v1.0.1

Published

Funcion para boton de Seguridad HomeBase

Downloads

8

Readme

Nuggies

A utility package for Discord Bots!

Installation

Table of content:

- installation

- database connect

- Giveaways

- Button Roles

- Dropdown Roles

- handle interactions

- applications

npm:

npm i nuggies

yarn:

yarn add nuggies

connect to database

features like giveaways require a database connection, you can connect to database using

Nuggies.connect(mongodburi)

params

uri - the mongoDB connection string

Giveaways

click here for giveaways bot code using nuggies package

Preview

Usage

connect

You can connect to the mongoDB database

const Nuggies = require('nuggies');
Nuggies.connect(mongURI);

params

mongoURI: the mongo URI

Create

You can create giveaways with .create Example code can be found below

       const Nuggies = require('nuggies')
       Nuggies.giveaways.create({
           message: message,
           prize: 'test',
           host: message.author.id,
           winners: 1,
           endAfter: '10s',
           requirements: { enabled: false },
           channel: message.channel.id,
       });

options

message: Discord Message

prize: String, prize of the giveaway

host: the host of the giveaway

winners: Number, the winners count

endAfter: String, The time after the giveaway will end

requirements: Object, the requirements for the giveaway. example: requirements: {enabled: true, roles: ['role']}

channel: the channel ID the embed will be sent to

drop

you can create drops with .drop, first to click the button gets the win!

example:

Nuggies.giveaways.drop({
  		message: message,
  		prize: 'test',
  		channel: message.channel.id,
  		host: message.author.id,
  	});

options

message: Discord Message

prize: String, prize of the giveaway

host: the host of the giveaway

channel: The channel where the drop will be sent

End

End is a function which will help you end giveaways easily

You can end giveaways with .end

   Nuggies.giveaways.end(message, data, giveawaymsg);

params

message: Discord Message

data: data from the database, can be obtained by using the .getByMessageID property

giveawaymsg: fetched giveaway message

Reroll

You can reroll giveaways easily with .reroll

You can simply use this function by writing a line of code.

    (async () => {   
    const win = await Nuggies.giveaways.reroll(client, messageID);
    }()

params

client: The Discord Client

messageID: The message ID of the giveaway

startTimer

you can start the timer again after restart, note that it automatically starts the timer when the giveaway start.

You can simply use this function by writing a line of code.

    await Nuggies.giveaways.startTimer(message, data);

params

message: Discord Message

data: mongoose document, can be obtained by using .getByMessageID

GotoGiveaway

returns a url button leading to the giveaway.

    (async () => {   
    const button = await Nuggies.giveaways.gotoGiveaway(data);
    }()

params:

data: mongoose document, can be obtained by using .getByMessageID

getByMessageID

This gets the mongoose document for the giveaway

   (async () => {   
   const doc = await Nuggies.giveaways.getByMessageID(messageID);
   }()

params

messageID: the message ID of the giveaway

startAgain

starts the giveaway again after restart, put this in ready event to start All the giveaways again.

Nuggies.giveaways.startAgain(client)

params

client: Discord Client

Customize Messages

customize the messages that users see

const Nuggies = require('nuggies');
 Nuggies.giveaways.Messages(client, {
   dmWinner: true,
   giveaway: '🎉🎉 **GIVEAWAY MOMENT** 🎉🎉',
   giveawayDescription: '🎁 Prize: **{prize}**\n🎊 Hosted by: {hostedBy}\n⏲️ Winner(s): \`{winners}\`\n\nRequirements: {requirements}',
   endedGiveawayDescription : '🎁 Prize: **{prize}**\n🎊 Hosted by: {hostedBy}\n⏲️ Winner(s): {winners}',
   giveawayFooterImage: 'https://cdn.discordapp.com/emojis/843076397345144863.png',
   winMessage: '{winners} you won {prize} Congratulations! Hosted by {hostedBy}',
   rerolledMessage: 'Rerolled! {winner} is the new winner of the giveaway!', // only {winner} placeholder
   toParticipate: '**Click the Enter button to enter the giveaway!**',
   newParticipant: 'You have successfully entered for this giveaway', // no placeholders | ephemeral
   alreadyParticipated: 'you already entered this giveaway!', // no placeholders | ephemeral
   nonoParticipants: 'There are not enough people in the giveaway!', // no placeholders
   nonoRole: 'You do not have the required role(s)\n{requiredRoles}\n for the giveaway!', // only {requiredRoles} | ephemeral
   dmMessage: 'You have won a giveaway in **{guildName}**!\nPrize: [{prize}]({giveawayURL})',
   noWinner: 'Not enough people participated in this giveaway.', // no {winner} placerholder
   alreadyEnded: 'The giveaway has already ended!', // no {winner} placeholder
   dropWin: '{winner} Won The Drop!!' // only {winner} placeholder
})

params

dmWinner - Boolean - If bot should dm the winners of giveaway

giveaway - String - Title text of giveaway message

giveawayDescription - String - Giveaway embed description

endedGiveawayDescription - String - Ended giveaway embed description

giveawayFooterImage - String - Image/Gif in embed footer

winMessage - String - Message to send when winner is declared

rerolledMessage - String - Message to send when giveaway is rerolled

toParticipate - String - Instruction on how to participate the giveaway

newParticipant - String - Ephemeral message that participant sees when they participate

alreadyParticipated - String - Ephemeral message that participant sees if they have already participated

nonoParticipants - String - Message when there are not enough participants for giveaway

nonoRole - String - Ephemeral message when participants doesn't have required roles

dmMessage - String - Message to send to winners of giveaway (only works in dmWinner is true)

noWinner - String - Message when giveaway is ended/rerolled and there are not enough participants

alreadyEnded - String - If giveaway is already ended

dropWin - String - Message sent when drop winner is declared

Placeholders - {guildName}, {prize}, {giveawayURL}, {hostedBy}, {winners}, {requiredRoles}(only works for nonoRole)

Button Roles

click here for fully functional button-roles bot

constructor

constructor. use .setrole() on it to create buttons

const something = new Nuggies.buttonroles().addrole({
  color: 'red', 
  label: 'test', 
  role: '781061040514269185',
  });

options

color: the button color. Optional. Defaults to grey

label: Button label

role: role that would be added on click

emoji: ID of the emoji on the button, optional.

create

creates the button roles

Nuggies.buttonroles.create({ 
  message: message, 
  role: something,  /*buttonroles constructor*/ 
  content: new Discord.MessageEmbed().setTitle('xd').setDescription('xdxd') });

options

message: Discord Message

role: The object recieved from the buttonroles constructor.

content: content, can be a string or a Discord Embed

dropdown roles

constructor. use .setrole() on it to create dropdown options

const something = new Nuggies.dropdownroles().addrole({ 
  label: 'test', 
  role: 'roleID',
  emoji: 'emojiID'
  });

options

label: dropdown option label

role: role that would be added on click

emoji: ID of the emoji on the dropdown option, optional.

create

creates the dropdown roles

Nuggies.dropdownroles.create({ 
  message: message, 
  role: role, /*dropdownroles constructor*/ 
  content: new Discord.MessageEmbed().setTitle('xd').setDescription('xdxd') });

handle interactions

features including buttons and dropdown menus require certain functions to handle the interaction

handleInteractions

Nuggies.handleInteractions(client)

params

client: Discord Client

Applications

Applications help you make your life easier with different types of applications you might have to handle! Here's how you can implement it click here for a fully function applications bot

setup

a pre made template for your bot.

Nuggies.applications.setup(message)

params

message: message callback from message event

addApplication

Creates a application for which anyone can make a response.

Nuggies.applications.addApplication(
  { guildID, questions, name, emoji, channel, description, label, maxApps, cooldown, responseChannelID },
)

params

guildID: The ID of the guild in which the application is to be added questions: An array of questions to be asked in DM, Example: js ['How old are you?', 'How much time would you devote to it?']; name: The name of the application\

emoji: The emoji to be put in the menu

channel: The ID of the channel in which the message is to be sent

description: The description of the application

label: The label of the application in the menu

maxApps: The maximum amount of application 1 can create before it gets accepted/declined

cooldown: The cooldown before creating another response

responseChannelID: The channel to send responses in

deleteApplication

Deletes an application for the guild

Nuggies.applications.deleteapplication({ guildID, name });

params

guildID: The ID of the guild name: The name of the application to remove

create

Creates/Initializes the application system for the guild

Nuggies.applications.create({ guildID, content, client })

params

guildID: The ID of the guild to be created in content: The content of message to be sent in the channel client: The discord.js client used

getDataByGuild

Gets the data from database for you

Nuggies.applications.getDataByGuild(guildID);

params

guildID: The ID of the guild

License

Nuggies npm licensed under the terms of Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International ("CC-BY-NC-SA-4.0"). Commercial use is not allowed under this license. This includes any kind of revenue made with or based upon the software, even donations.

The CC-BY-NC-SA-4.0 allows you to:

  • [x] Share -- copy and redistribute the material in any medium or format
  • [x] Adapt -- remix, transform, and build upon the material

Under the following terms:

  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • NonCommercial — You may not use the material for commercial purposes.
  • ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

More information can be found here.