#development

1 messages Ā· Page 142 of 1

hushed robin
#

ok thx

civic scroll
#

the opacity of the icon is 5%

hushed robin
#

also do u know

lyric mountain
#

now it's much better

hushed robin
#

if i need an api key for the anilist api

pale vessel
#

not at all

#

unless you want to do mutations of course

hushed robin
#

oh thats nice

#

whats a mutation?

pale vessel
#

modifying user data for example

hushed robin
#

oh nah

#

i don't need to do that

proven lantern
#

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?

civic scroll
#

but most of the time it would be null

hushed robin
#

why does SUMMER as the season work

#

but STRING doesn't

#

I get 400 with string

lyric mountain
#

not gonna answer that

hushed robin
#

why not

#

oh wait

#

i'm slow nvm

proven lantern
#

try SALT

#

and PEPPER

hushed robin
#

😭

#

lord help me

pale vessel
#

did null work

#

it should ignore the filter altogether if you set the value to null

hushed robin
pale vessel
#

no problem man

hushed robin
#

yes ty

#

btw whats the max amount of slash command options you can have?

pale vessel
#

25

hushed robin
#

hm

#

that should be more than enough

pale vessel
#

it's never enough

~tim, probably

hushed robin
#

🧌

#

for me it should be enough i just want to add all of these

#

btw

#

how can i convert a hex code to

#

int

proven lantern
#
Number(`0x${hex}`)
#

untested

lyric mountain
#

just parseInt(hex, 16)

#

remove the # beforehand

proven lantern
#

yeah, parseInt is better

#

btw this is working perfectly

hushed robin
lyric mountain
#

I'd change the name tho, else u might bamboozle urself later on

#

like const luminance = (rgb) => ...

hushed robin
#

my anime bot is working

#

now i need to add paginating

lyric mountain
#

that's a manga sir

hushed robin
#

bruh

lyric mountain
#

u forgot to specify the type of the search

hushed robin
#

whats the difference

lyric mountain
#

...

#

one is a book, the other is a tv series

#

ur making a search anime command and don't know what a manga is?

hushed robin
#

bruh

#

both r anime

lyric mountain
#

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

hushed robin
#

are you happy\

lyric mountain
#

that's a manga too

hushed robin
#

bro

#

no it's not

lyric mountain
#

it is

hushed robin
#

how is it not an anime

#

i added the filter

pale vessel
#

that's the next arc

hushed robin
#

to only show anime

#

bruh

pale vessel
#

it's anime

hushed robin
#

good

proven lantern
lyric mountain
hushed robin
#

demon slayer is the only anime book i've read

#

and chainsaw guy too

#

those are one of the only two good animes

#

why are there no results for chainsaw man

lyric mountain
hushed robin
#

can you explain the above

#

it works on editor

proven lantern
#

why would they make id required, but allow it to be null???

hushed robin
lyric mountain
#

u likely miscoded something

lyric mountain
hushed robin
pale vessel
#

which is nullable

proven lantern
pale vessel
#

it didn't say id? so you can't

proven lantern
#

i want id?

lyric mountain
hushed robin
#

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
}```
lyric mountain
#

see if it's as expected

hushed robin
#

?

#

season is null

lyric mountain
#

nvm then

hushed robin
#

bruuhhhh

#

does api hate me

pale vessel
#

try omitting the season filter

hushed robin
#

removing?

pale vessel
#

remove the filter and variable and see if it's still empty

hushed robin
#

ok

lyric mountain
#

season filter is mostly useless tbh if ur making a command

pale vessel
#

if so then maybe null breaks it

hushed robin
#

bruh

#

it works now

lyric mountain
#

everyone will search by name mostly

hushed robin
#

hm

#

so i need to pass everything in weirdly

proven lantern
#

when you see null you should be on alert for bugs

hushed robin
#

this is going to suck

proven lantern
#

at least in JS

lyric mountain
hushed robin
#

who has a solution for this

proven lantern
lyric mountain
hushed robin
#

bro

#

i wanna add it

#

😐

lyric mountain
#

nobody will use it

hushed robin
#

idc

lyric mountain
#

nobody even remembers which season an anime was released

lyric mountain
proven lantern
pale vessel
hushed robin
#

ok

lyric mountain
pale vessel
#

although that MIGHT also break for entries that don't have season set so you should also add null in the list

lyric mountain
#

because those cannot have properties

proven lantern
#

what nonexistant stuff does js allow you to access without throwing?

lyric mountain
hushed robin
#

{
page: 1,
perPage: 1,
type: 'ANIME',
search: 'Chainsaw Man',
season: [ 'SPRING', 'SUMMER', 'FALL', 'WINTER' ]
}

{ status: 400, message: 'Bad Request' }

wheat mesa
#

Literally any property

lyric mountain
#

not all

hushed robin
#

bro he just said to make it that

lyric mountain
#

ah, well yeah it wont work

hushed robin
#

ok well

#

how can i not pass the variable if it's null?

pale vessel
#

set it to [MediaSeason!] as the variable type

hushed robin
#

ok

proven lantern
# lyric mountain

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?

hushed robin
lyric mountain
#

cuz typeof isn't acessing any prop

pale vessel
#

apparently it's not nullable, try removing null from the array and the exclamation mark

lyric mountain
proven lantern
#

ok, so typeof would prompt it into a different access pattern

lyric mountain
#

typeof is a different kind of thing

proven lantern
#

but you want (1).something to thow in other situations?

lyric mountain
#

trying to access any nonexistant property should throw

hushed robin
pale vessel
#

what do you mean?

lyric mountain
#

but js is made in a way to have an extremely lenient runtime

#

that avoids to throw any exception at all

hushed robin
#

you said remove null

proven lantern
lyric mountain
#

not exactly

#

groovy is there to prove that's not necessarily true

pale vessel
proven lantern
#

yeah, i guess it's fine as long as typeof still works

lyric mountain
#

typeof should also be gone

#

instanceof is superior in pretty much every way

hushed robin
#

bad request

proven lantern
#

instanceof encourages a hierarchical design which is bad

#

composition over inheritance

wheat mesa
#

yeah no that’s just not true

#

Composition is not always the solution

#

Inheritance is not perfect but neither is composition

lyric mountain
#

if a class is of type T, then it's expected to have all properties and methods of T

proven lantern
wheat mesa
#

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

lyric mountain
#

besides, u can also use instanceof for interfaces

proven lantern
#

you shouldn't use class in JS

lyric mountain
#

this is how adding properties at runtime works in groovy

hushed robin
#

guys how can i not add a property at all if null

lyric mountain
#

u can't access a nonexistant prop yet u can still compose a dynamic object

lyric mountain
proven lantern
#

how do you check if a property exists in a condition?

hushed robin
#

i want season to not be added at all if null

proven lantern
#
if(b.something) {
  println b.something
}
#

like that?

lyric mountain
#

ofc since groovy allows operator override u could do this:

pale vessel
proven lantern
#

i dont like it reserving the hasProperty function name

pale vessel
#

they don't have season_in and season_not_in filter either

#

which would've worked

lyric mountain
pale vessel
#

you'll just have to fetch all seasons and filter the result yourself

proven lantern
#

what do you think he meant by this?

lyric mountain
#

u can shorten that, I just wanted to write a quick example

#

actually, didn't even need the getProperty thing

proven lantern
hushed robin
#

it works fine if I don't add the season variable

#

I'm just trying to figure out a good way to do it

proven lantern
wheat mesa
#

Have you ever considered that maybe he’s wrong?

proven lantern
proven lantern
wheat mesa
#

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

hushed robin
#

will this work

proven lantern
#

c isn't really oo, but smalltalk is

wheat mesa
#

Stable release from 1980 šŸ’€

hushed robin
frosty gale
#

try it, graphql user

hushed robin
#

I’m forced to

#

anilist only has graphql api

#

i found a solution

proven lantern
#

the way options are stored for subcommands is so dumb

lyric mountain
#

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

hushed robin
lyric mountain
#

They do what

hushed robin
#

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

proven lantern
#

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".
hushed robin
#

variables they provide

#

wait

#

hm

lyric mountain
hushed robin
#

it's not any different from what i'm doing

lyric mountain
neon leaf
#

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?

lyric mountain
#

It'll not find that variable

hushed robin
#

look at their query above

lyric mountain
hushed robin
hushed robin
#

if they can do it why can't i

#

?

lyric mountain
#

Well, try it and see

hushed robin
#

it works

#

w

proven lantern
#

Alan Kay is a differnt guy. he invented oop

lyric mountain
#

But that quote is likely because he used the wrong word for the context

sage bobcat
lyric mountain
#

Doesn't mean c++ is bad

#

I mean, it IS bad, but not because torvalds hate it

sage bobcat
proven lantern
lyric mountain
#

No, he loves c

#

Smalltalk looks like liquid hell

proven lantern
sage bobcat
proven lantern
tulip ledge
#

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

sage bobcat
neon leaf
#

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

proven lantern
sage bobcat
earnest phoenix
sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

šŸ—£ļøšŸ’ÆšŸ”„

neon leaf
#

C++ better than rust smh

proven lantern
tulip ledge
#

or how do you think I should do it then

proven lantern
#

each user should have their own record

sage bobcat
#

One message removed from a suspended account.

tulip ledge
#

because saving it to the user will present with the same issue I'm trying to avoid

sage bobcat
#

One message removed from a suspended account.

tulip ledge
hushed robin
#

bro why is it saying bad request now

#

it was working before

#

what the frick

proven lantern
#

make another table keyed off of the user

tulip ledge
#

but not with redis

sage bobcat
tulip ledge
#

I'm using keyv mysql

#

so making another table isn't an option x)

lyric mountain
proven lantern
#

add a new column

tulip ledge
#

so a new column for each user

lyric mountain
#

And my opinion might be biased from my experiences with winapi

tulip ledge
#

with an active state true or false?

#

and what about the channels?

lyric mountain
#

Ik c++ is not only winapi, but it left a sour taste

proven lantern
#

some activites might not conflict with others

tulip ledge
#

mmh

earnest phoenix
tulip ledge
#

but what about the channels?

lyric mountain
proven lantern
tulip ledge
#

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µ

proven lantern
#

you'd want another table

lyric mountain
#

I can get the reasoning for the rest, like not using new and declaring variables like Class abc;

tulip ledge
#

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

proven lantern
#

but if that's not an option then it'll get dirty

sage bobcat
hushed robin
#

someone help me

#

i keep getting bad request with graphql

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
lyric mountain
proven lantern
lyric mountain
#

the myth comes mostly from java EE types (or old libs)

tulip ledge
lyric mountain
#

which is not really the standard lib

tulip ledge
#

that's why I used the expiry map as it's a map with a ttl built in

proven lantern
#

is that possible?

earnest phoenix
tulip ledge
#

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?

hushed robin
#

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
        }
    }
}```
tulip ledge
#

isn't it achieving the same thing but then with latency?

proven lantern
tulip ledge
#

true but how much memory do you think it'll take in?

proven lantern
#

depends, but at somepoint you'll run out

lyric mountain
earnest phoenix
proven lantern
#

restarting the server will clear everyones state

tulip ledge
#

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

earnest phoenix
#

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?

tulip ledge
#

as I have a user and profile cache already and then a state cache aswell

proven lantern
tulip ledge
#

what do you mean autodeleted?

proven lantern
#

ttl attribute

tulip ledge
#

if the server restarts, the memory gets cleared too no?

hushed robin
proven lantern
#

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

tulip ledge
#

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?

hushed robin
#

nvm i fixed

proven lantern
tulip ledge
#

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

hushed robin
#

wtf is Ecchi

#

nvm

#

google told me

proven lantern
tulip ledge
hushed robin
#

is it possible to make it so

spark flint
#

i need to add caching to my site KEKW

hushed robin
#

you can select many choices in slash command option

tulip ledge
#

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

proven lantern
tulip ledge
#

never used reddis before

proven lantern
#

it's a database that uses memory instead of storage

tulip ledge
#

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?

proven lantern
#

yeah, having a ttl field would be nice

#

use dynamodb

tulip ledge
#

nvm keyv has a ttl

proven lantern
#

nice

tulip ledge
#

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

proven lantern
#

the ttl should be longer than any activity will ever take

tulip ledge
#

ok so like half an hour?

proven lantern
#

idk how long they are

tulip ledge
#

yeah max 15 minutes

proven lantern
#

i'd need more domain specific knowledge

hushed robin
#

why tf do anilist descriptions have html in them

tulip ledge
lyric mountain
#

give him more context

proven lantern
#

specialized knowledge of the activity for you bot

tulip ledge
#

oh alright

lyric mountain
hushed robin
#

now i need to manually remove html

lyric mountain
#

yes

#

a simple replace chain will do it

#

they only use formatting tags, nothing exceptional

tulip ledge
#

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?

proven lantern
#

i'd make the timeout like 10x the longest a game could take

tulip ledge
#

so 200 minutes?

#

3 hours and 20 minutes

proven lantern
#

that should be enough

#

you can always change it if you need more time

tulip ledge
#

alright

#

but it's not like 3 hours and 20 minutes could be overkill?

hushed robin
#

why tf is some of the text it returns all caps

lyric mountain
#

likely enums

hushed robin
#

how can i make it not caps

#

just first letter caps

tulip ledge
#

alright, and how do you think I should save them then? key: userid, value: task?

lyric mountain
#

optionally make a function so u dont need to type it every time

tulip ledge
#

because I need to find a decent way of saving the channels too right?

proven lantern
#

the key should be the activity id or just a generic id

tulip ledge
#

mmmh

#

but how should I get it from the db then?

#

because keyv is essentially like a map, I have to db.get(key)

proven lantern
#

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

tulip ledge
#

Wow hold on, I don’t get this

proven lantern
#

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

hushed robin
tulip ledge
#

ohhh, no no, that's not how it works haha

hushed robin
#

w me

proven lantern
tulip ledge
#

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

proven lantern
tulip ledge
#

mhm ok

proven lantern
#

you dont care if two different users run an intensive command at the same time?

tulip ledge
#

yeah I see what you mean

#

I do, if it's in the same channel

proven lantern
#

so what you want is this key ['intensive_command', channel.id].join('|')

tulip ledge
#

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

proven lantern
#

queries by key should be quick

hushed robin
#

how do i get this from the anilist api

proven lantern
#

select statements with joins are where you run into issues with speed

tulip ledge
#

for the other commands I can just use 1 query for the user

#

Alright @proven lantern thank you so so much for helping me ā¤ļø

frosty gale
#

@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

earnest phoenix
frosty gale
#

what does the new header even contain?

#

i hope its not os specific functions

#

as in its completely static

proven lantern
tulip ledge
#

well I do want it to block others tho but I already implemented it

#

it's working like it should

proven lantern
#

noice

tulip ledge
#

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

earnest phoenix
# frosty gale what does the new header even contain?

It contains the necessary declarations for the dynamic memory allocation operations provided by the language, it includes the following:

  1. operator new - used to allocate memory dynamically in the free store
  2. operator new[] - used to allocate memory for arrays dynamically in the free store
  3. operator delete - used to deallocate memory allocated using operator new
  4. operator delete[] - used to deallocate memory allocated using operator 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

wheat mesa
#

What about smart pointers ;c

proven lantern
#

can you set a ttl for each record separately?

tulip ledge
#

; )

#

I just made the ttl the cooldown of the command as the commands have cooldowns like 10 mins and 1 hr and stuff

proven lantern
#

nice, so each activity can have a ttl that makes sense for the activity

tulip ledge
#

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

hushed robin
#

how can i make this embed look better

proven lantern
#

headers

tulip ledge
#

how did u do that

proven lantern
#

## headers

#

big headers

frosty gale
#

im compiling with -ffreestanding and static libgcc so no standard lib at all (my mistake)

#

though im happy to hear your ugly possible solution

earnest phoenix
tulip ledge
#

wait was headers a feature since like always?

#

I'm sure I've never seen it used before

earnest phoenix
#

It's a new feature

proven lantern
#

discord needs to support table markdown soon

tulip ledge
#

ah ok cuz block quotes and such were already a thing

tulip ledge
proven lantern
tulip ledge
#

ah true

tulip ledge
proven lantern
#

this is my layout now. i don't like how the numbers line up

tulip ledge
#

that way the numbers are perfectly under each other

proven lantern
#

i was going to make 2 versions

tulip ledge
#

just one field with the users and then one field with the points

proven lantern
tulip ledge
#

ah

#

add pagination?

lyric mountain
#

including the emojis

proven lantern
#

pagination would be guild wide so they would interfere

lyric mountain
#

this forces a monospaced font, so they'll line up

proven lantern
#

so it'll be offset

tulip ledge
tulip ledge
proven lantern
tulip ledge
#

or the empty unicode character idk if that works on dc tho

proven lantern
#

could work

tulip ledge
#

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

proven lantern
#

that could work

tulip ledge
#

yeah

#

that's what I did

tulip ledge
proven lantern
#

or % 25

#

yeah

tulip ledge
#

what can you do that with arrays? oh no I see what you mean

earnest phoenix
# frosty gale though im happy to hear your ugly possible solution

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);
}
tulip ledge
#

I swear to god c++ is chinese for me, imma stay with high level languages for the time being

peak drum
#

Everybody that doesn’t have a basic knowledge of programming would say that about html

wheat mesa
#

@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
earnest phoenix
# wheat mesa <@456226577798135808> I’m learning C for uni in the fall, and I’m creating some ...

That depends, you should generally always go for references instead of pointers

However, there can cases where you should use pointers:

  1. Nullability, if the passed argument can be absent (NULL) then use pointers
  2. Pointers can be reassigned to point to different objects at different times
  3. Pointers can be used to manage the ownership of objects, such as dynamically allocated memory
  4. 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

frosty gale
#

thanks though I appreciate it

earnest phoenix
#

You're welcome

frosty gale
#

kinda like c but with added stuff

#

old computer with the newest rgb and case

earnest phoenix
proven lantern
earnest phoenix
#

I'm sorry but your health class has betrayed you, they're making you use unhealthy practices by implementing everything yourself

proven lantern
hushed robin
#

is there anyway to get a list of all anime

#

on anilist

lyric mountain
#

no, do you even have an idea of how many anime exists?

hushed robin
#

i could get them all

#

but

#

it would take 377 requests to the api

#

i wonder if there an option that takes less request

frosty gale
#

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 :)

frosty gale
#

do all heavy lifting for you

#

(we don't talk about c)

hushed robin
#

i really need this

sharp geyser
#

no one cares

hushed robin
#

lol

#

bros hostile for no reason

frosty gale
#

battleless at this point make a new account and rebuild your reputation as a kind young man just learning the ropes

hushed robin
#

my reputation is perfectly fine

sharp geyser
#

No one wants to help someone who tells them they are wrong

sharp geyser
#

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

hushed robin
#

that's a lie

#

and you know it

#

🤣

frosty gale
#

But I doubt the api will let you retrieve all of them at once

hushed robin
#

i did

frosty gale
#

too computationally expensive for an api

#

just go through all pages and collect the animes that way

hushed robin
#

thats a lot of requests tho

#

when my bot is public it will hurt

queen needle
#

Why do you want all animes?

hushed robin
queen needle
#

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?

hushed robin
#

yes but it will take my bot out for like 4 minutes due to ratelimits

#

do you think that'll be fine

sharp geyser
#

Ratelimits through what?

hushed robin
#

wym

#

the apis ratelimits

sharp geyser
#

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

hushed robin
#

cache?

#

heck no

queen needle
#

...

frosty gale
sharp geyser
#

issue with this is if your bot goes down then you will have to repopulate the cache

hushed robin
#

yea

#

thats why i was going to use database

sharp geyser
#

Bro what

hushed robin
#

maybe i can just do one request per minute

frosty gale
#

do the animes constantly update? is that why you need to fetch stuff constantly?

hushed robin
#

no

#

tbh it's probably fine to just update them everytime the bot restarts

sharp geyser
#

Anime doesn't update within a day unless its the day a new episode releases (which isn't done but like once a week)

hushed robin
#

i mean episodes don't really matter

#

i just want the name and id of the anime

sharp geyser
#

Then why the fuck are you worried about constantly updating them

hushed robin
#

cus

#

if new anime

#

it needs to be updated

sharp geyser
#

Then idk fetch every other day to repoplate the cache

#

or once a week

frosty gale
#

isn't this the kind of problem graphql is designed to solve?

queen needle
#

^

sharp geyser
#

I don't really use graphql so no idea

frosty gale
#

can't you look up only the most recently updated animes or something on the api

hushed robin
#

and there's about 18550

frosty gale
#

that's the whole point of graphql afaik lol conditional queries so you don't have to fetch and process everything

hushed robin
#

so divide them and u get 371 requests

frosty gale
#

I mean do it on the api side

sharp geyser
#

point of graphql is to fetch only what you need

frosty gale
#

so the api only sends you back the most updated ones

hushed robin
#

let me see

sharp geyser
#

if you only need the id's and names then just fetch all the animes and only grab the name and id

frosty gale
#

no wonder no one uses graphql šŸ’€

#

at this point just use rest

sharp geyser
#

the point of graphql was to get around what rest doesn't do

hushed robin
#

after further checking the docs

#

you cannot get recently updated anime

#

or anything

sharp geyser
#

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

hushed robin
#

it's cool

sharp geyser
#

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

frosty gale
#

feels unnatural having a whole query language for it though and sending that query string as a body for your data

sharp geyser
#

and you can refetch every other day or weekly thats the only solution I can think of

sharp geyser
#

but its just something new to learn that doesn't really matter unless you're sending massive amounts of data over rest

hushed robin
#

it's easy to learn

#

i learned it quickly it's cool stuff

sharp geyser
#

easy to learn how to use an already implemented graphql

#

harder to actually implement your own graphql

hushed robin
#

yeah ofc

#

ok i am going to write a script to store all of the animes into my database

sharp geyser
#

That seems so pointless

#

but ok

hushed robin
sharp geyser
#

Yea but storing it in your database is the pointless thing

#

Just store it in a map

queen needle
#

If someone is using the command won't they know what anime they want to look up?

hushed robin
#

which is what I need to fetch the data

queen needle
#

You can't search by name?

hushed robin
#

but it can return incorrect results

queen needle
#

Couldn't you take 10 results show them in an embed with a select menu letting them choose which one they want?

hushed robin
#

but autocomplete is better

queen needle
#

But this is easier, and isn't a bad idea

hushed robin
#

ITS WORKING

#

oh wait

#

is what i'm doing breaking this rule

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
#

does it still count

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

yea

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
#

autocomplete

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
#

i already stored it in my database

#

i guess i need to delete it now

hushed robin
#

it only takes like 3 minutes

sage bobcat
#

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.

hushed robin
#

hm

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
#

idk how to cache for this

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

no

sage bobcat
#

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.

hushed robin
#

why can't i just usue a map

lyric mountain
#

Maps aren't compressed

#

You'll run out of memory very quickly

#

Besides, using redis is very much map-like

hushed robin
lyric mountain
#

Depends on your reqs/m

hushed robin
lyric mountain
#

How many queries you do per minute

#

And how long u keep it in memory

hushed robin
#

till my bot dies

lyric mountain
#

Then it's not really a cache

#

Store it in a database then

hushed robin
#
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 ?

lyric mountain
#

Don't use redis if ur keeping it forever

hushed robin
#

well i'm not

#

because it breaks anilist tos

lyric mountain
#

?

#

To keep the data?

hushed robin
wheat mesa
#

since when have you cared about tos

lyric mountain
#

Ok but that's a different matter

#

How long do you plan to keep the fetch data?

hushed robin
wheat mesa
#

(never)

hushed robin
lyric mountain
#

Redis is for caching, what ur doing is not a cache

#

?

hushed robin
#

if I store it it will break tos

lyric mountain
#

Then set a time for that data to expire

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

Either store permanently on a databse or temporarily on redis

#

Not the other way around

hushed robin
#

what

sage bobcat
lyric mountain
#

What are u even talking abt?

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

ok

#

i don't think you understand the current conversation

sage bobcat
#

One message removed from a suspended account.

lyric mountain
hushed robin
#

have a good day

hushed robin
lyric mountain
#

Store the data for like 1 hour or so

hushed robin
#

that defeats the point tho

lyric mountain
#

With expiration set to LTA

sage bobcat
lyric mountain
#

If u store permanently it defeats the point of a cache

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

"Hoarding’ or mass collection of data from the AniList API is strictly prohibited."

would u consider this breaking this rule

sage bobcat
lyric mountain
hushed robin
sage bobcat
#

One message removed from a suspended account.

lyric mountain
sharp geyser
#

Why not just make your own database of anime information at this point trollface

lyric mountain
#

Whenever the data is acessed it'll refresh the timer

#

So frequently acessed data will always be cached

hushed robin
#

huh

lyric mountain
#

Huh what

sharp geyser
#

All it does is purge data that isn't frequently access right haku?

wheat mesa
#

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

lyric mountain
#

Caches have 2 modes, either LTA or LTW

sharp geyser
#

any data they request you can then fetch from the anilist api and recache it

sage bobcat
lyric mountain
#

Last time acessed or last time written

hushed robin
#

ok

hushed robin
#

i'm not doing this anymore

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

Already gave up ffs

hushed robin
#

no

#

i'm not giving up

sharp geyser
#

Hey props to him for at least going at it for more than a few minutes

hushed robin
#

i'm not doing it because it's against their tos

lyric mountain
#

AaaaaaaaaaaaaaaaaaaAAaaaaaaa

#

Just use a damn timed cache

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

a timed cache

sharp geyser
#

Woah

hushed robin
#

dude for my purpose i would need it to last forever

#

so it means i just can't do it

lyric mountain
#

Then u don't need a fckin cache

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

Actually what haku said should work for you

lyric mountain
#

Both me and faithie are saying the same

sharp geyser
#

while you might not be able to autocomplete everything you can at least autocomplete commonly searched up animes

hushed robin
#

do you guys understand what i want to do ?

sage bobcat
sage bobcat
sharp geyser
#

then make your own fucking anime database and fetch from it

#

smh

lyric mountain
#

First of all, u can't put all anime on autocomplete

hushed robin
#

i can

sharp geyser
#

Discord has a limit does it not?

hushed robin
#

it's autocomplete

lyric mountain
#

How are u gonna put almost 200k entries in a damn autocomplete?

hushed robin
#

so i will just filter it by what the persons searching

#

then slice at 25

wheat mesa
#

šŸ’€

hushed robin
#

so it fits in discords limits

hushed robin
lyric mountain
#

25...

hushed robin
#

but i deleted the database

sharp geyser
#

are you trying to implement a fuzzy search or smth in a discord bot

lyric mountain
#

Do u have any idea on how many anime with very similar name there are?

#

And how long some anime names csn get?

hushed robin
#

i want an autocomplete man

lyric mountain
#

For example Dungeon Ni Deai Wo Motomeru No Wa Machigatteiru Darou Ka?

hushed robin
#

i would just truncate

sharp geyser
#

That makes no sense

hushed robin
#

yes

lyric mountain
#

That defeats the purpose of autocomplete entirely

sharp geyser
#

Then you are just cutting off the name of the anime

hushed robin
#

so

sharp geyser
#

which is pointless

lyric mountain
#

Many anime share a very similar name

hushed robin
#

it will still show accurate results

sharp geyser
#

nah

hushed robin
#

yea

sharp geyser
#

I'd rather search anilist themselves than use your auto complete

hushed robin
#

sure

lyric mountain
#

Shingeki No Kyojin
Shingeki No Bahamut

#

Good, u truncated, but both are shingeki

sage bobcat
hushed robin
lyric mountain
#

See the message below it

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

no...?

sharp geyser
#

battleless you are a hopeless cause

hushed robin
#

discords text limit for autcomplete options is like 100

#

both of thhose would fit easily

sharp geyser
#

Thats not the point

lyric mountain
#

The issue becomes even worse when u consider oneshot-based anime

#

Which have very long names

#

Like danmachi

hushed robin
#

that looks short to me

lyric mountain
#

Or Gate Jieitai Kanocchi Nitte Kaku Tatakaeri

lyric mountain
sharp geyser
#

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

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

Oneshots have basically a sentence as a name

sage bobcat
#

One message removed from a suspended account.

hushed robin
#

so it would be fine

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

"That time I got reincarnated as a XXX and did YYY"

sharp geyser
#

alright im done fucking with this guy

#

he's on his own

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

Akikan

sharp geyser
#

that time i got reincarnated as a spider and was a horrible anime

#

šŸ‘€

lyric mountain
#

Nahhh

#

I'm craving for the next season

sage bobcat
#

One message removed from a suspended account.

hushed robin
sharp geyser
#

That anime makes zero fucking sense

#

They quite literally kept true to what a spider does and time warps everything

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

Makes the story hard to follow if you dont know spiders perceive time differently

lyric mountain
#

It's a VEEEERY well done mindblow

sharp geyser
#

Im not waiting till the second season

lyric mountain
#

No really, it all makes sense retroactively

sharp geyser
#

thats like saying one piece gets good at episode 500

lyric mountain
#

Like, suddenly u understand everything what happened and why it happened

sharp geyser
#

Watching that anime gave me a headache

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

Also dont get me started on Re:Zero

#

šŸ‘€

lyric mountain
#

Re:Zero Kara Kuro desu yo

#

I think

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

Re:Zero MC has the biggest plot armour i've ever seen

lyric mountain
#

Rezero has the most stupid mc u mean

#

Nah, zero no tsukaima mc is worse

sharp geyser
#

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

lyric mountain
#

I'd be fine with that if he wasn't a simp for priscilla

#

Rem didn't deserve that

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

You'll end up hating subaru too

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

Lmao

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

The only anime I couldn't stand finishing was zero no tsukaima

#

And I saw REALLY bad anime

sharp geyser
#

Another horrible anime was SAO

#

First & Second arc was okay

#

after that nah

sage bobcat
#

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.

lyric mountain
#

Sao is a funny case, they messed up every even arc and hit a banger on every odd arc

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

Dont get me wrong I like it but after a while it got too weird and repetitive

#

Also just bought DayZ

lyric mountain
#

Aincrad good, alfheim bad, ggo good, mother's rosario bad, alicization 1 good, alicization 2 bad

lyric mountain
sharp geyser
#

Oh of course

#

I mainly got it to play with some friends tho

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

MR didn't have the same oompf of the rest

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

It was all about the other asuna that had a terminal disease

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
#

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

lyric mountain
#

Skill issue

hushed robin
#

😐

sage bobcat
hushed robin
#

I’m a good programmer

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed robin
sharp geyser
sage bobcat
hushed robin
#

Yknow what I mean

sharp geyser
#

lol

sage bobcat
hushed robin
#

but I’m at least decent

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

If you were decent you would get your head out your ass

wheat mesa
sharp geyser
#

Im in the valley of despair all the time

hushed robin
sharp geyser
#

thats because you're at the Peak of "Mount Stupid"

hushed robin
#

no

#

I don’t think I’m overconfident

wheat mesa
#

I'd say I'm like slightly above valley of despair

sage bobcat
#

One message removed from a suspended account.

proven lantern
#

i'm the most modest person in this entire discord server

wheat mesa
#

the irony of that statement

sage bobcat
#

One message removed from a suspended account.

hushed robin
sharp geyser
#

At this point my knowledge of programming comes from what tim has told me

hushed robin
#

and of course I want to do things my way it’s my code 🤨

sharp geyser
#

and a lot of trial and error

sage bobcat
sharp geyser
hushed robin
sage bobcat
hushed robin
#

I didn’t take your suggestion because it wasn’t what I wanted to do

sharp geyser
sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

That statement alone speaks volumes

hushed robin
#

so I just scraped the idea entirely

sharp geyser
sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

you asked for a solution they gave you one and you didn't want it

#

yep not stubborn

hushed robin
sharp geyser
hushed robin
#

they decided to give me one, I didn’t ask

sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

What the fuck are you on bro

hushed robin
#

but it wasn’t what I was looking for so I didn’t implement it

hushed robin
sharp geyser
#

Asking for help is asking for a solution to your problem

pale vessel
#

what do you even need help with

sharp geyser
#

nothing now

sage bobcat
#

One message removed from a suspended account.

pale vessel
#

good

sharp geyser
#

he doesn't wanna do it anymore

hushed robin
sharp geyser