#development
1 messages Ā· Page 142 of 1
the opacity of the icon is 5%
also do u know
now it's much better
if i need an api key for the anilist api
modifying user data for example
so you can't do something like this because it could be null so you'd have to check for null or use null coalescing before trying to use the spread operator?
it depends on use cases really
but most of the time it would be null
huh
why does SUMMER as the season work
but STRING doesn't
I get 400 with string
not gonna answer that
yeah it did
no problem man
25
it's never enough
~tim, probably
š§
for me it should be enough i just want to add all of these
btw
how can i convert a hex code to
int
ok
nice
I'd change the name tho, else u might bamboozle urself later on
like const luminance = (rgb) => ...
that's a manga sir
bruh
u forgot to specify the type of the search
whats the difference
...
one is a book, the other is a tv series
ur making a search anime command and don't know what a manga is?
anime comes from animation (animeshon)
unless u manage to invent harry potter technology u can't really watch a book
it's like saying this is a movie
that's a manga too
it is
that's the next arc
it's anime
good
is there anyway to omit id instead of having to pass id: null for emoji's inside a button component?
https://discord.com/developers/docs/interactions/message-components#button-object
ah, that explains why I didn't see it yet
demon slayer is the only anime book i've read
and chainsaw guy too
those are one of the only two good animes
wtf
why are there no results for chainsaw man
manga
why would they make id required, but allow it to be null???
u likely miscoded something
because null is a valid value
but i have same query as editor
?snowflake
which is nullable
i want to omit id
it didn't say id? so you can't
i want id?
console log your query
my query
Page (page: $page, perPage: $perPage) {
media(type: $type, search: $search, season: $season) {
title {
romaji
english
native
}
id
averageScore
coverImage {
extraLarge
large
medium
color
}
}
}
}```
my variables
```json
{
page: 1,
perPage: 1,
type: 'ANIME',
search: 'Chainsaw Man',
season: null
}```
see if it's as expected
season
nvm then
try omitting the season filter
removing?
remove the filter and variable and see if it's still empty
ok
season filter is mostly useless tbh if ur making a command
if so then maybe null breaks it
everyone will search by name mostly
when you see null you should be on alert for bugs
this is going to suck
at least in JS
buddy nulls were there before undefined, just accept it
who has a solution for this
most laguages don't have 2 bottom values
remove season filter altogether
nobody will use it
idc
nobody even remembers which season an anime was released
yes, that's an issue because js allows u to access nonexistant stuff when it should've thrown an exception
js throws when you try to access stuff unless you use elvis
if no season is provided, then make the variable value ["SPRING", "SUMMER",
...]
ok
it doesn't, only when u try to access something from null/undefined
although that MIGHT also break for entries that don't have season set so you should also add null in the list
because those cannot have properties
what nonexistant stuff does js allow you to access without throwing?
{
page: 1,
perPage: 1,
type: 'ANIME',
search: 'Chainsaw Man',
season: [ 'SPRING', 'SUMMER', 'FALL', 'WINTER' ]
}
{ status: 400, message: 'Bad Request' }
Literally any property
ONE value of those
not all
bro he just said to make it that
ah, well yeah it wont work
set it to [MediaSeason!] as the variable type
ok
add null too
so typeof (1).something === 'undefined' would throw. but you'd probably want some other function to check for the existence before using the accessor function or something like that?
bad request
it wouldn't
cuz typeof isn't acessing any prop
apparently it's not nullable, try removing null from the array and the exclamation mark
ok, so typeof would prompt it into a different access pattern
typeof is a different kind of thing
but you want (1).something to thow in other situations?
trying to access any nonexistant property should throw
so what am i suppose to return
what do you mean?
but js is made in a way to have an extremely lenient runtime
that avoids to throw any exception at all
you said remove null
that would make it hard to write dynamic code
keep the array the same as this and change the type to [MediaSeason]
yeah, i guess it's fine as long as typeof still works
bad request
instanceof encourages a hierarchical design which is bad
composition over inheritance
yeah no thatās just not true
Composition is not always the solution
Inheritance is not perfect but neither is composition
if a class is of type T, then it's expected to have all properties and methods of T
I always see these examples with code nobody would ever write. ECSs are a good example of the strengths of composition, but also itās not perfect
besides, u can also use instanceof for interfaces
you shouldn't use class in JS
this is how adding properties at runtime works in groovy
guys how can i not add a property at all if null
u can't access a nonexistant prop yet u can still compose a dynamic object
you'll still need to dynamically generate the filters
how do you check if a property exists in a condition?
i want season to not be added at all if null
if (b.hasProperty("something"))
ofc since groovy allows operator override u could do this:
wym
welp, looks like it requires the filter to accept a list which in this case it doesn't
i guess i already do this for everything with typeof. it might not hurt
i dont like it reserving the hasProperty function name
you'll just have to fetch all seasons and filter the result yourself
what do you think he meant by this?
u can shorten that, I just wanted to write a quick example
actually, didn't even need the getProperty thing
i noticed the font changes a bit
well
it works fine if I don't add the season variable
I'm just trying to figure out a good way to do it
You LOVE this dude, my god
Have you ever considered that maybe heās wrong?
he agrees with me a lot
of course
He seems like an old dude that misses the days of writing 1500 lines of unreadable C, and hates that newer features in languages make things more manageable tbh
will this work
he thinks c was a bad idea and smalltalk should have been more popular since it was a better language
c isn't really oo, but smalltalk is
Stable release from 1980 š
hello
try it, graphql user
bruh
Iām forced to
anilist only has graphql api
i found a solution
the way options are stored for subcommands is so dumb
Won't work most likely
Since u added the variable on the query
If you want to omit a variable I already told u to dynamically generate the query
Instead of hardcoding it
Or just save yourself the effort and remove that useless season filter
they do it though
They do what
I can see it on the query from the AniList website
they provide season in the query but don't in the variables and it works
what do you think Alan Kay meant by this?
I'm sorry that I long ago coined the term "objects" for this topic because it gets many people to focus on the lesser idea. The big idea is "messaging".
That's not what I meant
it's not any different from what i'm doing
so I have a github oauth2 app, does the ratelimit for rest calls to ex user infos apply to my ip or the specific user?
It'll not find that variable
they literally do the same thing tho...
look at their query above
That's only declaring the variable
For the requester
Well, try it and see
Ur too fixated on that guy
Alan Kay is a differnt guy. he invented oop
But that quote is likely because he used the wrong word for the context
One message removed from a suspended account.
Torvals hates c++ and invented linux and git
Doesn't mean c++ is bad
I mean, it IS bad, but not because torvalds hate it
One message removed from a suspended account.
did torvald wish smalltalk became popular instead of c?
all the text is squiggly lines. i think this website is broken
One message removed from a suspended account.
lol ty
Ok, so I'm working on an RPG bot and a lot of the tasks are doing using minigames like fighting and crafting. These are timed and such and are annoying of multiple people do it at the same time in the same channel (also ratelimiting maybe?). I also don't want users to do 2 of these tasks at the same time as it could have issues with saving user's data as these tasks take time to complete and I only fetch the user data at the start of the task and then update and save, so you can see how there could be issues if a user runs one of these commands in the middle of running another. I'm currently using this approach:
// client
public activePlayers = new ExpiryMap<Snowflake, handler>(60000, []);
this.on("interactionCreate", async (payload: Interaction) => {
if (payload.isButton() || payload.isSelectMenu()) {
if (this.activePlayers.has(payload.message.id)) {
let handler = this.activePlayers.get(payload.message.id);
this.activePlayers.set(payload.message.id, handler);
}
}
});
// types
type handler = {
getUserId(): Snowflake | Snowflake[];
getChannelId(): Snowflake;
onStart(): void;
cleanUp(): void;
}
// handler
constructor() {
...
this.onStart()
}
public getUserId() {
return this.cmd.member.user.id;
}
public getChannelId() {
return this.cmd.message?.channel.id;
}
public onStart() {
this.client.activeChannels.set(this.getUserId(), this);
}
public cleanUp() {
this.client.activeChannels.delete(this.getUserId());
}
private onEnd() {
this.cleanUp();
...
}
So this way I add the user to a map that removes the entries after a minute. If the user interacts (using a button or select menu) the map gets updated refreshing the entries ttl. This way I can check before executing a command if the user is in an active task or the channel is occupied. I'd first like your opinions on this approach and if there might be a better approach? And then I also have an issue with this. In my fighthandler's onStart method I add the user with the handler to the map, but when I try to get the entry in my slashcommand handler the map is somehow empty, even tho if I log the map in the fighthandler the map does have the correct entry
One message removed from a suspended account.
whats the best way to get the primary email of a github user using the javascript sdk? technically (await <Octokit>.rest.users.listEmailsForAuthenticatedUser()).find((e) => e.primary) works but I dont want to fetch unneeded data
nope, this website is broken too, but it's broken differently
One message removed from a suspended account.
Just saw this conversation, mind explaining why you think it's bad?
One message removed from a suspended account.
One message removed from a suspended account.
š£ļøšÆš„
C++ better than rust smh
i wouldn't wait an indeterminate amount of time. i would set something in the database to indicate user x is doing something. once it's done remove that value from the database. then check if the user is doing something from the DB before doing something else. you'll want consistent reads
so you think I should save an array with user id's to the db?
or how do you think I should do it then
each user should have their own record
One message removed from a suspended account.
because saving it to the user will present with the same issue I'm trying to avoid
One message removed from a suspended account.
I have a cacheµ
make another table keyed off of the user
but not with redis
One message removed from a suspended account.
Personally? I just dislike the route it took, starting with the weird syntax choice
add a new column
so a new column for each user
And my opinion might be biased from my experiences with winapi
Ik c++ is not only winapi, but it left a sour taste
i would make it an enum
some activites might not conflict with others
mmh
You're the first person I've ever seen to call C++'s syntax choice as weird, what syntax do you consider as weird in particular?
but what about the channels?
Mostly the extremely verbose types and -> or :: everywhere
save the activity like this. activityName.channelId then split by ..
const [activityName, channelId] = activity.split(".")
mhm but the issue is if a different user executes a command it won't trigger that right?
because if you're saving like: key: userid, value: activityName.channelId then I won't be able to check if the channel is occupiedµ
you would read from the db and check yourself
you'd want another table
I can get the reasoning for the rest, like not using new and declaring variables like Class abc;
also, what if I save a state to the user and the bot crashes or something happens and the user's state never gets updated back to inactive
but if that's not an option then it'll get dirty
One message removed from a suspended account.
One message removed from a suspended account.
extremely verbose types
I fail to see how C++'s types are verbose, and it's a bit ironic since you use Java :^)
->or::everywhere
I mean, they make quite a lot of sense in a middle-level programming language like C++, they're to distinguish between the qualifiers being accessed
ironically, java types aren't really verbose
make a separate table with a ttl attribute
the myth comes mostly from java EE types (or old libs)
yeah that's what I thought, I'm using keyv so a seperate table is not an option
which is not really the standard lib
that's why I used the expiry map as it's a map with a ttl built in
create a separate instance of the DB
is that possible?
Can you show me a C++ type that's verbose? And compare it to types in Java (if possible)?
well it's possible if I create another db yeah
but why would I choose to get more traffic to the db instead of saving it to memory?
why bad request
{ page: 1, perPage: 1, type: 'ANIME', search: 'Chainsaw Man' }
$page: Int
$perPage: Int
$type: MediaType
$search: String
$seasonYear: Int
$season: MediaSeason
) {
Page(page: $page, perPage: $perPage) {
media(type: $type, search: $search, season: $season) {
id
title {
romaji
english
native
}
coverImage {
extraLarge
color
}
averageScore
}
}
}```
isn't it achieving the same thing but then with latency?
memory is more expensive than db storage
true but how much memory do you think it'll take in?
depends, but at somepoint you'll run out
quite hard to ask me to remember one now, it's been a couple years since I touched cpp
Btw that's as good as it's going to get
restarting the server will clear everyones state
yes but that's not bad tho
since if the bot restarts all the tasks stop aswell
so there's no issue with duplicate tasks being ran
I'd actually prefer that over the states being saved
but yes, indeed, the problem is if the bot gets really big it'll be very intensive on memory
Weird and probably dumb question....
But when using Next.js, where should I be putting all of my meta tags and stuff like that? Should that go in the index file? Or one of the _document.js or _app.js files?
as I have a user and profile cache already and then a state cache aswell
if it autodeleted then it wouldn't be too bad, but manually setting the states after a restart would be annoying
what do you mean autodeleted?
ttl attribute
if the server restarts, the memory gets cleared too no?
does anyone with graphql experience know
if you save state in the db then it would be possible to restart the server in the middle of a long process and have it continue from the middle of the process
mmmh? how?
The way I see that being possible is to save the handlers to the db and then loading every handler and rerunning it where it left off
or am I not getting what you mean?
nvm i fixed
the state would be save to the db and the logic would take into account the current state
ah I see
but I don't really need that
as I'd have to store a lot of data to get back to a state of the fight for example
I think I'll keep the memory way and monitor it closely. If I need to swap to database storage I will
if you save all state in a DB then you can switch to serverless hosting. which means you only pay for server time when someone is running a command
yeah but i also have a cache tho?
is it possible to make it so
i need to add caching to my site 
you can select many choices in slash command option
I found a way to get a new table using keyv I'll try the db way
and how do you think I should save them then? Because keyv is key value storing also I don't think keyv has ttl
you dont really need a cache with serverless. at least not in the code. you can use a service like reddis
never used reddis before
it's a database that uses memory instead of storage
ah, but i also don't really need serverless hosting
but how do you think I should save them then? Because keyv is key value storing also I don't think keyv has ttl
Keyv doesn't have ttl so do I save them with a timestamp, problem is then that people who use a command once and never use the bot anymore just clog up the states table then no?
nvm keyv has a ttl
nice
ok perfect
now do I just keep my original approach or do I just set like a really high ttl of like an hour?
since tasks will never take longer than like 5 minutes and maybe 15 minutes for dungeons
the ttl should be longer than any activity will ever take
ok so like half an hour?
idk how long they are
yeah max 15 minutes
i'd need more domain specific knowledge
why tf do anilist descriptions have html in them
wdym domain specific?
give him more context
specialized knowledge of the activity for you bot
oh alright
they're supposed to be embedded in sites
so
now i need to manually remove html
yes
a simple replace chain will do it
they only use formatting tags, nothing exceptional
So for fighting you get a random mob and you press buttons (moves) to deal damage. You keep doing this untill the mob is dead. But if you can't beat the mob in 5 minutes you automatically lose, so fighting never lasts longer than 5 minutes. Dungeons on the other hand is harder to calculate because it generates random rooms and they can be puzzle rooms and such and based on the floor you encounter more rooms. Same here with miniboss rooms if you can't defeat them in 5 minutes you lose and puzzle rooms can't take longer than 3,5 minutes and treasure and shrine rooms last 1 minute exactly. Currently the first floor has 4 rooms with the boss room so let's say if you get 3 miniboss rooms + the boss room the max it could take is 20 minutes
but the issue is that the higher floors you go the more rooms the dungeons will contain so they could take even longer
but maybe I set the ttl during the generation of the dungeon? And I just do ammount of rooms * 5 minutes or smth?
i'd make the timeout like 10x the longest a game could take
likely enums
nope
alright, and how do you think I should save them then? key: userid, value: task?
make it all lowercase, remove the first letter, make it uppercase, add the first letter back
optionally make a function so u dont need to type it every time
because I need to find a decent way of saving the channels too right?
the key should be the activity id or just a generic id
mmmh
but how should I get it from the db then?
because keyv is essentially like a map, I have to db.get(key)
so lets say activity1 has a blue room that only one user can be in. you could use a key like
['activity1', 'blue_room'].join('|')
the id should be the thing that is blocked
Wow hold on, I donāt get this
if user 2 wants to go in the blue room in activity1 they would check ['activity1', 'blue_room'].join('|') to see if they can go in first. if they can then they set it so no one else can get in. then when they leave they delete id ['activity1', 'blue_room'].join('|') from the db
ok i did it
anime.status.charAt(0).toUpperCase() + anime.status.toLowerCase().substring(1)
ohhh, no no, that's not how it works haha
w me
but you can use the id to indicate the thing you want to block at a detailed level
no so, I'm trying to make it so a user can't use 2 "intensive" commands (cmds that take time to complete) at once and I also don't want 2 users to use 2 "intensive" commands in the same channel
so the key could be something like ['intensive_command', user.id].join('|')
mhm ok
you dont care if two different users run an intensive command at the same time?
so what you want is this key ['intensive_command', channel.id].join('|')
So I have some intensive commands: craft, hunt, adventure, cook, dungeon and I don't want 2 of them being done in the same channel
ah ok
so I'm just saving 2 things to the db?
so essentially when a user executes a command I'm making 3 different db queries
isn't that quite intensive tho?
or is that fine
queries by key should be quick
how do i get this from the anilist api
select statements with joins are where you run into issues with speed
ok, and I can ofcourse also only query if the user runs an intensive command
for the other commands I can just use 1 query for the user
Alright @proven lantern thank you so so much for helping me ā¤ļø
@earnest phoenix another c++ q if you dont mind (i hope)
i have a class and I want to create an instance of it using new like
struc* item;
item = new struc();
but I want to initialise the memory with my own custom allocator, for instance malloc instead of the one c++ uses for new operator
so essentially i want the memory allocation process to be completely up to me, but as for initialising class members to default and calling the constructor, up to c++
I tried to use "placement news" i think they're called but I get this error: No matching 'operator new' function for non-allocating placement new expression; include <new>
struc* item;
item = new (malloc(sizeof(struc))) struc();
I don't think including new will help me, especially since im working with only the static versions of the standard library
any idea on initialising classes without new?
to avoid doubt i can always add code onto the struc class
You cannot use placement new without including the new header
what does the new header even contain?
i hope its not os specific functions
as in its completely static
['intensive_command', 'craft', channel.id].join('|') would be a better key. so craft doesn't block hunt and other commands
well I do want it to block others tho but I already implemented it
it's working like it should
noice
š
I think I might actually save the message id so I can make a reference link to it, so people can just click it and go to their task
It contains the necessary declarations for the dynamic memory allocation operations provided by the language, it includes the following:
operator new- used to allocate memory dynamically in the free storeoperator new[]- used to allocate memory for arrays dynamically in the free storeoperator delete- used to deallocate memory allocated usingoperator newoperator delete[]- used to deallocate memory allocated usingoperator new[]
These operators are used implicitly when you use the new and new[] keyword to allocate dynamic memory, and the delete and delete[] keywords to deallocate the memory, they can also be called explicitly if needed
The new header also provides the nothrow version of the operator new and operator new[] functions, which return a null pointer instead of throwing an exception if the memory allocation fails
Including the new header (<new>) is necessary when using placement new, which allows you to specify a custom memory location for object construction, and when using the nothrow variant of the operator new functions
And the new header doesn't use OS-specific APIs, it only provides the declarations, not the memory allocation implementations
But note that if you really don't want to use the new header there's also a way to use custom allocators in C++ without it but it's ugly
What about smart pointers ;c
this actually could be overkill. if the bot restarts in the middle of an activity it'll take 3hs to let them do another activity
can you set a ttl for each record separately?
already implemented that
; )
I just made the ttl the cooldown of the command as the commands have cooldowns like 10 mins and 1 hr and stuff
nice, so each activity can have a ttl that makes sense for the activity
ye
and for dungeons I can just get the amount of rooms and multiply it by a certain amount of time so it'll be exact time a dungeon could max take
how can i make this embed look better
headers
I tried to use the new header but yeah it doesnt appear to be included
im compiling with -ffreestanding and static libgcc so no standard lib at all (my mistake)
though im happy to hear your ugly possible solution
Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to d...
well I didn't know they added all the other markdown features to dc
wait was headers a feature since like always?
I'm sure I've never seen it used before
It's a new feature
discord needs to support table markdown soon
ah ok cuz block quotes and such were already a thing
I don't see a real use case for it tho in a chat app
displaying a leaderboard
ah true
I just used:
š„
š„
š„
4.
5.
6.
...
for my elo bot I made a while ago
this is my layout now. i don't like how the numbers line up
ah, well you can use 2 fields and put them inline with the second one having an invisible emoji as title
that way the numbers are perfectly under each other
but i can only use 25 fields
i was going to make 2 versions
;-; why do you need 25 fields?
just one field with the users and then one field with the points
leaderboards can have hundreds of people
put the numbers like this
including the emojis
pagination would be guild wide so they would interfere
this forces a monospaced font, so they'll line up
but the names are different length
so it'll be offset
what do you mean? just split the thing you're displaying into different arrays and put that in a 2d array then just display the array based on the page being the index
use empty emojis to create an equal whitespace
but the message is seen by everyone in the discord server the same way. so some other user could paginate
or the empty unicode character idk if that works on dc tho
oh you mean like that
maybe, find the length of the longest username and then pad the other names with whitespace
could work
split it up in multiple embeds? I made a bot with leaderboards for a hypixel skyblock guild a long time ago and I just split it up in 5 embeds it was like 125 users
you mean like return an array of embeds that each have the max number of fields
that could work
you can just use slice method and slice it into equal chunks and then send an embed for each chunk
what can you do that with arrays? oh no I see what you mean
Then you'd have to invoke the constructors and destructors yourself
Here's an example:
#include <cstdlib>
#include <iostream>
struct Foo {
int bar;
Foo() {
bar = 0;
std::cout << "Constructor called" << std::endl;
}
~Foo() {
std::cout << "Destructor called" << std::endl;
}
void baz() {
std::cout << "Hello from Foo" << std::endl;
}
};
template <typename T>
void construct(T* object) {
new (object) T();
}
template <typename T>
void destroy(T* object) {
object->~T();
}
template <typename T>
T* allocate() {
void* memory = std::malloc(sizeof(T));
return static_cast<T*>(memory);
}
template <typename T>
void deallocate(T* object) {
std::free(object);
}
int main() {
// Allocate memory using custom allocator
Foo* foo = allocate<Foo>();
// Call the constructor to initialize the object
construct(foo); // Constructor called
// Call a member function
foo->baz(); // Hello from Foo
// Do whatever else
// ...
// After you're done using the object, destroy it
destroy(foo); // Destructor called
// And finally deallocate the memory you allocated for the object using custom allocator
deallocate(foo);
}
I swear to god c++ is chinese for me, imma stay with high level languages for the time being
Everybody that doesnāt have a basic knowledge of programming would say that about html

@earnest phoenix Iām learning C for uni in the fall, and Iām creating some basic data structures to learn more about how to create things. Is the best way to implement āmethodsā on structs just passing a pointer to the struct and operating on the data there?
void add(SomeCollectionStruct* thing)``` for example
That depends, you should generally always go for references instead of pointers
However, there can cases where you should use pointers:
- Nullability, if the passed argument can be absent (
NULL) then use pointers - Pointers can be reassigned to point to different objects at different times
- Pointers can be used to manage the ownership of objects, such as dynamically allocated memory
- Passing large objects as references is more efficient, however, if the object can be absent (point 1) then use pointers
But what you're currently doing is fine
that makes me wanna cry š templates are so ugh in c++
thanks though I appreciate it
You're welcome
it's Chinese even to some of the better of us
kinda like c but with added stuff
old computer with the newest rgb and case
Though I wonder, why are you trying to avoid using the standard library? And why is it just static in your case?
i was taught to avoid the standard libraries in my health class
I'm sorry but your health class has betrayed you, they're making you use unhealthy practices by implementing everything yourself
maybe i'm mixing things up in my head
no, do you even have an idea of how many anime exists?
on anilist, ~18,850
i could get them all
but
it would take 377 requests to the api
i wonder if there an option that takes less request
I can't im doing this on a microcontroller so there's no existing environment all im left with is my silly little code
so I have to implement everything from scratch and can only really use static libgcc
c++ kinda sucks for this kinda stuff but I really wanted classes so here I am
you have to even call internal constructors yourself before you hand over control to your c++ code otherwise undefined behaviour :)
standard library best thing to ever exist
do all heavy lifting for you
(we don't talk about c)
no one cares
battleless at this point make a new account and rebuild your reputation as a kind young man just learning the ropes
why?
my reputation is perfectly fine
I've already went over this with you, everytime I see you asking for help and someone does you are always arguing with them that you are doing it right and they are wrong
Im not getting into it again with you
I guess you can try setting the perpage parameter to as high as you can go
But I doubt the api will let you retrieve all of them at once
i did
too computationally expensive for an api
just go through all pages and collect the animes that way
Why do you want all animes?
autocomplete š¤©
Couldn't you do a system where you fetch them all once, save them somewhere and every maybe day or so do it again to update?
yes but it will take my bot out for like 4 minutes due to ratelimits
do you think that'll be fine
Ratelimits through what?
You can just do it on startup of the bot initially
and then have some kind of cron job or whatever to update the cache daily
...
it would likely take just as long if not a little quicker than going through all pages
issue with this is if your bot goes down then you will have to repopulate the cache
maybe i can just do one request per minute
do the animes constantly update? is that why you need to fetch stuff constantly?
Anime doesn't update within a day unless its the day a new episode releases (which isn't done but like once a week)
Then why the fuck are you worried about constantly updating them
isn't this the kind of problem graphql is designed to solve?
^
I don't really use graphql so no idea
can't you look up only the most recently updated animes or something on the api
yea but i can only fetch 50 animes per page
and there's about 18550
that's the whole point of graphql afaik lol conditional queries so you don't have to fetch and process everything
so divide them and u get 371 requests
I mean do it on the api side
maybe
point of graphql is to fetch only what you need
so the api only sends you back the most updated ones
let me see
if you only need the id's and names then just fetch all the animes and only grab the name and id
the point of graphql was to get around what rest doesn't do
after further checking the docs
you cannot get recently updated anime
or anything
with a rest api it sends you all the data, with graphql you select what kind of data you want back
its an attempt to de-bloat response bodies
it's cool
If anilist is using graphql, fetch all animes but only request for the ids and names of those animes and you'd just have an array of objects (probably) of the names and ids
feels unnatural having a whole query language for it though and sending that query string as a body for your data
and you can refetch every other day or weekly thats the only solution I can think of
I mean I get the gimmick behind it
but its just something new to learn that doesn't really matter unless you're sending massive amounts of data over rest
easy to learn how to use an already implemented graphql
harder to actually implement your own graphql
yeah ofc
ok i am going to write a script to store all of the animes into my database
i want autocomplete
If someone is using the command won't they know what anime they want to look up?
yes but they likely won't know the ID
which is what I need to fetch the data
You can't search by name?
i mean you can
but it can return incorrect results
Couldn't you take 10 results show them in an embed with a select menu letting them choose which one they want?
sure
but autocomplete is better
But this is easier, and isn't a bad idea
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
what if i store it in cache and not a database
does it still count
One message removed from a suspended account.
yea
One message removed from a suspended account.
One message removed from a suspended account.
autocomplete
One message removed from a suspended account.
One message removed from a suspended account.
i could just refetch when my bot starts
it only takes like 3 minutes
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
hm
One message removed from a suspended account.
One message removed from a suspended account.
idk how to cache for this
One message removed from a suspended account.
no
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
why can't i just usue a map
Maps aren't compressed
You'll run out of memory very quickly
Besides, using redis is very much map-like
how quickly
Depends on your reqs/m
wym
import { createClient } from 'redis';
const client = createClient();
client.on('error', err => console.log('Redis Client Error', err));
await client.connect();
await client.set('key', 'value');
const value = await client.get('key');
await client.disconnect();
is this all i need to do to use redis ?
Don't use redis if ur keeping it forever
in mass,
since when have you cared about tos
always
(never)
till my bot dies
Then as I said, don't use redis
Redis is for caching, what ur doing is not a cache
?
but I can't
if I store it it will break tos
Then set a time for that data to expire
One message removed from a suspended account.
Either store permanently on a databse or temporarily on redis
Not the other way around
what
One message removed from a suspended account.
What are u even talking abt?
One message removed from a suspended account.
One message removed from a suspended account.
But he wanta to store it without expiration on redis
have a good day
i wanna store it for autocomplete
Store the data for like 1 hour or so
that defeats the point tho
With expiration set to LTA
One message removed from a suspended account.
Not really, cache is meant to be temporary
If u store permanently it defeats the point of a cache
One message removed from a suspended account.
"Hoardingā or mass collection of data from the AniList API is strictly prohibited."
would u consider this breaking this rule
One message removed from a suspended account.
I know, that's why im telling him to set an expiration
i want kuuhakus answer
One message removed from a suspended account.
One message removed from a suspended account.
Setup redis, set it to expire on LTA (last time acessed) with a duration of your preference
Why not just make your own database of anime information at this point 
Whenever the data is acessed it'll refresh the timer
So frequently acessed data will always be cached
huh
Huh what
All it does is purge data that isn't frequently access right haku?
rate my first C program š ```c
#ifndef VECTOR_H
#define VECTOR_H
#include <malloc.h>
#include <stdio.h>
typedef struct {
int capacity;
int* items;
int size;
} Vector;
void initVector(Vector* v) {
v->capacity = 10;
v->items = malloc(10 * sizeof(int));
v->size = 0;
}
static void resize(Vector* v) {
int* newItems = malloc(v->capacity * 2 * sizeof(int));
v->capacity *= 2;
printf("New internal size: %d\n", v->capacity);
for(int i = 0; i < v->size; i++) {
newItems[i] = v->items[i];
}
free(v->items);
v->items = newItems;
}
void add(Vector* vector, int item) {
if(vector->size + 1 >= vector->capacity) {
resize(vector);
}
vector->items[vector->size] = item;
vector->size++;
}
#endif
Caches have 2 modes, either LTA or LTW
any data they request you can then fetch from the anilist api and recache it
One message removed from a suspended account.
Last time acessed or last time written
ok
Yes
i'm not doing this anymore
One message removed from a suspended account.
Already gave up ffs
Hey props to him for at least going at it for more than a few minutes
i'm not doing it because it's against their tos
One message removed from a suspended account.
a timed cache
Woah
Then u don't need a fckin cache
One message removed from a suspended account.
Actually what haku said should work for you
Both me and faithie are saying the same
while you might not be able to autocomplete everything you can at least autocomplete commonly searched up animes
do you guys understand what i want to do ?
One message removed from a suspended account.
but i want all anime
One message removed from a suspended account.
First of all, u can't put all anime on autocomplete
i can
Discord has a limit does it not?
it's autocomplete
How are u gonna put almost 200k entries in a damn autocomplete?
š
so it fits in discords limits
it's actually 18k
25...
but i deleted the database
Do u have any idea on how many anime with very similar name there are?
And how long some anime names csn get?
i want an autocomplete man
For example Dungeon Ni Deai Wo Motomeru No Wa Machigatteiru Darou Ka?
i would just truncate
yes
That defeats the purpose of autocomplete entirely
Then you are just cutting off the name of the anime
so
which is pointless
Many anime share a very similar name
it will still show accurate results
nah
yea
I'd rather search anilist themselves than use your auto complete
sure
One message removed from a suspended account.
so?
See the message below it
One message removed from a suspended account.
no...?
battleless you are a hopeless cause
discords text limit for autcomplete options is like 100
both of thhose would fit easily
The issue becomes even worse when u consider oneshot-based anime
Which have very long names
Like danmachi
that looks short to me
Or Gate Jieitai Kanocchi Nitte Kaku Tatakaeri
Neither of those shingeki are oneshots
The point is a lot of animes share common names, if you cut off parts of the name they can get mixed with other animes
thus not accurate anymore
One message removed from a suspended account.
Oneshots have basically a sentence as a name
One message removed from a suspended account.
that is under 100 characters
so it would be fine
One message removed from a suspended account.
"That time I got reincarnated as a XXX and did YYY"
One message removed from a suspended account.
Akikan
One message removed from a suspended account.
unless those two words are over 25 characters each it would still be fine
That anime makes zero fucking sense
They quite literally kept true to what a spider does and time warps everything
One message removed from a suspended account.
Makes the story hard to follow if you dont know spiders perceive time differently
The ending of the second season explains it all
It's a VEEEERY well done mindblow
Im not waiting till the second season
No really, it all makes sense retroactively
thats like saying one piece gets good at episode 500
Like, suddenly u understand everything what happened and why it happened
Watching that anime gave me a headache
One message removed from a suspended account.
One message removed from a suspended account.
Re:Zero MC has the biggest plot armour i've ever seen
Guy has the ability to go back and time and still fucks it up
Entire of season 1 was him trying to save this girl
One message removed from a suspended account.
You'll end up hating subaru too
One message removed from a suspended account.
Lmao
One message removed from a suspended account.
One message removed from a suspended account.
The only anime I couldn't stand finishing was zero no tsukaima
And I saw REALLY bad anime
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Sao is a funny case, they messed up every even arc and hit a banger on every odd arc
One message removed from a suspended account.
Dont get me wrong I like it but after a while it got too weird and repetitive
Also just bought DayZ
Aincrad good, alfheim bad, ggo good, mother's rosario bad, alicization 1 good, alicization 2 bad
There's still a community for it?
One message removed from a suspended account.
One message removed from a suspended account.
MR didn't have the same oompf of the rest
One message removed from a suspended account.
One message removed from a suspended account.
It was all about the other asuna that had a terminal disease
One message removed from a suspended account.
One message removed from a suspended account.
who can rate my discord bot
if i send gif
why tf are the emojis of my bot like this on mobild
how can I fix this
Skill issue
One message removed from a suspended account.
why?
Iām a good programmer
One message removed from a suspended account.
One message removed from a suspended account.
feel free to express your opinion, I could care less
please do
One message removed from a suspended account.
lol
One message removed from a suspended account.
maybe
but Iām at least decent
One message removed from a suspended account.
this is quite difficult to understand
thats because you're at the Peak of "Mount Stupid"
I'd say I'm like slightly above valley of despair
One message removed from a suspended account.
i'm the most modest person in this entire discord server
the irony of that statement
One message removed from a suspended account.
Iām not stubborn
and of course I want to do things my way itās my code š¤Ø
and a lot of trial and error
One message removed from a suspended account.
code that doesn't function and you ask us for help to fix
A lot of my code functions perfectly fine
One message removed from a suspended account.
I didnāt give up because it was hard
I didnāt take your suggestion because it wasnāt what I wanted to do

One message removed from a suspended account.
That statement alone speaks volumes
yes but it wasnāt the solution I wanted
so I just scraped the idea entirely

One message removed from a suspended account.
thatās not true, I never asked for a solution

they decided to give me one, I didnāt ask
One message removed from a suspended account.
What the fuck are you on bro
but it wasnāt what I was looking for so I didnāt implement it
nothing
Asking for help is asking for a solution to your problem
what do you even need help with
nothing now
One message removed from a suspended account.
good
he doesn't wanna do it anymore
I didnāt ask for a solution though





