Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search Bar Functionality #663

Closed
Skillz4Killz opened this issue Aug 25, 2018 · 27 comments
Closed

Search Bar Functionality #663

Skillz4Killz opened this issue Aug 25, 2018 · 27 comments

Comments

@Skillz4Killz
Copy link
Contributor

Skillz4Killz commented Aug 25, 2018

One of the coolest things on discord is how amazing it's search bar works. Unfortunately, there is no way to interact with it using a bot that I am aware of. Instead i would have to fetch hundreds of thousands if not millions of messages depending on the servers activity and size in order to get the same functionality.

Is it possible to add this functionality so a request could be made something like:

GET /search/?in:#channel&filterText="keyword"

Which could send back any and all necessary messages instead of having to fetch so many messages in a loop.

@Pikachu920
Copy link

Pikachu920 commented Aug 28, 2018

This is purposefully not in the API. Like you said, search is very straining and thus discord limits it to human use only to limit the load.

@wipe2238
Copy link

wipe2238 commented Aug 28, 2018

@Pikachu920
Except it is part of API, just undocumented

No idea what's Discord team stance on using undocumented stuff, never had need for anything not mentioned in docs.

@AntiTcb
Copy link
Contributor

AntiTcb commented Aug 28, 2018

It’s a pretty easy guideline: if it’s undocumented, don’t use it.

@Pikachu920
Copy link

@wipe2238 but can bots use that endpoint?

@kyranet
Copy link
Contributor

kyranet commented Aug 28, 2018

They can't, it's for user accounts.

@b1naryth1ef
Copy link
Contributor

We've thought about adding support for this in the past, not sure if its still planned but I'll bump the request internally.

@macdja38
Copy link
Contributor

macdja38 commented Aug 29, 2018

That would be great, it really sucks to have to load a million messages with a bot just to find a couple hundred from one user!

@jhgg
Copy link
Member

jhgg commented Sep 1, 2018

The plan has always been to allow bots to use the search API, with a pretty high rate limit, and no message context, however this has always been considered a really low priority task, relative to other things the team and myself are working on. However, if you’re interested, replying to this issue with your specific use case and thumbs upping this comment will help me make a case for prioritizing this internally.

@SinisterRectus
Copy link
Contributor

I've been waiting patiently for this mostly for statistical purposes. In my case, the total_results field would be more useful than the actual messages. For example, checking total message counts/mentions/images/whatever per channel over some time period to measure channel activity.

@Skillz4Killz
Copy link
Contributor Author

Skillz4Killz commented Sep 1, 2018

My bot is used for Official Game servers for various different games. The game developers asked me to build a feature that could help them find key topics that are being discussed by all the players on those servers.

In this specific case, I was asked to analyze how many players have sent a message discussing lag in the last month compared to the month before. This would help analyze if the most recent changes to the game were helping improve lag issues or not.

Another case was about checking community feedback on certain topics. Example a new hero is released or some change is made and they wan't to get all the messages sent about that hero in X time frame that can be processed into relevant and irrelevant categories and splitting relevant into positive, negative, unknown subcategories to help improve their games as best as possible.

These official servers are really big for example, two off the top of my head are 92,000+ and 34,000+ members and really active servers.

These were requested based on how a similar thing was possible on a separate platform and it was asked of me if it was possible on discord as well. Theoretically, I can build this with loops and fetching every message in that time but that is kind of crazy due to the server's size. I made this issue in the hopes of finding a better way.

My use case is just one example of what is possible with this. Search opens up enormous possibilities for bot devs.

Just a few examples:

  • Detecting Self-Bots: Search for all messages with a embed and !user.bot
  • Building a activity graph/chart for channels/servers without needing to fetch every single message since the server creation.
  • Checking User activity by filtering messages from:@user and tracking overall activity per user
  • Notifications for specific keywords. For example, i could run a task once a day to find all message on my bot server that contain the word bug or help. So when i wake up every day i don't need to run these searches it will notify automatically.
  • Activity Leaderboards
  • Checking ALL messages that were missed during bot restarts or discord API issues.
    • Messages that should have been deleted due to auto-moderation features are not. Imagine, a user notices a bot is down for whatever reason and decide to start posting links, images or whatever that is restricted by bots normally.
    • Same for commands. If a command is missed during a restart/api issue it can be reprocessed easily.
  • Analytics, Analytics, Analytics!

@eritbh
Copy link
Contributor

eritbh commented Sep 1, 2018

Apart from the analytics side of things: I don't intend to develop this feature myself, as all of my bots are application-specific, but I could also see this feature being useful for pruning messages via general-purpose moderation bots, which could be given a search string in the same format as the search bar uses and delete all the messages that match it.

(An obvious limitation to the usefulness of something like this would be that messages older than two weeks can't be deleted via the bulk delete method (iirc), but bots could easily check themselves for messages in the results to fall within this time frame, and such a feature would still be useful regardless.)

@z64
Copy link
Contributor

z64 commented Sep 1, 2018

@Geo1088 indeed, the search endpoint supports &after=snowflake, and the API will do that 2 weeks filtering for you

(though, i feel GET /channels/{cid}/messages?after=snowflake and paginating would be much faster anyways for that)

@macdja38
Copy link
Contributor

macdja38 commented Sep 2, 2018

Part of my bot's logging features allow people to make decisions about if they should ban people based on their past behaviour on the server, it would be nice to be able to pull how much a user has chatted / some samples of messages in a user info command. For example someone who barely speaks and is suddenly attacking a bunch of people in chat is probably a problem, but if someone that's a contributing community member every day starts something one day, it may just be them having a bad day.

This would be along with the message deleting, say purging a specific users messages from a channel going back a couple days, without necessarily banning them then unbanning them or something like that, but I think Geo has already made a good case for that.

@Artuto
Copy link

Artuto commented Mar 13, 2019

Bumping this.
Any news? Will it be documented?

@LandyLane
Copy link

Bump. Would be very useful for moderating older comments that our current bots didn't filter. Thanks!

@monoclex
Copy link

Bump - my usecase is getting the total amount of messages sent by a user and the putting that into a csv or some usable output.

@advaith1
Copy link
Contributor

I also want to use this endpoint mainly just for getting the number of messages for a query.

@rixinsc
Copy link

rixinsc commented Jul 15, 2019

For me, it would be easier and convenient to implement some moderation feature such as the inactive members pruning used by Libereus since I no longer need to write expensive check like this. (Which can take hours on large servers)

@greysdawn
Copy link

Jumping on the bump train, very useful for monitoring how often key phrases are used or for getting info on a user's activity levels in servers that can't use the built-in prune function for some reason or another

@Yomanz
Copy link

Yomanz commented Jul 17, 2019

I'd use this in my epic projects!

@speedstyle
Copy link

I would use this for moderation (deleting all messages matching certain criteria), notifications (DMing users when messages appear with certain criteria) and statistics (seeing which channels and users are the most active). I restart my bot relatively frequently due to development, so in particular being able to find messages not in cache, and to notify users of messages sent while restarting, would be very useful.

@monoclex
Copy link

monoclex commented Oct 4, 2019

Bump - need this to search for moderation purposes, searching users' post history since the entire lifespan of the server.

@LJNeon
Copy link

LJNeon commented Oct 30, 2019

Bump, as others have said this would be very useful for statistics.

@jnccd
Copy link

jnccd commented Dec 5, 2019

Why was this closed?

@AntiTcb
Copy link
Contributor

AntiTcb commented Dec 5, 2019

Why was this closed?

It's not?

@SinisterRectus
Copy link
Contributor

It is still open; the linked issue was closed.

@Andy-William
Copy link

I want to see which emoji is used the least, to replace them with better ones. This will help so I don't have to search manually 1 by 1

@discord discord deleted a comment from archiif Jan 29, 2020
@discord discord deleted a comment from advaith1 Jan 29, 2020
@discord discord deleted a comment from archiif Jan 29, 2020
@discord discord deleted a comment from wipe2238 Jan 29, 2020
@discord discord deleted a comment from archiif Jan 29, 2020
@discord discord deleted a comment from wipe2238 Jan 29, 2020
@discord discord deleted a comment from archiif Jan 29, 2020
@discord discord deleted a comment from archiif Jan 29, 2020
@discord discord deleted a comment from wipe2238 Jan 29, 2020
@discord discord deleted a comment from Skillz4Killz Jan 29, 2020
@discord discord deleted a comment from advaith1 Jan 29, 2020
@discord discord deleted a comment from archiif Jan 29, 2020
@discord discord locked as off-topic and limited conversation to collaborators Jan 29, 2020

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests