#development

1 messages · Page 1964 of 1

lyric mountain
#

<T> is basically <T extends Object>

#

u could have <A, B, C, D>

#

which means the compiler should expect 4 generics that extend Object

earnest phoenix
#

O

#

Possible heap pollution from parameterized vararg type ide is warning me about smth mmLol

lyric mountain
#

ah yes, just checked

#

class doesn't need <T>

earnest phoenix
#

That's good to know

lyric mountain
earnest phoenix
#

I wonder what a possible heap pollution means

lyric mountain
#

when u don't limit varargs type it's possible to pass gibberish to it

earnest phoenix
#

Ah

lyric mountain
#

effectively polluting an array without reason

earnest phoenix
#

Makes sense

lyric mountain
#

this is also a useful one to have

earnest phoenix
#

BondedList?

lyric mountain
#

it guarantees all elements inserted into it will be processed

#

I use it in my tcg

#

all cards receive an owner and game instance whenever they're added to a slot

earnest phoenix
#

I don't know how useful that could be to me since idk what you mean by processed

lyric mountain
#

that way I don't need to do it every time

lyric mountain
earnest phoenix
#

Hm

lyric mountain
#

it'll replace any everyone that enters the list

earnest phoenix
#

So if @everyone is found in the list of args it will repalce it

lyric mountain
#

ye

earnest phoenix
#

That is quite useful

#

Helps remove sensitive info

lyric mountain
#

another one I like a lot

earnest phoenix
#

BiContract?

lyric mountain
#

it executes an action if, and only if, both sides of the contract are filled

#

I use it for multithread rendering

earnest phoenix
#

Also I guess I should fuck with database stuff as well with java if I wanna get the full experience

lyric mountain
#

JPA for ORM

earnest phoenix
#

hmm

lyric mountain
#

don't remember the name for the lib for raw sql

#

jpa does accept raw too

earnest phoenix
#

Any docs for jpa?

lyric mountain
#

also it doesn't give a fck abt what database ur using, if it can store data it can work with jpa

lyric mountain
#
Baeldung

Object-Relational Mapping (ORM) is the process of converting Java objects to database tables. In other words, this allows us to interact with a relational database without any SQL. The Java Persistence API (JPA) is a specification that defines how to persist data in Java applications. The primary focus of JPA is the ORM layer. […]

earnest phoenix
#

Sucks it doesn't have darkmode

#

I can't read it

lyric mountain
#

kekw true

earnest phoenix
#

god it is impossible to read that page's examples

#

They could of chosen a better font color

lyric mountain
#

there's a plugin for chrome that makes all pages dark

earnest phoenix
#

Oh?

#

I tried finding something like that

lyric mountain
#

it also works for any other page

earnest phoenix
#

Dark Reader

lyric mountain
#

that one too

earnest phoenix
#

There now I can read without my eyes being burnt

#

ty for that

lyric mountain
#

later on intellij ultimate, you'll get a built-in database manager

earnest phoenix
#

I have intellij ultimate

lyric mountain
#

why is it different?

earnest phoenix
#

I have a student license

lyric mountain
#

in-database language highlighting

#

I use it to edit my card's effects

earnest phoenix
#

Once I make an open source project tho I can get free license if I keep working on it

#

so that will be nice

#

github education pack I only really use jetbrains products from it KEKW

lyric mountain
#

"Oh but it's just highlighting"

#

nope, everything works

#

ctrl space, ctrl Q, alt enter

earnest phoenix
#

So is JPA built in or do I have to install it somehow

#

I seemed to have missed that part

lyric mountain
#

you first install hibernate

#

then u add jpa

earnest phoenix
#

hibernate?

lyric mountain
#

actually, just add both together, maven handles it

#

yeah, JPA is actually a layer

#

hibernate is one of the implementations of it

#

jpa alone does nothing

earnest phoenix
#

But how do I

lyric mountain
#

add to maven

#

shouldn't be too complicated to convert to xml

earnest phoenix
#

yea I can do that

lyric mountain
#

then you'll need a persistence.xml

#

baeldung probably has a template file there

#

if u don't need connection pooling you just need the top 2 lines

#

c3p0 is the pooler

#
<properties>
  <!-- connection data -->
  <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>

  <!-- hibernate properties -->
  <property name="hibernate.dialect" value="put your database dialect here"/>
  <property name="hibernate.jdbc.batch_size" value="30"/>
  <property name="hibernate.show_sql" value="false"/>
  <property name="hibernate.enable_lazy_load_no_trans" value="true"/>

  <!-- C3P0 properties -->
  <property name="hibernate.c3p0.min_size" value="1"/>
  <property name="hibernate.c3p0.max_size" value="4"/>
  <property name="hibernate.c3p0.timeout" value="300"/>
  <property name="hibernate.c3p0.max_statements" value="50"/>
  <property name="hibernate.c3p0.idle_test_period" value="3000"/>
  <property name="hibernate.c3p0.preferredTestQuery" value="SELECT 1"/>
  <property name="hibernate.c3p0.testConnectionOnCheckout" value="true"/>

  <!-- generate tables automatically -->
  <property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
#

those are the settings I use

#

there are more, but those I've fine tuned for constant IO ops

earnest phoenix
#

I see

lyric mountain
#

first one is the driver, in this case for postgresql

earnest phoenix
#

should I put that in the resources folder?

lyric mountain
#

yes, inside META-INF folder

earnest phoenix
#

META-INF?

lyric mountain
#

there's more to it tho

#

grab the template from baeldung

earnest phoenix
#

This is getting confusing ngl

lyric mountain
earnest phoenix
#

The guide doesn't say anything about a persistance.xml kekw

earnest phoenix
#

At least I can't seem to find one

lyric mountain
earnest phoenix
#

I see

lyric mountain
#

ever used sequelize?

earnest phoenix
#

Yea

lyric mountain
#

then you'll get jpa quickly

earnest phoenix
#

Though it has been a while so I don't exactly remember everything about it aha

lyric mountain
#

annotation-based column definition

earnest phoenix
#

Ah

lyric mountain
#

then for getting data

#

or if u want

earnest phoenix
#

So you can either use raw sql or their methods

lyric mountain
#

.find() searches strictly for the primary key

#

sometimes you need to write a query for better control of what u retrieve

earnest phoenix
#

I see

lyric mountain
#

to save something:

earnest phoenix
#

mmm

#

Also I typically just use DBeaver to look at my database stuff

#

as I dont know how the built in database thing works

lyric mountain
#

just click on the database tab

#

a credentials screen will popup after that

earnest phoenix
#

I am sort of confused here with the whole definition of things

lyric mountain
#

also it's funny to see your classes relationship

earnest phoenix
#

why do they use private when defining columns?

lyric mountain
#

generally u don't want a public property

earnest phoenix
#

Mmm true

lyric mountain
#

that's because using getters and setters allow better control of what goes in or out

#

I saw people use publics when the getters and setters wouldn't have any additional processing

#

but I just don't like it, so I go full getter and setter for everything

#

personal preference, both are fine

earnest phoenix
#

So you set the getters and setters inside the model?

#

How are the getters and setters used?

lyric mountain
#

normally, jpa fills the values for u

#

you just use it like u do with members or any other object

#

obj.setValue("abc")

#

jpa saves that object with value abc

#

when u retrieve, it'll have abc in value

earnest phoenix
#

Do you ever have to use the getters or setters yourself?

lyric mountain
#

ye, all the time

earnest phoenix
#

Mmm

lyric mountain
#

jpa uses reflection instead of getters/setters

#

so it's u who will use it mostly

earnest phoenix
#

GuildDAO

#

I assume that is the model?

lyric mountain
#

data access object

#

I name all my data access classes with DAO

earnest phoenix
#

this jpa stuff is kind of confusing

#

I might take a break for now

lyric mountain
#

so GuildDAO contains all methods that manipulate the data in database

earnest phoenix
#

ic

lyric mountain
earnest phoenix
#

Well ima take a break for now

lyric mountain
#

sure

earnest phoenix
#

So it is just a helper class for the guild model

lyric mountain
#

basically

#

I find it better than having dangling sql all over the codebase

earnest phoenix
#

That is true

#

I might make one myself

lyric mountain
#

if u want u can explore my repo, most of it is pretty simple to understand while others...are others

#

just stay away from /handlers and you'll stay sane

wheat mesa
#

reflection is fun 😉

earnest phoenix
#

How does the Require annotation work tho?

#

Like how do you do the permission checks?

lyric mountain
#

it's in managers/CommandManager.java

#

basically I grab the declared array and check if my bot has all the supplied perms

#

if one is missing, I show an error message

earnest phoenix
#

Mmm

#

I dont see that part then again the code is a bit confusing for me rn so I will just re-look at it at a later point

#

:p

lyric mountain
#

right here

#

notice the req == null ? new Permission[0] : req.value()

#

req.value() is the array of permissions

earnest phoenix
#

hmm

lyric mountain
#

then I just compare both current perms set with required perms set

#

if one is missing = error message

earnest phoenix
#

Yea bit confusing but I think I follow somewhat

lyric mountain
#

there's a considerably simplified version of my manager on my repos

#

I WAS supposed to release it as a library

#

but too lazy to write documentation and setup everything needed to publish

sudden geyser
#

who's holding you hostage

lyric mountain
#

me

sudden geyser
#

oh just publish it anyway

#

half oss libraries are undocumented

lyric mountain
#

my dignity wouldn't allow it

sudden geyser
#

higher percent for enterprise software

#

click on apple or google's api docs and you'll see "No overview available" for half the classes

lyric mountain
#

kekw

#

nah, one day maybe, when my pagination lib is free of bugs

#

I also need to add support for dropdown menus

bronze socket
#

how to make embed like this?*

lyric mountain
#

like this how?

bronze socket
#

this

#

embed

#

thiss

lyric mountain
#

you mean the lack of color stripe to the side?

bronze socket
#

yes

lyric mountain
#

just set the color to match the embed

bronze socket
#

;-;

#

how

lyric mountain
#

...u don't know how to make embeds?

bronze socket
#

hex code? to same as embed colour??

lyric mountain
#

yes

bronze socket
#

okay

#

ty

lyric mountain
#

np

bronze socket
#

btw do u know the hex?

#

coz i have to search for it ;-;

lyric mountain
#

inspect element

bronze socket
#

op

#

tysm

earnest phoenix
lyric mountain
#

lul

earnest phoenix
#

I hope I become good at java like u one day bro

#

This shit sometimes be confusing

lyric mountain
#

nah I'm not good, there's a lot of room for improvement

bronze socket
#

which bot u made?

lyric mountain
#

I've reworked many stuff in the source code over the time

#

shiro

#

not the dog, the girl

earnest phoenix
bronze socket
lyric mountain
wheat mesa
#

I feel like Java itself isn't all that hard to learn, but it can be very difficult to master the managing of structure and passing data around and such

#

which takes time and experience to learn

earnest phoenix
#

Yea

lyric mountain
#

Most java hatred is due to its dark past

#

And given that this is the age of "code less, do more", verbosy langs like java lose a lot of popularity

old cliff
#

a=b=c=10; works in java?

bright tundra
#

why i cannot add bots on top.gg

winter pasture
bright tundra
winter pasture
bright tundra
#

yes

#

sure

#

wait

winter pasture
#

If the tags are too long, the submit button does not work

bright tundra
#

ok

#

gotcha

winter pasture
#

So try removing the large ones and then submit it

bright tundra
winter pasture
#

-upto

gilded plankBOT
#

The average up-to-date approval times are stated [here](#support message).

This does not mean it will take the same amount of time someone else's bot took to be reviewed and does not mean your bot is guaranteed to be reviewed within that time frame.

There is no exact time for how long bot approval will take.

There is a queue and you're not first, nor are you last.

Read more about our reviewal process here

lyric mountain
lyric mountain
#

probably

#

lemme check

rigid maple
#

Output of line 27: "Hello"
but when using it elsewhere;

  let response = await client.getResponse(connection);
  console.log("33")
  console.log(response)

Output is empty

#

it processing but does not return an output

rigid maple
#

31-32 in voiceStateUpdate event ( this is where i run the function )
I'm listenin to TuranGe and others in a function ( function works but doesn't return me )
if it did return it would log 33 to the console

lyric mountain
#

ah nvm, that's a speech-to-text

#

update node

rigid maple
#

I have no clue what to do

earnest phoenix
#

Are you using v12 or v13?

#

*discord.js

#

because thats weird

rigid maple
#

Any ideas on what I can do?

#

neppkun

#

ben ne yapabilirim bir fikrin var mı ?

#

😕

earnest phoenix
#

okay

vivid fulcrum
#

emb needs to be inside of an array

#

it... isn't

earnest phoenix
#

it isnt

#

message.channel.send({ embeds: [emb] })

pale vessel
#

@vivid fulcrum how have you been

rigid maple
#

Is it possible for a function to not return a value and terminate any subsequent processes?

sudden geyser
#

What do you mean

#

An early return?

lyric mountain
#

if (something) return;

#

if whatever is calling it expects a return, you might need to return a default value, generally null

woeful pike
#

it already defaults to undefined so

lyric mountain
#

that for js

boreal iron
#

going crazy freerealestate

lyric mountain
#

is that memory or frequency?

boreal iron
lyric mountain
#

and what is frequency?

boreal iron
#

absolutelly enough for the server

lyric mountain
#

wait

true nymph
#

How do I change command from / to something else

lyric mountain
true nymph
#

I just added the bot to a server

lyric mountain
true nymph
#

Mee6 and top gg share the same sign which is this /

lyric mountain
#

again, you don't, that's a thing with slash commands

boreal iron
lyric mountain
#

what you want are prefixed commands, which most new bots don't support

boreal iron
lyric mountain
boreal iron
#

virtualization

lyric mountain
#

crysis at medium resolution?

boreal iron
#

Nah lots of virtual servers, what else do you need that amount of RAM for

#

8GB here, 16GB there, 4GB there etc... 96GB wasn't enough

earnest phoenix
boreal iron
#

once I install Chrome on my server I'm prepared!

earnest phoenix
#

Once you're done driving of course

boreal iron
#

Look at the beautiful load sharing

boreal iron
#

wtf are you actually doing in this channel? can't be the real Voltrex

earnest phoenix
#

Wtf are you doing without driving? This can't be the real FakE

boreal iron
#

lmao

#

You will get access to the old member and new member obj

#

alright

lyric mountain
#

"Please don't abuse"

**I know what we're gonna do today Ferb! **

hexed garnet
#

Is there a way to have my bot running on heroku with it sending a message once it recives a post from the top.gg

boreal iron
#

Dunno about the limitation of that platform but as long as you listening for incoming webhooks, you can go on with the user data and send a message for example, yeah

hexed garnet
#

But will there be enough minutes per month?

boreal iron
#

Dunno about the limitation of that platform

#

You gotta read it yourself

#

If they limit per request then it depends on the amount of requests of course

wheat mesa
#

fake don't block me but I'm about to make a bot in java 😉

hexed garnet
split hazel
#

me too

hexed garnet
#

Ur not gonna do it?

wheat mesa
#

@boreal iron

#

him

hexed garnet
#

Ahh

wheat mesa
#

resident java hater

hexed garnet
#

Blocked

split hazel
#

you run a java program: -100 social points

hexed garnet
hexed garnet
split hazel
#

fix: your pc has the java interpreter installed: -100 social points / day

split hazel
#

yes

hexed garnet
#

Bruh

boreal iron
wheat mesa
#

noooooooo :C

boreal iron
#

Btw I’ve got push notifications disabled for discord

wheat mesa
#

Yeah I just pinged you so the other guy would understand what I was talking about

boreal iron
#

You need to be patient until my highly appreciated and informed answer will follow

#

Yeah I noticed, but it doesn’t matter anyways, I need to enforce the block!
Damn why did you move to the dark side using Java…

wheat mesa
#

in my defense I'm forced to use it in school

#

might as well have a project to get way ahead of what the school is teaching

#

cs classes in american public schools are so slow

#

we're just now getting to arrays lmfao

boreal iron
#

Then leave the school early and educate yourself, as ez as that

wheat mesa
#

nah

#

I've got a good school record so far

boreal iron
#

There are things more important than that!

wheat mesa
#

Not gonna drop out of high school, too risky

cinder patio
#

are you in high-school?

wheat mesa
#

Yeah

boreal iron
#

Touching Java is a crime

lyric mountain
#

yall getting CS classes in highschool?

#

here we only get in university

cinder patio
#

yeah lmao "cs classes in school are so slow"

#

I'm pretty sure 90% of high-schools don't have cs programs

wheat mesa
#

It's a 2nd year cs class

#

technically a "college level course" because it's AP

cinder patio
#

I mean I had CS classes in high-school too but it was simple stuff. Mostly VB, C# and C++

lyric mountain
#

still, here people are so iliterate in computers that there are MS Word courses

wheat mesa
#

I think the most advanced it gets this year is like abstract classes

#

the problem with our classes is that it isn't really about real-world practices, just about learning about CS in general

lyric mountain
#

you say "boolean" and people think you're cursing them

wheat mesa
#

We had to make a class that was a "managed array" of ints

#

because they don't teach us about arraylist until next unit

#

is that something that people do a lot? our cs teacher was like "A managed array is very common in real world use!"

lyric mountain
#

ah yes, reinventing the wheel, classic

#

people used to

#

but then collections came

#

when I say "used to" I'm talking abt jdk 7 or so

wheat mesa
#

collections are our lord and savior

lyric mountain
#

which is, what, 1999?

wheat mesa
#

lmfao

#

our teacher is on the old side for a programmer

#

I think she's in her 50s

lyric mountain
#

oh, 2011

#

damn but it felt so bad and outdated

wheat mesa
#

she told us that js arrays start at index 1 and I died inside

lyric mountain
#

tf

wheat mesa
#

(I don't blame her, she doesn't do js)

#

She probably just got confused with lua

lyric mountain
#

or delphi maybe

wheat mesa
#

also I've figured out that gradle isn't so terrible after all

#

just a pain in the ass for getting a modding environment setup for minecraft

lyric mountain
#

that's cuz minecraft doesn't support mods at all

wheat mesa
#

yeah

lyric mountain
#

so they "gambiarra"d it

wheat mesa
#

has to be decompiled and such

lyric mountain
#

ye

wheat mesa
#

up and running

#

and yes I know storing secrets in a class is a bad idea

#

just did it as temporary storage for that stuff until I get set up

split hazel
wheat mesa
#

lol

#

store it in a public google doc

#

5Head

lyric mountain
#

UPDATED log4j, be careful with old versions

wheat mesa
#

log4j pepowot

split hazel
#

use outdated log4j

#

better performance

boreal iron
wheat mesa
#

even the updated versions have vulnerabilities don't they? or has it all been fixed at this point

lyric mountain
#

they fixed the dangerous ones

wheat mesa
#

alright

lyric mountain
#

it no longer allows outside attacks

boreal iron
#

until now

wheat mesa
#

I assume adding log4j and slf4j are the same process as adding jda was

split hazel
#

mfs over at log4j creating vulnerabilities like theres no tomorrow

wheat mesa
#

I mean, they're volunteers but yeah

lyric mountain
wheat mesa
lyric mountain
#

log4j was passed to a small indie company now

#

ahem, just some nobodies called Apache Foundation

#

those are the lines u need

#

except the spring one

boreal iron
lyric mountain
#

?

wheat mesa
boreal iron
#

oh now all the snow outsite... guess I've got something to do

#

meh

lyric mountain
#

ye, that's disruptor

#

required for async logger

wheat mesa
#

alright got it all set up now

#

time to make bot go brr

#

damn you got fancy in your bot, using static initialization blocks

boreal iron
#

Please... you still have the chance to avoid it

wheat mesa
#

just trying something new

#

never messed around with pure oop languages with discord bots before

lyric mountain
#

-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

#

add this to jvm args

#

to enable async logger

wheat mesa
#

got it

lyric mountain
boreal iron
#

I think we need an exorcism for you!!1!

wheat mesa
#

only ever used js/ts/c++ for bots

#

c++ was a pain in the ass because of my lack of experience attempting to compile for a VPS

#

but I know that java will work on a vps so long as I have access to the jvm

lyric mountain
#

it'll run pretty much anywhere

#

even on a smart fridge

wheat mesa
#

yup

#

that's something I really like about java

#

compiling for multiple platforms with other langs is annoying

#

also since you're the java expert, what's the benefit of catching specific error types over just doing ```java
try {
// something
} catch(Exception e) {
// more something
}

lyric mountain
#

btw, some good jvm args```
-XX:+UseZGC ---> zero-latency garbage collector
-XX:+UseStringDeduplication ---> prevents heap filled with duplicate strings
-Dfile.encoding=UTF-8 ---> prevents shitty encoding errors

wheat mesa
#

I'd assume it's just so the compiler knows what methods & props the error class has

lyric mountain
wheat mesa
#

ah

lyric mountain
#

Exception will catch anything indisciminately

#

like, u can have more than one catch

#
try {
// something
} catch(AException e) {
// more something
} catch(BException e) {
// more something
} catch(CException e) {
// more something
} catch(DException e) {
// more something
}
wheat mesa
#

oh wait I didn't know you could do that

#

that's sick

lyric mountain
#

or even multi catches```java
try {
// something
} catch(AException | BException e) {
// more something
} catch(CException | DException e) {
// more something
}

wheat mesa
#

ok java is suddenly becoming my favorite error handling language

#

don't tell fake I said that

lyric mountain
#

u can also have a finally block on tries

#

and self-closing streams

wheat mesa
#

self-closing streams similar to how c# has ```cs
using (var somethingThatTakesLotsOfMemory = new whatEver()) {
// stuff with that
} // disposed without having to call .Dispose()

lyric mountain
#
try (FileInputStream fs = new FileInputStream(file)) {
// do something with fs
}

// no need to close, it auto-closed after finishing the try block
wheat mesa
#

nice

lyric mountain
#

obviously u can also add catches/finally there

#
try (FileInputStream fs = new FileInputStream(file)) {
// do something with fs
} catch (IOException e) {
// handle the error
} finally {
  System.out.println("Big success")
}

// no need to close, it auto-closed after finishing the try block
wheat mesa
#

that's cool

#

didn't know java had that, only knew c# had it

lyric mountain
#

java also has something c# doesn't have yet

#

enhanced switches

#

it allows outputting the result of a switch directly into a variable

#

and no longer requires break after every single case

wheat mesa
#

oh yeah I never understood why c# didn't allow falling through

#

(as well)

lyric mountain
#
int type = ...;
String value = switch (type) {
  case 1 -> "Hello";
  case 2 -> "World";
  case 3 -> "!";
  default -> "You shouldn't use that value.";
};
wheat mesa
#

I bet java doesn't have this though ```cs
using System;
using System.Runtime.CompilerServices;

async async async(async async) => await async[async][async][async][async];

[AsyncMethodBuilder(typeof(builder))]
class async {
public async this[async async] { get => null; }
}

static class util {
public static awaiter GetAwaiter(this async a) => throw null;
}

class awaiter : INotifyCompletion {
public bool IsCompleted => true;
public void GetResult() { }
public void OnCompleted(Action continuation) { }
}

class builder
{
public builder() { }
public static builder Create() => throw null;
public void SetResult() { }
public void SetException(Exception e) { }
public void Start<TStateMachine>(ref TStateMachine stateMachine)
where TStateMachine : IAsyncStateMachine => throw null;
public async Task => throw null;
public void AwaitOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
where TStateMachine : IAsyncStateMachine => throw null;
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine => throw null;
public void SetStateMachine(IAsyncStateMachine stateMachine) => throw null;
}

lyric mountain
#

hmmm, what am I looking at?

wheat mesa
#

I don't know

#

async

boreal iron
#

async async async(async async)

wheat mesa
#

it's funny because that actually compiles

#

c# allows classes to be called async

lyric mountain
#

when u forget to lock reserved keywords

boreal iron
#

class class class

wheat mesa
#

even more

lyric mountain
#

that's terrible

wheat mesa
#

that's the point

lyric mountain
#

no fckin way I didn't know this:```java
int i = 0;
while (i++ < 5) {
//do shit
}

#

never thought abt using increments within the loop conditional

cinder patio
#

Then the index will start at one though, you need to initialize i to -1

#

if you want it to start from 0

lyric mountain
#

well yeah

sharp saddle
#

to build a Discord welcome system, do you need to activate an intent?

lyric mountain
#

ys

sharp saddle
#

wich?

lyric mountain
#

anything related to guild events

sharp saddle
#

Do you need Server Member Intents?

lyric mountain
#

not sure, but probably

sharp saddle
#

ok ty

lyric mountain
#

try without anything

#

then go adding one by one

sharp saddle
#

ok

#

Do you know why I'm asking this?

lyric mountain
#

cuz ur welcome isn't working?

sharp saddle
#

no

#

my bot has no intent yet

lyric mountain
#

eh

sharp saddle
#

and it must be boring to send form to discord activate

neat ingot
lyric mountain
#

normally I'd use a for loop, but while is cleaner now that I know abt that

#

then theres groovy```groovy
5.times {
//do shit
}

neat ingot
#

dang. that really reminds me of ruby. i loved that syntax

sudden geyser
#

That's just ambiguous

#

How do you distinguish between an int and a double

blissful falcon
#

How do i define channels?
TypeError: Cannot read properties of undefined (reading 'channels')

lyric mountain
sudden geyser
#

But what if they supported them

#

It's more about the syntax

lyric mountain
#

double notation id 0d

#

it'd be 5d.times { ... }

sudden geyser
#

:o

blissful falcon
# earnest phoenix show your codes
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, MessageButton, MessageActionRow, MessageSelectMenu } = require('discord.js');
module.exports = {
    data: new SlashCommandBuilder()
        .setName('8ball')
        .setDescription("Ask a question")
        .addStringOption(option =>
            option.setName('text')
                .setDescription('What is the text?')
                .setRequired(true))


    ,
    async execute(interaction, message, client, channels) {
        const userQuestion = interaction.options.getString('text');
        const randomNumber = Math.floor(Math.random() * 8);
        let eightBall = 'eightBall';
        switch (randomNumber) {
          case 1:
          eightBall = 'It is certain';
          break;
          case 2:
          eightBall = 'It is decidedly so';
          break;
          case 3:
          eightBall = 'Reply hazy try again';
          break;
          case 4:
          eightBall = 'Cannot predict now';
          break;
          case 5:
          eightBall = 'Do not count on it';
          break;
          case 6:
          eightBall = 'My sources say no';
          break;
          case 7:
          eightBall = 'Outlook not so good';
          break;
          case 8:
          eightBall = 'Signs point to yes';
          break;
  
        }
        
interaction.reply(`The user asked: '${userQuestion}'.`)
 var channel = client.channels.cache.get(interaction.channelId)
var messagesent = await channel.send("Loading the answer")
 sendMessage.edit(`The user asked: '${userQuestion}'.  The answer is: '${eightBall}'.`)

    }
}```
lyric mountain
#

non-decimal numbers are integers in java, even when u do double a = 5 it'll become double a = 5.0

#

upcasting it is

earnest phoenix
sudden geyser
#

I was thinking of cases like 5.3.times {} due to the two dots

lyric mountain
#

guess what

sudden geyser
#

But groovy doesn't use two dots

lyric mountain
#

it does support doubles

blissful falcon
#

Didn't notice that lol.

lyric mountain
#

your case gets rounded to 5 as it seems

#

probably bcuz it increments by 1 each time

sudden geyser
#

it's just about the syntax—not the times method

#

Was surprising

wheat mesa
lyric mountain
#

groovy is surprisingly lenient

wheat mesa
#

btw, what's the interface naming convention in java? I'm used to C# where it's usually IClassName, but it doesn't seem to be that way with java

#

I assume it's not as necessary since java doesn't just use class Name : Class1, Interface1, Interface2 and instead uses class Name extends Class1 implements Interface1, Interface2

lyric mountain
lyric mountain
wheat mesa
#

I don't think it's as necessary since you can tell if it's an interface or not from the keyword used

lyric mountain
#

ye

wheat mesa
#

I'll stick with C# notation though since I'm just used to it

feral aspen
#

I have this particular code: bot.channels.cache.get("721389007564701756").send({ content: x.join(" ") });; and I'm willing to convert it to using .fetch(), and I did it as the following:

(await bot.channels.fetch("721389007564701756")).send({ content: x.join(" ") });

Usually, when it comes to errors, it errors this:

Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.

What could be the cause of this? (Why it's not working)

feral aspen
#

It's a console.js file.

module.exports = async bot => {
    let prompt = process.openStdin();
    prompt.addListener("data", res => {
        let x = res.toString().trim().split(/ +/g);
        bot.channels.fetch("721389007564701756").send({ content: x.join(" ") });
    });
};
#

Allows you to type on console.

wheat mesa
#

if you're sending it to one channel then I highly recommend fetching the channel once and not every time data is received in the console

#

Also you need to await fetching the channel

feral aspen
#
module.exports = async bot => {
    let prompt = process.openStdin();
    prompt.addListener("data", res => {
        let x = res.toString().trim().split(/ +/g);
        (await bot.channels.fetch("721389007564701756")).send({ content: x.join(" ") });
    });
};
#

Error, too. :)

wheat mesa
#

with the current way you do it, it would have to be something like this: ```js
module.exports = async bot => {
let prompt = process.openStdin();
prompt.addListener("data", async res => {
let x = res.toString().trim().split(/ +/g);
(await bot.channels.fetch("721389007564701756")).send({ content: x.join(" ") });
});
};

#

there's no such thing as top level async in js (yet, I think that might be a proposed feature)

#

since res => is an arrow function, you need to make that arrow function async in order to use await inside it

feral aspen
#

Oh.

#

I appreciate it!

wheat mesa
#

but again, I'd recommend only fetching the channel once

#

so you're not constantly spamming the api

feral aspen
wheat mesa
#

once you fetch a channel it's cached

#

check if the channel is cached, if it's not, then fetch

#

if it is cached, then grab it from the cache

#

@lyric mountain your command handler is pure bliss

lyric mountain
#

oh, u saw it

wheat mesa
#

Yeah

#

I had looked at it a little while back when I was trying to make that command handler for forge

#

But I didn't look too much into it until now

#

Just looking at how to structure my commands

lyric mountain
#

nice

feral aspen
#

Can you await (await function());?

wheat mesa
#

why would you need to do that..?

feral aspen
#

I'm doing that for a collector.

wheat mesa
#

personally never seen something return Promise<Promise<T>> if that's even possible

feral aspen
#

I remember it is.

#

const m = await (await bot.channels.fetch('ID')).send();

wheat mesa
#

yes you can do that

feral aspen
#

👍

civic scroll
#

💀

#

double await sure looks quirky

novel jetty
#

Anyone know how i can fix this?

split hazel
#

but a npm rebuild canvas should fix it

lyric mountain
#

@wheat mesa soon, a command signature validator

#

it'll be like this

spark flint
#

how do you center text and images with node-canvas

lyric mountain
#

and different from discord's shitty command signature, you can have multiple signatures per command

lyric mountain
#

same for height

spark flint
lyric mountain
#

depends, generally graphics libs have means of retrieving a string's length

spark flint
#

not centered pain

lyric mountain
#

is that the whole image?

#

if so, your background image isn't resized

#

in this case, canvas_width / 2 - text_width / 2

spark flint
#
                const welcomeMsg = `Welcome to ${guild.name}`
                ctx.fillText(member.username, canvas.width / 2 - member.username.length / 2, 150);
                ctx.fillText(welcomeMsg, canvas.width / 2 - welcomeMsg.length / 2, 165)```
lyric mountain
#

nonono, that'll get string length

spark flint
#

ohhh

lyric mountain
#

not actual printable size

#

you need to get the string width in that canvas context

#

see the link I sent

spark flint
#

because thats for html

cinder patio
#

account for the text's font size

lyric mountain
#

that'd only work for monospace

lyric mountain
#

like, they all use canvas

#

there's this too

cinder patio
#

That's only for browser

lyric mountain
#

in java it's just graphics.getFontMetrics().stringLength("the text")

#

idk why js doesn't have something similar built-in

split hazel
#

if there wasnt a method it would get very messy

#

because fonts have different widths

frigid robin
#

How do you guys implement something that should run in a loop for multiple servers with different interval configurations?
One implementation I thought of: loop every 1 minute and store looped minutes in X. Then check DB for all server configs, and if X is a multiple of one of the intervals configured - then execute the command for those same servers

sudden geyser
#

It depends on what's being looped over.

#

For example, a mute command may have a collection of users left to unmute, but that number could be small or large, so setting a loop for each guild (or user even) may be expensive.

#

So I'd rather check on an interval every minute for users to be unmuted and run those actions all at once.

#

But for anything not expensive (because it doesn't linearly or exponentially grow), I'd be fine using multiple schedulers.

frigid robin
cinder patio
#

I think your implementation is good

frigid robin
#

yeah I definitely agree with that being expensive if it's user specific

sudden geyser
#

I'd prefer a single, global interval in your case.

#

Since it can grow linearly very quickly.

frigid robin
#

So what do most people do when servers have different configurations for time interval?

sudden geyser
#

But keep in mind that the decision is a performance reason. If you're hosting a small bot, you probably won't have to worry, and will have a better time assigning each channel its own interval.

spark flint
#

its a canvas buffer

solemn latch
#

Make a discord attachment directly with the buffer and addImage to it

quartz kindle
split hazel
#

someone smells

#

oh its just me nvm

cinder gorge
#

nice

spark flint
#

its now returning undefined

#

for member.username

sudden geyser
#

use member.user.username

spark flint
#

Alr

earnest phoenix
limber mica
#

Javascript is being annoying now :) Getting the error TypeError: Class extends value [object Object] is not a constructor or null With the code
commandMaps.js

const main = require('./../index.js')
const glob = require('glob-promise')

//this class extends the main class in the ./main.js folder
class commandMapHandler extends main.main {
  //No free code
}

module.exports = commandMapHandler

index.js

module.exports = {
    main: require('./core/main.js'),
};

main.js

const fs = require('fs');
const config = require('./../config.js')
const commandMaps = require('./commandMaps.js')

class main {

    constructor() {}

    async init() {
        this.config = config
        this.loadCommands()
    }


    async loadCommands() {
        let cmdmap = new commandMaps()
        this.logger.info(cmdmap)
        cmdmap.register()
    }

}

module.exports = main;
#

I tried to figure it out, but nothing helped

pearl trail
#

main.main ?

limber mica
#

with just main

#

but the error gets changed to TypeError: Class extends value #<Object> is not a constructor or null

sudden geyser
#

Your export is just the class

#

So main by itself is your class

#

But you're doing main.main, which does not exist.

#

Hence, undefined/null

limber mica
sudden geyser
#

Wait, interpreted that wrong

#

Maybe it's concerned about the circular dependency you introduce.

pearl trail
#

oh wait didnt see that you required the index one, try console.log-ing require('./core/main.js') in index?

pearl trail
#

bruh

limber mica
#

so its not recognizing the export?

pearl trail
#

yes

limber mica
#

but module.exports = main; is included?

#

Le funni moment

#

Is it just me being retardo or nodeJS being dumb

sudden geyser
#

Maybe it's due to circular dependencies. Take this:

main.js -> commandMaps.js -> index.js -> main.js

By the end, main.js hasn't been fully loaded, so it returns what it currently has: an empty object.

limber mica
#

ohhhhhh

sudden geyser
#

Since that's the default export

limber mica
#

hmm

sudden geyser
#

You can fix it by restructuring your files.

limber mica
sudden geyser
#

You'd need to break the circular dependency.

#

You can't have main.js and commandMaps.js rely on each other

#

A solution would be to merge the files

#

Or reconsider your code in general

limber mica
#

Orrrrrrr

#

hmmm

sudden geyser
#

Or separate them, but that doesn't apply to your case.

limber mica
#

Ill merge them

#

Thanks for your help

#

I tried to use index.js to BREAK the circular dependancy

#

But I just extended it

green kestrel
#

hmmm interesting

lyric mountain
astral iris
#

So, this is going to sound dumb but how do I do a return to multiple scopes?

Life for example

channel.send(message).then(async message => {
await message.react('🧪').catch(() => {
errorHandler(....)
message.delete();
return
});
channel.send(reactionEvent)```
#

Cuz if the .catch() goes off then the channel.send(reactionEvent) shouldn't work

lyric mountain
#

Finally?

#

U could also use an external variable

#

Idk if js has something alike, but in java u have atomic values

earnest phoenix
#

Well return should work there no?

quartz kindle
#

use await?

#

you cant "return multiple scopes"

earnest phoenix
#

tim async/await is for losers

quartz kindle
#

because a promise is not a scope, its a whole different timeline

earnest phoenix
#

all my homies never use async/await we use .then nesting

astral iris
quartz kindle
#

if you use .then().catch() the reactionEvent will be run immediatelly, it wont sit around waiting

#

unless you either await, or put the reactionEvent inside a finaly or something that is part of the promise timeline

lyric mountain
#

You could have the message send inside the promise tho

#

Ah nvm

#

Mobile formatting got me

astral iris
#

I explained the code bad, here is the actual code LMAOO

await interaction.channel.send({ content: 'Test' }).then(async m => {
                    await m.react(interaction.options.getString('emoji')).catch(() => {
                        errorHandler(interaction.client, interaction, 'This is not a valid emoji or I do not have access to this emoji.');
                        m.delete();
                    });
                    m.delete();
                    // Database
                    const Settings = await settings.findOne({
                        GuildID: interaction.guild.id,
                    });
                    Settings.StarboardEmoji = interaction.options.getString('emoji');
                    await Settings.save().catch();
                    interaction.reply({ content: 'Starboard Emoji Updated!', ephemeral: true });
                });```
earnest phoenix
#

haku this jpa stuff makes no sense

#

😩

astral iris
#

Sorry, I tried to not have to send it cuz I hate sharing my code KEKW

round cove
#

I had an interaction die on me earlier claiming it was unknown.

#

After it was already replied to.

lyric mountain
#

Tell me your issue, and I'll lessen your suffering

earnest phoenix
#

that is just called skill issue

round cove
quartz kindle
#

you're doing m.delete() twice?

earnest phoenix
lyric mountain
#

Oh

#

It's pretty much a copypaste of sequelize

#

Your class must be tagged with @Entity

earnest phoenix
#

Ima be honest I dont remember how to use sequelize

lyric mountain
#

At that point, intellij might start hinting u abt what's missing

quartz kindle
#

ima be honest dont use sequelize

astral iris
earnest phoenix
#

I stopped using sequelize when I figured out typeorm was a thing

astral iris
#

Cuz I was hoping the return there would stop the entire function

earnest phoenix
#

How do I fetch, delete, update, insert, etc

astral iris
#

Use MongoDB

earnest phoenix
#

that jpa guide or whatever on baledung wasn't that good in terms of explaining that

earnest phoenix
quartz kindle
astral iris
#

Okay, Imma just use an external var LMAO

quartz kindle
#

literally just remove the m.delete() from the catch and it will be fine

round cove
#

^

earnest phoenix
#

Can't u just use Promise in this scenario if you really wanted to?

#

then again I forget what the actual issue is so ima shut up

#

:p

lyric mountain
#
@Entity
@Table(name = "name_ur_table") 
public class ATable {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;
	
	@Column(columnDefinition = "VARCHAR(255) NOT NULL DEFAULT ''")
	private String name = "";

	//getters n setters
} 
#

So, @Entity marks that class as persistent

quartz kindle
#

i dont understand decorators

earnest phoenix
#

Annotations?

lyric mountain
#

@Table defines table data, you don't need it but it's fine to have some customization

#

@Id is, you guess it

earnest phoenix
#

Does java call them decorators or annotations

#

I cant remember

lyric mountain
#

Annotations

quartz kindle
#

jabba calls them the hutts

earnest phoenix
#

I at least remember that

lyric mountain
#

@GeneratedValue means the value will be automatically generated

earnest phoenix
quartz kindle
#

im wearing beskar

#

good luck

earnest phoenix
#

I understand what the annotations mean haku

lyric mountain
#

Strategy IDENTITY means database-generated value (AUTO INCREMENT basically)

earnest phoenix
#

I do not understand how to use the models to fetch, delete, insert or update

lyric mountain
#

@Column is column definition, u also don't need it, but is fine to write it for better control of generated columns

#

To manipulate the data you first need a entity manager factory

earnest phoenix
#

Mmm ic

lyric mountain
#

This is everything you need to get started

quartz kindle
#

java is bad because it needs entire factories to produce simple goods

#

:^)

lyric mountain
#

I tried to keep my factory simple and straightforward, no need to complicate it for no reason

sudden geyser
#

the simplest factory is no factory

lyric mountain
#

Nah, in this case the factory is justified

#

You create and destroy entitymanagers all the time

#

Imagine having to set their properties all the time, yikes

quartz kindle
#

imagine having to hire bounty hunters to do your dirty work

lyric mountain
#

Kekw, that's the hero system

fiery stream
#

can anyone help me debug the error please 🥺

lethal trout
#

how can i get the number of votes my bot has?

fiery stream
lethal trout
fiery stream
lethal trout
#

ic

civic scroll
#

check if the object already has it

#

or it's privated

fiery stream
lament rock
#

Unity CS is really weird 😵‍💫

#

My best accomplishment so far is making a script that iterates over the scene and recreating the entire scene tree on a UI panel where each GameObject has its own names, transform and other components and settings attached to it. It uses quite a bit of memory to build the tree, but I could probably reduce that by not caching the whole tree.

#

Next on my list is to make the scene "hackable" from in game where the player can make arbitrary changes to the scene

proven lantern
#

i dragged the role to the top and it worked. im confused

lament rock
#

It needs to be able to manage the role itself to add it to a member

#

and of course the target role must not be the client's highest role or higher than the client's highest

onyx socket
#

Is there any way to get data from an embed sent by another bot without having access to message.content?

spark flint
#

I don't think so as you can't see messages without message.content

torn bough
#

👍 👍

#

🍞 🍴 😋

spark flint
#

?

torn bough
#

I'm blind my apology do you know if there is braille in any mining and why not cause my difficulty level has doubled

spark flint
#

…………………. .. …… ………. …… ………… ….

…… … ……..

#

Braille

torn bough
#

Oh yeah somebody told me if your house is haunted do not get miner it will never sync is there any truth to this cause my place may be haunted can I get a refund do to not syncing do to 0paranormal activity my unit has a mind of it's own

spark flint
#

what

#

I thought you were blin

#

d

torn bough
#

In one eye and legally blind in the other but somehow I can see the green light on my bobcat from a mile away

#

Somehow I got the best surgeon in the world

civic scroll
#

legally blind

#

you sure

#

just update eye

spark flint
#

just software update

#

turn it off and on

civic scroll
#

skill issue

sharp saddle
#

to enable privileged intents from a verified bot, do I really need to make a video or something?

solemn latch
#

not that I am aware of

simple stump
#

I'm attempting to see if an HTTP request returns a different value every second (getting the value is no problem, that works fine), but in the loop will the value newAPI change? As of now, that doesn't seem to be the case.

  if (cmd.toLowerCase() === `${prefix}track`) {
    if (message.member.roles.cache.some((r) => r.name === "eltik")) {
      if (args.length < 2) {
        message.reply("You need to provde an user!");
      } else {
        message.reply("Tracking...");
        let isOnline = await getOnline(args[1]);
        if (!isOnline) {
          const currentAPI = await getAPI(args[1]); // Get the data
          setInterval(async () => {
            let newAPI = await getAPI(args[1]); // Get the new data
            if (currentAPI != newAPI) { // If the data changes, do x.
              message.channel.send("Person is online.");
              console.log("is online");
              clearInterval(); // Clear the interval.
            }
          }, 1000); // Repeat the loop every second.
        } else {
          message.channel.send("Online"); // Don't worry about this
        }
      }
    }
  }
wheat mesa
#

Hitting an api endpoint every second is a bad idea

split hazel
#

buta why not:(

#

in computer terms a second is very long

wheat mesa
#

Yes but most services probably don’t want you hitting their api every single second :p

#

Depending on what kind of endpoint it is/what it does you might get ratelimited

#

I doubt there’s a valid reason to check an api every second anyways

earnest phoenix
#
const x = db.get("falls");
//[ { ButonRole: 1234, memberLog: 'memberlog' } ]

const y = x.find(obj => obj.hasOwnProperty("ButonRole"))
//{ ButonRole: 1234, memberLog: 'memberlog' }
#

is this correct output?

wheat mesa
#

It’s the correct output if that’s what your desired use case is

#

I don’t personally see the point of this

#

You’re just getting the same object twice

earnest phoenix
#

same output

#

shouldnt be difference?

lyric mountain
#

isn't it because all the objects there have ButtonRole?

#

like, in both cases it'll pick the first value

earnest phoenix
lyric mountain
#

find by id maybe?

#

idk what is your structure nor what ur trying to accomplish

earnest phoenix
#

Get value of ButonRole which is in array

#

Actually it works better removing array if it is possible

lyric mountain
#

what is buttonrole? what is its structure? what is the expected result?

earnest phoenix
#
{
    "x": [
        {
            "y": "yString"
        },
        {
            "z": "zString"
        }
    ]
}
#

get me "zString"

#

I want that

lyric mountain
#

that makes no sense at all

wheat mesa
#

What on earth

earnest phoenix
#

bruh why

#

i have db

#

i wanna use it clear

#

so i am using push method

#

and it makes my db as that

#

i need get value

#

and i cant get it directly bc of array

lyric mountain
#

contabo

quartz kindle
earnest phoenix
#
let a = db.find(obj => obj.hasOwnProperty("JoinedUsersLog")) 
        let b = db.find(obj => obj.hasOwnProperty("LeftUsersLog")) 
        let c = db.find(obj => obj.hasOwnProperty("AutoRole"))
#

And i found it

slow whale
#

Command (play) unable to run
RangeError: Provided argument must be present.

#

?

lyric mountain
wheat mesa
#

9 times out of 10 if you’re using hasOwnProperty() there’s probably a better solution

civic scroll
#

also consider using a Map instead if you want a better search and use Map.entries for iterating later

quartz kindle
#

you're still using 3 loops when you could use just one

#

and even then, he can design his data in a way that doesnt require any loops

#

which is the whole point of "why is he using arrays when he could use objects"

lyric mountain
#

sometimes one might wonder, "maybe I should've used sql"

boreal iron
#

Pff Java user…

lyric mountain
#

default avatar has no speak

wheat mesa
#

he’s driving don’t distract him!

lyric mountain
#

ah true

boreal iron
wheat mesa
#

:c

boreal iron
earnest phoenix
sudden geyser
#

php

split hazel
#

this makes me want to harm a defenceless orphan

surreal sage
#

If you have a array like this:

var array = [
{
id: "noneofyobusiness"
}
]```
How would you `array[searchbyid]`?
sudden geyser
#

You use .find to get the element in the array

#

So you can compare the .id with equality.

surreal sage
#

kk ty

#

@sudden geyser Is there a method to still do it within the []'s?

#

findIndex nvm haha

sudden geyser
#

wdym

surreal sage
#

The moment you call tech support, you figure it out on your own -Linus Tech Tips

#

I'm using quick.db and I want to set something to null

#

Which look similar to that array I showed

sudden geyser
#

Doesn't quick.db have a delete function

surreal sage
#

.set(key, null)

limber mica
lyric mountain
#

instead of blabla --> index and index --> blabla, have blabla/index --> global

#

that way u prevent circular references

limber mica
#

I have an idea

limber mica
#

so like

class hmhm {
  constructor(extend) {
            this.extend = extend
 }
}
lyric mountain
#

while you can, you should never need to import index

#

for 99% scenarios, a global class would be appropriate

limber mica
#

my starting file is start.js

#

But thx

earnest phoenix
#

Can i join strings in a string?

#
`${string1 + string2}`
``` something like this
sudden geyser
#

Yes.

earnest phoenix
#

ok ty

sudden geyser
#

But given you're using template strings, you could also do

`${string1}${string2}`

Or, if you don't need the template strings,

string1 + string2

At this point, it's a choice of style. I'd choose the concatenation without template strings if variables are all I have.

earnest phoenix
#

I knewed the first method but like it has many ones and in 1 ${} is a bit shorter

modest maple
#

Shorter.!= better

sudden geyser
#

Shorter is not always better, but there's not much to differ in this situation.

#

So choose your poison

boreal iron
#

that’s what she said

sudden geyser
#

I'd argue the second option is better since template strings are inherently about concatenation, so embedding it in your templates is kind of pointless.

sharp saddle
#

Why the fuck my bot join on VC selfMuted?

sudden geyser
#

maybe it doesn't like the voice channel

surreal knoll
#

I'm not too sure how to fix this issue 😕

sudden geyser
#

A syntax error means the structure of your program is wrong

#

Like if you bought a drink and got it but there was no drink in the cup

#

In this case, you're probably missing a { somewhere or you have an extra }

#

You can share more of your code also

surreal knoll
#

This is the config.js file

sudden geyser
#

can you share more of your code (up)

#

e.g. uploading it to hastebin

surreal knoll
#

pastebin?

#

i dont see anything wrong 😶

sudden geyser
#

I see something wrong with channels

#

Your formatting makes it hard to spot

#

But you're probably missing a }

#

Since you haven't closed the opening bracket at the very top

#

You're in two layers deep (module.exports > config)

#

But all you close is channels and config

surreal knoll
#

so where am i supposed to put the { and }?

sudden geyser
#

Near the end (})

surreal knoll
sudden geyser
#

I told you why you're missing one already.

surreal knoll
#

right

#

the config

surreal knoll
#

It says bot connected successfully but none of the commands work

earnest phoenix
#

can I do this in a few lines? (or in a human-readable format) ```js
if(deck1 === null){
await db.set(deck1_${message.author.id}, chsa)
} else if(deck2 === null){
await db.set(deck2_${message.author.id}, chsa)
} else if(deck3 === null){
await db.set(deck3_${message.author.id}, chsa)
} else if(deck4 === null){
await db.set(deck4_${message.author.id}, chsa)
} else if(deck5 === null){
await db.set(deck5_${message.author.id}, chsa)
} else if(deck6 === null){
await db.set(deck6_${message.author.id}, chsa)
} else if(deck7 === null){
await db.set(deck7_${message.author.id}, chsa)
} else if(deck8 === null){
await db.set(deck8_${message.author.id}, chsa)
}

sudden geyser
#

that's some yanderedev work

#

and yes, you can

#

with a loop

#

For example, you could put your deckX variables in an array and iterate over it with a for loop

#

In that for loop, you check if deck is null and set it if true

#

and make sure to break out so it doesn't process the others

#

but there's a good chance you could improve the code and structure fundamentally

#

as how you're storing it doesn't look efficient

earnest phoenix
# sudden geyser as how you're storing it doesn't look efficient

ik, there's a better storing way (too better... but I started like this 6 months ago and there are many players playing with this bot and I don't want to reset the db) so I'll do what you said (any example of breaking it? With break, i'm thinking of switch lol)

#

oh I remembered that you can use true in switch

#

ty

#

it's longer but more readable

warm arrow
#

Odd, php library isnt installing lmfaoedf

wheat mesa
#

I'd recommend rewriting the db structure on a test bot/test db and then migrating over

earnest phoenix
#

If you are using a for loop you could easily make that better

#

Assuming I understand the situation at hand here a for loop is a good option

quaint wasp
#

why does this function not return the responce ?

#
    function bitcoin() {
        let apiKey = config.coinMarketCapAPIkey;
        let responce;

    var options = {
    method: 'GET',
    url: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
    headers: {
        'X-CMC_PRO_API_KEY': `${apiKey}`
    }
    };

    axios.request(options).then(function (response) {
        let data = response.data;
        console.log(data)
        responce = data.data;

    }).catch(function (error) {
        console.log(error);
    });

    return responce;
    }```
#

It gets the data

#

and there are no errors..

#

(data is and array in the data recived)

#

ping in reply...

sudden geyser
#

Because promises will resolve some time in the future.

#

There's no guarantee response will be assigned a value by that return.

#

Instead, you should return a promise resolving to that value.

#

For example,

axios.request(options).then((res) => res.data);
#

That returns a promise resolving to the the response data.

#

So you'll need to resolve that promise elsewhere in your application. @quaint wasp

quaint wasp
#

oh

sudden geyser
#

Another issue is the naming conflict between function (response) {...} and let response;

quaint wasp
#

and i am gussing I also need to add await to the responce

sudden geyser
#

Ah, didn't notice.

hasty mulch
#

How do you do an f-string in Lua?

earnest phoenix
#

Like formatted strings?

wheat mesa
#

I think he means string interpolation

earnest phoenix
#

mmm well I can only think of string.format

wheat mesa
#

never used lua before but that probably helps

hasty mulch
earnest phoenix
#

string.format() is probably the most basic way to do such a thing

#

print(string.format("Hi %s", user))

scenic kelp
#

it's beyond me why programming languages still don't have native string interpolation in 2022

earnest phoenix
#

I wish a lot of languages would just allow the use of how js does it ${user} to make things easier

scenic kelp
#

something along that {} line yeah

earnest phoenix
#

It would make my day easier

#

kekw

scenic kelp
#

C# has a special type of string, same idea $"Hello, {thing}!"

earnest phoenix
#

Yea

scenic kelp
#

it just really surprises me how some languages still haven't implemented it

earnest phoenix
#

That is one of the reasons I loved C#

hasty mulch
#

Python does it print(f'{insert string here}')

earnest phoenix
#

How easy it was to format strings

scenic kelp
#

like working with java was like a bruh moment

#

i also love C#'s @ strings