nuggiesv3

A utility package for Discord Bots!

Usage no npm install needed!

<script type="module">
  import nuggiesv3 from 'https://cdn.skypack.dev/nuggiesv3';
</script>

README

Nuggiesv2

A utility package for Discord Bots!

NPM Info

For errors and questions you can join our support server

Table of content:

โžช ๐ˆ๐ง๐ฌ๐ญ๐š๐ฅ๐ฅ๐š๐ญ๐ข๐จ๐ง

โžช ๐ƒ๐š๐ญ๐š๐›๐š๐ฌ๐ž ๐‚๐จ๐ง๐ง๐ž๐œ๐ญ๐ข๐จ๐ง

โžช ๐†๐ข๐ฏ๐ž๐š๐ฐ๐š๐ฒ๐ฌ

โžช ๐๐ฎ๐ญ๐ญ๐จ๐ง ๐‘๐จ๐ฅ๐ž๐ฌ

โžช ๐ƒ๐ซ๐จ๐ฉ๐๐จ๐ฐ๐ง ๐‘๐จ๐ฅ๐ž๐ฌ

โžช ๐‡๐š๐ง๐๐ฅ๐ž๐ซ ๐ˆ๐ง๐ญ๐ž๐ซ๐š๐œ๐ญ๐ข๐จ๐ง

Installation

npm i nuggiesv3

yarn:

yarn add nuggiesv3

Connect to database

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

Nuggies.connect(mongodburi)

๐๐š๐ซ๐š๐ฆ๐ฌ

uri - the mongoDB connection string

Giveaways

๐‚๐ฅ๐ข๐œ๐ค ๐ก๐ž๐ซ๐ž for giveaways bot code using nuggies package

Preview

Usage hmmm

๐‚๐จ๐ง๐ง๐ž๐œ๐ญ

You can connect to the mongoDB database

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

๐๐š๐ซ๐š๐ฆ๐ฌ

mongoURI: the mongo URI

๐‚๐ซ๐ž๐š๐ญ๐ž

You can create giveaways with .create

Example code can be found below

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

๐Ž๐ฉ๐ญ๐ข๐จ๐ง๐ฌ

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

๐ƒ๐ซ๐จ๐ฉ

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

๐™ด๐šก๐šŠ๐š–๐š™๐š•๐šŽ:

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

๐Ž๐ฉ๐ญ๐ข๐จ๐ง๐ฌ

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 is a function which will help you end giveaways easily

You can end giveaways with .end

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

โ„™๐•’๐•ฃ๐•’๐•ž๐•ค

message: Discord Message

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

giveawaymsg: fetched giveaway message

๐‘๐ž๐ซ๐จ๐ฅ๐ฅ

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);
    }()

โ„™๐•’๐•ฃ๐•’๐•ž๐•ค

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);

โ„™๐•’๐•ฃ๐•’๐•ž๐•ค

message: Discord Message

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

๐ ๐จ๐ญ๐จ๐†๐ข๐ฏ๐ž๐š๐ฐ๐š๐ฒ

returns a url button leading to the giveaway.

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

โ„™๐•’๐•ฃ๐•’๐•ž๐•ค

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

๐ ๐ž๐ญ๐๐ฒ๐Œ๐ž๐ฌ๐ฌ๐š๐ ๐ž๐ˆ๐ƒ

This gets the mongoose document for the giveaway

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

โ„™๐•’๐•ฃ๐•’๐•ž๐•ค

messageID: the message ID of the giveaway

๐ฌ๐ญ๐š๐ซ๐ญ๐€๐ ๐š๐ข๐ง

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

Nuggies.giveaways.startAgain(client)

โ„™๐•’๐•ฃ๐•’๐•ž๐•ค

client: Discord Client

Button Roles

click here for fully functional button-roles bot

๐‚๐จ๐ง๐ฌ๐ญ๐ซ๐ฎ๐œ๐ญ๐จ๐ซ

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

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

๐•†๐•ก๐•ฅ๐•š๐• ๐•Ÿ๐•ค

color: the button color. Optional. Defaults to gray

label: Button label

role: role that would be added on click

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

๐‚๐ซ๐ž๐š๐ญ๐ž

creates the button roles

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

๐Ž๐ฉ๐ญ๐ข๐จ๐ง๐ฌ

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'
  });

๐Ž๐ฉ๐ญ๐ข๐จ๐ง๐ฌ

label: dropdown option label

role: role that would be added on click

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

๐‚๐ซ๐ž๐š๐ญ๐ž

๐‘ช๐’“๐’†๐’‚๐’•๐’†๐’” ๐’•๐’‰๐’† ๐’…๐’“๐’๐’‘๐’…๐’๐’˜๐’ ๐’“๐’๐’๐’†

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

Buttonclick

๐‡๐š๐ง๐๐ฅ๐ž๐ฌ ๐š๐ฅ๐ฅ ๐ง๐ฎ๐ ๐ ๐ข๐ž๐ฌ ๐ข๐ง๐ญ๐ž๐ซ๐š๐œ๐ญ๐ข๐จ๐ง ๐ญ๐จ ๐ฐ๐จ๐ซ๐ค

client.on('clickButton', button => {
    Nuggies.buttonclick(client, button);
});

๐๐š๐ซ๐š๐ฆ๐ฌ

client: the discord client button: the button callback from the clickButton event

๐ƒ๐ซ๐จ๐ฉ ๐‚๐ฅ๐ข๐œ๐ค

handles all the dropdown interactions

client.on('clickMenu', async (menu) => {
    Nuggies.dropclick(client, menu);
});

๐๐š๐ซ๐š๐ฆ๐ฌ

client: the discord client menu: the menu callback from the clickMenu event

๐”๐ฉ๐๐š๐ญ๐ž๐ฌ

1.0.0 -Nuggies.giveaways.connect(mongodburi) +Nuggies.connect(mongodburi)

1.0.1 ๐๐ž๐ญ๐ญ๐ž๐ซ ๐…๐จ๐ง๐ญ๐ฌ

๐‹๐ข๐œ๐ž๐ง๐ฌ๐ž

Nuggies๐ฏ3 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:

  • Share -- copy and redistribute the material in any medium or format
  • 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.