/nagis-asu

Primary LanguageJavaScriptOtherNOASSERTION

Nuggies

A utility package for Discord Bots!

NPM Info

For errors and questions you can join our support server

Installation download

Table of content:

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 hmmm

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

Button Roles

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 gray

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

buttonclick

handles all the button interactions

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

params

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

dropclick

handles all the dropdown interactions

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

params

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

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:

  • 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.