A utility package for Discord Bots!
For errors and questions you can join our support server
npm:
npm i nuggies
yarn:
yarn add nuggies
features like giveaways require a database connection, you can connect to database using
Nuggies.connect(mongodburi)
uri - the mongoDB connection string
click here for giveaways bot code using nuggies package
You can connect to the mongoDB database
const Nuggies = require('nuggies');
Nuggies.connect(mongURI);
mongoURI: the mongo URI
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,
});
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!
example:
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
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
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
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.
creates the dropdown roles
Nuggies.dropdownroles.create({
message: message,
role: role, /*dropdownroles constructor*/
content: new Discord.MessageEmbed().setTitle('xd').setDescription('xdxd') });
handles all the button interactions
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
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.