#We're making a wrapper over the Discord API using Java!!

1 messages Β· Page 5 of 1

lavish nest
#

and project can grow with new contributors from outside, you never know

molten tusk
#

wow

oak flare
#

damn

#

got no email about it somehow

#

ah well its draft

molten tusk
#
public class ExampleSlashCommand {

    @SlashCommand(
        name = "quiz", description = "A fun Java quiz", options = {
            @CommandOption(
                name = "q1", description = "What is an Integer?", type = CommandOptionType.STRING
            ),
            @CommandOption(
                name = "q2", description = "What package is List in?", type = CommandOptionType.STRING
            ),
            @CommandOption(
                name = "q3", description = "What does JVM stand for?", type = CommandOptionType.STRING
            ),
            @CommandOption(
                name = "q4", description = "Is a String a primitive?", type = CommandOptionType.STRING
            ),
        }
    )
    public void handle(SlashCommandEvent event) {
        // TODO: Logic to handle the slash command
    }
}
#

oh its draft yes

#

πŸ–€

#

wazei is doing some many pr

sharp ferry
#

Not sure if using annotations is a good solution

oak flare
sharp ferry
#

is to compile time check the argument and only provide what is possible

#

contrary to what jda is doing

plain ledge
#

not method yk

oak flare
#

well discuss that on github please

molten tusk
#

I think parameter might be too hard because a slash command can have many options and branches

#

The example is so long lol

molten tusk
#

I'm really supporting this projects "no boilerplate" approach!

molten tusk
plain ledge
molten tusk
#

Annotations have compile time check already I thought

#

bc you have to specify the fields in the code

#

I have never worked with annotations before

plain ledge
#

validation*

molten tusk
#

Data type validation

orchid portal
orchid portal
sharp ferry
orchid portal
sharp ferry
#

Yea

orchid portal
#

how do i test the api? like local setup @oak flare

oak flare
#

you mean like running an example bot?

#

the project include one

#

put your bot token and you are good to go

#

or you mean like really testing

orchid portal
#

smhow i completely missed the example project

oak flare
#

lmao

orchid portal
#

@oak flare does the bot works?

#

coz its not working for me

oak flare
#

it does for me

#

what exactly is not working?

orchid portal
#
17:40:16.106 [vert.x-eventloop-thread-0] WARN  com.javadiscord.jdi.internal.gateway.handlers.events.EventCodecHandler - Unknown event received PRESENCE_UPDATE
17:40:32.209 [vert.x-eventloop-thread-0] ERROR io.vertx.core.impl.ContextImpl - Unhandled exception
java.lang.NullPointerException: Cannot invoke "com.javadiscord.jdi.core.models.guild.Guild.id()" because "guild" is null
        at com.javadiscord.jdi.core.Guild.<init>(Guild.java:32) ~[core-1.0.0.jar:?]
        at com.javadiscord.jdi.core.GatewayEventListener.getGuild(GatewayEventListener.java:67) ~[core-1.0.0.jar:?]
        at com.javadiscord.jdi.core.GatewayEventListenerAnnotations.receive(GatewayEventListenerAnnotations.java:243) ~[core-1.0.0.jar:?]
        at com.javadiscord.jdi.internal.gateway.handlers.events.EventCodecHandler.lambda$handle$0(EventCodecHandler.java:266) ~[gateway-1.0.0.jar:?]
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) ~[?:?]
        at com.javadiscord.jdi.internal.gateway.handlers.events.EventCodecHandler.handle(EventCodecHandler.java:266) ~[gateway-1.0.0.jar:?]
        at com.javadiscord.jdi.internal.gateway.WebSocketHandler.handleMessage(WebSocketHandler.java:76) ~[gateway-1.0.0.jar:?]
oak flare
#

maybe ask wazei

orchid portal
#

how

#

hes not active on discord

oak flare
#

make a github issue or smth

#

didnt test the new code

#

so it might not be working for me as well

#

and be a code issue

oak flare
orchid portal
#

lmk

oak flare
#

bot works fine for me

#

when did that error happen?

orchid portal
oak flare
#

everything worked fine with default code

orchid portal
oak flare
#

just like any main method

orchid portal
#

ohh u clicky click the hexagon in ur ide's gui goo

oak flare
#

how do you run it? lol

orchid portal
#

./gradlew run

#

try dat

oak flare
#

still works just fine

#

did you setup your bot correctly?

orchid portal
oak flare
#

yep

orchid portal
oak flare
#

well I just gradle run instead of the wrapper

#

I doubt thats a problem though

orchid portal
#

yea that should be no problem

#

@oak flare is ur bot is in more than 1 server?

oak flare
#

uh no

orchid portal
#

my bot is in 2 server and its only worky for 1 of em

oak flare
#

ah that could be a problem

#

there is some sharding stuff

#

not sure how it works

orchid portal
#

me neither

oak flare
#

might be our implementation

#

I would make an issue

orchid portal
#

@oak flare also have we thought anything about event listiners with a constructor?

oak flare
#

wdym exactly?

orchid portal
oak flare
#

ah well idk

#

but we should give the user the ability to create some factory implementation

#

also worth an issue

orchid portal
oak flare
#

currently it only uses zero arg constructor

orchid portal
#

i think we should get rid of @EventListiner

orchid portal
#

i also saw that code today

oak flare
orchid portal
oak flare
#

and then?

orchid portal
#

handle each even listener annotation separately

oak flare
#

so it only scans for methods

#

instead of classes

orchid portal
#

ys

oak flare
#

yeah would make sense tbh

#

thats how spigot does it

orchid portal
#

i'll try implementing that

oak flare
#

well I think we should maybe provide both approaches?

oak flare
orchid portal
oak flare
#

well everyone

orchid portal
oak flare
#

such an important design decision should be discussed

molten tusk
orchid portal
molten tusk
#

ya

orchid portal
#

@oak flare can u try

oak flare
#

im eating rn

molten tusk
#

when is wazei back?

orchid portal
#

no one knows

#

well probably someone knows but i dont

oak flare
#

huh it doesnt work for me as well

#

but I get different error

#
15:38:46.094 [vert.x-eventloop-thread-0] INFO  com.javadiscord.jdi.internal.gateway.WebSocketManager - Connected to Discord
15:38:46.400 [vert.x-eventloop-thread-0] ERROR io.vertx.core.net.impl.ConnectionBase - Max frame length of 65536 has been exceeded.
15:38:46.421 [vert.x-eventloop-thread-0] ERROR io.vertx.core.net.impl.ConnectionBase - Connection was closed
15:38:46.421 [vert.x-eventloop-thread-0] WARN  com.javadiscord.jdi.internal.gateway.WebSocketHandler - The web socket connection to discord was closed. You will no longer receive gateway events.

as soon as the bot is on two server

#

and completely works fine again after removing from one of the server

#

I think you need some proper sharding setup for multiple server

#

well not sure tbh peepo_think

#

sharding seems to have a different purpose

molten tusk
#

wazei taught us what sharding is

#

either here or somewhere else but 1 shard = 1 web socket connection

oak flare
#

but you dont need one websocket for each server right?

molten tusk
#

never

molten tusk
#

it is working for me :S

orchid portal
oak flare
#

just make a github issue bro

orchid portal
molten tusk
#

i need to turn on bot

#

its so slow

#

@orchid portal test it, online!!=

oak flare
#

and in this case it doesnt work for both of us with different errors lol

orchid portal
molten tusk
#

I went afk hehe

orchid portal
molten tusk
#

It's online still

#

Working from my phone

#

Do you see it offline??

orchid portal
molten tusk
#

Oh

molten tusk
#

i dont know how to make a bot

oak flare
#

what exactly?

molten tusk
#

when i try invite it to a server i get the error lilcoder gets

oak flare
#

as said I wouldnt be surprised if thats a code issue

#

so please make an issue on github

molten tusk
#

its not a code issue because i can't invite the bot to my server

#

the issue wants a reproduction steps

oak flare
molten tusk
#

if i make my own bot and invite to my own server everything is working

#

if somebody else makes a bot and I invite it to my own server I get the code grant error

oak flare
#

ah

#

go into discord applications setup

molten tusk
#

ok

oak flare
#

there is this option in the Bot settings of your application

molten tusk
oak flare
#

hm

#

then idk

molten tusk
#

i fixed it

#

i had to turn off oauth2 code grant

#

its working for me in 3 servers

molten tusk
#

i was given this to show off ❀️

#

snippet of how little the boilerplate is

oak flare
#

nice

restive void
#

Bababooie

sharp ferry
molten tusk
#

Maybe all intents are set by default

#

@oak flare can you help

restive void
#

Whats up with this project

plain ledge
#

it's in a somewhat working state

restive void
#

Interesting

light loom
#

I'll revive this soon now that i'm back

oak flare
#

no way

#

welcome back peepo_heart

light loom
sinful snow
#

has this project been developed ?

light loom
oak flare
#

does volatile provide performance gains though?

#

and we dont do any compare and set

#

so volatile should just be fine

light loom
#

All the operations are thread safe on AtomicBoolean and I think it's more "safer" than using volatile. The reason I say safety is because I've had problems in the past with volatile which sometimes causes values to not been seen. I guess PTSD really

oak flare
#

yeah sounds like PTSD to me lmao

light loom
#

@oak flare there are some available tickets if you want to start with them

#

I beleive we're kinda done but just need to test and make sure we're not missing anything

#

then document the code

#

and we're ready for maven

oak flare
#

hm ok

light loom
#

I would really appreciate if the testing could be the focus though because I really really wanna publish to maven

#

A good way is to write bots, add them to the :examples and see how it feels

light loom
#

I did a comparison with python and it was really close to the "smallest" possible code to write an echo bot

#

Which honestly is super impressive and goes to show how all our contributions and efforts have great weight in comparison to other frameworks

#

Soon

void main() {
  new Discord().start();
}```

Is a possibility because of the language enhancements
oak flare
#

hm its hard for me to write the tests without background tbh

#

it talks about this right? com.javadiscord.jdi.core.api.ApplicationRequest

#

but where can I find it in the discord api docs?

light loom
#

So each thing is named after the resource in discord

oak flare
#

I see

light loom
oak flare
#

and this got two endpoints I guess?

#

get and edit

light loom
#

yeah probably

#

if we're missing anything then create tickets

#

but I think it's the first one

oak flare
#

ok now I need to find out how to properly write integration tests πŸ˜΅β€πŸ’«

light loom
#

follow the existing examples

oak flare
#

yeah going to check older prs

light loom
oak flare
#

going to come back if I need help

light loom
#

when you commit any channels you reference; use 1242792813700055134L as the ID

#

i mean test locally in your own but change to ^ after

oak flare
#

I would need to setup a discord bot for testing right

#

damn

light loom
#

i can give u my creds

#

and access to the GHA server

#

ah wait i cant

#

GH doesnt expose secrets

oak flare
#

all good

#

I am just not sure how to properly test

#

like what do I test in a simple get request?

#

that it just succeeds?

light loom
#

yeah and just check the result is expected in your discord server

#
    @Test
    void testCreateInvite() throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(1);

        long testChannelId = 1242792813700055134L;

        AsyncResponse<Invite> asyncResponse = guild.channel().createInvite(testChannelId, 10000, 10, true);

        asyncResponse.onSuccess(res -> {
            assertEquals(10000, res.maxAge());
            assertEquals(10, res.maxUses());
            assertTrue(res.temporary());
            assertNotNull(res.code());
            latch.countDown();
        });

        asyncResponse.onError(Assertions::fail);

        assertTrue(latch.await(30, TimeUnit.SECONDS));
    }

#

for example this test

oak flare
#

well wouldnt it be different depending on bot token?

light loom
#

but also manually make sure the "thing" happened in discord

light loom
#

just give full perms

#

ty btw peepo_heart

oak flare
#

np

#

but like I get an Application object with a bunch of fields, do I even check these fields?

#

like if we check this test:



    @Test
    void testGetUser() throws InterruptedException {
        long wazeiUserId = 821143476455342120L;
        CountDownLatch countDownLatch = new CountDownLatch(1);
        AsyncResponse<User> asyncResponse = guild.user().getUser(wazeiUserId);
        asyncResponse.onSuccess(
                user -> {
                    assertEquals(wazeiUserId, user.id());
                    assertEquals("wazei", user.displayName());
                    assertEquals("0", user.discriminator());
                    assertFalse(user.bot());
                    countDownLatch.countDown();
                });
        asyncResponse.onError(Assertions::fail);
        assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
    }
#

what if you change your username?

#

the test would fail

#

this seems like a major problem with testing this

#

we start to assume things

#

also I see you using CountDownLatch everywhere, I think at this point it might make sense to make a wrapper around AsyncResponse that got the logic for it

#

also code like this:

AsyncResponse<Void> response = ...; // #1
response.onSuccess(...);
response.onError(...);

couldnt this fail if technically the call #1 executes fast enough to be before the onSuccess/onError calls and thus they get ignored?

#

this probably wont happen 99.99% of the time

#

but this is kinda assuming stuff again

light loom
light loom
oak flare
light loom
#

i mean sure feel free - the main goal is to ensure everything works so how its done is up to you

oak flare
#

yeah true, though there is probably more important stuff currently

light loom
#

yeah - i just don't want us shipping a broken product

#

frankly, other discord libraries have little to no tests! shocking

oak flare
oak flare
#

no wonder why they are ass lmao

light loom
#

yeah

oak flare
#

but its just hard to test tbh

light loom
#

its hard that's right but once we've done it - we can without doubt say "our discord framework is the best"

#

because we have test evidence

oak flare
light loom
#

create a discord account specific for the tests πŸ˜„

oak flare
#

yeah I thought about that peepo_think

#

but like overall, what about deleting a channel?

#

you would want to have the same environment before and after testing

light loom
#

yeah so a delete channel test = create first (using the API) and then run delete

oak flare
#

so do you setup the server using the tests like creating a channel, store the id and then delete later?
this would assume that the create endpoint works without problems peepo_think

light loom
#

i only do some manual setup but if we can we can setup the environment within the test itself

oak flare
#

so we start testing by using our own implementations

#

im not that deep into testing, so I cant really tell shit

light loom
#

the tests are allowed to be bad

oak flare
#

lol

light loom
#

as long as its "testing"

light loom
#

can you elaborate

oak flare
#

why not?

#

you think its just not realistic right?

light loom
#

let me test it hang on

oak flare
#

is assertTrue legal in @BeforeAll?

light loom
#

a bit weird ig

oak flare
#

basically what LiveDiscordHelper is doing

light loom
#

how

#

well, even so - code doesn't need to be perfectr

oak flare
#

all good, just trying to get familiar with the code base

light loom
#

it was a simple way to reduce duplication and to focus more on testing

oak flare
#

and kinda got confused about the LiveDiscordHelper

light loom
#

yeah its just used to start the server πŸ™‚

#

"Live" meaning - using the real discord server

#

assertTrue(STARTUP_LATCH.await(30, TimeUnit.SECONDS)); in factr

#

this probably isnt needed

#

STARTUP_LATCH.await(30, TimeUnit.SECONDS) just this is fine

oak flare
#

also is this even going to work?

asyncResponse.onError(Assertions::fail);
#

its going to run on a different thread

#

not sure if junit got support for that

#

seems weird nonetheless

#

also what do we do with endpoints that have optional parameters like ApplicationRequest#editCurrentApplication?

#

it currently doesnt really support that

light loom
oak flare
#

not in this case

#

ig

#

?

light loom
#

maybe a mistake ;o

oak flare
#

how would something like that look like? you got any other example cases?

#

maybe like ChannelRequest#createMessage?

light loom
#

yeah

#

i'll go through it all with you tomorrow because it's 11pm here and bed time πŸ˜„ but try get started and do what's best. keep tab on these questions because it's hard for me to answer your questions with the limited access I have to the code

oak flare
#

all good, just going to try on my own for today and you can then give feedback on the pr :D

light loom
#

thanks ❀️

plain ledge
#

@light loom do we have a functional way to define commands?

#

As opposed to annotations

molten tusk
#

Welcome back wazeii

steep spruce
light loom
#

We could save 1 extra line by doing new Discord(...).start();

#

It completes well for "smallest echo bot"

#

And competes well against the JS/python libraries for reduces boilerplate, that is an accomplishment for a java based lib

sharp ferry
#

could be better

#

with the new main class

light loom
#

If you use the provided one πŸ™‚

sharp ferry
#

wdym

light loom
#

In gradle mainClass = "com.javadiscord.Main"

#

Instead of creating your own

#

I'm trying to find some time to finish the project because we're really close

#

Then I can publish the first alpha version onto maven!

lavish nest
plain ledge
light loom
steep spruce
oak flare
#

?

light loom
#

is it because there's no token provided? is it the syntax? whattt

#

if you don't give a token, it'll grab it from env vars

#

otherwise, it'll call discord and create a bot automatically!!

#

joking at the last bit :p

#

but that would be a cool feature πŸ‘€

steep spruce
light loom
#

our code is better than python :3

#

i checked what python looks like

#

it's more ugly once you start getting deep into it

steep spruce
#

πŸ€”

#

idk when I used python I was not very knowledgeable

oak flare
light loom
oak flare
#

all good peepo_heart

#

your answer :(

light loom
#

updated lel

oak flare
#

not sure if you get my question

light loom
#

What exactly should I test?

#

each of the API method calls that we do

#

as for the default state

oak flare
#

yeah, sorry, but what is the default state

#

and assuming some default fields is just bad

light loom
#

honestly, i have no idea how to approach that - do whatever you think works for the test itself

#

i know i know

oak flare
#

we would need to make some setup and cleanup state, but what if these fail, then we end up in a broken state that we would need to fix manually

light loom
#

yeah pre-commit fails on every test so i'm kinda OK with the "it works on my machine" approach for now

oak flare
light loom
#

there's a bigger issue with long rate limits

#

for some endpoints you can only do like 5 requests per week

#

or something

oak flare
#

bruh what

light loom
#

at the least we should use these tests as a way of proving manual verification

#

we just need something/somebody to run through the work and check, does it at least work

#

we can always better the testing approach later

light loom
oak flare
#

damn

light loom
#

it's a pain to test discords API

#

a really big pain

#

and it's probably the reason nobody has done it

#

because they're bad

#

πŸ˜„

#

but us...

#

we are experts

oak flare
#

im not

light loom
#

you are good enough

#

at least an expert on this project

#

like you can follow the code and know where everything is

oak flare
#

how can I close these comments while editing a file? kinda annoying

#

nvm got it

light loom
#

it'll be so nice ❀️

oak flare
#

damn yea

#

nice detailed issue description peepo_heart

#

might work on it

light loom
#

do it! i have a lot of code I can share

#

I started working on it but forgot to fork the repo so i couldn't push

oak flare
#

bruh I have no idea how to do this testing shit

#

like there is no value at all if I add assertions like this:

assertEquals(1240663319203811329L, res.id());
assertEquals("TestBot", res.name());
assertEquals("This is a bot to test the java discord api wrapper.", res.description());
assertNull(res.tags());
light loom
#

pretty close?

#

yeah there is a value

oak flare
#

its going to fail for your bot

light loom
#

that's okay - at the least it works right?

#

it's like manually verifiying and using the junit test as the evidence

oak flare
#

well thats what onSuccess already tells me

light loom
#

good good, looks correct, we've deserialised the response correctly

#

and to get the correct response, the request needed to have been correct

#

so overall, correct

#

assertNull(res.tags()); besides this one, not sure if it should be null?

oak flare
#

yeah thats what the simple onSuccess check is telling me, but these field checks are worthless

oak flare
#
Application[id=1240663319203811329, name=TestBot, icon=null, description=This is a bot to test the java discord api wrapper., rpcOrigins=null, botPublic=true, botRequireCodeGrant=false, bot=User[id=1240663319203811329, username=TestBot, discriminator=2314, displayName=null, avatar=null, bot=true, system=false, mfaEnabled=false, banner=null, accentColor=0, locale=null, verified=false, email=null, flags=0, premiumType=null, publicFlags=0, avatarDecoration=null], termsOfServiceUrl=null, privacyPolicyUrl=null, owner=User[id=565887697269293066, username=squidxtv, discriminator=0, displayName=SquidXTV, avatar=77a4cb1ba1de4b24d8ec77fbe1ad82e5, bot=false, system=false, mfaEnabled=false, banner=null, accentColor=922250, locale=null, verified=false, email=null, flags=256, premiumType=null, publicFlags=256, avatarDecoration=null], verifyKey=144b5ed922052918556af0bc4990f788579c9cfdd1d5b625104e5690a9a70e9a, guildId=null, guild=null, primarySkuId=null, slug=null, coverImage=null, flags=565248, approximateGuildCount=1, redirectUris=[], interactionsEndpointUrl=null, roleConnectionsVerificationUrl=null, tags=null, installParams=ApplicationInstallParams[scopes=[applications.commands, bot], permission=633318697598975], customInstallUrl=null]
#

I guess the ? means it can be null

light loom
#

yeah i think so or optional/sometimes

#

problem is they use partial objects 😦

#

they sucky for that

oak flare
light loom
#

cool then yeah

#

i'm happy with your test tho, it's working

#

that's what matters

oak flare
#

hm im not sure

#

the type itself isnt prefixed

light loom
#

wym

oak flare
#

its an optional field

#

and not nullable

#

but could it be that our json parsing automatically makes it null?

#

if its not in the response

#

then we have the same shit for two different cases

#

in both cases it will be null

#

though in one its an optional field

#

and in the other its actually null

light loom
#

optional and null are the same really for a response

#

it's either there or it isn't

oak flare
#

hm not really

#

it gets interesting if a field is actually optional and nullable field

#

the user cant know if the object is actually null or just wasnt in the response

light loom
#

is there a usecase for this information?

oak flare
#

there might be

light loom
#

JDA doesn't give you that, it's null by default

oak flare
#

jda is ass though

light loom
#

yeah it is

#

😦

#

okay let me think on it

#

can always update the test once I come to a conclusion

#

and it's good because when we do implement it that check/changes, our tests will fail in the correct spots

oak flare
#

an example would be the Channel Resource
what if the user of our library uses the get channel endpoint and then
wants to do something based on three different scenarios:

  1. name wasnt included in the raw json (optional)
  2. name is actually null
  3. name exists
    it wont be able to do that because 1) and 2) look like the same in the Channel object
light loom
#

hmm

worthy flower
#

hello

#

do i go directly to project tasks and pick something or what ?

light loom
light loom
#

I was experimenting with the framework because I needed to make a command and I couldn't create forms because we forgot to do the impl

light loom
#

or somebody can implement it's available for now

wicked wadi
#

Hey, is this project alive?

steep spruce
#

not using slf4j? I have been disappointed

light loom
light loom
plain ledge
#

they feel WAYY to much code for them

light loom
#

The bit that feels verbose is the annotations part for commands but the regular method is fine

plain ledge
#

Is there a way to search threads

light loom
#

hm, it'll be one of the actions we created

#

It's been a little while since I've looked at the codebase, my memory is a little foggy at the moment

plain ledge
#

but i found it!

light loom
#

Oh haha

#

We're almost at the finishline for this framework

plain ledge
#

😭

worthy flower
#

i tried to join but wasn't lucky

#

i hope i come in part 2

light loom
worthy flower
#

i'll try

worthy flower
plain ledge
worthy flower
#

alright

light loom
#

we only have 26 tickets left to be done from the looks of it

#

(given we don't raise more peepo_christ)

plain ledge
light loom
#

Discover the power of gen AI in boosting developer productivity and innovation. Through in-depth demos, we'll showcase how to use gen AI to enhance developer productivity across the software development lifecycle. You’ll also learn how to easily build production-grade gen AI applications using Google Cloud technologies and your favorite ecosyste...

β–Ά Play video
#

reckon gemini could finish our framework? peepo_think

#

this piece of shit AI

oak flare
#

bruh

light loom
#

i have no idea how to feed it the codebase

oak flare
#

bruh thats cringe lol

light loom
#

it sucks - i tried it and it was giving me half baked ass 😦

#

Why does Google confidently lie to us 😦

#

"Hey this product is awesome, it's the best in the market and can do all these innovative features trust me bro"

#

the product: thisisfine

plain ledge
#

@light loomcan we tag the repo with hacktoberfest?

light loom
#

lets do it

#

what do i gotta do

plain ledge
#

click the gear there

light loom
#

just a tag?

#

done!

plain ledge
plain ledge
#

@light loom Would you accept a PR to migrate off vertx?

#

either to a more lightweight (jar size) websocket client or to java's?

light loom
#

If it can be done native in Java that would be good!

plain ledge
light loom
#

Eh sure

plain ledge
# light loom Eh sure

Ok one more thing, what are your thoughts about refractoring the WebSocketManager to just like GatewayWebSocket, I think it would make sense since Java-WebSocket favors inheritence for creating the client but I'm not sure if that's an antipattern

#

nvm*

plain ledge
#

need to test now

oak flare
#

nice

light loom
#

oh no you're using the search wrong

#

use "In Project" not "Directory"

plain ledge
plain ledge
light loom
plain ledge
light loom
#

no

plain ledge
#

so the echo bot is supposed to just exit?

light loom
#

this is your impl that's not blocking

#

if you run it on main, it'll block

#

sorry not block but keep a thread alive

plain ledge
#

h,,

#

hmm

#

forgot to call .connect() 😭

plain ledge
light loom
#

Changes look good

#

Have you tested the edge cases like disconnecting and reconnecting your internet?

#

Also, look into the sonar issues, dw about pre-commit

oak flare
#

is there really no functional interface for this in the standard lib?

plain ledge
oak flare
plain ledge
#

Couldn't a Runnable make sense?

#

it's something ran when something else occurs

oak flare
#

well I dont know context, but Runnable should be used with Threads

#

hm well

light loom
#

Don't listen to them, if a runnable fits, it's fine

oak flare
#

javadocs doesnt say anything

#

yeah then use Runnable ig

#

it probably said something else back in the days

light loom
#

You can check by looking at the docs from an older version

oak flare
#

yeah I am doing right now

#

and see

light loom
#

Good stuff, somebody at oracle was like "guys let's not be idiots" πŸ‘πŸ‘

oak flare
#

yeah literally lol

plain ledge
#

@light loom Did we not handle any other frames besides close frame before?

#

14:10:48.243 [WebSocketConnectReadThread-68] WARN com.javadiscord.jdi.internal.gateway.handlers.events.EventCodecHandler - Unknown event received PRESENCE_UPDATE

light loom
#

Ooh maybe we didn't

plain ledge
#

before all it checked was Close Frame

light loom
#

Hmm that's interesting

#

Not sure how we missed it

plain ledge
#

this is unreleated to websocket we are just missing a couple of events

light loom
#

Ah

plain ledge
#

any idea what im supposed to do here?

light loom
#

public void stop() {
if (client != null && !client.isClosed()) {
try {
client.closeBlocking();
} catch (InterruptedException e) {
Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.

            LOGGER.error("Failed to close websocket client: {}", e.getMessage());
        }
    }
#

Basically,

Thread.currentThread(). interrupt();

#

Or something

plain ledge
#

yeah how should I rethrow the exception? I rethrew it as a runtime exception and still sonar complained

#

oh

oak flare
#

throw e;

#

sonar also got more detailed description

#

with examples etc

plain ledge
#

everyone has to throw it now?

oak flare
#

I dont have context

#

but throw e; is what sonar refers to when saying

Either re-interrupt this method or rethrow ...

plain ledge
#

oh

plain ledge
#

this gets called in like 4 places, 1 being a non user facing lambad

oak flare
plain ledge
#

😭

#

api tests failed, logs doesnt say which one and api doesnt even depend on gateway how did that break

sharp ferry
#

πŸ‘€

oak flare
#

no idea but the API tests are weird/bad imo anyways, they do real api calls which can easily break

plain ledge
plain ledge
oak flare
#

it already says it

plain ledge
#

oh im blind af

#

@light loom These integration tests are weird

#
    @Test
    void testGetUser() throws InterruptedException {
        long wazeiUserId = 821143476455342120L;
        CountDownLatch countDownLatch = new CountDownLatch(1);
        AsyncResponse<User> asyncResponse = guild.user().getUser(wazeiUserId);
        asyncResponse.onSuccess(
                user -> {
                    assertEquals(wazeiUserId, user.id());
                    assertEquals("wazei", user.displayName());
                    assertEquals("0", user.discriminator());
                    assertFalse(user.bot());
                    countDownLatch.countDown();
                });
        asyncResponse.onError(Assertions::fail);
        assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
    }
#

there must be a better way to do this

oak flare
#

yeah thats why I stopped on my PR about tests

#

these tests are just bad, they require a pre state in a different environment

#

but I got no idea what to do about it

#

thats probably why other discord libraries got no tests

plain ledge
#

im gonna comment out this test for now since I dont think it should block this PR to have integration tests reworked

plain ledge
#

alright workflow passing now

light loom
#

Yeah Tests are flakey

#

Don't worry too much about them

#

I'm not actually sure why the tests are flakey, like is there something we're doing wrong?

#

It's lame that in the GHA we don't see logs because they often run perfectly fine locally pepekek

plain ledge
light loom
#

that's okay, did you test?

plain ledge
#

Until we through some remote tester and anyone can run tests there it won’t work fell

light loom
#

the dc stuff

plain ledge
light loom
#

yeah

plain ledge
#

Yes

light loom
#

all good? πŸ™‚

plain ledge
#

I tested it with the echo bot

#

It all works good

light loom
#

approved ur pr

plain ledge
#

Sweet

plain ledge
#

squid are u able to put a review on it so it can get merged?

#

requires 2 reqviewers 😭

oak flare
#

ah yeah np

#

well I cant really tell anything about that java websocket lib

#

done

oak flare
#

yeah I noticed that

#

check my comments peepo_heart

steep spruce
#

anyways when can I use this lib for production

#

I wanna connect my cool bot to my cool server

oak flare
#

you kinda can already I think

#

but there is no guarantee that everything works

#

and its pretty likely actually that some parts like deserializing/serializing has 1-2 issues

plain ledge
#

Due to missing values in enum my pr foxes but I haven’t had to time to finish it

oak flare
#

Ah i thought it’s just a lib change

plain ledge
#

So I fixed them in that too

#

Discord added new onboarding things to the guild feature enum

oak flare
#

I see

#

Project so dead, no one noticed lmao

light loom
#

It's not that it's dead or unnoticed

#

Just a time problem, I knew there was some events not being handled, it was just a matter on when we do it

#

I think I did go brain-dead at one point and saw issues but never thought about raising them

worthy flower
#

is this project dead ?

oak flare
#

uh kinda since wazei left

#

no one is stopping us from keep going though

#

just no one having the effort at the moment

steep spruce
#

Or are there github collaborators

oak flare
steep spruce
#

Right you can just make a fork

oak flare
#

but doenst really matter who owns the repo

oak flare
#

because me and others have access

steep spruce
#

ah

oak flare
#

(though ofc as an outsider you need to make a fork and then pr before being part of the org/repo)

#

I would be open giving that project some love tbh

#

biggest problems are writing tests sadly

steep spruce
steep spruce
oak flare
#

jda is pretty shit actually

#

its just big

oak flare
# steep spruce Why?

they run against an actual discord bot, which requires a server
now tests should be isolated and repeatable which is hard in that case

#

like a test changing the name of a channel

#

but after that it should also reset it back, so its isolated and repeatable

#

but now imagine something breaks in the test

#

the reset doesnt happen and the discord server for testing is in a broken state

steep spruce
#

that means the testing framework you guys are using is either not being utilized properly or isn't good enough

#

or you guys are throwing exceptions like it's popcorn at the chicken jockey scene inside of a cinema

oak flare
#

I sadly don't have any idea how to design proper tests for this though

#

or we go the jda route and just dont test LUL

#

ig they actually do have tests πŸ€”

lone galleon
#

4000+ posts, have you started yet?

#

How about when Discord pulls the rug and disable api for third party?

plain ledge
plain ledge
#

We started to test but they weren’t very meaningful and broke somewhat often

#

We weren’t testing against discord api just a stub

molten tusk
#

Is this project done regardless of tests?

plain ledge
brisk eagle
#

YAS

lone galleon
plain ledge
lone galleon
#

THEY in the general sense of X, Reddit, facebook, etc not Discord explicitly. Just the trend to let the community find the happy path to monetization then attempt to try to take it over.

#

Amazon is a good example, study sales data then launch competing products with their sellers as well as priority product placement to take arbitrage.

plain ledge
#

Ah

chrome iris
#

hii can i help something???

steep spruce
#

@oak flare

#

why not you use mocking? instead of interacting with real discord api

#

you can use mockito

plain ledge
#

we used the discord openai spec with smth

worthy flower
#

hello !

#

do you think really that this new framework is going to be the alternative to JDA and others ?

oak flare
#

yeah, jda is pretty shit, but this can only work if people put in their effort which isnt really the case

worthy flower
#

I see

#

I think we can do it

#

but first of all, i need like a recap about what has been done so far and what is missing

#

to reach a first release

#

anybody with great knowledge about this project can help

oak flare
#

wazei

#

but he is gone

worthy flower
#

otherwise, i'll have to explore it by myself

#

it sounds like wazei wanted us to be in this situation to learn lol

oak flare
#

but the Projects board should give some indication of whats missing