0

I am trying to develop a bot using discord.py that will be able to go through the channel, count how many times a certain word is used, then give me the top X number of users that have said that phrase (in a given timeframe), along with the number of times that they have each said it.

So if I do !bump7, I want it to give me the top, say, 10 users that have said "bump" in the last 7 days

Or !hello10, which would give me the top 10 users that have said "hello" in the last 10 days.

The message would look something like... Billybob 34 times Cathrynaloha 27 times Suzy 3 times JohnDoe 2 times

I have the bot connected to the discord server, but I can't seem to figure out how to make this particular command work. And unfortunately no, I don't have anything in the works, as I'm just trying to search through here to see if anything similar has been done. So far, not a whole lot has been helpful. So any help on developing the client.command() would be awesome! Thank you!

-

I've actually tried really hard to do something similar to this person here: Discord.py: How to go through channel history and count the occurrences of a phrase?

However, it does not work at all, and I have no idea why. The conversation there is not exactly extensive, so I don't have a whole lot of context to work out anything. So re-opening/reiterating seems beneficial here

I've tried searching other areas in this site (and even a handful of other sites) to see if I can't troubleshoot it myself, but have run into too many walls. Guidance would be awesome.

  • I would also accept a command that just generates the number of times a phrase has been used in a given time, regardless of top users. So if I did !bump7, it would just return "37 times" or something. That would be super awesome as well! – Kurt Winkler Feb 03 '23 at 23:46
  • Discord bots have no access to the search bar, so the only way to do this is using `channel.history`. However, keep in mind that ratelimits are a thing. Before making this command, consider if you really need it (do people really care?). – stijndcl Feb 04 '23 at 00:04
  • I'm fine with it looking into the channel history. It honestly just needs to look at the last 1000 messages or so. And yes, it's needed. I'm a moderator on a server and this is something we're looking for, which is why I'd like to build it (seeing as no other bot I can find offers such a thing). – Kurt Winkler Feb 05 '23 at 15:59
  • I should also mention that it really just needs to do it in one specific channel, not the entire server. – Kurt Winkler Feb 05 '23 at 17:14

0 Answers0