idjinn / discord.js-collector Goto Github PK
View Code? Open in Web Editor NEWLibrary to easily create message collector, reactions collector and reactions role on discord.js v12, with customization ways.
License: GNU General Public License v3.0
Library to easily create message collector, reactions collector and reactions role on discord.js v12, with customization ways.
License: GNU General Public License v3.0
Hi, how i can setup this? https://i.imgur.com/A6lD4Qt.png because by default id don't works
i was gonna test out this package to use, but it keeps saying this error whenever i try to use it, and doesnt give me role when i react. (node:624) DeprecationWarning: Mongoose: findOneAndUpdate()
and findOneAndDelete()
without the useFindAndModify
option set to false are deprecated.
Hi, i have an issue because, reaction role creates, but after reacting message, role has been given and reactions are removed (all). How to repair that?
Describe the bug
whenever I try to execute the setup command, i get this error
Please insert here your code if possible
if (message.content.startsWith('.rrsetup')) {
const role = message.mentions.roles.first();
if (!role)
return message.reply('You need mention a role').then(m => m.delete({ timeout: 1000 }));
const emoji = args[1];
if (!emoji)
return message.reply('You need use a valid emoji.').then(m => m.delete({ timeout: 1000 }));
const msg = await message.channel.messages.fetch(args[2] || message.id);
if (!role)
return message.reply('Message not found! Wtf...').then(m => m.delete({ timeout: 1000 }));
reactionRoleManager.createReactionRole({
message: msg,
roles: [role],
emoji,
type:1
});
If you're using d.js-collector, please update to latest version or higher: ^1.7.8
This version fix problems with settings and reaction role, before this version member can win multiple toggle roles.
when using a Menu for Config when say someone is on the home meun or anywhere on there if they want to get out or talk they cant as it will delete the button is there anyway to stop the message collector using a stop reaction maybe or smth i tried but cant get anything working...
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
For much reasons, this lib will be completely rewrite. New version will be 2.0 LTS. Please wait before open issues.
Is your feature request related to a problem? Please describe.
No, it's just a new feature.
Describe the solution you'd like
Currently, you have to specify the roles you want to add/remove. It would be great if you are able to specify custom actions based on the reaction, instead of a role. So an event called reactionRoleAdd without the role parameter, but with an emoji parameter, so that you can take action based on the emoji.
Describe alternatives you've considered
Nvt
Additional context
Nvt
Currenly lib hasn't a partial support. Need do it.
Hi, storage json probably doesn't work
(I don't think I have anything wrong there)
Otherwise it works well
I'm getting error
Before give/take some role, execute hook functions to check if will or not bypass this action.
Some issues is coming because some error throws or wrong logic and clear reaction roles... Need make option in constructor to not delete RR, but just disable it. Will avoid wrong deletes.
Describe the bug
Well I don't think its a bug but maybe I only have some problem in the code. It will just save the role in my MongoDB and thats all. It doesn't even console log a reactions all it does is just save the role in DB and react to message. I would be really happy if you could help me with it.
Code
const { ReactionRoleManager } = require('discord.js-collector'); // npm i discord.js-collector
const reactionRoleManager = new ReactionRoleManager(client, {
storage: false, // Enable reaction role store in a Json file
path: __dirname + '/roles.json', // Where will save the roles if store is enabled
mongoDbLink: 'mongodb+srv://VAR*****:*****@cluster0.cjyyh.mongodb.net/RoleReakce' // See here to see how setup mongoose: https://github.com/IDjinn/Discord.js-Collector/blob/master/examples/reaction-role-manager/Note.md
});
reactionRoleManager.on('ready', () => {
console.log('Reaction Role Manager is ready!');
});
// When user react and win role, will trigger this event
reactionRoleManager.on('reactionRoleAdd', (member, role) => {
console.log(member.displayName + ' won the role' + role.name)
console.log(member)
});
// When user remove reaction and lose role, will trigger this event
reactionRoleManager.on('reactionRoleRemove', (member, role) => {
console.log(member.displayName + ' lose the role' + role.name)
});
client.on("message", async (message) => {
const args = message.content.split(' ').slice(1);
// Example
// >createReactionRole @role :emoji: MessageId
if (message.content.includes(`addrole`)) {
const role = message.mentions.roles.first();
if (!role)
return message.reply('You need mention a role').then(m => m.delete({ timeout: 1000 }));
const emoji = args[1];
if (!emoji)
return message.reply('You need use a valid emoji.').then(m => m.delete({ timeout: 1000 }));
const msg = await message.channel.messages.fetch(args[2] || message.id);
if (!role)
return message.reply('Message not found! Wtf...').then(m => m.delete({ timeout: 1000 }));
reactionRoleManager.createReactionRole({
message: msg,
roles: [role],
emoji,
type:1
});
/**
* Reaction Role Type
* NORMAL [1] - This role works like basic reaction role.
* TOGGLE [2] - You can win only one role of all toggle roles in this message (like colors system)
* JUST_WIN [3] - This role you'll only win, not lose.
* JUST_LOSE [4] - This role you'll only lose, not win.
* REVERSED [5] - This is reversed role. When react, you'll lose it, when you take off reaction you'll win it.
*/
message.reply('Done').then(m => m.delete({ timeout: 500 }));
}
else if (message.content.includes(`rrdel`)){
const emoji = args[0];
if (!emoji)
return message.reply('You need use a valid emoji.').then(m => m.delete({ timeout: 1000 }));
const msg = await message.channel.messages.fetch(args[1]);
if (!msg)
return message.reply('Message not found! Wtf...').then(m => m.delete({ timeout: 1000 }));
await reactionRoleManager.deleteReactionRole({message: msg, emoji});
}
});
Desktop (please complete the following information):
To shortly resource used (database, requests and etc) maybe give more than 1 role per reaction will be nice.
Describe the bug
When trying ReactionCollection.question() from example I found a bug. Doesn't use the custom emojis added into the ReactionCollector.question .
Please insert here your code if possible
const BaseCommand = require('../../utils/structures/BaseCommand');
const { MessageEmbed } = require('discord.js');
const { MessageCollector, ReactionCollector } = require("discord.js-collector");
module.exports = class BotsCommand extends BaseCommand {
constructor() {
super('bots', 'Bot', []);
}
async run(bot, message, args) {
const botMessage = await message.reply('Curse or Pray?');
ReactionCollector.question({
botMessage,
user: message.author,
reactions: {
'๐': async (reaction) => await message.react(reaction.emoji.name), // Your custom function here.
'๐': async (reaction) => await message.react(reaction.emoji.name),
'๐': async (reaction) => await message.react(reaction.emoji.name)
}
});
}
}
Screenshots
Desktop (please complete the following information):
Hello I want the reaction manager to get the message ID from all channels. how can I do it
const msg = await message.channel.messages.fetch(args[2] || message.id);
This isn't releated to any problem tho it will be helpful!
A lot of people new to discord.js and coding and even to this package might need to use easier db's like quick.db than mongo cause sometimes mongo is hard to setup [for beginners]
Create a example for using quick.db
Create a example for using the package with quick.db in the examples folder , this will defo increase interest in the package and help people who just started coding!
None
None
Additional context
No additional context ๐
TypeError: messageReactionsRoles.map is not a function
at ReactionRoleManager.__onRemoveAllReaction (/rbd/pnpm-volume/f01c8349-cc29-499e-bebc-a133046860a1/node_modules/.registry.npmjs.org/discord.js-collector/1.6.1/node_modules/discord.js-collector/src/reaction-role/manager.js:677:53)
I got this new error....
also this line "manager.js:125"
btw, thanks for the fast recent update ๐
The title is self explanatory, whenever a reaction role is deleted, make the bot remove the reaction from the message which had the reaction role.
can you make it possible to store it to database like mongodb or mongoose instead of json? if its already possible, please make an example on how to do it...
Hi, i have an issue because, reaction role creates, but after reacting message, role has been given and reactions are removed (all). How to repair that?
How can i remove reaction role? Can you add example code how to remove reaction role from database by message id or by channel mention?
Hi! I think quick.db is great db, and should be added ๐. What do you think about time limit with message collectors? ex. 30seconds
Getting:
static DEFAULT_YES_NO_REACTIONS = ['โ
', 'โ'];
^
SyntaxError: Unexpected token =
It would be cool if reaction role manager could work with bot messages, or unless it does and I am doing something wrong.
I want to make staff application bot for my server.
Can you please send me example code how to make it using this package?
I want to have my questions in array (like this let questions = ["question1", "question2"]
) and I want that bot will ask first question, wait for response, then ask another question from array. I want to have response timeout for user 5 mins (that when user didnt responded to question within 5min promt will be ended and message will be sent). Answers should be returned in array, then i will make embed from it and send it to specifed channel.
The problem:
Now lib not check even if the bot can give role to each member who reacted to win some role. Need do that and emit event (like missingRequirements
) to dev handle it.
Hi, how can I limit time for message collector and specify what message will be sent to channel if user does not respond on time?
I just wanted to know where is the reaction role info saved incase I put the storage to false
Is your feature request related to a problem? Please describe.
Currently there is only thwo ways to store reaction role data: JSON and MongoDB
Describe the solution you'd like
Simple way to make it do with multiple database, or configurable to unsupported databases.
Is your feature request related to a problem? Please describe.
Problem installing npm package, when I install the package by using npm i discord.js-collector
I get this error Error Message.
Describe the solution you'd like
I would like to install the Discord.js-Collector package and use it.
Describe alternatives you've considered
I tried to install the package by using npm i [email protected]
& npm i discord.js-collector@~1.7.8
to reveal no luck either.
(node:10192) UnhandledPromiseRejectionWarning: Bad input: I canno't find emoji 738846732514754690
(node:10192) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
NPM: "discord.js-collector": "^1.6.5",
why do i still have this error? unexpected token static DEFAULT_COLLECTOR_TIME = 30_000??
manager line :80
err: client param must be client somthing
i dont really get it, im using client extender
this.reactionRoleManager = new ReactionRoleManager(this, {
storage: true, // Enable reaction role store in a Json file
mongoDbLink: this.config.mongoDB // See here to see how setup mongoose: https://github.com/IDjinn/Discord.js-Collector/tree/dev/examples/reaction-role-manager/Note.md
});
is this wrong?
i was working with this library, but it seems i can't navigate at all, the reaction reset is working but the content isn't moving.
my environment is
node v12.18.3
discord.js ^12.4.1
discord.js-collector ^1.5.5
Hi, unfortunately the problem with the json database persists.
Everything is stored there, but after restarting the bot, the already set reaction roles do not work
Describe the solution you'd like
Hi, can you please add option to create verify reaction role. I mean that when user react to emoji bot will give him role and remove his reaction, role should not be removed when reaction will be removed.
This will be useful for react to get Member role embed panels.
Every message deleted with some reactions trigger allReactionsRemove
, even if the message wasn't active reaction roles.
The code:
Discord.js-Collector/src/reaction-role/manager.js
Lines 875 to 918 in 6725205
Ok, also how does this work?
// When someone removed all reactions from message reactionRoleManager.on('allReactionsRemove', (message) => { console.log(`All reactions from message ${message.id} was removed, all roles was taken and reactions roles deleted.`) });
I am often getting it to console.
Is this trigerred only when the message is also reaction role or on every message where reactions were removed?Originally posted by @ririko5834 in #34 (comment)
this time reaction collector
TypeError: Cannot read property 'map' of undefined
at /rbd/pnpm-volume/132446c5-eb2c-4523-af58-4ea57d3879ef/node_modules/.registry.npmjs.org/discord.js-collector/1.6.5/node_modules/discord.js-collector/src/collectors/reactionCollector.js:372:41
this line : reactionCollector.js:372:41
For questions, support about errors and code you may want join in we discord server for fast answer, for not need open a issue. For that, please flow this link
The data is already being written to the database, but it will not be restored after the bot is restarted
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.