#development
1 messages · Page 96 of 1
That you're able to add these to a list and use their interface methods
Only really used interfaces for instancing, such as being able to tell what type of data i am about to parse using instanceof
oooowh so if you have an array of an interface, it can hold all types of classes IF the classes implement that interface? that makes more sense now
thank youu!
yep, u can always put subclasses in the same collection in they implement the same interface/superclass
ahaaa i see!
i could then for example loop over tit and use all methods on it that i defined.
Pog
if i define a public int in the interface, it will be readable by all classes but not changeable right?
unless they make a copy?
owh i see but int price = 50; for example
it would be readable but not changeable right?
Not in the interface, the interface is essentially a "blueprint"
Theoretically a blueprint
I see, thanks once again!
There's something called abstract interfaces too, but tbf have never worked with these myself
So ask the java god KuuHaKu about abstract interfaces
Since abstract classes are able to do what you were mentioning
interfaces can only have static constants
i haven't reached that part yet so i don't think i need them for this course
that means all "variables" will be final
uhuh yeah! Got it, thank you!
Was i right with the abstract classes tho?
Honestly you made all puzzle pieces fall within 10 minutes, something my teacher couldn't in 2 hours
web frontend development and rust
they both dont go together
eh they do for me imo
especially wasm

if they dont for u then you do you
wasm is slower than js
https://webassembly.org/docs/use-cases/
it shouldnt be used for normal web dev
Made a state validator which passes state assignments and previous values to the next do/go call.
param 0 is code
param 1 is expected value
param 2 is error value [status code, text]
param 3 is key to assign to state
Helpful for things like POST form validation and protecting against Cross Site Request Forgery
so like a more pieced together assert
Essentially. Although this to me is way more easy to digest and each stage depends on each other stage prior succeeding
https://prnt.sc/aAqOlMOWckMG
I'm filling the form for my discord bot verification, how do I answer this question?
The only message content that my discord bot stores is the AFK reason & it's stored as long as the user doesn't send a message in chat. There's no point in deleting it after 30 days.
discord wants you to delete that after 30 days then
i wouldnt count that as storing message content
afk reason is specifically an option for a command, initiated by the user
what they are worried about is storing message content from people's conversations and stuff, like message backups and stuff like snipe commands
Ah I see. So storing Waifu names is also not something they'd count as storing message content I assume.
For context, users can collect cards & set names for their cards with commands which are stored inside the database
yeah i would count that as setting options for the bot, not as storing message content
i want a help with interactions in discord.py can any helps me?
ask your question
In java, i am creating a interface geometric and 2 classes that implement this geometric interface
i want to push these 2 created objects from the classes into a geometric array
where's the best place to have that array stored?
in the interface itself would be a nono, but where else?
I have a iohandler, must i put it in there then?
Huh?
Just Geometric[] would be fine would it not?
Maybe I don’t understand the question
Oowh i can explain it a bit more thorough
I have 2 classes, triangle and circle.
I also have an interface Geometric that has several methods to be defined.
I want to create an array that holds all triangles and circles i want
but for that i must create an array of geometric right. Where should i put this array? Inside the gemoetric interface? Because i want to be able to access it from all classes, and modify it within the classes.
hope that i made it a bit more clear
are u trying to retrieve all classes that implement Geometric?
because, like, I don't get what ur trying to do, but I think u have the wrong idea of what an interface is
interface: is essentially a blueprint
you cant pass values to other classes that implement that interface
you'd need an abstract interface and a static variable
not java
do python
funny snake language
do php
funny elephant language
crab language
do elephant
or gopher
swift if you use a mac
u could try groovy
no fuckin clue what astro is
do assembly
Oh god no not for oauth
I just meant in general
Rust has some good crates for oauth afaik though
crabs in a crate
for sites I'd just use the basic html kit
that's backend, not front
they can be done separately, it's all api in the end
idk, for backend I just use java
an endpoint
oauth is nothing more than a 2-step api flow
you redirect the user to oauth
user authorizes
you receive the key
you trade the key with the server
you receive the data
you redirect the user to whatever u want
storing is just to be able to retrieve the data again without needing to ask for authorization
any language will suffice, oauth ain't as complicated as it seems
store what?
if they aren't logged in there's nothing to store
Oauth should handle redirects anyway.
simply redirect
like, idk how to explain, all u need to do to control user flow is redirecting the request
oauth will send u whatever u need, just do your work from inside the backend
u can just redirect the user as soon as the payload arrives then finish the processing in the rest of the function
in some sense it ain't too different from handling message events in discord
Beware this is just a class, not the main. I had a design question. Would it be okay to have one big helper function, or do yall recommend me to part it down? Like one for input, the other to extract parameters etc?
i always was told to make small helper functions, so i could do that here but it seems pretty useless to do that.
yes you can (and should) make a helper class to keep all the commonly used methods
do note tho, u don't need to use \n in println
because println already include a linebreak
Well sometimes a double new line looks better..
int a; // no initializer (default initialization)
int b = 5; // initializer after equals sign (copy initialization)
int c( 6 ); // initializer in parenthesis (direct initialization)
// List initialization methods (C++11)
int d { 7 }; // initializer in braces (direct list initialization)
int e = { 8 }; // initializer in braces after equals sign (copy list initialization)
int f {}; // initializer is empty braces (value initialization)
according to learncpp.com the first 3 are not "modern" C++ and are not really recommended under most situations, so what are the downsides compared to those 3 to the last 3?
I also don't really understand the difference between copy and direct initialization
It doesn’t matter very much in the grand scheme of things
These are just different ways to initialize things
So there is no downside?
maybe direct allocates with the value inside while copy allocates then insert the value
regardless, compiler will use the optimal way anyway
^
so in grand scheme of things there is no big difference between them it just comes to a matter of preference?
@wheat mesa There is a benefit to list initilizations tho
int x {4.5} actually gives a compiler error rather then just a warning in the IDE
So if it can't safely hold the value in the type specified it will error rather than try and implicitly convert it
Most people still use the generic = initializer
ima use the list variant
The different types of initialization become more important when working with classes and structs
= has the advantage of allowing ctrl + F
ctrl + F?
yes, to find places where a variable is declared
Ah
without = there's nothing u can use to search
I can just search the variable name
well, yes, but what if u need to find all variable declarations?
initialization*
if u search for { it'll return scope braces too
Im talking about looking for a specific variable declaration
There are many objects in an array and I want to calculate the number of "author" values in these objects.
an example array;
let array = [
{ user: "TuranGe", balance: 25, author: "User1" },
{ user: "popoasd", balance: 255, author: "User1" },
{ user: "Prowdy", balance: 31, author: "User1" },
{ user: "Asd", balance: 1, author: "User2" },
{ user: "Asda", balance: 12, author: "User2" },
{ user: "Asdasd", balance: 11, author: "User3" }
]
The output I want is:
User1: 3
User2: 2
User3: 1
occurrences, u mean
idk if js has, but u could use a bag
or just search on google https://stackoverflow.com/questions/5667888/counting-the-occurrences-frequency-of-array-elements
let array = [
{ user: "TuranGe", balance: 25, author: "User1" },
{ user: "popoasd", balance: 255, author: "User1" },
{ user: "Prowdy", balance: 31, author: "User1" },
{ user: "Asd", balance: 1, author: "User2" },
{ user: "Asda", balance: 12, author: "User2" },
{ user: "Asdasd", balance: 11, author: "User3" }
]
let ObjArray = []
let obj = {}
array.forEach(ele => {
if(ObjArray.includes(ele.author)){
obj[ele.author] += 1
}else {
ObjArray.push(ele.author)
obj[ele.author] = 1
}
})
console.log(obj) // { User1: 3, User2: 2, User3: 1 }
let me know if anything went wrong
I did it but then I need to separate them with join by putting , I can't call join function on objects
how do you want the output to be ?
[
{ user: "User1", length: 3 },
{ user: "User2", length: 2 },
{ user: "User3", length: 1 }
]
alr let me try
let array = [
{ user: "TuranGe", balance: 25, author: "User1" },
{ user: "popoasd", balance: 255, author: "User1" },
{ user: "Prowdy", balance: 31, author: "User1" },
{ user: "Asd", balance: 1, author: "User2" },
{ user: "Asda", balance: 12, author: "User2" },
{ user: "Asdasd", balance: 11, author: "User3" },
]
let sira = array.reduce(function(sums,entry){
sums[entry.author] = (sums[entry.author] || 0) + 1;
return sums;
},{});
let sorted = Object.entries(sira)
.sort(([,a],[,b]) => b-a)
.reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
I can sort it like this
Even I don't really understand what's happening there
Although that should do what you want
sira counts how many times an author appears
Oh wait you don't want it like that you want it like above nvm
and sorted just sorts by most to least
my goal is a code that will return array input like this
i will try to make it happen
then instead of your second reduce reducing it to a sorted map reduce it to an array
ok thanks
you could accomplish it with just .map(([author, count]) => ...) where ... is a map following the user length map example
since map creates an array of items you'd have it in your wanted form
did you create it or is it someone else's bot
I mean my ENRA bot
Where can I get their diacord
-wrongserver
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(
Your btw XD
am I dumb or did I forget how map works
we all forget how map works
I wonder if reduce with an array accumulator is easier?
let array = [
{ user: "TuranGe", balance: 25, author: "User1" },
{ user: "popoasd", balance: 255, author: "User1" },
{ user: "Prowdy", balance: 31, author: "User1" },
{ user: "Asd", balance: 1, author: "User2" },
{ user: "Asda", balance: 12, author: "User2" },
{ user: "Asdasd", balance: 11, author: "User3" },
]
let sira = array.reduce(function(sums,entry){
sums[entry.author] = (sums[entry.author] || 0) + 1;
return sums;
},{});
let sorted = Object.entries(sira)
.sort(([,a],[,b]) => b-a)
.map(([author, count]) => {
return { user: author, length: count }
})
Is this how it works?
idfk
map takes a collection and returns a new collection by applying a function to each item
so yes
I actually have not used js in months
return array.reduce((acc, cur) => {
let index = acc.findIndex(obj => obj.author === cur.author);
if (index !== -1) {
acc[index].count++;
} else {
acc.push({user: cur.author, count: 1});
}
👀 ?
even shorter would be .map(([author, count]) => ({ user: author, length: count }))
or just to keep the variables the same name to get rid of the colons
@rigid maple
let array = [
{ user: "TuranGe", balance: 25, author: "User1" },
{ user: "popoasd", balance: 255, author: "User1" },
{ user: "Prowdy", balance: 31, author: "User1" },
{ user: "Asd", balance: 1, author: "User2" },
{ user: "Asda", balance: 12, author: "User2" },
{ user: "Asdasd", balance: 11, author: "User3" }
]
let ObjArray = []
let obj = {}
array.forEach(ele => {
if(ObjArray.includes(ele.author)){
obj[ele.author] += 1
}else {
ObjArray.push(ele.author)
obj[ele.author] = 1
}
})
let sorted = ObjArray.map(x => ({user: x, length: obj[x]}))
console.log(sorted)
please don't do that
this is what i do it returns me object;
{ User1: 3, User2: 2, User3: 1, }
so I can't print as
2- User2: 2
3- User3: 1```
output:
map returns an array, so I don't see how that'd be the output
thanks
let me know if anything went wrong.
he said he wanted it to be an array in the first place
ok thanks for your help
did it work ?
Ofc that works
i know the code works i tested it but i was asking because i did not know if this is the exact output he wanted
All you are doing is looping over the array of objects and any point that it finds a author with the same name it increments
its not rocket science
Who said its rocket science man ? chill out
i was asking to see if it fits his needs
I disagree with your method tho
I don't like the idea of using forEach over what was originally being used
show us how you would do it
let array = [
{ user: "TuranGe", balance: 25, author: "User1" },
{ user: "popoasd", balance: 255, author: "User1" },
{ user: "Prowdy", balance: 31, author: "User1" },
{ user: "Asd", balance: 1, author: "User2" },
{ user: "Asda", balance: 12, author: "User2" },
{ user: "Asdasd", balance: 11, author: "User3" },
]
let sira = array.reduce(function(sums,entry){
sums[entry.author] = (sums[entry.author] || 0) + 1;
return sums;
},{});
let sorted = Object.entries(sira)
.sort(([,a],[,b]) => b-a)
.map(([user, length]) => ({user, length})
How klay said it would be how i'd do it
that's a way better way to do it
idk if its better but its how i'd do it
I made the simpler way to do it tbh
you can remove the ,
Good to know
it can take over a week to get verified
Wait wtf
its closer to two weeks right now
i was waiting to see what you were typing LMAO
Yes they straight up say "Up to 1 WEEK OR MORE." #support message
Trying to upgrade fans and ram and the case the server came in is proving to be very difficult to work in :/
each cpu has 4GB of DDR3
Did u ever think "Maybe I have too many coolers"?
or Maybe I dont have enough coolers
Besides, won't the top left cooler be blocked by the top right?
I would guess its a high airflow server case so it probably wouldn't matter too much? 🤷
Not super high airflow. I plan on replacing the 2 fans directly on the heat sinks with 2 blowey-ma-trons that blow air towards the back of the case
but the fans are soldered to the heat sinks
waiting on some 120mm fans to show up at my door
the case in question
You can go to thrift stores and pick up old pc cases for pretty cheap, would definitely be interesting to mod it to fit your board and might have better airflow
question for python devs who have done web-apps
is it possible to just use flask to run a prod website
cuz fuck that error message
Server without RGB?
Damnit, we're in 2023 - that's not allowed anymore
Aha i see, thank you!
I have made a html file, to show a small dashboard. Is it actually possible to also have a discord bot running in the same file?
Like, i never tried it, to combine multiple purposes and languages in a singular file
yeah ofc, thanks for all the help!
ikr I might as well just spec my own server pc
tbh idk if that motherboard even has an rgb controller header
likely not because it's a really old platform
I highly doubt tbh
Got a not that old dual socket system myself but there aren't any rgb pins on the mainboard
Which would be really weird imo
😅
But I'm using certified hardware only anyways and I have never heard of certified server rgb lightning
is the djs v13 channel.messages.fetch max still 200?
100 like always (API limit)
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
thanks papi
@earnest phoenix does this look fine?
this is what it defaulted to when I made the new build tool config
That should be good, though the debugger should be LLDB since you're using LLVM
what should C Compiler be do you think?
Clang-CL is both a C and C++ compiler, what do you mean it's not correct?
I mean is that when I set it as that it returned a CMake Error
What's the error?
https://hastebin.com/share/zagigobile.bash actually doesn't seem to be due to clang-cl
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
but yea after changing to use clang this happened
Open the file explorer and go to C:\Program Files\LLVM\bin, what is in there?
a lot of exe and dll files
Show screenshot
I cant fit it all
Maybe screenshot once or twice
nvm I can
Interesting, open a terminal and run clang-cl --version, what does it output?
PS C:\Dev\cpp\LearnCPP> clang-cl --version
clang version 15.0.7
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
That should work then, hmm, try writing a basic C program like Hello World and compile it with clang-cl
I dont even know how to write C
#include <stdio.h>
int main() {
printf("Hello World\n");
}
it turns into an exe file
So it does work, looking at that CMake error again I think you don't have rc.exe in your PATH
What happens when you try to run rc (or rc.exe) in your terminal?
not a recognized cmd
ye so it just doesn't exist on path
Go to C:\Program Files (x86)\Windows Kits, what do you see?
Go to 10, and open the directory with the highest version
Love it when finding a compiler is harder than writing the code
Yeah
Yes, it's strange that it's not in PATH for you
do I add the entire dir to path or only the rc.exe
The entire directory should be at the PATH
You're welcome
how do i convert a file object to a buffer?
I'm trying to POST a file, but form-data doesn't accept files as objects
the object is in the format json { "fieldname": "file", "originalname": "211107600-1e04ba3c-68a4-423c-bc09-ae5ea4fec1ba.mp4", "encoding": "7bit", "mimetype": "video/mp4", "buffer": { "type": "Buffer", "data": [] // very very big array }, "size": 123245 }
obvious answer would be to POST file.buffer, but I need the filename, mimetype and size as well
The very big array is your buffer
imagine using the file explorer to find files
cmd for life 😎
Just to install a fucking simple gcc took me like 1 hours
is there any noticable difference between a Intel Xeon 26XXv2 CPU and a AMD EPYC 7443p for Minecraft, Databases, Websites, Nodejs & Python?
Probably the worst server to ask /s
what do you guys think of my horrendous database code?
https://pastes.dev/fvuZF9KvX4
21/20 - using ${} makes your database super secure
Also Type ORM is a thing in 2023
I do use injection secure statements, just not for the table, where and update are secure
:P
I couldnt find a ORM that supports mapping nested json values to database columns
so I just made this myself, works fine enough
Best lang to make a desktop program?
I want to run a bash command which exists for 60 seconds long
It outputs 1 line around every second
I want to save those lines
I want to do this in node with child process
I tried using child_process.spawn but I doesn't give me anything when I listen for messages
I want to get the Watts on each line
https://stackoverflow.com/a/22365830
This might work one second
I'm running a Python script through a child process in Node.js, like this:
require('child_process').exec('python celulas.py', function (error, stdout, stderr) {
child.stdout.pipe(process.stdout...
yup all g
general question, am i doing this right?
im running a Sanic site (sanic -> uvicorn), its forwarded ufw allow 80and shows up on the domain, everything seems fine.
But i have to run it with sudo sudo python3 main.py or else it fails to bind to port 80 (which from what i understand, is where you run HTTP webservers)
never done web/network stuff
just wanna know if thats the correct way to be doing it
im also getting this "GET /static/js/scroll.js HTTP/1.1" 304 Not Modified
no clue what that means
The reason why you're getting an error with binding it to port 80 is because sudo executes it with root
Anything below 1024 is a privileged port and needs root access
yeah thats what i was reading, so im doing that right then?
Yeah, especially with sudo, thats correct and normal
ive never ran a website before so i dont really know if i should be putting it directly on port 80
Port 80 is the default http port yeah
alr alr, so im right with forwarding 80?
Yup with allowing 80 through your firewall
also never really messed with that, all i know is you open a port up so you can access smth on a local pc
A port is essentially a door on which an application can talk to another application, so when your browser tries to visit yourwebsite.com, it tries to go through that door
yeye, thats basically all i know about it
ive been told running sanic/flask alone without wsgi or something isnt safe, uvicorn is asgi, so thats performs the same task right?
No clue tbf
again, all i know is youre supposed to run something over flask/sanic and i saw uvicorn was one of the options
Never worked with prod based wsgi lol
or something along those lines, not running a web server barebones on a domain
ah, ive just straight up never worked in any of this
super new to me, ive only done local stuff
got a friend that hosts all my stuff and gave me a subdomain so i figured i'd dip my toes in
ty for the help, from what ive gathered i think im good to call this 'production' level and leave it running so the sites accessible to everyone
I have like 5-6 apps running on barebone flask, never had issues
Of course it might have an impact on performance somewhat
Though never experienced it
im not really worried too much about performance, sanic is async + way faster than flask from what ive heard, so i should be good performance wise
sites super simple anyways
theres also flask async
sonic
fast sonic
@lyric mountain Hey regarding what you told me yesterday about seperating the java methods into smaller methods using helpers: What about this code, is it okay now or does it even need more seperation? https://pastebin.com/4GuQfv0U
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
like, for each single option i created a seperate method.
or can i break it down even more?
Eh, pastebin
The idea isn't abt breaking, but more about reusing commonly repeated code fragments
For example, let's say u had a method to await user input that was repeated 1:1 in many places
Instead of writing it everywhere, simply make an awaitInput() method
Also, for helper methods always make them static
And the enclosing class abstract
That way you don't need to instantiate it everytime and you hint to the runtime that it'll never be instantiated
@eternal osprey
Btw u can use string format instead of concatenation
And please, make a helper method for printing
owh i see, thank you!
Yup i will try to check if i have lots of functions i keep re-using and create a helper function for it
is the code okay tho, or is it fucking astrocious?
apart from the above notices
wdym with this btw?
public static void println(String str) {
System.out.println(str);
}
That way u can import static your.package.Helper and use println() instead of sout
owh i see, thanks! I haven't covered that in the course yet but it will definitely look better!
The code right now is already a bit more broken down into smaller parts, however some methods/functions don't really get used a lot so i cannot break it down further then right?
I mean, it would be strange to have a whole method for only 1x use
What is Structures.js?
?
looks like some gift code
yeah
there is nothing like structure.js
this.parentNode.querySelector('input[type=number]').stepUp()
Why not read parentNode in react
TypeError: Class extends value #<Object> is not a constructor or null
at Object.<anonymous> (/home/runner/all-in-one-discord-bot/node_modules/discord.js/src/structures/TextChannel.js:15:27)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/runner/all-in-one-discord-bot/node_modules/discord.js/src/util/Structures.js:96:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
you're trying to extend something that isn't extendable
idk really i took from yt
Bad idea
yep
what version of node.js are you using
but could u plz tell whats the issue?
No idea without seeing the code
Or knowing the node version
U should really try to learn how to make a bot, instead of copying from somewhere
If it ever breaks (and it will) you'll be left hopeless with a non-working code that u don't know how to fix
yeah u r right
For instance, what kind of bot is it?
btw how to know node version? i m on replit
node -v
Doesn't seem too hard to make from scratch, but you need knowledge on how js works
ReferenceError: node is not defined
how to update?
Well, for replit it's a bit tricky, I'll need @sudden geyser here
ok
search google
they should let you set the node version
though using repl.it as a host is generally a bad idea
19, but it's probably not LTS
ohk
Anyway, isn't there any bot on topgg that does what u need already?
yeah but....uk a feeling of self hosted bot hehehe
Well, I do know what u mean, but you're up to a lot of work keeping it alive
yeah
The current latest LTS (known as the stable release) is v18, the latest non-LTS release is v19
You can see from https://nodejs.org/
NodeOS when
running apps only made in js
Performance 📉
https://node-os.com/ thats pain
The first operating system powered by node.js and npm
I bought myself a kvm and didn't even bother to check if I had enough display port cables

whats that
keyboard, video, mouse
a switcher where you have inputs that can change between PCs
instead of peripherals per PC
i want something like that for screens
imagine having a central pc with multiple screens in different places in the house
and each screen be its own desktop
but sharing the same pc
lmao
would be cool
and make it voice activated
"computer, move to the kitchen"
turns on kitchen tv and shows main desktop
It is kinda cool tho, but I think you need a lots of pc to do that
or maybe rasberypie
I tried to make a smart home with some wifi controler module
and it works :)))
cutting some wires, connect it to the boards and then control it with your phones, kinda cool tho
could definitely do something akin with home assistant
i dont want multiple pcs, just one main pc connected to all screens
and be able to move the pc from screen to screen without having to plug/unplug cables
is typcasting a bad thing to do?
typecasting* in java
i want to convert doubles to an integer
Sometimes, it's necessary, but it should be avoidable if possible like changing what data types you normally use
yeah indeed, i just created one seperate hlper function for doubles and one for integers
that way i could work around it, thanks papi!
why would an interface extend another interface?
Like it doesn't make sense, why don[t the classes just implement that focking interface directly instead of first extending it and hen implementing it
the same reason a class extends a class
sometimes you want to add an additional methods to the interface, and usually u cant modify the original code
so waddya do? you extend it
i see, so if in one interface i got the void checkoption(string x) method, and i extend that interface to another interface, in that supertype i have to put the checkoption(string x) again right?
or should i already define it in the subinterface?
and what about the classes? Should they implement the new interface as well? Or only the old (sub) interface?
no
sorry for all the questions, but i can't find good sources online about these questions
interfaces don't (and can't) need to implement the super-interface's methods
it'll just inherit the contract
think of it like a sum
so ```java
public interface ContractA {
void doShit();
}
with ```java
public interface ContractB extends ContractA {
void doSmth();
// void doShit(); <-- inherited
}
will result in a sum of ContractA + ContractB
meaning any class that implements ContractB will automatically be implementing ContractA
inherited interfaces looks suspect
it's the only way to add additional clauses to interfaces if u can't modify the original code
so any class implementing contractA will also be implementing the methods of contractB !
no
inheritance only works one way
a class that implements ContractA doesn't implement ContractB
only the other way around
so ContractB = (ContractA) theObject; will work, ContractA = (ContractB) theObject; will error
why would you want to add additional clauses to existing interfaces as opposed to creating a new one
aha i see!
take Graphics for example, it's the interface used for all java2d drawing gimmicks
for compatibility reasons, instead of changing the old interface they chose to extend it into Graphics2D
which works with every Graphics application, but contains additional methods
plus every java2d classes were changed to always use Graphics2D, but they still return as Graphics
simply because it'd break existing applications
So if i understand it correctly, the object will have type contractB ContractA ClassType (<-- ClassType if applicable)
it'll have only ContractB
you still don't need an extended interface for that when you can just implement both interfaces separately
Ahh yeah indeed!
you can't really
Okay i understand it now, honestly inheritance is pretty cool
you'd need to have twice as many methods just because you're using two separate interfaces
and that'd mean twice as much work using said framework
when extending would solve any and every compatibility issue
for example, to get a graphics2d instance u do var g2d = someImage.createGraphics()
no, you'd create interface 2 while leaving interface 1 alone
so you aren't duplicating methods
don't think u get the real reasoning
like, they needed to add more (and useful) methods to the Graphics interface
but doing so might break existing code (for example, implementing classes that happened to have identical method signatures)
if u implement 2 interfaces u still can't use the two at once
because one would not be translatable to the other
public class Stuff implements ContractA, ContractB {
...
}
I cannot reasonably know that every ContractA will have the methods from ContractB
meaning I'd need to check for which interfaces said class include
plus, when extending interfaces u don't need to re-type every single method, u just write the new ones
say it Hohse, no need to wait for us
create an array of that sequence and print it
or use process.stdout.write (nodejs only)
❤️
kuu, you are awesome btw
Take this for example:
public interface Organism {
public void create();
}
public interface Animal {
public void trick();
}
You aren't duplicating create in Animal, nor are you using extends. This leaves an interface alone to be concerned truly about itself. If you want create and trick, you say so at the signature level (at least, it should be that simple).
Breaking existing code isn't done here (nor is a concern here), plus that's more a limitation of all interface methods being required, as opposed to opt-in.
honestly, just wanted to let ya know. Thanks for all the help! You saved a few hours (and fucking brain meltdown) by answering my questions
public static void stuffWithAnimal(Animal a) {
a.create();
a.trick();
}
for example
you'd not be able to do this if you're using 2 interfaces (and don't which class will be supplied)
this is exactly why Graphics2D extends Graphics
you need the methods from Graphics, but also the methods from Graphics2D, and you have no idea what class will be coming from the caller
the only way that'd work (without extending) is if you replicated the methods from A to B, which would break the "single responsibility" rule
oh, so java doesn't support multiple interfaces on a thing
seen this now https://stackoverflow.com/a/13261667/14695788
it does allow multiple interfaces
but not extending
public class Stuff implements InterfaceA, InterfaceB, InterfaceC, InterfaceD {
...
}
but it can only have a single superclass
for generics, it can have <T extends InterfaceA & InterfaceB>
it's just looked down upon because u can't cast T to either interface
so u can't also pass it as an argument unless the function allows that exact ancestry
no wait, might've confused this part
anyway, there're reasons stated on the net, too tired to think abt it now
is | not an option
why am i getting this error
TypeError: crypto.createHash is not a function
afaik it is a function 
nodejs? what version
how do i check again
node --version
how do i fix it 
idk 💀 could you share some more of the file that is causing the error?
like what
as much as you feel comfortable sharing, it'd be nice to see where you're defining crypto etc
const json = JSON.stringify(options.data)
const md5 = await crypto.createHash("md5").update(json).digest("base64")
this is the whole function
async setEntry(options,universe_id){
const id = universe_id || this.client.data.global_universeId
if (!id) {throw "DATASTORE: universe_id is not available nor gloval_universeId!"}
if (!options) {throw "DATASTORE: options is a reqired parameter!"}
options.datastoreName = this.name
if (!options.datastoreName) {throw "DATASTORE: There is no datastoreName set for this class!"}
if (!options.key) {throw "DATASTORE: Please provide a key to get the data from!"}
if (!options.data) {throw "DATASTORE: Please provide a data in order to update the entry!"}
const json = JSON.stringify(options.data)
const md5 = await crypto.createHash("md5").update(json).digest("base64")
const res = await axios.post(url+`/universes/${id}/standard-datastores/datastore/entries/entry`,options.data,{
params: {
'datastoreName': options.datastoreName,
'entryKey': options.key
},
headers: {
'x-api-key': this.client.data.api_key,
'content-md5': md5,
'content-type': 'application/json'
}
}).catch(err=>{
console.log(err.response.data)
})
if (res) {
return res.data
}
}
and i'm assuming crypto is defined properly with a require/import? that's the only thing i could think of
cause in console that line works fine
it is built in but you have to import it
oh
and if it wasn't being imported you should get a ReferenceError
now its working
oh wack

and it also works for me without importing it so idk
but hey at least it works /shrug
i'm not a js dev anymore so the wonders of this language are beyond me
how i make my bots status mobile
can i use the top.gg logo to link to my bot's vote page?
i noticed this in the terms of service which seems related
Dbots?
Anyway, don't think "redirect to vote page" counts as commercial usage, so ur fine
Especially since it'll be redirecting to the original site
Eh, so it used to be called dbots?
here's how i'm going to use it by the way
It's not commercial usage, it's fine
How do you make it say "[bot] is thinking..." with slash commands with discord.js
Like not make the bot respond with that but to just change the text after it says "Sending command"
Do you mean to edit the response?
With some bots it changes to "[bot] is thinking..."
Assuming you’re using djs, .deferReply()
Sending command is the time it takes for Discord to notify either the webhook or the bot's gateway connection that an interaction has occurred. Bot is thinking is when a reply is deferred and goes forever until the original interaction response is edited.
If you can respond immediately, do that instead of deferring the reply
You'd only end up hitting rate limits faster if you were adamant on showing thinking
slash commands dont really have rate limits, or have special limits
at least deferring has no limits, followups might have
They go towards a bucket. I've been unable to respond to interactions before because of 429s (when the routify handling was botched) and then because of waiting for limit resets
that makes no sense because interactions are initiated by discord, they have to expect a response for the thing they themselves initiated
Edit Original Interaction Response happens over rest, also receiving over gateway requires rest
public void findMatches(String option, double[] toRevert) {
if (option.equals("x")) {
for (int i = 0; i < allObjects.length; i++) {
if(!alreadyNull(i)) {
double toFind = allObjects[i].getXCoordinate();
for (int j = 0; j < toRevert.length; j++) {
if (toFind == toRevert[j]) {
allObjects[j] = allObjects[i];
}
}
}
}
}```could someone tell me why this returns me 2x the normal amount?
Allbojects only contains 2 elements, but it returns me a duplicate
?
how can i make one
you need to write one
it's kinda like a contract where you state what, why and when you'll be doing
https://www.contractscounsel.com/b/how-to-write-terms-and-conditions there are lots of guides online
Need to write terms and conditions for your business? Click here to follow a step-by-step guide and learn the 9 key elements that must be included in 2022.
it's basically a legal document
and after a write one that need a link
there's no "right one", you write what fits to your app
after writing it just put it somewhere publicly available and grab the link
its write not right sorry
if u have a public github repository u can write one there and use the url
otherwise any text host will suffice really
even some endpoint in your own server
okay
anyone know why 🙁 #general message
impossible to help without code
what's wrong with it
(file is in commands)
and where is that code located?
(file is in commands)
try ../database.db
try executing SELECT name FROM sqlite_schema WHERE type = 'table' AND NOT LIKE 'sqlite_%'
try just database.db
hm, then better-sqlite3 uses the project root instead of relative path
ty both of you ‼️
Discord outdated command won't disappear..
always use absolute paths for everything even if you don't think you need it. You need it
modules that accept relative paths should have require like module resolution and it's dead easy to do
I would never have thought of doing a database in .yaml files
Pretty original indeed
Even slower than JSON 
You should open an issue on the repository you cloned, maybe they'll help you @earnest phoenix 
Ah, those YouTube tutorials
They don't explain anything and then people don't know what to do
@gilded plank
does anyone know how to fix it? my gitlab & runner are containerized and I want to connect to my registry from my workflow
the thing is, I am using my public registry url
i have no clue where ist getting docker: from
I just got preogress though by changing the executor
I'm trying to embed calendly into my react site but it gives me html which i cant use in jsx as it contains the script tag any idea how to solve? I'm trying to add this to my react app:
<link href="https://assets.calendly.com/assets/external/widget.css" rel="stylesheet">
<script src="https://assets.calendly.com/assets/external/widget.js" type="text/javascript" async></script>
<script type="text/javascript">window.onload = function() { Calendly.initBadgeWidget({ url: 'https://calendly.com/vigintillion/consultation', text: 'Book a call', color: '#0069ff', textColor: '#ffffff', branding: undefined }); }</script>
nvm found an npm package
how can i add a delay before rerunning the animation?
I think u can use seconds instead of percent
i used javascript in the end
you tried to set a choice value to that string, but it was expecting a number, not a string
it can't be a string?
not if you set the type to number or integer
helloo
i have a number
p = 47
if(p => 0 && p <= 10) {
console.log("rare")
}
why its console.log rare?
=> is an anonymous function
which presumably takes an arg p and returns 0, which will just always be true in the condition since functions are truthly
what you meant is 0 <= p && p <= 10
console.log("Ready")
i fixed it thanks
or >=
(I have nothing better to do)
if p > 10 && p < 10
If (false)
if (!true)
Can webhooks have buttons?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
if(0n)
if (true-true)
if(true ^ true)
if (1 >> 1)
if (--true)
does anyone know what the super keyword means?
this = this class
super = parent of this class
Hi, how did you setup a background on vscode?
Ohh, thanks :)
Hello, I have a little problem about a file. At the time of launching I look at the content but if I modify this file with another program that if is not updated.
const file = fs.readFileSync(".......", 'utf-8')
setInterval(() => {
console.log(file)
}, (1000));```
Is there an alternative to FS.readFile for this?
tu veux faire quoi?
it's possible from local image?
plus simple en français, en d'autre mot.
Check le ficher tous les X temps et voir le changement car il est modifier par un autre programme mais avec fs.readFileSync il prend le changement en compte
tu veux vérifier chaque 1s si y'a un changement ?
c'est un exemple ouais (il n'est pas modifié par l'application qui check important a précisé)
tu stocks le contenu du fichier en chaine de caractère
const content = JSON.stingify("LE CONTENU DE TON FICHIER")
//et tu fais une nouvelle vérification de contenu
setInterval(() => {
const newContent = JSON.stringify("LE CONTENU DE TON FICHIER")
if(content === newContent) return false; //Aucune modification faite
}
, 1000)
On c'est mal compris
you are reading the file and saving it into a variable
then you are just logging the saved variable again and again
@dusky fog
the value will always be the same
oh I see
thx !
I need help
TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
at Client._validateOptions (/home/runner/Aguapanela-con-queso/node_modules/discord.js/src/client/Client.js:489:13)
at new Client (/home/runner/Aguapanela-con-queso/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/home/runner/Aguapanela-con-queso/index.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14
I don't understan, what is my mistake?
You didn’t give any gateway intents when logging in
Aka you need to pass in the intents parameter when instantiating your client
It’s in the djs guide if you’re struggling
My vscode is transparent so its just my desktop background
what is the code for reaction role (python 2023) ?
I mean, we’re not YouTube
Probably a question better suited for google than us
(Unless you get more specific)
"(python 2023)" is literally a typical quickhacks youtube video
Yeah lol
(working | verified 2023 | no code | check desc)
(github repo in desc | quick and easy | no experience needed | copy paste | certified by dev)
(works like magic | sorcery | wizardry | for dummies | literally click and run)
(works | thanks mom)
I shall end the joke here before it runs for too long
(rework 2023.2 | patch bypassed | can’t stop us)
I can though. Stay on topic please 🙏
(family friendly | PG13 | safe | clean | no virus | on topic)
Pain and suffering
i will help. why is this returning typeData correctly, but always returning Playing: as typeTitle ⁉️
🤯🤔‼️
What
I don’t understand the question
for example, if it's members, it should return Members: as the typeTitle, but it's returning Playing:
he's saying the variable typeTitle is not being set
by the switch cases
its always setting it with the first switch case value
Can I see where you declare typeTitle
There is no declaration there
👆
Just assignment
declaration means var/let/const
I have to declare it?
Yes
otherwise its implicitly a global

Hence why it’s probably getting fucked up ^
typeData is returning what it should
type could also only just be returning playing
well
are you running that switch case more than once?
no
show more code pls
what code
💀
whatever comes before and after that switch
Do you happen to have another variable called “typeName” somewhere else in your code
Anywhere in your code
let him cook
typeTitle you mean? and no
well nothing does it's a function which i'm importing into the main file and calling
??
there’s nothing before it
and after?
nothing
no return?
wym?
its a function that does not return anything?
then show
^^
is that the issue
yes
Or there’s something else you’re not showing
let typeTitle;
let typeData;
switch(...) { ... }
return { typeTitle, typeData }
thats it besides the part where i convert the typeData into a locale string
Yes please, this is js not python C:
yeah did this
the thing is, global variables are bad unless you know what you're doing
well
Aka they’re bad unless you’re Tim
in your case your function is setting 2 global variables, one of them is sync, the other isnt
is that why only one is working
so every time you call the function, it immediately sets the sync variable, but the async variable not yet
by the time the async variable finishes setting, the sync variable may have been overwritten by the next time the function is called, because its global
makes sense
If you don’t do variable declarations anywhere else in your code I’d highly recommend changing that now
Since it can lead to mysterious bugs such as this
I unironically didn't notice there was a switch-case until yall mentioned it
Please add an indent level inside cases
Readability
Because no indentation makes it hard to spot where the cases are
Sometimes I wonder why didn't js get the enhanced switches yet
Usually it gets qol features before other langs
where should i indent
After the case
i like doing mine like this
switch(a) {
case b: {
doC();
break;
}
}
Same
It's been ages since I wrote switches like that, but I also used braces
or like this if its a one liner:
switch(a) {
case b: doC(); break;
}
ye
and for multi-case cases:
switch(a) {
case b: case c: {
doBorC();
break;
}
}
why use those things
{}
It’s interesting that even with such a simple control flow concept as a switch case there’s so many tricks with it
Scope preservation
oh no python user 😱
helps keep things visible, clear and organized
But yeah that’s the idea
ok
more readability and lets you see the clear boundaries of the scope
damn late message
plus the good old switch true
discord laggedfor me
switch(true) {
case a > 10: {
...
}
}
this ?
Much better
ok
Want to experience some fun? remove those breaks 
:^)
what would happen
bruh
it would go through every case if it evaluates properly
I like groovy switches
return switch (value) {
case { it > 10 } -> "Bigger than 10"
case String -> "Isn't even a number"
case 5 -> "Is five"
}
i believe default ts and eslint disallow switch fallthrough lmao
why
pretty sure I could do switch fallthrough with ts
Well yeah but ts is nothing more than a suggestion tbh
yea
You can always tell the compiler to shut up and it’ll listen
I believe up until recently (or maybe even still) C# treated falling through as a compile error
Can you use switches to determine the type of something like what haku did
lel
There’s some tricks but I don’t believe there’s a solid way to do like switch(typeof someObj)
guys
In java it'll be possible next version
what does break do outside of switch
Plus auto-casting
nothing I dont think
Stops a loop body
unless you are in a loop
Probably some other stuff too but not sure about those use cases
tho your IDE will probably warn you if you use break outside of the appropriate use cases
The only other usage is breaking out of named loops
Oh yeah
named loops?
Very niche
switch(typeof) is a thing in js, idk about other langs
Is it?
yeah?
Oh well i guess typeof is just an operator that returns a string
yup
I forgor
yes
Was thinking more like Java where there isn’t a solid way to do it
loop:
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (x == 5) break loop;
...
}
}
No
no
Shitty example, but it'll do
switch is like if-else
It’s based on context
Switch statements are just syntactic sugar for if else essentially
obscure js things, blocks with labels
Most langs have it, can also name blocks in java
Basically just means a more friendly way to write something
I actually know about t his, didn't know it was called a named loop
i see
thinks that make code easier to understand, but under the hood does the same thing as you would do with more complicated code
U can also name blocks, but depending on the lang it'll do nothing
so like .some?
“Syntactic sugar” usually means you can write something in one way, but the “sugar” is that you can do it in a nicer way
block: {
...
}
I wonder if C++ has named loops
Probably
Basically every language feature over machine code could be considered syntactic sugar though by that definition I suppose 😆
It's pretty useful, especially if ur doing image ops
my bot is now fully using sqlite no more discord messages database 😵💫
Excuse me?
Wtf
is this guy from breaking bad
more or less, you could say that a array.forEach is syntatic sugar for for(const item of array) but thats not exactly true because they work differently under the hood, but for example class in js is syntatic sugar for working with prototypes, under the hood they do exactly the same thing, but classes are easier to understand and write
wait wrong reply
i was replying to this
should i use for of will it really make a difference
Are we just going to ignore that this guy used discord messages as a database?
yes
yes
thats more unreliable than json
no longer though it's now sqlite
kuuhaku recommended me better sqlite so after a day of some hard brain thoughts i switched
unless you're writing performance-sensitive code, no it wont make a difference
sqlite is by far the easiest of them
ok im going to keep forEach
it looks prettier
also guys
Im also pretty sure forEach is slower compared to a conventional for of loop
actually, for(const item of array) itself is a syntatic sugar for for(let i = 0; i < array.length; i++) { const item = array[i] }. unlike array.forEach, those two for loops do exactly the same thing under the hood
well not actually exactly, but semantically the same thing
for(... of) will always be a bit slower
in the bigger scope of things is for of faster then forEach?
for..of should be roughly the same performance as array.forEach
waiting since a week for bot verification on



