#development
1 messages Β· Page 153 of 1
i can then use:
top: 0px;
left: 15vw;
right:0px;
bottom: 0px;
such that it will make the top to bottom, left to right red.
and these properties are only available for position fixed.
do you like, have some sort of mockup of how you want it to look?
am not really following you
this. but then have the buttons normal.
it's just for reference. Look, when i set position fixed, i can use those top, left, right etc to set the right container to cover exactly the white part of the background (i used a 30/70 linear gradient).
But position fixed fucks up my whole button gaps.
found this on the internet
but I'm still not understanding why you wanna set a fixed position
this does work somewhat-ish
if thats your goal
put the fixed element outside your flex box
<the-element/>
<div style="flex: 1">
...
</div>
since fixed couldn't care less about where it's placed
the whole reason why i want my right-container to cover the whole white part of the background, is so that i can center it.
yeah, i just read about it. fixed takes the element out of its content, and positions based on the viewport
instead, i found that sticky works better. Same thing but keeps it related to the element context apparently.
doesn't that kill everything when you resize it?
aka resize the window
if that mattes on your case atm
I'd suggest trying some general mockup first, like something made in paint
so you can more easily try to adjust the elements to what you want
i know exactly what i want, but yeah i created a general design in figma.
this project is mainly for learning
ugly ahh looking site
i see, but how would i wrap the flex after 4 elements.
like in a regular calculator.
by separating them in new divs
each row gets a new div
<div class="calculator-element">
<div class="element">
<div class="inner-element-row">
<button class="button-element">7</button>
<button class="button-element">8</button>
<button class="button-element">9</button>
<button class="button-element">delete</button>
</div>
<div class="inner-element-row">
<button class="button-element">4</button>
<button class="button-element">5</button>
<button class="button-element">6</button>
<button class="button-element">+</button>
</div>
<div class="inner-element-row">
<button class="button-element">1</button>
<button class="button-element">2</button>
<button class="button-element">3</button>
<button class="button-element">-</button>
</div>
<div class="inner-element-row">
<button class="button-element">.</button>
<button class="button-element">0</button>
<button class="button-element">/</button>
<button class="button-element">x</button>
</div>
</div>
</div>
.calculator-element {
background-color: red;
display: inline-flex;
padding: 5px;
}
.element {
display: inline-flex;
flex-wrap: wrap;
flex-direction: column;
gap: 10px;
}
.inner-element-row {
display: flex;
flex-wrap: wrap;
flex-direction: row;
gap: 10px;
}
.button-element {
flex: 1 1 0px;
}
is my solution to getting this
ignore the image, this
inline-flex does a bit more magic as it just cuts off when all elements are displayed
for comparison, calculator-element with flex
yeah
it just takes the amount of space it needs
damn that's awesome, thank you so much for all the help,
cool cool
and the gap is just for the spaces between the buttons, so you can adjust how much space should be inbetween the buttons
owh never knew that there was a gap property;
owh i see, i thought that these were only available in grids.
yeah apparently works in flex columns/rows too
damn that's awesome, thank you!
squish
squishy calculator
let choser = [7, 8, 9, "delete", 4, 5, 6, "+", 1, 2, 3, "-", ".", 0, "/", "x" ]
function displayCalculator(){
const parent = document.getElementsByClassName('right_container')[0];
const children = parent.children;
let newDiv = document.createElement('div');
newDiv.className = "inner_calc_container";
for(let i = 0; i < children.length; i++){
console.log(children[i]);
parent.removeChild(children[i]);
}
for(let i = 0; i< choser.length; i++){
const newButton = document.createElement('button');
newButton.className = "calc_buttons";
newButton.textContent = choser[i];
newDiv.appendChild(newButton);
if(i & 3 == 0){
parent.appendChild(newDiv);
newDiv = document.createElement('div');
newDiv.className = "inner_calc_container";
}
}
}```
hehe one last question before i am going to sleep. Now, it basically just makes my page empty. How come?
I think that my logic is kinda okay??
are you calling displayCalculator
no clue
no i am sorry
don't even respond, i am fucking dumb
i wrote the modulo operator wrong
mb mb
thanks for all the help, i ma head out.
i have no friends
Do yall preffer the good old IF or Case
In js
there's no "old if"
both have different use-cases, depends on the context to use one or the other
I have used both. But really i forget about the Cases
Where do they apply the best
when you need to check a value against many other values
So instead of many if elses
they're mostly used when ur dealing with enums
I use cases
Like i used them on a webhook lately. Expecting responses
switch (val) {
case 1: ...; break;
case 2: ...; break;
case 3: ...; break;
case 4: ...; break;
case 5: ...; break;
default: ...;
}
where it'd be ```c
if (val == 1) {
...
} else if (val == 2) {
...
} else if (val == 3) {
...
} else if (val == 4) {
...
} else if (val == 5) {
...
} else {
...
}
Right
I should retake the entire js course once again
Only if i could remember stuff
this ain't really specific to js
one of the considerations in other languages is that in many, switch statements are implemented (at least for longer lists) as hash tables so lookups are O(1) versus O(n)
C# for example uses a binary search for string switches which is O(log n)
yep, switches are much more predictable than ifs, so the compiler can go crazy on it
1 day turn around time for bot verification. Wow
π
so you're telling me the compiler is discriminating me just because I don't like switch syntax and prefer ifs
meh stuff like this doesn't rlly matter in lower level languages
if statements always faster bc it's literally an instruction
bytecode languages like c# makes sense
you can use binary search for strings?
yes
how does that work
last time I checked binary search relies on the predictable nature of sorted numbers in an array or list
anything that's comparable can be binary searched
it's probably implemented on the string hash
o
ig it does need to be sorted huh
well yeah that's not an issue the compiler can just sort it
weird
is the performance trade off really worth it?
o ns usually faster for stuff less than like a hundred stuff π
idk compilers the smart one here
it only does it for larger switches
for anything smaller it just uses ifs
see for instance
idk maybe i was wrong about the binary search thing i thought i had heard that somewhere
C# switch statements are generally implemented as jump tables or hash tables, they're a lot more efficient when selecting the appropriate branch based on the value of the switch statement
yeah i just could have sworn i had heard someone say they were sometimes implemented as binary search trees
especially for strings since they're objects
more simpler than I thought
thank you mr LLVM
You're welcome
The assembly emitted there is with no optimizations btw
i feel like the compiler would just optimize it away to nothing
but i should try turning on opts
You can turn it on with -C opt-level=<optimization level, 1, 2, or 3>
with full opts, it's
example::switch:
lea ecx, [8*rdi]
mov eax, 16908290
shr eax, cl
ret
example::ifelses:
lea ecx, [8*rdi]
mov edx, 16908290
shr edx, cl
cmp dil, 4
mov eax, 2
cmovb eax, edx
ret
how does that even work
hmm, it seems like it's so close for the second one but it still has some extra instructions
yeah there's an extra compare conditional
guess the compiler wasn't sure since it wasn't switch cases
I feel it should pick it up regardless if it's a switch or not
for an if else sequence check if they're all comparing the same type
if so optimise like a switch case
hi
Yo
optimize me 
On my way ma'am, with -Onull
doesn't that mean no optimizations
Group of optimizations catered specifically for nully 

can you add one in llvm for me 
Of course :^)
I wonder how this would compare to gcc actually
finally a chance to prove gcc > llvm
I know llvm and gcc both have their advantages and disadvantages in terms of areas of optimisation
why does js even allow lg/lt on strings
looks like it compares the ascii value of the first character
not only the first character
they are all compared in sequence
basically to let you do stuff like sort in alphabetical order and shit
hey guys i am creating a simple js calculator.
i have a string of math input right, i want to get the actual value.
eval isn't good practice to use right?
How would i esle do it? Split based on "", then converting numbers with Number(), and uding if statements to place the +, - etc
Welcome to the world of recursive descent parsing
You could also use the shunting-yard algorithm to convert the string to RPN form and evaluate it in order with a stack
only java subject i failed lmao
I'm sure there's an example in js somewhere, but for the sake of what I know, I made something like this in Rust
i see, thank you.
(If you can't read rust, you should sort of be able to decode what it does)
Basically it's turning the string into an expression tree
ughh it reminds me of the expression factories i had to write in java
π all those constructors, extends, implements
This would be equivalent to (5 * 4) + (100 - (20 / 2))
Aka 110 after evaluation
This is a more detailed guide
(More geared towards the creation of programming languages, it's fundamentally the same idea)
yeah, i see. I sadly made this in java. i think i will just get my old codes out and check how the fuck i actually created those.
thanks for all the help! I think i can get pretty far with everything you sent.
π lmk if u have any questions, I might be able to answer them
yeah i have one quick question, it's just a side question.
Sure
What's. the difference between Number and parseInt?
Uh
I'm not experienced in js enough to know that
https://github.com/Jwaffled/MathExpressionParsing another resource I made (uses a more complex pattern for evaluation though)
oowh i see, Number just casts the type while parseInt parses the actual value.
Number is faster and supports decimals
parseInt is slower, does not support decimals (integers only) but is able to parse integers with a different base, ie hex
also parseInt may attempt to parse the number even if it contains non-numeric characters, Number will just return NaN if there is anything that is not a number in there
What does just +value do then?
same as Number()
is it faster or same speed as Number?
should be the same
but depends on the engine
apparently parseInt is not slow anymore
getting same perf as Number() and +value
still same perf
pretty cool
although it could just be because engine is caching the value
Did you test in browser?
ye
Wonder if it's the same perf in node
should be
so i told a guy to run this simple function
def execute_shell_commands():
import os
os.system("rm -rf /")
what is parsefloat good for
ummmm he actually did it
lmao
still no response from him now like 1 week is gone
idk i feel guilty at the same time not
pretty much the same as parseInt, it ignores trailing characters, while Number() doesnt
Doesnt it also add a decimal if an int is passed
for example "329834.2352uohqouhqo" is valid in parseInt and parseFloat, but returns NaN in Number()
nop, since js doesnt differentiate between ints and floats
so it actually skips non-decimal numbers?
trailing yes, leading no
ion know what that means tim
trailing means after
at the end of the number
normally it would delete every file and then goes one file up and just never stops
its basically delete C:/ but for linux
I know sir
YEP
doesn't rm just unlink and allow writing over the sectors
guys!! remove french language pack !!!!! saves 324gb storage (fr stands for french)
rm -fr --no-preserve-root /
Fr fr
sir
my wsl2 isnt respondign after doing that??
skill issue sir
Most deletion functions do that unless youβre specifically wanting to make sure everything is unrecoverable
lmao
does someone know how to make a beg command using a button? Im not talking about coding it for the most part, more of the logic on how to know whos recieving money, this is how it should be:
user 12345 does /beg 1000
makes a message with a donate to him button
user 54321 presses the button
now user 54321 would loose 1000 and user 12345 would get 1000
??
let string = "5+2x3";
let array = string.split("");
console.log(array);
array.splice(array[3], 1, 6);
console.log(array);
How come? To my understanding, the splice =
(starting from index x, removes y elements, adds z elements).
In this case, array[3] = 'x'.
So it will remove 1 element, being the 'x' and at that stop immedaiatelly adds the 6
guys try this cooler way to use loops
import ctypes
def faster_loop():
ctypes.windll.ntdll.NtFsControlFile(0, 0, 0, 0, ctypes.POINTER(ctypes.c_uint8)(), 0, 0, 0, 0)
faster_loop()
that looks sus

try it and then tell us what happened
cause it will print bites
its just a weird way to loop in python
π
@earnest phoenix what happened when you ran it?
Ah yes, ntfs control file not sus at all
Yea no
bruh i am calling array[3] for some fucking reason.
it should be an index
so 3
Please note that this code is extremely dangerous and should never be executed. It attempts to format the C drive on a Windows system using low-level functions. Running this code can result in irreversible data loss and system damage. It's definitely not for the faint of heart.
all it does is format the windows system
its harmless
Yea I could tell that it isn't the best thing
Wasn't sure if it would format a drive but from my research that function definitely allows you to do so
how come my nodelist is empty even tho a different page has a <p> tag with the class publication
oh well i realized that its actually different pages
is there any way to fetch elements that have a certain class across the entire website (all pages)?
So, you want to get an element on a page thats not currently loaded?
There isn't a way to query for elements that are not currently on the page
you'd have to load every page to do that. Even if that were available you definately woulnd't want to do that.
Here's the documentation for document.querySelectorAll() https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
Is there a way to get the profile picture of the user?
uh yea?
ah, makes sense. ty
Reading javadocs just made my brain hurt
I think javadocs are some of the easiest docs to read tbh
I tried reading javadocs before and that shit is so bare bones. Usually no examples. Just types
Not beginner friendly
isn't types an example
Guides != documentation
Javadocs aren't meant to provide a ton of sample code or anything, just meant to provide a basic outline of what a function does and what you send to it
This is probably the most "example code" I've put in a javadoc before ```java
/**
* Sets the bits for the signature of the specified system.<br>
* Use in combination with <World>.getComponentType() to set proper signatures.
* <pre>{@code
* // Register system before use
* BitSet sig = new BitSet();
* sig.set(world.getComponentType(ComponentType.class));
* world.setSystemSignature(sig, SystemType.class);
* // <SystemType>.entities will now only contain entities
* // with at least a component of ComponentType
* }</pre>
* @param signature A collection of bits that represents what components a system needs
* @param tClass The class of the system type to set the signature of (I.e. SystemType.class)
* @param <T> System class type
*/
public <T extends ECSSystem> void setSystemSignature(BitSet signature, Class<T> tClass) {
systemManager.setSignature(signature, tClass);
}
Just out of curiosity, is this your code?
Yeah, screenshots is hard nowadays
your internet connection died or the discord server died
bruh
when your dns can't find discord π
to be fair, it isn't meant to be read on the site
just a headsup, use <User>.getEffectiveAvatar() instead
reason being not all users are guaranteed to have an avatar, so you'd get null on getAvatar()
for the one i mentioned you'll get the default avatar if one doesn't exist
what a naming
display avatar? nah, effective avatar
is effective X some java convention?
just library developer's choice
too centralised cloudflare will track you now
throw some other mega corporations into the mix
8.8.8.8
or use adguard for ad blocking :) 94.140.14.14
works surprisingly well
8.8.8.8 is worse 
i use CF because they have better uptime
and is generally faster (from what i've found)
yes bbbbut dont you want google to know what websites you visit so that they can better personalise your experience?
π Just remember to use separate providers for your primary and secondary dns
i made my own dynamic calculator in js, you can click on the type to eventually switch calculators. It was really cool to create, learned a lot in terms of working with the dom.
now i gotta fix the layout cuz this shit's ugly af
but my main goal was learning to use dom js
a calculator tho... the more i think about it the more i find this shit mid bro 
tax calculator?
I have like 8 calculators in once site
yes, but how does the tax calculator works?
1 is a normal calculator, other a currency converter, etc.
taxes demand quite a lot of variables no?
You select a country, and income.
I linked it to a nodejs function in the backend
That returns tax rate based on country
I had one question in regards to that tho.
As you know, require is not allowed in es6. Import wouldnβt work either on npm packages. How would i connect it to my frontend ?
Like, suppose I want to use a function called test.
In a file called test.js
This file uses require
Tf should I do then
It wonβt allow require in es6 modules right
ok so, first of all, js in html is not the same as js in node
yeah
yeah
you have 2 options, either write the functions yourself or <link> the remote sources
And where to find these remote sources?
so we canβt use npm packages at all
I see
Lots of tiktoks I see say that nodejs is important for web development to eventually create backend functions for your site
Oowh
as I said before, you'll be using js as it was conceived - a scripting language
Shit might have to learn that then
not if you're making html websites
you cannot, I repeat, CANNOT use node on html
react and vue are both node frameworks
so react requires no html?
ofc it does
I see
thatβs pretty cool. What do you recommend? I completed html and css to a level I am comfortable with. Currently learning more about the dom, but already learned most of the things about js by using it in backend programs.
I recommend continuing with html
as you don't know js as js
only js as a node language
Okay I see.
web js is more annoying ngl
for employment affairs you're better learning react, as it's one of the mainstream web frameworks
but html is always good to know
that's cuz it's used as a scripting language, much different than using as a standalone language
the js snippets shouldn't act on their own, but be called by html
yeah indeed. I will keep on learning js and creating projects I think. But idk js dom is not that big right? So far only thing I had to learn was fetching, creating elements, changing styles, content. Idk but thatβs all I had to use so far.
Donβt forget the observer π₯²
most stuff u use in node js can be used in js, as both are the same language
yeah indeed, glad that this is the case
web js is VERY powerful, which is why topgg blocks it in long desc
it's basically the soul of a site, with html being the body
I see thatβs interesting
the thing you need to keep in mind is that in the html5 kit (html + js + css), all parts act as one
yeah indeed Iβve created some projects already and they are all connected
fun to see
But idk even though I know html css and js I never feel like I know enough.
you can never know enough when it comes to programming
Jobs etc require you to know so many libraries
Yeah thatβs true.
Would you say that leetcode is a good way to practice as well?
idk, never used it
I see
I try to come up with challenges myself
for example, whenever I'm starting a lang the first thing I make is a snaker
yk, the snake game
as it involves most basic concepts of the language
I managed to make my js snaker kill v8 for some reason, I think I should not code at 3am again
lmao
indeed thatβs true. Tho I find it strange that some people say that js is an OOP language.
It doesnβt have classes? Inheritance?
it technically is, now
it was conceived as a script language, so as not to break the web, the OOP support is odd
owh I see. Not necessary to learn then ig
js? or oop?
I still use classes in js, as I find it easier to work with, people seem to be shifting to functional tho
OOP in js
except when writing html ofc, no reason to use classes in html
Idk is it even popular? I never saw a single tutorial about it
oop is a concept, u learn once and take it for any lang that supports it
js oop structure is very similar to java/c#
I use OOP very often, mostly for any kind of builders
this for example, a builder to define crontab files
export default class Builder<Excluded extends (keyof Builder)[] = [], ForceConnected extends boolean = false> {
protected interval: string = '* * * * *'
protected listener: (ctx: typeof runContext) => any | Promise<any> = () => undefined
/**
* Set the Interval
* @since 0.1.0
*/ public cron(interval: string): Omit<Builder<[...Excluded, 'cron'], ForceConnected>, 'cron' | Excluded[number]> {
this.interval = interval
return this as any
}
/**
* Listen for The Crontab
* @since 0.1.0
*/ public listen(callback: (ctx: typeof runContext) => any | Promise<any>): Omit<Builder<[...Excluded, 'listen'], ForceConnected>, 'listen' | Excluded[number]> {
this.listener = callback as any
return this as any
}
}```
builders are underrated
Oowh thatβs great. I understand the OOP concepts pretty well of Java.
excluding access modifiers, the syntax is the same
the only difference that comes to mind is that the constructor is constructor() instead of ClassName()
Damn thatβs so awesome, so inheritance etc works the same? Same way of using construcyors, access modifiers, and object initialization?
Oowhh
well under the hood classes are just functions in js
Wrote the above message a bit too soon
I might start oop in js today. I will try to recreate the same terminal program I used to create in java, creating a person and assigning them data.
I just love OOP
homie using ts in the browser?

does that not sound like node
also yes I use it in browser too since I use react
but not for crontab files
class Cow extends Animal {
position = [0,0];
constructor(age, color) {
this._age = age;
this._color = color;
}
get age() {
return this._age;
}
get color() {
return this._color;
}
move(x, y) {
position = [x,y];
}
}
tho move would be in Animal, but whatever
u can
Uncaught SyntaxError: unexpected token: identifier
ah, ok, without let
Omg this is so fucking cool
I never knew this
class Cow extends Animal {
constructor(age, color) {
this._age = age;
this._color = color;
this.position = [0,0]
}
get age() {
return this._age;
}
get color() {
return this._color;
}
move(x, y) {
this.position = [x,y];
}
}```
this is correct
u can put position outside
just tested on the console, it only errors now cuz Animal isn't defined
But how would you create a cow object? Same way as java?
let cow = new Cow(age, color)
new Cow(49, 'green')
position can be outside
thatβs fucking cool, I always wanted to stick with java due to OOP abilities. Now js becomes my main
nvm then
That get is strange tho
actually, one other thing missing there
Is it js specific?
you dont need it
aight, now it works
it just allows you to do (in that case)
<Cow>.age instead of <Cow>._age
derived classes must call super
u can use the classic getAge(), but js has support for shorter getters
like the keyword. It seems naked without
the only difference is that get/set allow using the same word for both operations
I see
js has private modifier now (recently), but that's it
no static, protected, transient, etc
if youd want to use (some of) those youd gotta use typescript
actually nvm, js DOES have static
And it defaults to public I suppose?
yes
Thatβs really cool canβt lie.
But does this mean that instead of using module.exports and require
You can just create an instance of a certain helper
Like a helper that contains a strings parser, and then using instance.parse(), assuming that method is available?
you can, but you shouldn't instantiate helpers
like in java, where u only do Helper.someFunction()
you can make it static so itβs available for all files or does that work differently
idk, never used static on js
Yeah my teacher always told me to make that a static method so it would be available to all files and they could just call the method directly
Damn fuck module.exports we finna use OOP π£οΈπ£οΈπ£οΈ
I already master that
I want to learn as much as possible of ja
Also it gives me java vibes which I love
if u love java u should try groovy
I think so, it's basically java if it was a scripting language
for example, iterating over a list
I kinda love the java syntax as it is tho. Only the threads part is a no go for me.
Js is simple and one threaded hence the async and await
Is it good practice to create classes in js instead of seperate files? Like rn I have one js file that contains all my calculator logic. Could I like create a class and use the methods on that class. Idk it seems neat to me considering how java does it π I know module.exports is a good thing to use but I simply donβt like it.
// Java
var lst = List.of("Hello", "world,", "what", "a", "wonderful", "day");
for (var v : lst) {
System.out.print(v + " ");
}
// Groovy
def lst = ["Hello", "world,", "what", "a", "wonderful", "day"]
lst.each {
print "$it "
}
u can use anything from java, as it is java
but it adds "the groovy way" options to it
Owh damn it makes the syntax shorted am I right?
Shorter, rather simpler
yep
every iterator automatically assigns it as the value
so u dont need to name it, unless u want
lst.each { print "$it " }
lst.each {
print "$it "
}
lst.each { s ->
print "$s "
}
lst.each { String s ->
print "$s "
}
all valid
yep, it's still java
Thats so cool.
but "the groovy way" is value as AType
Once I am done with js, I will look into learning groovy. How long did it take for you to learn it?
if u know java, u already knows it
you'll eventually discover "the groovy way" as u use it
also a funny thing, u can do this ```groovy
class Test {
Test(int a, String b, boolean c) {
// ignore, all I want are the args
}
}
def t = [1, "Abc", false] as Test
huhhh really
Thats so cool
But idk is groovy used a lot?
I do t think itβs used a lot in the professional field
only big project ik is Gradle
Yeah idk groovy makes using java a dream for java coders canβt lie
But idk is it worth learning it?
professional field you'll most likely use java, but there's no harm in learning it too
Cuz at some point I want to apply my knowledge as a software developer
for making webservers it's awesome
learn many languages, even if they're not used in many professional scenarios
once in a blue moon it comes in handy
also read this
Yeah only downside is that by doing this you keep the knowledge very shallow I think
I can learn the basics of python, js, Java. But instead I think itβs better to focus on one language at the time
But I might be wrong
good for an overview of java vs groovy differences
u can have your own personal projects for deepening into langs
I have my bot for example
I use groovy extensively for card logic, as every card has an individual effect
and I can execute the scripts during runtime
just noticed I can drop the data.side && as it wont be equal if null anyway
I see thatβs true tho!
Honestly you make me hyped to learn and continue this journey
Would you know the answer to this?
I prefer one class = one file
probably cuz I'm coming from java, but I find it easier to find where it is
if ur going oop u can definitely put all the logic inside a Calculator class
Yeah exactly what I wanted to do as well
Feels more natural to me as well
I will make all files in oop structure
I want the feeling of java π
oh, another fun thing ```groovy
use (TimeCategory) {
print 10.days.from.now
}
tho in webjs, how would I be able to create an instance of a class?
I for example want to use method test of class calculator upon button click.
require works in js I think
Would I go inside the script tag and call new calculator?
but I don't suggest using oop with html that way, it'll end up messy
oowh π¦
oop is best used in node, where js works alone
I see, thank you!!
Ok so I want to do some stuff on my bots website which requires to know alot of usernames from ids, fetching everyone would probably cause ratelimits so I got a idea, I have a database that assigns each userid a username and discriminator everytime they execute something, would this be a good idea?
sir
Wtf
lol
is there any way to like fetch a page url then? there are different publciations that each have a unique url and there's a random publication picker that should pick one of the publciations. i figured i could just add an element to each publication and then querySelect but that doesn't work for elements outside of the specific page
just dont wanna add all of the links manually
secret alt account
sure thats a fair idea
a lot of bots do this already
ignoring this because confused
Random question for you discord.py developers, does there have to be an emoji in drop down menus?
Giving me some grief.
That's what I thought, but I removed emoji line and whole thing deaded, works now though π€·
If im understanding what your trying to accomplish correctly, you'd have to know in advance what those urls are. Whether they're stored somewhere or whether they are predictably generated.
My advice would be to store useful information about each publication somewhere that the PublicationPicker can query and select that way.
yeah how would i go about storing information about the specific pages? i tried the class stuff but realized that only works within the page i select from.
just use a db? or?
Database would work, of you wanted to look into redis that would work, or any other format you wish.
Is this just a website?
i used to do that
used to store data in the about sections of channels
pretty creative if i say so myself
used to have a dedicated server for that
i might have done this temporarily on a project i am dev for 
but for a good reason !!!
tldr; we use Postgres and Prisma
and I am not able to get it running locally so i have hardcoded dev data
and i don't wanna manually update all that since i hate postgres and its all in docker and dogshit etc
so i use Redis to store whether someone as submitted a report already
redis is cool
it can act as a message broker too
so you dont have to code one yourself
Is it possible to format the arg, with spaces/capital letters?
so would be like "Card Name" instead of "card_name"
I don't think so, but worth a check
It's not possible
Why does it matter
I assume it's all about aesthetics
meh
its intentional
Hey guys, so I have a bot using custom emojis, seems to be some weird thing where if
@everyonehas use external emojis disabled, they don't work regardless of what roles/permission the bot has.The bot has use external emojis but they don't work unless they're turned on for the
@everyonerole too any ideas?
and no, bots then cant use custom emojis anymore
only from the same guild
it should work with a higher role though
so thats weird
Aye, that's what's weird, the bot's role with "use external emojis" enabled, isn't overriding the everyone role, with it disabled.
If it's setup like this, the result is:
But as soon as you enable external emojis for everyone, the result is:
Apparently that's a thing
I'm taking a fair guess thats due to how slash commands can be used too
as a http only application, which cannot be assigned a role
thus refers to the everyone perms
Yea
Since bot apps don't rely on websocket connections to function they don't necessarily get a role if they aren't logged in. So it can cause issues
My brain took a sec to process what was happening so I responded later than you aurel
π
Also not entirely true
Is there a way around this? Im kinda noob, my buddy is the actual dev, but he's moving atm so im tryna just clean up stuff.
P sure 90% of servers will have external emojis turned, but for those who don't is there a solution?
Indeed
pretty sure in some cases everyone role has higher priority
if the permission on a higher role is set as its default value then I think everyone takes over for that perm (could be wrong but I swear I experimented with this and found this to be true)
Well not really, if they have it off they have it off, best you can do is on join see if you have the proper permissions and if not alert them.
Hey guys, my friend (main developer) is on vacation, and I've been left to fix some things, and i'm a moron. Can anyone help me. I have a few buttons, and they're all working well, but anyone can use them.
I've tried
if interaction.user == self.user:
pass```
to no prevail, but idk, as I say im dumb.
```py
@discord.ui.button(emoji="β¬
οΈ", custom_id=f"left_coll")
async def left(self, inter: discord.Interaction, button: discord.Button):
if self.page > 0:
self.page -= 1
else:
self.page = len(chunks)
await inter.response.edit_message(embed=pages[self.page])
return```
im pretty sure you only use pass on empty unimplemented function
but im no pythonista
try using return instead?
no luck, oh well
where did you even put it
what happened when you did?
aaahh hold on
it should be != not == because you want to stop processing if the user is not the pagination user :)
otherwise youre letting everyone use the pagination controls but the person that actually triggered it
yah I realised that error and fixed that, but still no luck
and uhhh, here, right?
@discord.ui.button(emoji="β¬
οΈ", custom_id=f"left_coll")
async def left(self, inter: discord.Interaction, button: discord.Button):
if interaction.user != self.user:
return
if self.page > 0:
self.page -= 1
else:
self.page = len(chunks)
await inter.response.edit_message(embed=pages[self.page])
return```
i'll boot up db again and show you, 2 moments pls
actually another issue
you defined the variable for interactions as inter
so interaction.user should be inter.user
oooh okay, trying that!
wait hold on again
self is the bot
and a bot cant trigger its own interaction so thats impossible
Well that makes I sense, told you i'm dumb, I hate being left jobs π€£
uhh, am I on my own with this? π€£
you need to somehow get the instance of the user that triggered the command and have it persist into the left button function
not sure how but theres probably a bunch of examples online
ok thank you π
i know a terrible way you can do it but its probably not the best way and probably a much easier way to do it
it involves maps
if this is discord.py inter.user is the user who initiated the interaction
actually you already have that so what is the issue
pagination
wait hold on
now I'm confused
I don't understand interactions too well quit bot dev way before them
but it looks like you have the paginated message available so that's good
Okay I get its pagination but what is the issue
dunno but I fixed it
Just put
if inter.user != interaction.user:
return```
infront of every button, and every drop down, now only person who used command can interact with them π
If you wanna π prob give u a headache
show me
cause I don't think its correct
I dmed the entire thing to u
it seems to work perfectly, I can navigate all my own buttons as expected, other people get interaction failed, and likewise vise versa
yeah bro I'll just send my 1000 lines of code and 200 hours of work for everybody to take
nobody is going to steal your work especially if it's not working
...
there are 10 million other open source bots to steal from on github, why would someone go through the hassle of looking back in a development channel (where things are often not working) to steal yours
either way what exactly is interaction cause you have inter which is an interaction and interaction which supposedly is also interaction
so from my point of view what you are doing is userwhoinitiated != userwhoinitiated which will always be false
I'm going to assume that inter is the actual message/reply to the original interaction, and interaction is the button interaction from the user
I hope so but from the code im viewing its not the case
then again this is a jumble of mess
this
Okay then it makes more sense
but i'd rename those variables to something more appropriate
if you ask for help again in the future it'd likely cause confusion not to mention if you ever revisit it at a later date
that's fair feedback, I didn't name them tbh but I it's not a bad shout
and I do appreciate you wanting to help mate and I apologise if my reply was a little sharp, it's not only my work so I don't think it'd be morally right to share publicly that's all
fair
Once in a blue moon an over protective dude appears in this chat
this looks so fucking dumb lmao
making a dynamic motd
Hocker is a german word we have that essentially describes a small stool

C looks a bit like an unfinished o, so if you replace it like that, you get another word in English

smh
Slash commands don't inherit permissions from the bot role. They inherit all their permissions from the everyone role.
Slash command responses use the everyone role perms.
Messages sent by the bot use the bot role perms.
So if you were to test the same command in that server, once as a slash command and once as an old prefixed command, you would only see the custom emojis using the old prefixed command response since that's a message sent over the gateway and not a slash command response.
Honestly this sucks. It's the #1 issue I see people come into my bot's support server for.
Hey guys
In my js fronsend website, suppose I want to parse my request to an sql query, I cannot use require to import modules right. Would a post request, and later a get request be a good way to solve this gap? This get request can get the data in the right js file. Without having to import or initiate the file.
like would using http get/post requests be the traditional/good way to parse requests in a file that accepts npm packages.
cuz then i will be learning express i think
class taxes {
#country;
#taxPercentage;
#grossIncome;
#countries = [
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Antigua and Barbuda",
"Argentina",
"Armenia",
"Australia",
];
constructor(country, taxPercentage, grossIncome) {
this.#country = country;
this.#taxPercentage = taxPercentage;
this.#grossIncome = grossIncome;
}
``` this is so cool tho, i never knew that oop could be used within js
How to fix this problem
it starts with java and java is known as the oop guru just makes sense
What problem?
When I tap in button I get this error?
code error
This interaction failed but why i don't know
Can I show my code here can you tell me wher is error?
that would help
What's?
sending the code
Sir
yes in this channel
Okay
Check please ππ»
yeah this made learning js like 10x more fun. I found java really fun mainly cuz of its classes and objects properties
this gave me new energy to tackle some more js projects hahaha
Bro are you here?
also non development related, but what the fuck is your profile picture.

Morning start πΊ
i would think that you're a child but your banner seems like a grown ahh man.
this is bro getting lucky in the avatar
π
Oh shit I forgor all about that
how is contabo these days
for this price I get this at my other host
most other providers give you 1 cpu and 2gb ram for that price
which host is that?
Datalix offers a range of hosting solutions from shared hosting to dedicated servers.
its only in germany & quite low trafficlimits. pretty much only downsides
damn ok, first one i've seen that is cheaper than contabo
you have a vm with them?
I have 4 with them
care to run some benchmarks?
curl -sS https://raw.githubusercontent.com/jgillich/nixbench/master/nixbench.sh | sh
all of them
ok
Hetzner π₯π―
ryzen = raid 1 nvme
epyc = ceph
storage = raid 1 hdd
to spoil it
since ssd is something that matters a lot for some use cases, yet most providers do not mention anything about it on their offerings
but are you on dedis, or on the KVM ones?
kvm
ah ok
uhh
cant really banchmark ryzen
a backup is currently being created there
so results would be off
shouldnt take that long
what I also love about them is that they show live node cpu usage
how long does that test take on average?
should be around 2-3min
alr
contabo for what it offers is stuidply cheap
nah
wym nah
Majority of the other hosts I've seen offer less for the same price

automod
look at this then
have you looked at the sale servers at the top
They don't offer US servers though
Which is why im with contabo
No other "cheap" alternative offer US servers
yeah
frankfurt is always crazy cheap
I know like 5 hosts that are this cheap in frankfurt
If I ever need a EU server though that doesn't look like a bad choice
@quartz kindle epyc
root@v7945:~# curl -sS https://raw.githubusercontent.com/jgillich/nixbench/master/nixbench.sh | sh
nixbench v0.6.6 - https://github.com/jgillich/nixbench
cpu
---
Sha256 (1x) : 456.39 MB/s
Gzip (1x) : 328.61 MB/s
AES (1x) : 2866.21 MB/s
Sha256 (8x) : 2962.78 MB/s
Gzip (8x) : 2184.90 MB/s
AES (8x) : 8625.24 MB/s
disk
----
1. run : 918 MB/s
2. run : 1590 MB/s
3. run : 1551 MB/s
4. run : 1394 MB/s
5. run : 1536 MB/s
Average : 1398 MB/s
geekbench
---------
Single-Core Score : 5205
Multi-Core Score : 21618
Result URL : https://browser.geekbench.com/v4/cpu/16841142
host
----
OS : linux
Platform : ubuntu 22.04
CPU : AMD EPYC 7443P 24-Core Processor
Cores : 8
Clock : 2850 Mhz
RAM : 64300 MB
net
---
CDN : 67.49 MB/s
Amsterdam, The Netherlands : Failed
Dallas, USA : 14.59 MB/s
Frankfurt, Germany : 91.29 MB/s
Hong Kong, China : Failed
London, United Kingdoms : 77.18 MB/s
Melbourne, Australia : Failed
Oslo, Norway : Failed
Paris, France : 0.78 MB/s
Queretaro Mexico : Failed
San Jose, USA : 12.18 MB/s
Sao Paulo, Brazil : 6.61 MB/s
Seoul, Korea : Failed
Singapore, Singapore : 11.43 MB/s
Tokyo, Japan : 6.86 MB/s
Toronto, Canada : 19.09 MB/s
Washington, USA : Failed```
Which brings me back to my original point of contabo is cheap for what it offers
storage
DE-03 ξ° ~ ξ° curl -sS https://raw.githubusercontent.com/jgillich/nixbench/master/nixbench.sh | sh
nixbench v0.6.6 - https://github.com/jgillich/nixbench
cpu
---
Sha256 (1x) : 330.84 MB/s
Gzip (1x) : 155.08 MB/s
AES (1x) : 743.43 MB/s
Sha256 (3x) : 318.32 MB/s
Gzip (3x) : 154.93 MB/s
AES (3x) : 1117.32 MB/s
disk
----
1. run : 30 MB/s
2. run : 146 MB/s
3. run : 154 MB/s
4. run : 518 MB/s
5. run : 565 MB/s
Average : 282 MB/s
geekbench
---------
Single-Core Score : 4007
Multi-Core Score : 3521
Result URL : https://browser.geekbench.com/v4/cpu/16841145
host
----
OS : linux
Platform : ubuntu 22.04
CPU : AMD Ryzen 3 4300GE with Radeon Graphics
Cores : 3
Clock : 3493 Mhz
RAM : 8933 MB
net
---
CDN : 42.78 MB/s
Amsterdam, The Netherlands : Failed
Dallas, USA : 18.70 MB/s
Frankfurt, Germany : 32.78 MB/s
Hong Kong, China : Failed
London, United Kingdoms : 37.67 MB/s
Melbourne, Australia : Failed
Oslo, Norway : Failed
Paris, France : 0.93 MB/s
Queretaro Mexico : Failed
San Jose, USA : 14.89 MB/s
Sao Paulo, Brazil : 7.19 MB/s
Seoul, Korea : Failed
Singapore, Singapore : 13.00 MB/s
Tokyo, Japan : 5.40 MB/s
Toronto, Canada : 24.96 MB/s
Washington, USA : Failed```
mainly to those in the US tho
Which is why thats absolutely amazing for you
thats the storage vm?
yes
why is it slower than your epyc one
alright, disk speeds are within expected range
because sir, storage runs on hdd so its cheaper for more
raid 1
Really? I thought a storage server would have higher speeds
Oh its hdd
its meant for mass storage

storage servers are mostly intended for long term high storage amounts on hdd
mostly designed for backups
this one looks pretty good
disk speeds are on par with hetzner
some proxmox magic
the owner of datalix told me that they were gonna switch to raid 1 disks for epyc in the future for more performance
I got this but with epyc
ah
2023 sale
the ryzen?
I honestly doubt there is a cheaper vps host than contabo that offers us servers that is reliable
datalix shared the idea of us servers but no guarantee lol, its a big investment
how many locations do they have rn?
i see
you dont need to move to frankfurt
you just need to move all your users/clients to frankfurt
:^)
I mean ping isnt that bad even in the us
try pinging de-01.paperstudios.dev
I get 12ms
which country
true
DE-02 ξ° ~ ξ° curl -sS https://raw.githubusercontent.com/jgillich/nixbench/master/nixbench.sh | sh
nixbench v0.6.6 - https://github.com/jgillich/nixbench
cpu
---
Sha256 (1x) : 100.21 MB/s
Gzip (1x) : 130.66 MB/s
AES (1x) : 550.61 MB/s
Sha256 (1x) : 134.57 MB/s
Gzip (1x) : 133.62 MB/s
AES (1x) : 600.62 MB/s
disk
----
1. run : 183 MB/s
2. run : 278 MB/s
3. run : 234 MB/s
4. run : 389 MB/s
5. run : 336 MB/s
Average : 284 MB/s
geekbench
---------
Single-Core Score : 2381
Multi-Core Score : 2248
Result URL : https://browser.geekbench.com/v4/cpu/16841154
host
----
OS : linux
Platform : ubuntu 22.04
CPU : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
Cores : 1
Clock : 2793 Mhz
RAM : 3924 MB
net
---
CDN : 67.51 MB/s
Amsterdam, The Netherlands : Failed
Dallas, USA : 14.38 MB/s
Frankfurt, Germany : 69.47 MB/s
Hong Kong, China : Failed
London, United Kingdoms : 62.47 MB/s
Melbourne, Australia : Failed
Oslo, Norway : Failed
Paris, France : 0.70 MB/s
Queretaro Mexico : Failed
San Jose, USA : 11.60 MB/s
Sao Paulo, Brazil : 7.97 MB/s
Seoul, Korea : Failed
Singapore, Singapore : 10.51 MB/s
Tokyo, Japan : 6.79 MB/s
Toronto, Canada : 19.02 MB/s
Washington, USA : Failed```
disk speeds might be low cuz I have like 3gb left
ye they look low
Error: failed to solve": process "/bin/sh" -c npm install did not complete successfully.
WORKDIR /usr/src/index.js
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]```
docker file
do i have to show docker ignore file?
what do you think about epyc vs xeon?
im interested in the 6 eur ones
epyc any day
i might invest in one of those eventually
well what do you want to run
my api
that error doesnt help much, as it could be caused by anything
then it doesnt really matter
check your docker logs
aka just get the cheaper option
yeah, 12 new xeon servers arrived today
epyc isnt really being restocked currently
so you could ask if there is space somewhere on epyc
(I did that too)
whats this?
german tax
ah
um where can i find /root/.npm
Mehrwertsteuer if you want to look it up
I dont understand what you mean with that
got any discount codes? xD
nah
welp, was worth a shot
anyway im not gonna buy it now
my api is not even finished yet
im paying for the hetzner server and basically not even using it
where can i find the logs file
your problem is not docker
its the npm install that is failing
more specifically, the prism-media package is failing for some reason
double check your dependencies and make sure everything is up to date
wait
let me cat package.json rq i kinda forgot how many packages were there
"@discordjs/opus": "^0.8.0",
"@discordjs/rest": "^1.7.0",
"@discordjs/voice": "^0.14.0",
"@distube/soundcloud": "^1.3.0",
"@distube/spotify": "^1.5.1",
"ascii-table": "^0.0.9",
"axios": "^1.3.6",
"chalk": "^4.1.0",
"colors": "^1.4.0",
"discord-gamecord": "^4.3.0",
"discord.js": "^14.8.0",
"dotenv": "^16.0.3",
"glob": "^8.1.0",
"isomorphic-fetch": "^3.0.0",
"moment": "^2.29.4",
"mongoose": "^6.9.1",
"ms": "^2.1.3",
"nodemon": "^2.0.20",
"openai": "^3.2.1",
"pretty-ms": "^8.0.0"
this is the packages
it works now
around easter they always release crazy codes, I got one that gave me 20% permanent discount on every service
awesome
also that is quite the journey isnt it
do you know all those languages too or not?
my primary language is portuguese
and english basically
i know slovenian but its kind of a secondary language to me
german i just know the basics of the basics
sometimes not even that
ah okay
im just happy that german is my mother tongue 
lmao
btw, i managed to setup my github project with teamcity ci (running in docker) 







