Git Product home page Git Product logo

idjinn / discord.js-collector Goto Github PK

View Code? Open in Web Editor NEW
51.0 51.0 14.0 61.6 MB

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

JavaScript 100.00%
discord discordjs embed-paginator message-collector paginator reaction reaction-menu reaction-role reactions-collector reactions-roles rr

discord.js-collector's Introduction

Hello There

Thrends IDjinn's GitHub stats

discord.js-collector's People

Contributors

ewox07 avatar garingwox avatar idjinn avatar sahhas16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discord.js-collector's Issues

(node:624) DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify` option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#findandmodify

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.

Reaction Roles

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?

[Bug]: Bad input: addRole({...}) message must be a Message Object.

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
        });

Screenshots
image

[Warning] Please upgrade your version

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.

[Bug]:

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...

[Feat]: how to change time

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.

[Info]: Rewrite is comming!

For much reasons, this lib will be completely rewrite. New version will be 2.0 LTS. Please wait before open issues.

[Feat]: Custom action for "Reaction" Roles

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

Reaction Role STORAGE

Hi, storage json probably doesn't work
(I don't think I have anything wrong there)

Otherwise it works well

Doesn't work how it should

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});
  }
});

Screenshots
image

Desktop (please complete the following information):

  • Discord.js Version: 12.5.1
  • Discord.js-collector Version: 1.8.9
  • Operating system: Windows 10 Pro
  • What priority this should have? Please describe: High?
  • I've tested in last discord.js-collector version

[Bug]: Showing wrong emojis on reactionCollector.

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

image

Desktop (please complete the following information):

  • Discord.js Version: 12.4.1
  • Discord.js-collector Version: 1.8.4
  • Operating system: Windows 10 Pro 20H2
  • What priority this should have? Please describe: Low
  • I've tested in last discord.js-collector version

Unknown message !

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);

[Feat]: Adding quick.db db option

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 ๐Ÿ˜…

messageReactionsRoles.map

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 ๐Ÿ˜ƒ

Database support

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...

Reactions deletes

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?

Question

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?

Database suggesstion

Hi! I think quick.db is great db, and should be added ๐Ÿ‘. What do you think about time limit with message collectors? ex. 30seconds

question

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.

Question

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?

Reaction role storage

I just wanted to know where is the reaction role info saved incase I put the storage to false

[Feat]: Improve database support

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.

Problem installing the npm package.

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.

ERROR: Bad input

(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",

Unexpected Token

why do i still have this error? unexpected token static DEFAULT_COLLECTOR_TIME = 30_000??

Paginator do nothing

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

Json database

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

Paginator not working..

whatever I do, I even wait after reaction but paginator is stuck at first embed that it initially sent.
image
look at that am I doing something wrong? those ai, levelling, general's are embeds I defined above this code...

Verify reaction role

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.

[Bug]: allReactionsRemove triggered whenever message with reactions was deleted

Every message deleted with some reactions trigger allReactionsRemove, even if the message wasn't active reaction roles.
The code:

async __onRemoveAllReaction(message) {
const messageReactionsRoles = this.reactionRoles.filter((r) => r.message === message.id).array();
const membersAffected = [];
const rolesAffected = new Collection();
let reactionsTaken = 0;
for (let i = 0; i < messageReactionsRoles.length; i += 1) {
const reactionRole = messageReactionsRoles[i];
for (let j = 0; j < reactionRole.winners.length; j += 1) {
const winnerId = reactionRole.winners[j];
/**
* @type {GuildMember?}
*/
const member = message.guild.members.cache.get(winnerId);
if (!member) continue;
if (member.partial) await member.fetch();
for (let k = 0; k < reactionRole.roles.length; k++) {
const role = member.guild.roles.cache.get(reactionRole.roles[k]);
if (!role) continue;
if (await this.hooks.preRoleRemoveHook(member, role, reactionRole)) {
await member.roles.remove(role.id);
if (!membersAffected.includes(member)) membersAffected.push(member);
}
if (!rolesAffected.has(role.id)) rolesAffected.set(role.id, role);
}
reactionsTaken += 1;
}
await this.deleteReactionRole({ reactionRole }, true);
this.__debug(
'ROLE',
`Reaction role '${reactionRole.id}' was deleted, by someone take off all reactions from message.`,
);
}
this.emit(
ReactionRoleEvent.ALL_REACTIONS_REMOVE,
message,
rolesAffected,
membersAffected,
reactionsTaken,
);
}

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)

Reaction Collector map of undefined

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

[Support]: Discord server invite

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

Database Role React

The data is already being written to the database, but it will not be restored after the bot is restarted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.