1.0.1 • Published 3 years ago
djs-messagecollector v1.0.1
What is this?
This is a npm package that is made for the sole purpose of simplifying Message Collectors for you! Message Collectors are what you use to collect message in discord.js
installation
npm i djs-messagecollector
Or
yarn add djs-messagecollector
How to use
const MessageCollector = require('djs-messagecollector');
// then you create a new MessageCollector Class <There are default values.>
const collector = new MessageCollector({ message: Discord.Message }) // read more about the paramaters of this class below. this is using all of the default values.
// start your collector
const collect = collector.start();
collector.on('collect', message => { // The message that was collected.
console.log(message.content) // logging the message content...
})
collector.on('end', (collected, reason) => { // collected => the collected message, reason => the reason for the collectors end.
console.log(collected);
})
collector.on('dispose', message => { // The message that was disposed of.
console.log(message)
})
collector.resetTimer({ time: 60000, idle: 10000}) // resets the collectors timer read more on the djs guide https://discord.js.org/#/docs/main/master/class/MessageCollector?scrollTo=resetTimer
collector.stop(`Because i don't want it to run anymore. <optional>`) // ends the collecter and emits the 'end' event
collector.dispose(Discord.Message) // Disposes of a message and emits the 'dispose' event.
Paramaters
MessageCollector Class
- constructor
- Object: Properties Below.
- message:
Discord.Message
- channel:
Discord.TextChannel | Discord.TextChannel
- max : number, "The max messages to be collected" DEFAULT OF 1
- time : number, "The set time as were the collector would end." DEFAULT OF 60000
- filter: Function, "The Message Collector filter." DEFAULT OF (m) => m.author.id === message.author.id;
- Functions
start()
: Starts the message collector.stop(reason<optional>)
: Stops the message collector.dispose(message: Discord.Message)
: Disposes of a message and emits thedispose
event.on(event: "collect" | "end" | "dispose", callback(paramaters))
: listenes for a particular event.resetTimer(Options: {time: number, idle: number})
: Resets the collectors timer.