#development
1 messages · Page 1964 of 1
u could have <A, B, C, D>
which means the compiler should expect 4 generics that extend Object
O
Possible heap pollution from parameterized vararg type ide is warning me about smth 
That's good to know
I wonder what a possible heap pollution means
when u don't limit varargs type it's possible to pass gibberish to it
Ah
effectively polluting an array without reason
Makes sense
this is also a useful one to have
BondedList?
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
I don't know how useful that could be to me since idk what you mean by processed
that way I don't need to do it every time
for example:
List<String> list = new BondedList<>(s -> s.replace("@everyone", "`REDACTED`"));
list.addAll(List.of(args))
Hm
it'll replace any everyone that enters the list
So if @everyone is found in the list of args it will repalce it
ye
another one I like a lot
BiContract?
it executes an action if, and only if, both sides of the contract are filled
I use it for multithread rendering
Also I guess I should fuck with database stuff as well with java if I wanna get the full experience
JPA for ORM
hmm
Any docs for jpa?
also it doesn't give a fck abt what database ur using, if it can store data it can work with jpa
for sure, baeldung is ur friend
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. […]
kekw true
god it is impossible to read that page's examples
They could of chosen a better font color
there's a plugin for chrome that makes all pages dark
it also works for any other page
Dark Reader
that one too
later on intellij ultimate, you'll get a built-in database manager
I have intellij ultimate
why is it different?
I have a student license
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 
"Oh but it's just highlighting"
nope, everything works
ctrl space, ctrl Q, alt enter
So is JPA built in or do I have to install it somehow
I seemed to have missed that part
hibernate?
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
But how do I
yea I can do that
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
I see
first one is the driver, in this case for postgresql
should I put that in the resources folder?
yes, inside META-INF folder
META-INF?
This is getting confusing ngl
The guide doesn't say anything about a persistance.xml kekw
there isn't one
At least I can't seem to find one
I see
ever used sequelize?
Yea
then you'll get jpa quickly
Though it has been a while so I don't exactly remember everything about it aha
Ah
So you can either use raw sql or their methods
.find() searches strictly for the primary key
sometimes you need to write a query for better control of what u retrieve
I see
to save something:
mmm
Also I typically just use DBeaver to look at my database stuff
as I dont know how the built in database thing works
I am sort of confused here with the whole definition of things
also it's funny to see your classes relationship
why do they use private when defining columns?
generally u don't want a public property
Mmm true
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
So you set the getters and setters inside the model?
How are the getters and setters used?
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
Do you ever have to use the getters or setters yourself?
ye, all the time
Mmm
jpa uses reflection instead of getters/setters
so it's u who will use it mostly
so GuildDAO contains all methods that manipulate the data in database
ic
Well ima take a break for now
sure
So it is just a helper class for the guild model
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
reflection is fun 😉
Oh creating your own annotations nice
How does the Require annotation work tho?
Like how do you do the permission checks?
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
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
right here
notice the req == null ? new Permission[0] : req.value()
req.value() is the array of permissions
hmm
then I just compare both current perms set with required perms set
if one is missing = error message
Yea bit confusing but I think I follow somewhat
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
who's holding you hostage
me
my dignity wouldn't allow it
higher percent for enterprise software
click on apple or google's api docs and you'll see "No overview available" for half the classes
kekw
nah, one day maybe, when my pagination lib is free of bugs
I also need to add support for dropdown menus
how to make embed like this?*
like this how?
you mean the lack of color stripe to the side?
yes
just set the color to match the embed
...u don't know how to make embeds?
hex code? to same as embed colour??
yes
np
inspect element
woah hecker
lul
I hope I become good at java like u one day bro
This shit sometimes be confusing
nah I'm not good, there's a lot of room for improvement
which bot u made?
I've reworked many stuff in the source code over the time
shiro
not the dog, the girl
I mean if I can get anywhere near your level i'd be happy

nice
(✿◡‿◡)
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
Yea
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
a=b=c=10; works in java?
What are you seeing?
nothing it when i click on sumbit it does nothing
Can you send a screenshot of the tags section?
If the tags are too long, the submit button does not work
So try removing the large ones and then submit it
thanks it worked
and 1 more question sorry i know top.gg has stoped helping but just asking
How much time it will take usually to review bot
-upto
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
works in pretty much any lang I know of
ok
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
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
why exactly are u waiting a return at all?
ah nvm, that's a speech-to-text
update node
okay
@vivid fulcrum how have you been
Is it possible for a function to not return a value and terminate any subsequent processes?
that's pretty much return yeah
if (something) return;
if whatever is calling it expects a return, you might need to return a default value, generally null
it already defaults to undefined so
that for js
going crazy 
is that memory or frequency?

and what is frequency?
wait
How do I change command from / to something else
you don't
I just added the bot to a server
is that a 200GB ram server?
Mee6 and top gg share the same sign which is this /
again, you don't, that's a thing with slash commands
You shouldn't mix the prefixes for slash- and non-slash commands
what you want are prefixed commands, which most new bots don't support
Yeah of course... 192GB ECC RAM
tf are u running there?
virtualization
crysis at medium resolution?
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
Hmm, I see; you wanted to open a few Google Chrome tabs?
once I install Chrome on my server I'm prepared!
Look at the beautiful load sharing
I'm not atm 
wtf are you actually doing in this channel? can't be the real Voltrex
Wtf are you doing without driving? This can't be the real FakE
"Please don't abuse"
**I know what we're gonna do today Ferb! **
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
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
But will there be enough minutes per month?
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
fake don't block me but I'm about to make a bot in java 😉
Imma block you
me too
Wdym the fake at the atart
Ur not gonna do it?
Ahh
resident java hater
Blocked
you run a java program: -100 social points
Minecraft. Thooo
Fix: you make a java program: -100 social points
fix: your pc has the java interpreter installed: -100 social points / day
Mo
No*
yes
Sorry I have to! 
noooooooo :C
Btw I’ve got push notifications disabled for discord
Yeah I just pinged you so the other guy would understand what I was talking about
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…

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
Then leave the school early and educate yourself, as ez as that
There are things more important than that!
Not gonna drop out of high school, too risky
are you in high-school?
Yeah
Touching Java is a crime
yeah lmao "cs classes in school are so slow"
I'm pretty sure 90% of high-schools don't have cs programs
I mean I had CS classes in high-school too but it was simple stuff. Mostly VB, C# and C++
still, here people are so iliterate in computers that there are MS Word courses
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
you say "boolean" and people think you're cursing them
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!"
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
collections are our lord and savior
which is, what, 1999?
she told us that js arrays start at index 1 and I died inside
tf
or delphi maybe
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
that's cuz minecraft doesn't support mods at all
yeah
so they "gambiarra"d it
has to be decompiled and such
ye
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
dont let the others peer pressure you
btw, install log4j + slf4j
UPDATED log4j, be careful with old versions
log4j 

even the updated versions have vulnerabilities don't they? or has it all been fixed at this point
they fixed the dangerous ones
alright
it no longer allows outside attacks
until now
I assume adding log4j and slf4j are the same process as adding jda was
mfs over at log4j creating vulnerabilities like theres no tomorrow
I mean, they're volunteers but yeah
pretty much, with gradle you just add a new line
haha
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
You must be looking for trouble today…
do I need that random com.lmax dependency for log4j and slf4j to work as well, or is that just unrelated
alright got it all set up now
time to make bot go brr
damn you got fancy in your bot, using static initialization blocks
Please... you still have the chance to avoid it
just trying something new
never messed around with pure oop languages with discord bots before
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
add this to jvm args
to enable async logger
got it
https://logging.apache.org/log4j/2.x/manual/async.html <-- the whole tutorial for it
I think we need an exorcism for you!!1!
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
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
}
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
I'd assume it's just so the compiler knows what methods & props the error class has
smaller scope or per-exception action
ah
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
}
or even multi catches```java
try {
// something
} catch(AException | BException e) {
// more something
} catch(CException | DException e) {
// more something
}
ok java is suddenly becoming my favorite error handling language
don't tell fake I said that
self-closing streams similar to how c# has ```cs
using (var somethingThatTakesLotsOfMemory = new whatEver()) {
// stuff with that
} // disposed without having to call .Dispose()
try (FileInputStream fs = new FileInputStream(file)) {
// do something with fs
}
// no need to close, it auto-closed after finishing the try block
nice
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
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
int type = ...;
String value = switch (type) {
case 1 -> "Hello";
case 2 -> "World";
case 3 -> "!";
default -> "You shouldn't use that value.";
};
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;
}
hmmm, what am I looking at?
async async async(async async)
when u forget to lock reserved keywords
that's terrible
that's the point
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
Then the index will start at one though, you need to initialize i to -1
if you want it to start from 0
well yeah
to build a Discord welcome system, do you need to activate an intent?
ys
wich?
anything related to guild events
Do you need Server Member Intents?
not sure, but probably
ok ty
cuz ur welcome isn't working?
eh
and it must be boring to send form to discord activate
i like doing that kind of thing in js too. it helps keep things neater 😄
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
}
dang. that really reminds me of ruby. i loved that syntax
How do i define channels?
TypeError: Cannot read properties of undefined (reading 'channels')
doubles can't have a times method
:o
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}'.`)
}
}```
non-decimal numbers are integers in java, even when u do double a = 5 it'll become double a = 5.0
upcasting it is
var channel = client.channels.cache.get(interaction.channelId)
its client.channels.cache.get(interaction.channel.id)
I was thinking of cases like 5.3.times {} due to the two dots
guess what
But groovy doesn't use two dots
Ok, thanks!
it does support doubles
Didn't notice that lol.
your case gets rounded to 5 as it seems
probably bcuz it increments by 1 each time
either one works the same way, it's likely the channel isn't cached
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
probably C# notation, but never saw anyone bother with it
I don't think it's as necessary since you can tell if it's an interface or not from the keyword used
ye
I'll stick with C# notation though since I'm just used to it
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)
Where's this code ran?
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.
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
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. :)
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
but again, I'd recommend only fetching the channel once
so you're not constantly spamming the api
How do you want me to do that, though?
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
oh, u saw it
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
nice
Can you await (await function());?
why would you need to do that..?
I'm doing that for a collector.
personally never seen something return Promise<Promise<T>> if that's even possible
yes you can do that
👍
Anyone know how i can fix this?
only way i can think of you getting that is you're either using something prebuilt or you've moved your node_modules from linux/other os to windows
but a npm rebuild canvas should fix it
Its prebuilt yea
how do you center text and images with node-canvas
and different from discord's shitty command signature, you can have multiple signatures per command
image_width / 2 - text_width / 2
same for height
how do i get text length
depends, generally graphics libs have means of retrieving a string's length
is that the whole image?
if so, your background image isn't resized
in this case, canvas_width / 2 - text_width / 2
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)```
nonono, that'll get string length
ohhh
not actual printable size
you need to get the string width in that canvas context
see the link I sent
account for the text's font size
that'd only work for monospace
isn't it the same for both?
like, they all use canvas
there's this too
That's only for browser
but you can check out the source code and use it https://github.com/evargast/getTextWidth/blob/master/src/index.ts
in java it's just graphics.getFontMetrics().stringLength("the text")
idk why js doesn't have something similar built-in
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
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.
Let's say servers want a channel to be notified about something every X minutes, then on every loop I'd have to check whether the interval for any of the servers was met before I notify for those same servers
I think your implementation is good
yeah I definitely agree with that being expensive if it's user specific
I'd prefer a single, global interval in your case.
Since it can grow linearly very quickly.
So what do most people do when servers have different configurations for time interval?
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.
https://uwu.solutions/37uaSm8J how do i get this image in the embed?
its a canvas buffer
Make a discord attachment directly with the buffer and addImage to it
{
files: [{ name: "abc.png", attachment: image }],
embeds: [{ image: { url:"attachment://abc.png" } }]
}
nice
use member.user.username
Alr
shower
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
main.main ?
Does the same thing without
with just main
but the error gets changed to TypeError: Class extends value #<Object> is not a constructor or null
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
So im doing just "main" here and it gives this
Wait, interpreted that wrong
Maybe it's concerned about the circular dependency you introduce.
oh wait didnt see that you required the index one, try console.log-ing require('./core/main.js') in index?
returns {}
bruh
so its not recognizing the export?
yes
but module.exports = main; is included?
Le funni moment
Is it just me being retardo or nodeJS being dumb
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.
ohhhhhh
Since that's the default export
hmm
You can fix it by restructuring your files.
So how would I refrence main.js in commandMaps
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
Or separate them, but that doesn't apply to your case.
Ill merge them
Thanks for your help
I tried to use index.js to BREAK the circular dependancy
But I just extended it
hmmm interesting
Sometimes you need to use a global class
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
Finally?
U could also use an external variable
Idk if js has something alike, but in java u have atomic values
Well return should work there no?
tim async/await is for losers
because a promise is not a scope, its a whole different timeline
all my homies never use async/await we use .then nesting
NGL, I have never used finally I had to look it up 🤣
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
Might not work there, finally just guarantees something will run regardless of result
You could have the message send inside the promise tho
Ah nvm
Mobile formatting got me
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 });
});```
Sorry, I tried to not have to send it cuz I hate sharing my code 
I had an interaction die on me earlier claiming it was unknown.
After it was already replied to.
Tell me your issue, and I'll lessen your suffering
that is just called skill issue

you're doing m.delete() twice?
I dont get how defining entities and using them works
Oh
It's pretty much a copypaste of sequelize
Your class must be tagged with @Entity
Ima be honest I dont remember how to use sequelize
At that point, intellij might start hinting u abt what's missing
ima be honest dont use sequelize
Yeah, one for if it catches the error, the other for if it doesn't
I stopped using sequelize when I figured out typeorm was a thing
Cuz I was hoping the return there would stop the entire function
Yea but how do I make use of those in my code
How do I fetch, delete, update, insert, etc
Use MongoDB
that jpa guide or whatever on baledung wasn't that good in terms of explaining that
No
yeah you cant return from inside a promise like that, just remove the m.delete()
or can u?
Okay, Imma just use an external var LMAO
literally just remove the m.delete() from the catch and it will be fine
^
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
@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
i dont understand decorators
Annotations?
@Table defines table data, you don't need it but it's fine to have some customization
@Id is, you guess it
Annotations
jabba calls them the hutts
I at least remember that
@GeneratedValue means the value will be automatically generated
I will slice u open with my saber
I understand what the annotations mean haku
Strategy IDENTITY means database-generated value (AUTO INCREMENT basically)
I do not understand how to use the models to fetch, delete, insert or update
@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
Mmm ic
This is everything you need to get started
I tried to keep my factory simple and straightforward, no need to complicate it for no reason
the simplest factory is no factory
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
imagine having to hire bounty hunters to do your dirty work
Kekw, that's the hero system
can anyone help me debug the error please 🥺
how can i get the number of votes my bot has?
think you have to use dbl library for bot
mhm
yeah i think theres one for js n python dont know about other langs
ic
aka.
Property 'query' does not exist on 'User'.
check if the object already has it
or it's privated
ohh i already fixed that lol thanks tho
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
my bot has the manage role permission, but it gets a 403 error when calling the api
https://discord.com/developers/docs/resources/guild#add-guild-member-role
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
i dragged the role to the top and it worked. im confused
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
Is there any way to get data from an embed sent by another bot without having access to message.content?
I don't think so as you can't see messages without message.content
?
I'm blind my apology do you know if there is braille in any mining and why not cause my difficulty level has doubled
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
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
skill issue
to enable privileged intents from a verified bot, do I really need to make a video or something?
not that I am aware of
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
}
}
}
}
Hitting an api endpoint every second is a bad idea
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
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?
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
const y = x.find(obj => obj.hasOwnProperty("ButonRole"))
const z = x.find(obj => obj)
same output
shouldnt be difference?
isn't it because all the objects there have ButtonRole?
like, in both cases it'll pick the first value
So what should i do ?
Get value of ButonRole which is in array
Actually it works better removing array if it is possible
what is buttonrole? what is its structure? what is the expected result?
{
"x": [
{
"y": "yString"
},
{
"z": "zString"
}
]
}
get me "zString"
I want that
that makes no sense at all
What on earth
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
contabo
then dont use push? push is for arrays
I have to object from one guild i think push is better method
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
every time it gets worse 😩
9 times out of 10 if you’re using hasOwnProperty() there’s probably a better solution
const find = (key: string) => db.find(obj => obj[key]!!)
let
a = find('JoinedUsersLog'),
b = find('LeftUsersLog'),
c = find('AutoRole');
consider wrapping the logic inside a function if you reuse it
also consider using a Map instead if you want a better search and use Map.entries for iterating later
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"
sometimes one might wonder, "maybe I should've used sql"
Pff Java user…
default avatar has no speak
he’s driving don’t distract him!
ah true
Shut up, guy who’s also using Java 
:c

Sake Fake what do you use
?
php
this makes me want to harm a defenceless orphan
If you have a array like this:
var array = [
{
id: "noneofyobusiness"
}
]```
How would you `array[searchbyid]`?
You use .find to get the element in the array
So you can compare the .id with equality.
kk ty
@sudden geyser Is there a method to still do it within the []'s?
findIndex nvm haha
wdym
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
Doesn't quick.db have a delete function
.set(key, null)
Sorry for the late response, but global class?
a class to hold commonly used values
instead of blabla --> index and index --> blabla, have blabla/index --> global
that way u prevent circular references
I have an idea
Instead of that, cant I just technically "extend" it by passing the "this" variable of the class I want to extend it from on launch, and essentially just access the "this" property from there
so like
class hmhm {
constructor(extend) {
this.extend = extend
}
}
while you can, you should never need to import index
for 99% scenarios, a global class would be appropriate
Yes.
ok ty
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.
I knewed the first method but like it has many ones and in 1 ${} is a bit shorter
Shorter.!= better
Shorter is not always better, but there's not much to differ in this situation.
So choose your poison
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.
Why the fuck my bot join on VC selfMuted?
maybe it doesn't like the voice channel
I'm not too sure how to fix this issue 😕
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
This is the config.js file
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
so where am i supposed to put the { and }?
Near the end (})
dont i alr have tht?
I told you why you're missing one already.
I fixed the } problem but now we have this
It says bot connected successfully but none of the commands work
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)
}
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
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
Odd, php library isnt installing lmfaoedf
your structure is fundamentally flawed with the way you store data from the looks of it...
I'd recommend rewriting the db structure on a test bot/test db and then migrating over
It shouldn't be longer?
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
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...
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
oh
Another issue is the naming conflict between function (response) {...} and let response;
and i am gussing I also need to add await to the responce
2nd one is responce
Ah, didn't notice.
How do you do an f-string in Lua?
Like formatted strings?
mmm well I can only think of string.format
never used lua before but that probably helps
Yeah, like for example:
print("Hi {user}")
string.format() is probably the most basic way to do such a thing
print(string.format("Hi %s", user))
it's beyond me why programming languages still don't have native string interpolation in 2022
I wish a lot of languages would just allow the use of how js does it ${user} to make things easier
something along that {} line yeah
C# has a special type of string, same idea $"Hello, {thing}!"
Yea
it just really surprises me how some languages still haven't implemented it
That is one of the reasons I loved C#
Python does it print(f'{insert string here}')
How easy it was to format strings

