-
Notifications
You must be signed in to change notification settings - Fork 18
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
blacklist tags #76
Comments
You can use const posts = await booru.search('sb', ['cat'], { limit: 3 })
// Remove all posts from search results that have "dress" or "clouds" in their tags
const filtered = posts.blacklist(['dress', 'clouds'])
console.log(filtered[0]) Since this filters tags on your end (and not the API), you can end up with no results for 1 page and might need to search the next page: const posts = await booru.search('sb', ['cat'], { limit: 3, page: 2 }) I'll leave it up to you to decide if you just want to search 1 page only, or if you want to paginate until you find a result for the user (but you'll need to make sure that you don't get ratelimited or fetch pages forever) Most APIs will allow you to remove a tag from search results using So blacklisting tags is done in the package, not the API, so you can blacklist more than 3 tags. You can check out the implementation if you want to know how you could've implemented it in your own code (or if you need something more specific) You need to compare the array of tags you want blacklisted with the array of tags of each post If there's 1+ matches then you can filter out that post |
Thanks, the tag that i desire to blacklist wasn't all that common anyways so i don't think it would return a "no result" message. I'm sorry if this is out of the topic, but sometimes the embed for my bot doesn't show the image result (fileURL). Fortunately, i put a Edit: does |
You might be able to use I know some file types and I think images over 10MB don't embed on Discord? If you have some examples I could check them out. If the booru doesn't provide sample/preview sizes, then you'd have to resize it yourself, booru doesn't provide any image-editing code
Or in other words: booru.search('sb', ['cat'])
.then(posts => {
// "posts" is an instance of "SearchResults"
const filtered = posts.blacklist(['dog'])
}) is functionally the same as const posts = await booru.search('sb', ['cat'])
// "posts" is an instance of "SearchResults"
const filtered = posts.blacklist(['dog']) ( |
Thanks, i already figured out how to blacklist.
Then what about videos? I don't think it is possible to embed a video. Or is it possible to detect if the edit: the bot still returns an image/gif with the blacklisted tag after sending a "post not found" message. |
Videos can't be embedded inside message embeds (but gifs can) A video link (.mp4/.webm) can be embedded if you post the URL: You'd have to write your own code (or use another library) to detect videos, on my own bot I have an array of embeddable types and just check that
You might have to check your bot's logic to make sure you aren't continuing after you post the "post not found" message |
Thanks for giving me a reference, i've made it so my bot sends a separate non-embed message if the file is over 10MB/a video. However, it turns out that the embed limit was not actually 10MB and some images over 10MB still got embedded. BTW, I also removed the blacklist and just added a Much thanks for the help. |
just a simple question
is there a feature to blacklist tags on this package?
if not, i already have my own way to block certain words on my discord bot code with just using
if(message.content.includes(blacklist))
.but this method couldn't blacklist more than one tags without making the code incredibly messy.
edit: even if i blacklisted a word using that code, it could still return image tagged with something that i want to blacklist if the tags are specific enough.
The text was updated successfully, but these errors were encountered: