Gathering detailed insights and metrics for niboh
Gathering detailed insights and metrics for niboh
Gathering detailed insights and metrics for niboh
Gathering detailed insights and metrics for niboh
npm install niboh
Typescript
Module System
Node Version
NPM Version
70.4
Supply Chain
94.8
Quality
74.9
Maintenance
100
Vulnerability
99.3
License
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Feb 29, 2024
Latest Version
1.0.17
Package Id
niboh@1.0.17
Unpacked Size
140.62 kB
Size
15.61 kB
File Count
43
NPM Version
8.1.2
Node Version
16.13.2
Published on
Feb 13, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
3
Niboh is a library that provides powerful collectors for Discord Bots made using Discord.js library.
It allows you to collect almost every type of information, from a ButtonInteraction to a TextInput (message sent in the specified channel)
1yarn add niboh 2npm install niboh 3pnpm install niboh
1import { ButtonSelectCollector } from 'niboh' 2 3const messageComponents = [ 4 new ActionRowBuilder<ButtonBuilder>().setComponents( 5 new ButtonBuilder() 6 .setCustomId('cool-id') 7 .setLabel('Confirm') 8 .setButtonStyle(ButtonStyle.Success) 9 ) 10] 11 12const message = await someCoolInteraction.reply({ 13 fetchReply: true, 14 components: messageComponents 15}) 16 17const buttonSelectCollector = new ButtonSelectCollector({ 18 location: message.channel, 19 target: someCoolInteraction.user 20}) 21 22const buttonInteraction = await buttonSelectCollector.setProps({ message }).run() 23 24if (buttonInteraction) { 25 buttonInteraction.reply({ content: 'Confirmed!' }) 26}
Make sure to understand that the only part of the library that is actually being used is here
1const buttonSelectCollector = new ButtonSelectCollector({
2 location: message.channel,
3 target: someCoolInteraction.user
4})
5
6const buttonInteraction = await buttonSelectCollector.setProps({ message }).run()
7
8if (buttonInteraction) {
9 buttonInteraction.reply({ content: 'Confirmed!' })
10}
the rest is only a example of message sent with some components to be collected :)
You can combine collectors to run at the same time, but how can it be useful? You might want to run a ButtonCollector
with a TextInputCollector
, for example, imagine you want to ask a user to confirm an operation, so the user can confirm by clicking or writing a specific text.
1import { ButtonSelectCollector, TextInputCollector, CombineCollectors } from 'niboh'
2
3const buttonSelectCollector = new ButtonSelectCollector({
4 location: message.channel,
5 target: someCoolInteraction.user
6}).setProps({ message })
7
8const textInputCollector = new TextInputCollector({
9 location: message.channel,
10 target: someCoolInteraction.user
11}).setProps({ pattern: /^confirm$/ })
12
13const combinedCollectors = new CombineCollectors([
14 buttonSelectCollector,
15 textInputCollector
16])
17
18const result = await combinedCollectors.run()
19
20if (result.isButtonSelectInteraction()) {
21 const buttonInteraction = result.value
22 // ^ ? = ButtonInteraction | null
23}
24
25if (result.isTextInput()) {
26 const textInput = result.value
27 // ^ ? = string | null
28}
No vulnerabilities found.
No security vulnerabilities found.