README
Nuggiesv2
A utility package for Discord Bots!
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
๐๐จ๐ง๐ง๐๐๐ญ
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.