Laurian Hurduza
Laurian Hurduza

Reputation: 109

Count messages from a Discord server - Discord.js

Good afternoon,

I want to create a Discord Bot who can collect and count messages from a Guild for a specific mentioned user and to be possible to fetch the messages from a certain time to a certain time.

My command I want to look like this

*messages @user [date | periodOfTime]

I tried doing the part of when @user is mentioned to show its messages from that specific guild.

        db.add(`globalMessages_${message.author.id}`, 1);
        db.add(`guildMessages_${message.guild.id}_${message.author.id}`, 1);

        // Programing command

        async function messageCount() {
            let member = message.mentions.members.first() || message.member;

            let guild = await db.fetch(`guildMessages_${member.guild.id}_${member.id}`);

            message.channel.send(`**Guild Messages: \`${guild}\`**`);

        }    

        messageCount();

I run this code but it's not tracking as it should. It's just incremeting the command *messages ...

How can I make this command work as I wish?

Thank you for any kind of help.

Upvotes: 4

Views: 1762

Answers (1)

Bombo43453
Bombo43453

Reputation: 81

Try Doing What I did below in the second/first line.

db.add(`globalmessages_${message.author.id}`, +=1)

Upvotes: 1

Related Questions