#development

1 messages · Page 53 of 1

cursive musk
#

Error:
TypeError: message.client.botCommands.array is not a function

#

Does anyone know what I'm doing wrong? thanks

#

Should it be .values instead of .filter?

#

??

earnest phoenix
#

Array.from(message.client.botCommands.values())

cursive musk
eternal osprey
#

Does anyone know why my filter isn’t working? Like it totally makes my collector stuck. I am pretty sure that the member id is the user in the database as well. It just does nothing

neon leaf
#

Whats the best way to make UIs Like this and actually Code them? For the First id say Figma but the second one idk, Im tired of pure HTML + CSS

dry imp
#

whats figma

earnest phoenix
#

interface design app

earnest phoenix
neon leaf
#

Thanks, I'll Look into it, do you know any Templates that Look similar to my Screenshot?

earnest phoenix
#

Not by head but you can probably find one if you search for an admin dashboard template

neon leaf
#

omg, I never used react / any framework and now im hooked, its so easy to do anything

earnest phoenix
neon leaf
#

Finally I dont have to touch css files 🤩

earnest phoenix
#

You eventually will have to at some point

#

Not everything will be as you wish

#

So you'll probably need to edit things from time to time with custom styling

neon leaf
#

well yeah, I dont have to write 200lines of css to optimize it for mobiles atleast ( I hope)

hasty mulch
earnest phoenix
#

?

#

Is there some kind of joke I missed? ASthink

hasty mulch
#

No

#

Nvm

neon leaf
#

they are the exact same file but renamed

#

yes, the login file has the function renamed to login

neon leaf
#

nvm, It has to be Login, not login

tacit crest
#

@whole knot

neon leaf
#

why is this Button not executing the dologin function?

spark flint
#

try just js onClick={doLogin()}

neon leaf
#

nope

#

for some reason that executed the function on page load

radiant kraken
spark flint
#

Ah

cinder patio
#

the button is disabled

neon leaf
#

thats intentional

#

its enabled through js

#

and I can indeed see it changing color when clicking

cinder patio
#

how is it enabled through JS?

#

On the screenshot disabled will always be true unless Button passes something else to the actual button componnent

#

If you're 100% sure then the only other thing that comes to mind is that some other parent / child listener is stopping the event from propagating

neon leaf
cinder patio
#

that's your problem

#

you almost never interact with the document API directly in react

#

The Button component thinks it's still disabled because react uses a virtual DOM

#

you have to save the value of disabled in a state and update it when you have to:

const [isDisabled, setDisabled] = useState(true);

return <DarkMode>
    <Button disbled={isDisabled} ...>
    ...
neon leaf
#

Ive been trying for 3 hours lol

cinder patio
#

I've only used chakra like once so I can't really say without more code

lyric mountain
neon leaf
lyric mountain
#

with theme libs you 99% of the time use theme colors instead of raw colors

neon leaf
neon leaf
#

ok, got it working by putting it all in a different component

pearl mantle
#

@livid crow

wooden ember
#

ok so i know this isnt really bot realated but its still web related, kinda. so i have two raspberry pis or something right, I need one to send a message to another and the other way around too. i dont need any data to be sent other than a ping or something. the senario is that one receives a voltage on a pin and i need to send a "true" condition over the internet to another pi to put voltage on the pin on the other side. i got all that stuff done but idk how to send a message from one pi to another over the net. this wont be over a lan but over the internet. any simple suggestions? want to make this as low tech as possible to eventually just use a microcontroller like an esp32 rather than a pi.

#

idk how internet stuff works other than how to host a website tbh

#

so idk the protocolsl or anything so this might fall under the catagory of IOT

rustic nova
#

you could do it through sockets or a simple webserver running on express or in python, flask

#

and then just hook them up to your wifi and allow communication for these

lament rock
#

So, I'm trying to have a check box that toggles the background color and the solution I found was to set a class to a checkbox and with a :checked specifier, select a nearby element and change its properties, but what if I don't want to select a nearby element and want to change the body itself?

Here's what I have currently:

<body>
    <nav id="topnav">
        <a class="active navitem" href="/">Home</a>
        <a class="navitem" href="/about">About</a>
        <a class="navitem" href="/dash">Dash</a>
        <input type="checkbox" class="toggle">
    </nav>
    <div class="landing">
        <img class="landing-image" alt="Amanda, a red-haired cat girl with headphones and a white shirt smiling at the viewer" src="/images/amanda-mummy.webp" />
...
.toggle:checked + body {
    background: var(--inverted-main-gradient);
}

Is there even a way to select the body?

sharp geyser
#

You could use js to change the background when the checkbox is checked

lament rock
#

I don't want to use JS

quartz kindle
lament rock
#

So, I have to create a div above the nav bar and place the checkbox before that and somehow move the checkbox so that it's not awkwardly before the nav bar?

quartz kindle
#

yeah

#

you can use absolute positioning to move the checkbox outside

sharp geyser
#

This sounds like a hassle

lyric mountain
#

there's no shame in using js tho, if that makes maintenance easier

quartz kindle
#

have you seen those css-only tabbed menus? they use similar tricks

lyric mountain
#

web is html/css/js after all

lament rock
#

I get this ugly mess because the body bg is no longer specified and is based on a container div

quartz kindle
#

you can make fully functioning tabs with css only using invisible radio buttons

sharp geyser
#

Then that sucks for those people

#

:^)

lyric mountain
spark flint
#

Literally like 90% of modern sites use JS

#

It’s their fault if they don’t allow js

lyric mountain
#

unless ur using tor, I see no reason in blocking js

lament rock
#

trackers/ads

lyric mountain
#

the browser itself tracks u

lament rock
#

sucks

lyric mountain
#

and ads are 99% of the time blocked with a dedicate extension, not by disabling js entirely

sharp geyser
#

Anyone who blocks js and expects shit to function properly is just out of luck

lyric mountain
#

it's like removing someone's lungs and asking to run the tour de france

sudden geyser
#

should've told me sooner

lament rock
#

I figured out my issue

#

I set the position of the checkbox to absolute and it removed it. Then, I could just create a label for that checkbox

lament rock
wooden ember
eternal osprey
#
const filter1 = i =>  i.member.id === gamedatabase[key].user1
            const collector = r.createMessageComponentCollector(filter1,{
              componentType: "BUTTON",
              time: 10000,
              max: 5,
            });

            collector.on("collect", (i) => {
            
          console.log(i)```could anyone please tell me why when i add the filter the collector like doesn't work at all
#

even if the right user clicks on it>

#

It just freezes the collector

earnest phoenix
eternal osprey
#

voltrex i could marry

earnest phoenix
#

Oh damn girl mmLol

eternal osprey
solemn latch
#

indeed

fiery tangle
#

anyone here know regex?

spark flint
earnest phoenix
#

It won't work if the client doesn't have sufficient permissions to change a member's nickname, or if the member is the server owner

earnest phoenix
#

Hey guys long time no coming here

#

maybe too long

drifting cairn
earnest phoenix
#

So as of now I need help making a thing and it's to send a start message when my bot is added to a server

#

any ideas?

#

example bots can be many

#

nvm

#

it was guildCreate

sharp geyser
#

One I don't recommend as it can be annoying, two if you really want to, just look for the first chattable channel and send it there on join

lament rock
#

every guild starts off with a text channel that has the same ID as the guild which is the general chat. If that channel exists, there are good chances it's still general

sharp geyser
#

me who deletes that channel and makes a new general channel

lament rock
earnest phoenix
#

Hi

mild fjord
#

hi?

flat copper
#
app.use(express.static(__dirname + '/public')); 

in main.js

<link rel="stylesheet" type="text/css" href="css/style.css">

in html

but its still not loading css

true yew
#

.catch()

#
.catch(() => {
  //failed
})```
radiant kraken
#

why not just use await

#

and use a try catch

#

.then().catch() can get really messy

#

you probably forgot to await something

#

then you probably forgot to handle it in a try catch block

radiant kraken
radiant kraken
earnest phoenix
lyric mountain
#

that's cruel

wheat mesa
#

Just use js but all the html is in a raw string that gets inserted when the page loads 🧌

radiant kraken
neon leaf
#

will this wait for the data to be fetched in react?
fetch('some_url', { method: 'GET' }).then(res = res.json())

lyric mountain
#

unless you explicitly add await

neon leaf
#

maybe context matters, I wanna display info about a user in a component, currently using xhr the data only shows after you refresh the components, not page

neon leaf
earnest phoenix
#
node:internal/fs/utils:348
    throw err;
    ^

Error: ENOTDIR: not a directory, scandir './slash_commands/iogames.js/'
    at readdirSync (node:fs:1446:3)
    at /home/dragontahmid1/Descargas/New-discord-bot/handler/slash_command.js:9:30
    at Array.forEach (<anonymous>)
    at module.exports (/home/dragontahmid1/Descargas/New-discord-bot/handler/slash_command.js:8:41)
    at Object.<anonymous> (/home/dragontahmid1/Descargas/New-discord-bot/index.js:11:98)
    at Module._compile (node:internal/modules/cjs/loader:1149:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1203:10)
    at Module.load (node:internal/modules/cjs/loader:1027:32)
    at Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  errno: -20,
  syscall: 'scandir',
  code: 'ENOTDIR',
  path: './slash_commands/iogames.js/'
}

Node.js v18.10.0
``` hmmmmm
#

probably this is doing it ```js
client.guilds.commands.set.foreach( async => {
[...client.slash_commands].map(x => x[1].data)
}).catch(err => {
console.log(err)
})

sudden geyser
#

you'd need to show us slash_command.js

earnest phoenix
#
const { readdirSync } = require("fs"),
ascii = require("ascii-table");

let table = new ascii("Commands");
table.setHeading("Slash Commands", "Load status");

module.exports = (client) => {
        readdirSync("./slash_commands").forEach(dir => {
            const commands = readdirSync(`./slash_commands/${dir}/`).filter(file => file.endsWith(".js"));
    
            for (let file of commands) {
                let pull = require(`../slash_commands/${dir}/${file}`);

                client.slash_commands.set(pull.data.name, pull);
                table.addRow(file, '✅');
            
                if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
            }
        });
        // Log the table
        console.log(table.toString());
}
#

slash_command.js

sudden geyser
#

so you have a regular .js file in there and a dir

#

see here

#

your first readdirSync returns iogames.js and miscellaneous in an array

earnest phoenix
#

yes

sudden geyser
#

then you try to read each as a directory

earnest phoenix
#

ah

sudden geyser
#

but iogames.js is not a directory

#

so it fails

earnest phoenix
#

yeah

#

my eye sight problems

#

gotta get glasses soon

sudden geyser
#

try zooming in

earnest phoenix
#

k

sudden geyser
#

Anyway, you'll want to read the directory and filter out non-directories. Some links on how to do it:

An example with the code below.

readdirSync("./slash_commands/", { withFileTypes: true })
  .filter((d) => d.isDirectory())
  .map((d) => d.name)
  .forEach((dir) => {
    readdirSync(`./slash_commands/${dir}/`).forEach((file) => {
      // Now you have a `dir` and `file`, load it.
    })
  });
earnest phoenix
#

ty

#

I'll do that

wooden ember
#

why else would js be used other than complicated stuff you cand to with html and css

#

i mean thers dynamic elements and stuff i guess

#

but then i hate those cuz all it does is make the page take ages to load

#

unless its worth it

astral path
#

what's the thing that luca has a command for that lets you monitor your bot?

#

nvm, it's pm2

#

i think

#

¯_(ツ)_/¯

earnest phoenix
#

Yup! kryptonHype

quartz kindle
#

it doesnt really make it slow to load, unless youre doing shit stuff

lyric mountain
#

since they use edge cases or stuff that are so intricate that you simply cannot maintain it after a few weeks

#

nowadays it doesn't matter much if you dont use the most optimized path, internet is no longer limited to a couple kbps

#

also as tim pointed, js impact on loading times is minimal

wooden ember
#

bruh tell that to hald the bot websites that i look at like dank memers page

#

takes ages to load

lyric mountain
#

because it's not js

wooden ember
#

its not?

#

theres always 101 things moving and doing shit though

lyric mountain
#

they're limited by discord ratelimit

wooden ember
#

whats that got to do with the website

lyric mountain
#

you need to use discord to login to the site

wooden ember
#

oh that

#

i mean thats slow too but about the same as the rest of the page

earnest phoenix
#

hey guys we were making top.gg vote logs using dblapi.js and there is no error and I am running it on repl and for some reason there are no logs and no errors

lyric mountain
#

don't blame the whole language for an infinitesimally small edge case

#

you can bet all your money that it's not js that's making the page slow

#

and you can even check that, just press F12 and see performance tab

#

you'll see what's truly taking ages

lyric mountain
#

dblapi is deprecated

wooden ember
#

all i know is that alot of web pages with fancy shit take an age to load

lyric mountain
#

blame the devs, not the language

wooden ember
#

never looked into it just assumed thats what it was

wooden ember
#

yeah thats cool but if it negitivly impact user experience than thats not good

lyric mountain
#

if it was js' fault, the page wouldn't even load

wooden ember
#

ok thats pretty cool and onyl took like 4 seconds to load

#

not saying its js' fault im just daying its over used

#

something thats over used is bootstrap, had to use that to make a website in collage and its the most pointless thing ive ever seen

lyric mountain
sharp geyser
#

Hi haku

lyric mountain
#

most devs use frameworks or site builders that add much boilerplate to the site

#

if it was to be done through raw html, the same page could be much faster

lyric mountain
wooden ember
#

yeah but the issue then is you gotta load a bunch of stuff in the frame work that you never use but still takes up load time

lyric mountain
#

that's assets, not js

sharp geyser
#

One thing to also think about with page loads is images & any imported css

#

the site has to download that every time

wooden ember
#

i hate that too

sharp geyser
#

Also resizing massive images with css to a smaller size is never a good idea as it has to happen on every page load

wooden ember
#

this

sharp geyser
#

Another thing I learned is about retina displays

#

basically twice as many pixels can appear in the same grid making the image cripser on apple tech

#

so a 600px image can be downsized to a 300px image and still look crisp on a apple phone and also look better on non apple phones

lyric mountain
#

assets and styles are always what takes most of the loading time

sharp geyser
#

Yea

lyric mountain
#

there's a reason why most TOR sites don't use css at all

sharp geyser
#

Also just people doing wacky css

solemn latch
#

Who needs css? 👀

sharp geyser
#

a lot of css stuff if done wrong can make load times longer

#

I've learned some useful information in this linkedin course on css essentials mmLol

sharp geyser
wheat mesa
#

Are we considering 2000s old now :c

sharp geyser
#

yes waffle

lyric mountain
sharp geyser
#

its been nearly 23 years

#

2000 is almost a millennial

#

Im also sure that auto correct used the wrong word but idk Im too tired to care

wheat mesa
#

Imagine being tired

#

I have comp sci class next period

sharp geyser
#

I dont like how uneven this is

wheat mesa
#

We have to write linked list shit

sharp geyser
#

Imagne being in school

wheat mesa
#

I cannot figure out why my linked list add method is not adding in the correct order

#

It’s based on the compareTo method but it’s still wrong for some reason

sharp geyser
#

I was supposed to but my dad told me while I was half asleep that I have a doctors appointment then falls asleep himself and when I wake up he blames me I didn't keep him awake

wheat mesa
#

@lyric mountain you know Java very well, how do you make a linked list add in a specific order based on the stored object’s compareTo method

lyric mountain
#

aside from using LinkedList<>?

wheat mesa
#

Making our own

lyric mountain
#

u could use a map-backed list

#

or the map itself

wheat mesa
#

We had this

#

It has to be a linked list

lyric mountain
#

like, have all keys be indexes

wheat mesa
#

It’s a class that stores a LinkedList

#

As an instance variable

lyric mountain
wheat mesa
#

Not allowed to change the instance variables unfortunately, it has to be a raw linked list

lyric mountain
#

what is being used to hold the instances?

#

an array?

wheat mesa
#

We have a class that holds an instance variable of type ProductNode, which is a linked list

lyric mountain
#

...

wheat mesa
#

It’s very basic, ProductNode has an instance variable called data which stores the Product, and then a reference to the next node called front

lyric mountain
#

ok so...you're making a linked list...that uses a linked list?

wheat mesa
#

No no

#

We’re making a class that wraps around a linked list

#

Sorry I should’ve been more specific

lyric mountain
#

that...is what "using a linked list" means

#

I might be understanding wrong tho

wheat mesa
#

The class I’m writing code in has an instance variable that is a linked list, so I guess you could say that

lyric mountain
#

cant u just call the linked list methods?

earnest phoenix
lyric mountain
#

?

earnest phoenix
#

See a website on the about me of someone that is exactly that

wheat mesa
earnest phoenix
#

Just other domain etc.

wheat mesa
#

It’s our own linked list, not from the Java stdlib

lyric mountain
#

ok, so THAT linked list is what ur trying to make?

wheat mesa
#

I’m trying to make a class that stores that linked list as an instance variable

#

And then we’re making methods that wrap around it

earnest phoenix
lyric mountain
#

class MyList<T> extends TheOtherList<T> {

wheat mesa
#

Sorry for the pictures

#

That’s basically what it is

lyric mountain
#

what a shameless ripoff

#

they even blocked F12 (and right click)

earnest phoenix
#

ikr

lyric mountain
#

lemme see the source code (press F12 in another page, go to the site)

earnest phoenix
#

Sending email to the original owner to make them aware PepeHmm

wheat mesa
#

My main problem is that my add method doesn’t add the element in the correct order, since it’s supposed to add based on the compareTo ordering

lyric mountain
earnest phoenix
#

Yeah here it definitely didn't began with creativity

lyric mountain
#

they didn't even bother to remove cherupil photos

earnest phoenix
lyric mountain
#

ok so back to waffle

earnest phoenix
#

Sorry Waffle for killing your conversation Sadge

lyric mountain
lyric mountain
#

also, what is ur Node class?

wheat mesa
#

My idea was as follows:
Loop through the linked list while the next element is not null
Compare the data at the current element to the one being added via its compareTo method
If the result is less than or equal to 0, then it will be added after the current element (current.compareTo(oneBeingAdded) <= 0)
If they don’t belong in front of the current element, continue looping
Otherwise add it to the end of the list

#

The Node class and Product class are written 100% correctly, they were provided to us in the assignment

#

The compareTo method just compares the names of the products with their respective compareTo methods as well

lyric mountain
#

so it's a sortedlist, not a linked list

#

linked list preserves insertion order

wheat mesa
#

Not really, the add method is just based on sorting order

#

The other methods however do not preserve sorting

lyric mountain
#

I'm struggling to understand the whole thing tbh

wheat mesa
#

The first add method

lyric mountain
#

ok so you're the one writing ProductList I suppose

wheat mesa
#

Oh maybe I need to be checking if the element belongs BEFORE the current element or not

lyric mountain
#

what is being used to store the values inside ProductList?

#

an array, a list, what

wheat mesa
#

ProductNode

lyric mountain
#

ProductNode is a collection?

wheat mesa
#

No, it’s our basic implementation of a linked list

lyric mountain
#

sigh

wheat mesa
#

I gtg, I’ll try to fix it during my comp sci class

lyric mountain
wheat mesa
#

Not possible, it’s not a collection

lyric mountain
#

that is a mess by itself

wheat mesa
#

Yeah I agree

#

But it is what it is

lyric mountain
#

now I understand why most people come out of college hating java

sharp geyser
#

Funny thing is thats a highschool comp sci

#

he hasn't even hit college yet

lyric mountain
#

like, it's a damn biased method of teaching, no wonder why they see python and say "oh wow, this is much easier than java"

sharp geyser
#

kek

lyric mountain
#

@earnest phoenix btw I just checked, they even got as far as registering the site in dmca

#

tho they didn't verify the account

fervent moss
lyric mountain
#

good idea

earnest phoenix
cinder patio
#

hmm

quartz kindle
#

@lyric mountain@earnest phoenix

earnest phoenix
#

Yes very spooky plastic gun CS_pepehmm

lyric mountain
#

ye, we saw it lul

#

and obviously "coding can be boring af", when u don't code at all

earnest phoenix
#

I wonder how I got dmca striked, but ended up winning the case 🤯

Would be interested how a DCMA takedown from an Apple Senior Engineer would feel like for his parents PepeHmm

boreal iron
quartz kindle
#

his response:

blyat cyka jobany urod

quartz kindle
boreal iron
#

So… evil you mean?

earnest phoenix
boreal iron
quartz kindle
boreal iron
quartz kindle
#

i consider americans more evil xd

boreal iron
#

more dumb […]
Brings us back to Americans freerealestate

quartz kindle
#

i mean, yes, americans are dumb af

#

but russians are more often than not even dumber

#

because they are fueled by vodka

#

:^)

boreal iron
earnest phoenix
quartz kindle
#

fake taki dumbo

boreal iron
#

i like cliches

#

Fake ain’t dumbo

earnest phoenix
#

dumbo ooga booga

boreal iron
#

There’s something big, but not my ears tho

quartz kindle
#

oh my :^)

earnest phoenix
#

That's what she said I suppose PepeHmm

earnest phoenix
#

Azerbaijan or something like that

#

According to previous messages PepeHmm

sharp geyser
rustic nova
#

no rust

#

big sad

#

dont you dare say something about my rpc

sharp geyser
#

I am doing this for Halloween

rustic nova
#

pog

sharp geyser
#

I do have plans on making this something serious if it goes well though

#

So if I do I might make it in rust

sharp geyser
rustic nova
#

nah just code quality things

sharp geyser
#

Still 17 problems

earnest phoenix
sharp geyser
#

And never fixed

rustic nova
#

banned both rn

sharp geyser
#

Do it

rustic nova
#

here java jumpscare

earnest phoenix
#

type casting

lyric mountain
# rustic nova here java jumpscare
var lst = (ConnectionListener) listener;

switch (event) {
  case AsyncPlayerPreLoginEvent e -> lst.onConnect(e);
  case PlayerQuitEvent e -> lst.onDisconnect(e);
  case PlayerJoinEvent e -> lst.onJoin(e);
}
#

soon

rustic nova
#

unless your application has to work on lower versions of java

lyric mountain
#

rip then

rustic nova
#

look KuuHaKu, I have to go through the pain and agony to keep legacy support

#

im not djs on v500

lyric mountain
#

how...how far is your legacy support, may I ask?

wheat mesa
#

27 years

rustic nova
lyric mountain
#

jdk 8 then, oh the pain

rustic nova
#

must admit though

#

stupid me has mostly been working on jdk 8

#

never bothered to upgrade apart from the obvious one when log4j came

lyric mountain
#

there's so much improvement to the language as a whole, it's awful when I need to go back to older LTS versions

lament rock
#

How does this look for a dark mode?

#

light mode for context

lyric mountain
#

the navbar is too dark in the second image

#

oh wait, that's the browser itself

craggy pine
#

Agreed.

lyric mountain
#

hi miyu

lament rock
#

That is the browser

#

The actual site navbar is unaffected

lyric mountain
#

there's this one too

craggy pine
#

Only thing I'm like kind of not a fan of and It may just be a me thing is the emojis being used and how they're a nice blue and an ugly grey

lament rock
#

The grey ones are disabled

craggy pine
#

ah ok

#

Then yeah overall good color scheme

lament rock
#

Over all, supposed to be easy on the eyes and the dark mode is really just an easier on the eyes and also mostly and experiment

lyric mountain
#

a thing that I'd suggest, is making the fonts here slightly bolder

#

like, not enough to be called "bold", but slightly thicker

craggy pine
#

Thiccer

lament rock
#

Maybe

lyric mountain
#

or bigger

#

idk, maybe it's my eye but it's a bit straining to read that

lament rock
#

It's much easier to read on the site itself rather than the image

lyric mountain
#

perhaps it's also because I'm seeing a downscaled version of the whole site

craggy pine
#

Idk if you plan on adding more to the page itself, but if you are would making the actual music player which I assume is the top left one, span across the bottom be a better choice to give you more page space for other stuff.

lament rock
#

If there were more tracks queued, that's where they'd be

#

I can queue up some more

craggy pine
#

ah ok

lyric mountain
#

also...did you try comic sans to see how it fells in that site?

craggy pine
#

comic sans

lyric mountain
#

it gives me some comic vibes from the thicc outlines

#

might pair nice with comic sans

lament rock
craggy pine
#

Oh i see so you list the queue below the player

#

is 0:00 a bug?

lament rock
#

No. Just that it's a live stream

lyric mountain
#

make the duration bigger

#

75% the size of the box

lament rock
#

Also, the font is Discord's Whitney

craggy pine
#

Are you able to determine what a live stream is by the API? If so

#

maybe change 0:00 to "Live video"

#

or something

lyric mountain
#

if it returns 0 length it's safe to assume it's a live

lament rock
#

Technically

{"op":4,"d":{"track":{"class":"RequiresSearchTrack","id":"RK8e4JQgPfo","title":"Pixel Galaxy","length":236,"thumbnail":{"src":"","width":0,"height":0},"live":false,"uri":"https://youtube.com/watch?v=RK8e4JQgPfo","source":"youtube","author":"Snail's House"},"position":2}}
#

or just really short

craggy pine
#

"live":false,

#

i see

lament rock
#

LavaLink gives good info most of the time

#

One thing I am super not happy with is this

#

idk what to do here tbh

lyric mountain
#

Put your logo

wheat mesa
#

Rounded edges

#

More subtle of a gradient than that (it’s difficult to achieve proper contrast with a gradient between colors that drastic)

#

Also might want to use bigger font for the Welcome Back section, and remove the border around the entire thing, and instead go with a bigger font and bolded letters

lament rock
rustic nova
#

depends on bot theme/design really yeah

sharp geyser
#

So I just made a big fuckery of my codebase

#

Tried implementing a system similar to how djs handles dispatch events from the gateway so I can easily process them without the need of doing so for every single event when I am connecting my shard

rustic nova
#

on which major did you finish? v500?

sharp geyser
#

huh

boreal iron
#

Ok

#

Fuck you markdown

#

You and auto correct should burn in hell

sharp geyser
boreal iron
#

Idk

#

I don’t like discord and obviously it doesn’t like me, too

cursive musk
#
TypeError: member.sendCustom is not a function
    at /home/container/src/dashboard/dashboard.js:621:10
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) Promise {
  <rejected> TypeError: member.sendCustom is not a function
      at /home/container/src/dashboard/dashboard.js:621:10
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
}
#
.sendCustom({
          embeds: [
            new MessageEmbed()
              .setColor("GREEN")
              .setFooter({ text: `Powered by https://universebot.xyz` })
              .setTitle(`Application #${ticketID}`)
              .setDescription(
                `Hey ${
                  member.user.username
                }! Your form was Submitted and ready to be judged.\n\n**Form ID**: \`${ticketID}\`\n**Time:** ${moment(
                  new Date()
                ).format("dddd, MMMM Do YYYY HH:mm:ss")}`
              ),
          ],
        })
        .catch(() => {});
#

What am I doing wrong??

wheat mesa
#

.sendCustom doesn't exist on whatever you're trying to use it on

cursive musk
#

I don't know what was I thinking

#

My bad

raw nest
#

General question. How does NextAuth's (https://next-auth.js.org) Credentials (Username / Password) work exactly? Like is it some soft of OAuth2?
Or in general, how would I make a Username / password authentication in my app between frontend and backend? I thought about just authenticating, generating token, storing in localstorage and just give it an expiration timestamp

Authentication for Next.js

radiant kraken
sharp geyser
#

It supports a variety of methods of authentication

#

Email / Password or Oauth2 of some sort whether that be through Auth0, Google, Twitter, etc

#

And it gives out a JWT once it successfully auths by the looks of it

#

JWTs are cool cause it leaves little validation for you

#

You can also have your own way of storing the "session" though

raw nest
sharp geyser
#

Huh

raw nest
#

As far as I know

#

but still, that doesn't matter too much for the system itself right? xD

lament rock
#

???

#

Bro?

sharp geyser
#

Why would you want to expire a JWT

#

I don't think thats the point

raw nest
#

Maybe if the user logs out I don't want all the date to be somewhere around

sharp geyser
#

Thats when you'd delete the JWT

harsh nova
#

I store my jwt as well because I’m dumb and don’t fully understand it

sharp geyser
#

With JWTs I dont think you really need to store them yourself

earnest phoenix
#

That's the point of JWTs, stateless. There's no use in storing them on the server

#

Otherwise you're kind of just reinventing sessions

#

So no point on using JWTs

sharp geyser
#

JWTs are fine for something that only needs minimal security

#

personally I'd use oauth

#

Helps prevent attackers as the actual credentials are on the server and nothing gets sent to the client other than a token which they can't get unless you give it to em

#

Which at that point is your fault

earnest phoenix
#

I mean, that's mostly used/made for third parties but yeah you can use it

sharp geyser
#

Discord uses oauth for their logging in

#

Thats why each user is assigned a token on login

#

They made their own oauth server iirc though

#

so they don't use smth like Auth0 as a thrid party

earnest phoenix
#

Oh they use that as standard when logging in?

#

Thought was normal login

sharp geyser
#

As far as I know yes

earnest phoenix
#

To their login endpoint

#

Interesting

sharp geyser
#

They send the login creds to the server and it responds back with a token iirc

earnest phoenix
#

Yeah I mean that doesn't necessarily mean oauth2

#

I also do the same, just send a token back

sharp geyser
#

I don't know where it was but I read something about it

earnest phoenix
#

I though oauth2 was just used for applications

#

So that they can get data from discord

#

That's the purpose of oauth2

sharp geyser
#

I might of misread it

#

It was one of my late night reads

earnest phoenix
#

I mean they can use it, it just doesn't really make sense

#

Point of oauth2 is to allow a website or application to access resources from other web apps on behalf of a user

sharp geyser
#

Mhm

fervent moss
#

Does someone know how to get started with discord outh2 in website , i have some references but they are in php and i want in html css

earnest phoenix
#

You'll need something else than HTML/CSS only, and HTML/CSS will be used either way

rustic nova
#

yeah you cant make oauth in pure html/css, oauth is not something visibly done

boreal iron
#

lol

rustic nova
#

it is a process that allows your application to receive access to scopes on a account

#

or am I wrong @boreal iron

pine nova
#

ah yes oauth in html and css

rustic nova
#

I mean you could technically do it with js but why

pine nova
rustic nova
#

js in the sense of implementing javascript on your website

boreal iron
rustic nova
#

I wanna do discord bot in css

boreal iron
#

Maybe in css4

#

Who knows

pine nova
#

nah in brainf*ck

fervent moss
#

Was there some discussion here

earnest phoenix
#

Can anyone say how to get emojiid without nitro

rustic nova
#

doubt that's possible if you can't send the emoji

#

yeah you'd need nitro for it, have the bot go through all emojis of your guild and use the one you'd need

slim heart
dry imp
#

or use / or \ before the emoji i forgot

rustic nova
dry imp
#

i mean if he is on the server he still can do that iara_shrug

rustic nova
#

oh lol forgot you can use emojis on your own server

opaque marten
hidden gorge
#

can someone help me with my cloudflare?

dry imp
fervent moss
#

The best way is using some kind of bot made by urself for this stuff

rustic nova
hidden gorge
#

i keep getting this

#

@rustic nova

rustic nova
#
A missing DNS A record that mentions origin IP address.
A CNAME record in the Cloudflare DNS points to an unresolvable external domain.
The origin host names (CNAMEs) in your Cloudflare Load Balancer default, region, and fallback pools are unresolvable. Use a fallback pool configured with an origin IP as a backup in case all other pools are unavailable.
When creating a Spectrum app with a CNAME origin, you need first to create a CNAME on the Cloudflare DNS side that points to the origin. Please see Spectrum CNAME origins for more details
hidden gorge
#

i can’t figure this out

deft rock
#

Got anything for `redirected you too many times'?

rustic nova
#

well if you have no entries then nothings gonna happen

rustic nova
#

why do you have a cname on your domain if that domain is hosted on cloudflare

hidden gorge
#

it told to

#

me*

rustic nova
#

remove the first entry, as it doesnt make sense

#

what is your goal right now

hidden gorge
#

i just want to add cloudflare to my site

#

removed the www

rustic nova
#

then add a root entry (aka a new entry that has @ in the name, make sure it is a A record (A = your server ip)

hidden gorge
#

ok

rustic nova
#

If you want cloudflare to serve your website through their proxy (aka through cloudflare for example as a ddos protection), make sure the "with proxy" is selected

hidden gorge
#

i added my ip

#

and now the site doesn’t load

rustic nova
#

cloudflare only proxies http-based ports such as 80

#

but if it does look like this (ignoring the name part, you can both directly use your full domain or just @ ) then the cloudflare setup should be correct

hidden gorge
#

ok

#

like this?

rustic nova
#

so if you want something such as a webhook you're using for top.gg voting as a plain example, you'd need to either use port 80 or use something like apache2/nginx to reverse proxy that. Though thats another entirely different thing

#

nah not a cname

#

or is replit giving you these details?

hidden gorge
#

yes

rustic nova
#

nice images that wont load there

hidden gorge
#

yeah

rustic nova
#

that one

hidden gorge
#

it’s verified but won’t load i use freenom domains

rustic nova
#

yeah make sure it isnt proxied then

#

the cname

#

toggle the switch "proxied"

#

I can visit that site, works fine

#

might not be what you'd want to see but that works

#

so thats up to replit now

#

and gone again, worked for a second

hidden gorge
#

im relinking it

rustic nova
#

also

#

I suggest you to move away from freenom once you can

hidden gorge
#

i have $0

rustic nova
#

once you can, doesnt mean right away

hidden gorge
#

and i use it for my minecraft’s server ip 😂

rustic nova
sharp geyser
rustic nova
#

you too

sharp geyser
#

Ty <3

eternal osprey
#

hey guys i've got a bit of a mathematical question

#

I have a summation of these fractions: 1/2, 3/4, 7/8, 15/16 etc

#

for the regular formula 1/2^n

#

How would i come up with another formula

#

that would give the same outcome

#

so for example n = 1 gives 1/2 ofcourse with that outcome, so n = 2 will give 3/4

earnest phoenix
rustic nova
#

Glad I'm aware

#

@sharp geyser stinks more tho

lyric mountain
#

any other formula will be just unreduced versions of it

#

like 4/8 ^ n, or (2/4 / 2) ^ n

#

there's the sigma notation version (that represents the summation of 1/2 ^ n) that's

 n
 Σ 1/2 ^ i
i=1
crystal wigeon
#

hey umm, on button interaction "dispose" or "end" events how do i make all the buttons i've sent as disabled?

lyric mountain
#

edit the message, setting the new buttons

crystal wigeon
#

thanks

raw nest
#

Does someone know the software these docs are using because they are all very similiar?:
https://stripe.com/docs/api?lang=node
https://appwrite.io/docs/client/account
https://docs.github.com/en/rest/actions/artifacts
Like this code example on the left and sticke to the section and parameters etc. on the right. It's so similar ThinkO_O

Appwrite

Appwrite provides web and mobile developers with a set of easy-to-use and integrate REST APIs to manage their core backend needs.

lyric mountain
#

sorry but, there's nothing similar in them KEKW

#

that's just the standard documentation structure

eternal osprey
#

do you know that by any chance?

raw nest
lyric mountain
#

ye

#

there's a standard for documentation writing

#

like there is for scientific research structuring

#

if u want a builder for something similar, there's https://readthedocs.org/

eternal osprey
#

So don't worry about b, it's easy. However i would need an easier function for that one above

#

So we need to prove a

lyric mountain
#

there are also a thousand other builders tho, just choose ur flavor

eternal osprey
#

I already came up with a solution, but it's a hard formula so that would be too hard to proof in the inductive step

raw nest
#

bruh okay I was thinking about basic swagger first but it's kinda ugly 👀

lyric mountain
#

that's asking u to write the direct formula

eternal osprey
#

yeah

lyric mountain
#

well, u could use sigma notation

#

if ur teacher allows it

eternal osprey
#

so without having to use the summation part. So for example n = 3 would immediatelly return us 7/8

eternal osprey
#

we need something simpler with the use of /, 2, * , ^

lyric mountain
#

f(x) = 1 / 2 ^ x

eternal osprey
#

That's the same as the base summation formula,

lyric mountain
#

I don't really get what exactly u want

eternal osprey
#

And it wouldn't suffice as take x = 3, it would return 1/8 instead of 7/8

#

have you ever had mathematical induction and summations?

lyric mountain
#

it'd return 1 / 8

#

1 / (2 ^ x)

#

remember bodmas

#

wait, just reread what u wrote

#

why should it return 7/8?

eternal osprey
#

That last formula you see is the base formula, but this is a summation. So that means that you need to add each value up to each other. So imagine you have n = 1, you get 1/2. N = 2 gives 1/4 etc etc. But remember, it's a summation! So n = 2 would give 1/4 + 1/2 = 3/4

#

and so on

#

so n = 3 = 1/8 + 1/4 + 1/2 = 7/8

#

have you ever had mathematical induction?

lyric mountain
#

can't u really use sigma?

eternal osprey
eternal osprey
#

when i enrolled for this cs university class i expected coding instead of doing this 😭

lyric mountain
#

cs? I don't see where tf you'd use something like that lmao

wheat mesa
#

There’s a lot of math

lyric mountain
#

yeah but...not something like this

eternal osprey
wheat mesa
#

Just do [(2^n) - 1] / 2^n

#

Easy

eternal osprey
#

It's because i enrolled into an university instead of college. In college they mainly focus on coding.

eternal osprey
lyric mountain
#

a proper cs answer would be simply ```c
double x = 0;
for (int i = 0; i < n; i++) {
x += 1 / Math.pow(2, i + 1);
}

eternal osprey
eternal osprey
wheat mesa
#

I’ve never had a discrete math class

eternal osprey
#

oowh

wheat mesa
#

What is the format for answering this question

eternal osprey
#

Let me send you an example of a proof

quartz kindle
#

methmatics

sharp geyser
eternal osprey
#

As you see, they had the base formula 2i + 1 right?

lyric mountain
#

are u sure u joined cs and not math?

wheat mesa
#

So do sigma notation

eternal osprey
#

Now they wanted to find a formula that equals to sigma 2i + 1

#

which would be n^2

#

and we need to find such formula as well

wheat mesa
#

I don’t think I understand

eternal osprey
#

Ah

wheat mesa
#

I should be studying for my calc test next period 😭

eternal osprey
#

I should've never enrolled into computing science bro

#

wtf is this

#

like 80% is maths that fuck my ass

wheat mesa
#

99% of colleges/universities will require you to take a discrete mathematics class at some point

#

I don’t understand what the point of converting sigma notation into an n notation really is tbh, they’re just the same equations represented in different ways

eternal osprey
#

it's just a summation. You can call all numbers k, and the predicate holds for that k.

#

Now you need to prove that k + 1 holds as well

#

it's really vague and all, but thanks for trying

wheat mesa
#

I’m aware of what the notation means, I just don’t see the point

eternal osprey
#

Yeah they just want to fuck us

wheat mesa
#

Why would they not just allow you to write in sigma notation

eternal osprey
#

Because you wouldn't be able to proof it in the next steps

#

you would have to rewrite that same formula with k + 1 as parameter

wheat mesa
#

Why they gotta prove basic math 😭

eternal osprey
#

It's because in basic maths, they assume that something holds and thus is true, but that ain't really the case

eternal osprey
#

The top one

#

this is one example for you

wheat mesa
#

Then it’s just (2^i - 1)/2^i = k / k+1 no?

#

When i starts at 0

eternal osprey
wheat mesa
#

Oh wait yeah

eternal osprey
#

I used to have that answer yeah

#

for n > 1

wheat mesa
#

I gtg now, gl with that question

eternal osprey
#

wahahhaha alrighty, thanks mate

wheat mesa
#

Might help to ask some math geniuses in another server

eternal osprey
#

It's okay, thanks and good luck with your classes as well

lyric mountain
#

that'd be much easier with loops ☕

raw nest
#

Is there a way to change the architecture in a devcontainer?

#

Probably not right?

lyric mountain
#

not sure what that mean, but isn't the architecture bound to the cpu itself?

raw nest
#

ye I was thinking about that too but 1 mom

#

I found out you can define platform: e.g. linux/amd64 in a docker-compose.yml file and that should work.

sharp geyser
#

Alright so question

#

Lets say I have

switch(t) {
  case ReadyOpCode: {

    // do some stuff relating to ready
    break;
  }
  PacketHandler[data.t](client, data)
  break;
}

Would this go through ReadyOpCode and then go to the PacketHandler and execute?

cinder patio
#

is that even valid syntax?

lament rock
#

I doubt it. You should have that logic outside of the switch

#

if you wanted to only do stuff if the op is one you recognize and a default handler using the default case

sterile lantern
#

my dns is cloudfare, but what type of certificate do i generate (client/origin) for a mailserver

lyric mountain
sterile lantern
#

these are the dns records for the mail server (and another txt w/ domain name)

lyric mountain
#

if u want a fall-through switch u must not use break

sharp geyser
#

That could be troublesome

lyric mountain
#

and yes, that syntax is invalid

sterile lantern
#

i have one rn but it doesnt work

lyric mountain
#

not that we have such weakness in java ☕

sharp geyser
lyric mountain
#

just put it outside the switch

sharp geyser
#
[Function (anonymous)]
C:\Users\dyeaa\Documents\github\misty\typescript\trick-or-treat\src\structs\Shard.ts:86
                                PacketHandler[data.t](this.client, data.d);
                         ^
TypeError: handlers_1.PacketHandler[data.t] is not a function

Am I missing something?

#

btw PacketHandler[data.t] is that [Function (anonymous)] thing

sterile lantern
lament rock
#

it might be an array

#

if it says object, then lmao

#

and store it in a variable and call it

sharp geyser
#

It says function

#

😢

lament rock
#

was gonna ask if it was a constructor, but that would throw an error about needing the new key word

#

iirc

#

idk

sharp geyser
#

Yea

#

But if it is a function why is it telling me its not

#

😕

lament rock
#

its possible you cant call anonymous functions but what do I know

sharp geyser
#

No you can call anon funcs

quartz kindle
#

just do if(PacketHandler[data.t]) PacketHandler[data.t](...)

#
const fn = PacketHandler[data.t];
if(fn) {
  fn(this.client, data.d);
} else {
  console.log(`received unknown or unsupported event: ${data.t}`);
}
sharp geyser
#

Oh that makes sense

lament rock
#

I love seeing stats like this so much

#

although I need to rethink some UI across the board

sharp geyser
sudden geyser
sharp geyser
#

That guild count

#

Pretty decent amount

quartz kindle
#

i removed my stats command because i removed sharding

boreal iron
deft rock
#

How can I get my bot to listen to a port?

quartz kindle
deft rock
#

got a doc on that?

quartz kindle
#

like what is the port gonna be used for?

deft rock
#

for my status page

#

all I need it to do is listen to for say port 420

radiant kraken
boreal iron
#

Ewww

earnest phoenix
#

Do you guys do packs for myths of moonrise

boreal iron
lament rock
lament rock
#

a music bot

deft rock
lament rock
#

but I was a lot more dumb back then as a dev so

deft rock
#

Bot doesnt respond to commands. I have GuildMessages intent also

wheat mesa
#

no code no help :C

lyric mountain
#

That sums it all

long marsh
#

I'm wanting to build a bot that has guild-level ranks + global. Global seems easy enough; however, what is traditionally done for guild-level?
Ie. when someone new uses a command for the first time in a server, simply add them to that "guild"
What about when they leave the server? Does the bot listen for that member leave?

#

Unless there's something stupid simple that I'm not realizing 🤔

lyric mountain
#

Ig I can answer that

#

For my bot I have only one kind of profile: local

#

The global profile being the highest one

#

You could have something like a profile with nested profiles, like loritta does

deft rock
lyric mountain
#

This that the advantage of allowing server owners to edit the user's xp without affecting the global level

#

But also has the disadvantage of having to keep track of two separate profiles at once

long marsh
#

Ku, I did not provide enough context. When I say ranks, I mean game ranks. There's a global leaderboard; however, I have an open feature request to implement guild-level ranking. I'm struggling on how I would capture when a user "leaves" a server so that they're not tracked anymore on the leaderboard for that guild. Unfortunately, I don't see a straightforward way of doing this without tracking who leaves a guild (which I believe requires an intent)

wheat mesa
long marsh
lyric mountain
#

U don't really need any tracking at all, simply check if the user is still listed on the guild's cache

#

Most libs will remove it as soon as the user leaves

#

If all else fails, try to fetch the member

#

It'll either return the member or not

long marsh
lyric mountain
#

There are only 3 priv intents

#

Guild messages, guild intents and...I don't remember the last one

#

But I don't recall guild members being one

long marsh
#

Gotcha. Does this work the same with slash commands?

#

I guess as long as the bot is in the server, it works 🤷

lyric mountain
#

Yeah, it does

long marsh
#

I also assume that my implementation may be an issue here. I'm not using the Discord Gateway to receive interactions - I'm using an outgoing webhook.

lyric mountain
#

How you receive ints isn't really a matter, all you need it to be able to access member cache

#

Tho that's considering you're using a lib

long marsh
#

Yeah, that's doesn't exist for Webhooks.

#

If I need to list the guild members from an API invocation, I'm out of luck here. That would require a privileged intent.

#

Ie. using a webhook, I don't have a physical bot at all.

lyric mountain
#

Then you can't really, it doesn't require a priv intent but you can't "see" the server unless you have a bot there

slim heart
#

why do you need a list of members for a level bot?

lyric mountain
#

Interaction-only "bots" are strictly a trigger-answer kind of bot

#

You can't do anything on your own

lyric mountain
#

If anything, simply show the whole learderboards regardless of the member being in the server or not

#

The excuse can be "they were once, and scored a rank"

long marsh
lyric mountain
#

People will always complain

slim heart
#

yeah you dont get GUILD_MEMBER_REMOVE w/o guild_members intent

#

but why not apply for it if your use case is there

long marsh
lyric mountain
#

Is members a priv intent?

slim heart
#

yes?

long marsh
#

I'm guessing they do this by using their bot's guild cache. (like Ku has been mentioning)

lyric mountain
#

I always remember there were 3, but I only remember the first 2

slim heart
#

the big 3 are message content, members, and presence

slim heart
#

you dont need a list of members in the server to do lists, if you have their user id you can just display their info

lyric mountain
#

Guild-level leaderboard is definitely possible, you just won't be able to track which members are STILL in the server

slim heart
#

which is what most level anything bots do

#

(people will get mad if they get reset for leaving the server anyways so double win)

long marsh
slim heart
#

if they dont have the privileged intent they dont know the user isnt in the server anymore

#

they likely just show them on the leaderboard anyways

#

your best solution is to not mind if someone has left and instead just have an admin command to remove people if they please

lyric mountain
#

Unless the user had to authorize through oauth2

long marsh
lyric mountain
#

Tho that'd be clearly obvious

long marsh
#

Anyone want to join my test server for a quick test? lol

slim heart
#

and obnoxious to actually implement at scale [^ku]

long marsh
#

I'm worried about the scalability of the solution that I choose, ofc.

lyric mountain
#

I'd not worry much about scalability for an interaction-only bot, the weight is much lighter than a regular bot

#

Unless you reach millions of servers

slim heart
#

i mean the oauth part

long marsh
#

A webhook bot is simplistic, hosting the API on a server and allowing discord to send events is dead simple (thankfully)

#

No libraries needed.

lyric mountain
#

There's not much you can do without either the intent or oauth

long marsh
#

Right

lyric mountain
#

As I said, interaction bots only see what gets interacted with

long marsh
#

Right, def aware

lyric mountain
#

User presses a button -> bot knows user pressed a button

#

Tbh that's part of the reason why I'd never be able to switch to interactions fully

ocean jay
#

Hello I need some help

slim heart
#

discord.js moment

#

i think you need to make sure the user isnt a partial

ocean jay
#

o

slim heart
#

which itll never be but add a check that redefines it after fetching the partial

ocean jay
#

ah alright

#

I'm using typescript and this is hell

lyric mountain
#

That's a djs thing tho, not specifically ts

#

The difference is that js won't tell u something is wrong until shit happens

long marsh
lyric mountain
#

It is, but it saves you from debug hell sometimes since it is typed

sharp geyser
#
case GatewayOpcodes.Dispatch: {
                switch (data.t) {
                    case GatewayDispatchEvents.Ready: {
                        this.#session_id = data.d.session_id;
                        this.#readyAt = Date.now();
                        break;
                    }
                }
                if (PacketHandler[data.t]) {
                    PacketHandler[data.t](this.client, data.d);
                } else {
                    break;
                }
                break;
            }

This is largely how I handle events is this crude at all?

long marsh
lyric mountain
sharp geyser
#

It wont be just that one

#

Right now ready is the only one I do anything with internally though

#

I haven't done stuff with the other ones

lyric mountain
#

Btw u don't need brackets for cases

sharp geyser
#

It makes it look cleaner to me

lyric mountain
#

Unless u want to isolate variables

sharp geyser
#

I like the brackets being there cause it lets me know where it ends

lyric mountain
#

But yes, switch-case is probably the best way to handle such stuff

#

The alternative would be if-else, but it's horrible

sharp geyser
#

Yea lets not

#

I also have yet to implement rate limiting on the gateway

lyric mountain
#

Make sure you extract as much common code as possible from the branches tho

sharp geyser
#

So right now I can freely spam the gateway

lyric mountain
#

1 day ratelimit be like

sharp geyser
#

lol

#

I just don't know how I should handle rate limiting

lyric mountain
#

Listen to ratelimit header

sharp geyser
#

Gateway doesn't have that no?

#

only rest

lyric mountain
#

And make sure you don't retry any 4xx errors

sharp geyser
#

I am doing the gateway haku

#

I haven't touched any rest stuff yet

lyric mountain
#

Didn't touch gateway, so idk

sharp geyser
#

Yea

#

I had a semi working implementation a while back

#

I lost it tho

mortal jungle
#

hi

long marsh
#

No privileged intents. 🤔 ... I wonder how they did it

hasty mulch
#

Anyone familiar with listening for when a member gets timed out using d.py?

earnest phoenix
hasty mulch
#

Yeah, got that established now. Just working on the duration

rustic nova
#

timed_out_until on the member object

earnest phoenix
#

Yep

rustic nova
#

is None if no timeout is active

earnest phoenix
#

Returns an optional datetime, if timed out

rustic nova
#

is UTC based

#

let's be more specific

hasty mulch
rustic nova
#

the timedelta is based in utc

#

oh wait

#

yeah you can just convert a datetime to a timedelta if you'd want the duration

#

ngl discords built in way is good too, unless you need precision

#

oh you'd need to subtract the timeout until with the current time for that

hasty mulch
rustic nova
#

why not, what's the error

#

is it because there's some timezone-aware logic behind it?

hasty mulch
#

Can't subtract offset-naive and offset-aware datetimes, yeah

rustic nova
#

per stackoverflow, remove the timezone awareness

rustic nova
#

at least that's what I think lol

#

I'm pretty certain I had to deal with it before lmao

hasty mulch
#

Hold on, lemme ask UTC to remove its timezone, lol

rustic nova
#

lmaoo

#

or another answer from that same stackoverflow, datetime.now(timezone.utc)

#

but I don't think that's any different from utcnow

hasty mulch
#

No, would probably throw the same error

#

We could probably ask Discord to include a duration option in their API since the feature is so new

rustic nova
#

or an event itself entirely

#

which would make sense seeing what it does, such as disconnecting a user from VC, disallowing rejoining it etc

hasty mulch
#

Also, GitHub CoPilot wants me to use timed_out_reason. That doesn't exist, right? Lol

rustic nova
#

no lol doesn't exist

hasty mulch
#

Figured

rustic nova
#

if you're entirely fucked, you might need to fetch the audit logs for the reason lmao

hasty mulch
#

I was supposed to write a college essay two hours ago

rustic nova
#

lmaoo

hasty mulch
#

I think I'm going to stop here, lol

eternal osprey
#

hey guys, does anyone know what the & is in c++

#

like int function(int& test){}

#

Like why tf is there a &

#

and what is the difference between the above and this: int function(int test){}?

pale vessel
#

google?

eternal osprey
#

I tried

pale vessel
#

I see

eternal osprey
#

but i still don't understand the difference between them

pale vessel
harsh nova
rustic nova
#

must ask

#

what practical purpose do pointers have

#

you can essentially have a function that directly modifies the value without having to reassign it by the return value of that function right?

eternal osprey
#

I see! So imagine i have ```c++
int function(int& test){test = 5}

function(9);


 ```c++
 int function(int test){test = 5}

function(9);

```Now the variable test will be set to 5 as well?
rustic nova
#

you'd probably need another variable, but essentially on the second one, the "test" is within the function scope and doesn't change the value of the integer passed

#

on the first one, 9 would become 5

#

am I right family friendly

harsh nova
#

^ yeah that’s right

eternal osprey
#

Owhhh wow i understand it now

rustic nova
#

so tldr easier said:

& allows you to directly change the value of the variable you passed in

#

or better said, inherit

harsh nova
#

Normally it’s advised against mutating parameters passed to a function as that can lead to undefined behaviour

eternal osprey
#

So with the ```js
int function(int& test){test = 5}

function(9);This would indeed be set to 5. However forjs
int function(int test){return 5;}

test = function(9);```

#

Like thihs right?

#

Because we cannot change the test within the function, we must change it outside as we call by value

rustic nova
#

these are essentially the same mechanics yes, the second one benefits code functionality

eternal osprey
#

and in the first snippet we call by reference and can directly change the variable

rustic nova
#

readability*

eternal osprey
harsh nova
#

^ and you cannot access the test variable in the first example as you define it within the function parameters

rustic nova
#

well it depends on your goal:

  • readability for future Devs working on that route
#

or something else, can't tell what a benefit that has ngl