#development

1 messages ยท Page 2047 of 1

split hazel
#

discord js used to be a perfect lib (aside from the memory usage)

sharp geyser
#

๐Ÿ‘€

#

Maybe read the documentation of the lib you are using

sharp geyser
slender thistle
#

Serenity ๐Ÿ˜Ž

sharp geyser
#

You don't need to be advanced to read docs

sharp geyser
slender thistle
#

That's the point

split hazel
#

writing discord bots in statically typed languages rubs me the wrong way

slender thistle
#

Fair

split hazel
#

discord is very dynamic

#

it would only make sense for the language to also be dynamic

sharp geyser
#

I was trying to write a bot in java but the idea behind it is a bit annoying

#

My head hurts trying to understand the stuff I need to use

split hazel
#

bro dont even try

#

you have to queue message sends and shit

#

dont get the point

ancient nova
#

there is no lib for java

sharp geyser
#

You are wrong

ancient nova
#

you're gonna have to use raw api

sharp geyser
#

very very wrong

ancient nova
#

wdym

sharp geyser
#

JDA

#

dummy

royal portal
sharp geyser
#

It is literally THE lib to use when making a java bot

ancient nova
ancient nova
sharp geyser
#

This is what happens when people who don't know shit try and talk on a topic they know nothing about

#

you're lucky I wasn't a noob

sharp geyser
#

If you don't know shit don't talk about it

ancient nova
sharp geyser
#

use express

ancient nova
#

how long was it out for

sharp geyser
#

Years

#

almost since the bot api was a thing

slender thistle
#

JDA has been around for a LONG while lol

ancient nova
#

well it must've been smaller and I didn't notice it before

sharp geyser
#

hell

split hazel
#

hardcore discord.js and c++ developers trying to comprehend someone having a different opinion than you: ๐Ÿ˜ค๐Ÿฅต๐Ÿฅถ๐Ÿ˜ญ๐Ÿ˜ค๐Ÿ˜ค๐Ÿ˜ค๐Ÿคฌ๐Ÿคฌ๐Ÿคฌ๐Ÿคฌ๐Ÿคฌ๐Ÿคฌ

ancient nova
#

ยฏ_(ใƒ„)_/ยฏ

sharp geyser
#

I think they were even out when user accounts were being used as bots

slender thistle
sharp geyser
#

seems how it was the only discord lib in java at the time

ancient nova
sharp geyser
#

as far as I know anyway

#

or you just don't know as much as you claim

#

mr regex man

ancient nova
#

๐Ÿ˜ญ

sharp geyser
#

๐Ÿคทโ€โ™€๏ธ

sharp geyser
#

who else would we make fun of

#

:)

slender thistle
#

I'm supposed to be filtering URLs in Python but I'm too lazy to write a proper regex or check for them

earnest phoenix
#

something like this?

    blacklist.includes(word => {
        if (message.content.toLowerCase().includes(word)) message.delete() && message.author.send("Keep the use of Profanity out of our server!")
    })``` like this?
ancient nova
earnest phoenix
#

im new ok

slender thistle
sharp geyser
#

I mean still not half as bad as what you write

ancient nova
#

if (blacklist.includes(word)) { true } else {false }

earnest phoenix
#

I just want to export it from blacklist.js

ancient nova
sharp geyser
#

๐Ÿ‘€

slender thistle
ancient nova
#

just because I use regex doesn't mean I'm bad

sharp geyser
#

Yea sure

#

we can go with that ig

fathom sonnet
#

amm, stupid question: can I somehow make my bot to create and assign role to himself when he join some server?

ancient nova
earnest phoenix
#

so it takes the words from blacklist.json and deleted them with blacklist.js

slender thistle
#

Two contradicting statements in the span of few seconds

ancient nova
split hazel
#

ima just start spoonfeeding code explaining it is harder

sharp geyser
slender thistle
#

An example that could use improvement

ancient nova
#

he just said that he is new

slender thistle
rustic nova
sharp geyser
#

Aurel what are you doing here

rustic nova
#

requires manage_roles

#

hi

#

dunno

split hazel
#

no shit sherlock

rustic nova
sharp geyser
#

u supposed to lurk

rustic nova
#

Trying to literally avoid the pain from recoding this shitty verification thing I did in python

ancient nova
rustic nova
#

Because I didnt plan ahead

sharp geyser
#

never let the bad guys know ur here how else will you catch em

rustic nova
earnest phoenix
#

I feel stupid for not understanding what im doing wrong

#

damn

rustic nova
sharp geyser
#

kthxbai

sharp geyser
ancient nova
rustic nova
#

Python makes me hurt less than Java

#

just me not planning shit

ancient nova
#

if you want u can use what @sharp geyser wrote but it's more "advanced"

sharp geyser
#

I feel that

split hazel
#

anything is better than java

#

even brazil

sharp geyser
rustic nova
#

Now I'm literally writing some sort of "Program Process Plan"

#

So I dont fuck up shit again

sharp geyser
#

Seems like it does tho

ancient nova
sharp geyser
#

But I don't really know if there is a reason to do it this way

earnest phoenix
ancient nova
sharp geyser
#

I am shocked you didn't see an error trying that, unless you ignored it to ask here

ancient nova
slender thistle
#

Ignores the "learn basic js" message utterly

pine nova
#

๐Ÿ—ฟ

sharp geyser
#

they even checked it themselves

#

Skydust are you a mind reader?

split hazel
#

and just so you know the message author send code wont execute

slender thistle
#

Good luck getting hit in the face with the same broom more than once at this rate @earnest phoenix

ancient nova
#

can I spoonfeed?

slender thistle
#

I'm really not surprised

split hazel
sharp geyser
#

I wouldn't

#

that is just encouraging them the wrong way

slender thistle
#

If that's what you want, I'm not stopping you

sharp geyser
#

If you spoonfeed em they won't learn to try and solve it themselves

ancient nova
#

I mean

slender thistle
#

Not like they are trying right now...

#

Let them suffer consequences of their own actions

sharp geyser
#

Ah but the key is we are actually giving them advice

#

whether they listen or not is on them

split hazel
#

i'd say its fine to spoonfeed if you explain the code

slender thistle
sharp geyser
#

^

split hazel
#

trying to make them solve and make something they dont understand is hopeless

sharp geyser
#

It isn't they can't understand they don't try to

slender thistle
slender thistle
#

Sure thing. I'll be watching as well

pine nova
sharp geyser
slender thistle
#

Misty I'm gonna murder you

pine nova
#

lmao

sharp geyser
#

What this does is use what you were already doing, but checks if it doesn't include the word, if it doesn't it returns false else returns true

slender thistle
#

They don't need returns here

sharp geyser
slender thistle
#

You're just gonna confuse them even more

sharp geyser
ancient nova
#
// cache the json
const blacklist = require("./blacklist.json");

// compare "word" string to the blacklist json
if (blacklist.includes(word)) {
// delete the message. make sure "message" is defined
await message.delete();

//notify the author
return message.author.send("Keep the use of Profanity out of our server!");
} else {
 return;
}
earnest phoenix
#

so only thing I need to do is add
if (foundInText) {
message.delete();

ancient nova
#

it's hard writing code without vsc

slender thistle
#

No idea who you're talking about here lmao I didn't give any advice apart from judging

sharp geyser
#

Well true

lyric mountain
sharp geyser
#

I was reading baes message

slender thistle
#

Oh

sharp geyser
#

I noticed he returned booleans

#

so I assumed that is what was going on

slender thistle
#

lmfao

ancient nova
#

๐Ÿ˜ญ

sharp geyser
#

go back to writing your black magic java code haku

lyric mountain
pine nova
sharp geyser
#

btw haku

split hazel
#

i think y'all started coding yesterday

earnest phoenix
#

and how does the exports work?

sharp geyser
#

I tried making a cmd handler with reflections and failed miserably

ancient nova
earnest phoenix
#

module.exports?

ancient nova
sharp geyser
#

.contains is a thing in js?

ancient nova
#

it does what it says

ancient nova
split hazel
#

no includes needed

ancient nova
#

.Contains

#

case sensitive

pine nova
#

idk too first time hearing fr

ancient nova
#

hold on

pine nova
#

ye

#

knew includes but not contains

#

whats the difference

#

๐Ÿ’€

split hazel
#

my internet is so fucked it looks to me like chat is dead and im just talking to myself then a burst of 20 messages pop up

ancient nova
slender thistle
#

lol

pine nova
ancient nova
#

okay I was wrong contains doesn't exist in js weirdly enough

pine nova
#

lmao

slender thistle
#

Difference between includes() and contains()
The includes and contains both methods search for a substring within a string or find elements within an array. The includes() is a method present in JavaScript, whereas contains() is not present in JavaScript. It is used in other languages such as Java.

pine nova
#

yea not present

#

๐Ÿ’€

slender thistle
#

How does anyone still assume you to be a credible source for information, I wonder

earnest phoenix
ancient nova
# pine nova == ?

it's like indexOf, I think I got mixed up with c
"stringthis".Cotnains("this") // true

sharp geyser
#

Yea I was about to say

#

contains isn't a thing

ancient nova
#

but I could've sworn I ued it before

pine nova
#

i see

slender thistle
#

Probably in Java

ancient nova
sharp geyser
#

It is a thing in java yes

#

but not js

lyric mountain
#

they need to add a .has() method for 50% more confusion

slender thistle
#

๐Ÿ˜‚

ancient nova
sharp geyser
ancient nova
lyric mountain
#

ok so, usually you have everything accessed during compile time right? with reflection it's the opposite

ancient nova
#

you can use indexOf for this tbh

#

just make it into a function

lyric mountain
#

you don't know what something is during compile-time, only during runtime

sharp geyser
#

Ye

lyric mountain
#

reflection is awesome when you understand how it works

ancient nova
ancient nova
#

even though it's buggy the bugs can be helpful

still storm
#

hmm is it possible to disable "more like this" using css?

slender thistle
lyric mountain
sharp geyser
#

I understand the basic concept of how reflection works

#

But I have no idea how to practice using it

lyric mountain
#

or locating classes by @Annotation

slender thistle
#

Oh true

sharp geyser
#

you could also invoke them when you need to tho right?

ancient nova
#

I know this is a change of topic but do you guys like onions?

lyric mountain
#

in my command handler I just annotate command classes with @Command, the runtime finds them automatically

pine nova
sharp geyser
#

go away

#

:C

lyric mountain
#

reflection is meta-programming basically

ancient nova
still storm
lyric mountain
#

you use the context itself instead of the content

slender thistle
#

How does one write a basic URL filter?

sharp geyser
split hazel
# earnest phoenix ```const blacklist = require("./blacklist.json") (blacklist.includes(word)) ...
const tf = require("@tensorflow/tfjs");
const profanityModel = tf.sequential();
profanityModel.add(tf.layers.dense({
  inputShape: [200],
  activation: 'relu',
  units: 320
}));
profanityModel.add(tf.layers.dense({
  inputShape: [320],
  activation: 'sigmoid',
  units: 60
}));
profanityModel.add(tf.layers.dense({
  inputShape: [60],
  activation: "softmax",
  units: 2
}));
profanityModel.compile({{ optimizer: tf.train.adam(0.01), loss: 'meanSquaredError' });

const trainingData = tf.tensor2d([ ... ]);

model.fit(trainingData[0], trainingData[1], {
  epoch: 5000,
  shuffle: true
});
slender thistle
#

Preferably without using regex

ancient nova
sharp geyser
#

talk to bae he knows all about that

lyric mountain
pine nova
lyric mountain
#

use a lib for sanity

sharp geyser
#

he uses it in 90% of his code

ancient nova
sharp geyser
#

there is no good reason to use regex for nearly everything that can be done simpler

slender thistle
pine nova
#

idk i saw somewhere but forgot where

still storm
#

This feature is bad idea tbh

ancient nova
still storm
lyric mountain
#
#([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\xE000-\xF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\x00A0-\xD7FF\xF900-\xFDCF\xFDF0-\xFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?#iS
slender thistle
#

1 line of regex code is worse than 100 lines of normal code

split hazel
#

'use machine learning

slender thistle
pine nova
#

imagine knowing how to write a regex

sharp geyser
#

isn't using regex a performance hitter

pine nova
ancient nova
slender thistle
lyric mountain
#

the only thing more cursed than url regex is email regex

ancient nova
sharp geyser
#

performance go brrr

slender thistle
sharp geyser
pine nova
#

lmao

ancient nova
#

well...

slender thistle
#

And it shows

split hazel
#

he has a point

sharp geyser
#

Literally uses 200mb idle

ancient nova
slender thistle
#

I guess it just wasn't funny then

sharp geyser
#

Why do you think so many people go out to find lightweight modded clients for discord

slender thistle
#

Anyhoo, back to my question

lyric mountain
sharp geyser
#

discord claims to be for gaming but uses up a fuck ton of ram

ancient nova
pine nova
ancient nova
#

but I know why now

#

it was the cache from global illum

sharp geyser
#

you used regex everywhere?

slender thistle
lyric mountain
ancient nova
sharp geyser
lyric mountain
#

ye

split hazel
#

regex be like ยฃ%Qยฃ%&ยฃ(Q%&Qยฃ%$/426'246';2'462867236ยฃ%&ยฃ(%ยฃ(%

pine nova
#

i dont use it very much tho if i need for something i just find it on the net

lyric mountain
#

also, iirc regex is a HUGE green flag in ur curriculum

#

at least for data analyst

ancient nova
#

comparing strings is also easy with it

sharp geyser
#

I never bothered to learn regex I hardly find the need to use it

ancient nova
#

helped me solve many issues

sharp geyser
#

๐Ÿ‘€

#

comparing strings with regex

#

ah yes

ancient nova
#

well yes.. it's a good way to use regex

lyric mountain
split hazel
ancient nova
#

in some cases

lyric mountain
#

it works better than discord slashes, except for the UI part

#

it also allows a command to have many forms

ancient nova
sharp geyser
lyric mountain
#

I'm rewriting my entire codebase

ancient nova
#

smali

sharp geyser
#

Oh god

#

I don't wanna read your rewrite

lyric mountain
#

it's cleaner

sharp geyser
#

My head will explode

pine nova
#

imagine java

lyric mountain
#

I swear

split hazel
#

more than the actual language

ancient nova
#

it looks like machine code to a person who doesn't know smali

earnest phoenix
#

@sharp geyser

module.exports = async (prefix, client, message) => {
    const blacklist = require("./blacklist.json");

    let foundInText = false;
    for (let i in words) {
        if (message.content.toLowerCase().includes(blacklist[i])) foundInText = true
    }

    if (foundInText) {
        message.reply("Please don't use that word here")
        await message.delete()
    }
}
#

does this look better :/

ancient nova
split hazel
sharp geyser
#

just use the blacklist.includes()

#

unless it is not an array

ancient nova
lyric mountain
ancient nova
sharp geyser
#

So no one bothered asking

#

great

sharp geyser
#

If so just use blacklist.includes

ancient nova
split hazel
earnest phoenix
sharp geyser
sharp geyser
ancient nova
#

is it an array

sharp geyser
#

If it is an array then you have no need to loop

earnest phoenix
sharp geyser
#

๐Ÿ‘€

ancient nova
#

in an if statement

#

like I showed u in the very beginning

earnest phoenix
#

if (blacklist.includes(word)) {

await message.delete();

#

like this?

ancient nova
#

yes

split hazel
#

getting there slowly but surely

earnest phoenix
# ancient nova yes
module.exports = async (prefix, client, message) => {
    const blacklist = require("./blacklist.json");

    let foundInText = false;
    for (let i in words) {
        if (blacklist.includes(word)) {

            await message.delete();
    }

    if (foundInText) {
        message.reply("Please don't use that word here")
        await message.delete()
    }
  }
}
#

like this?

ancient nova
#

no need to loop

earnest phoenix
#

oh

ancient nova
#

no need for the global bool either

#

just the if statement is needed

#

blacklist.includes returns a bool already for u

sharp geyser
#

If it does include it you delete and send your message, if not do nothing

split hazel
#

we wont talk about that require inside the function

earnest phoenix
#

I want it to delete and send message

sharp geyser
sharp geyser
lyric mountain
earnest phoenix
#

hmm

#

why?

lyric mountain
#

it can easily be used to ratelimit ur bot

earnest phoenix
#

so instead of this:

ancient nova
earnest phoenix
#
module.exports = async (prefix, client, message) => {
    const blacklist = require("./blacklist.json");

    let foundInText = false;
    for (let i in words) {
        if (blacklist.includes(word)) {
            await message.delete();
            message.reply("Please don't use that word here")
    }
}
}
#

I need to delete message.reply

ancient nova
#

NO NEED FOR LOOPS

sharp geyser
#

If your bad word filter has a timeout doesn't that defeat the point tho

lyric mountain
#

make it like, delete up to 3 messages withing X time, then timeout the user for Y time

split hazel
#

you're telling me one step at a time for the require inside the function but y'all want them to add a timeout ๐Ÿ’€

sharp geyser
#

During that time out people can spam blacklisted words

sharp geyser
#

:c

ancient nova
#

maybe ban the person if they spam lol

#

c:

split hazel
#

lmao ban

earnest phoenix
# ancient nova NO NEED FOR LOOPS
module.exports = async (prefix, client, message) => {
    const blacklist = require("./blacklist.json");
        if (blacklist.includes(word)) {
            message.reply("Please don't use that word here")
            await message.delete();
    }
}
``` like this?
sharp geyser
#

One of the reasons blacklisted word filters are never done

earnest phoenix
#

aaaaaa i got it now

lyric mountain
sharp geyser
#

there is countless ways to get around them, and it will be hard to try and create a check and balance for all of em

ancient nova
split hazel
#

yeah but it sucks

sharp geyser
#

Cause that is really all you can do

earnest phoenix
#

so if someone spams maybe a timeout or mute?

#

or instant ban

#

after 3 times

ancient nova
#

I was joking

sharp geyser
#

Up to how you wanna handle it

ancient nova
#

with the ban

split hazel
#

machine learning is the only hope for filters

earnest phoenix
#

I dont have experience with it

ancient nova
#

say 30 minutes

split hazel
#

ban them for it

sharp geyser
split hazel
#

permanently

sharp geyser
#

a self reliant bot

earnest phoenix
#

so speedy telling me to let them get punished hard

#

kinda like that

ancient nova
#

this can be taken out of context

#

lol

split hazel
#

two messages sent at once? ban

ancient nova
sharp geyser
#

not the same user? who cares ban them both

#

seems suspicious

split hazel
#

i'd enjoy to colab on a machine learning project with someone

sharp geyser
#

I was joking cause I don't know machine learning

#

tho I do wanna try and learn it

split hazel
#

i dont know it much either ๐Ÿ’€

sharp geyser
split hazel
#

i only know the barebone basics

ancient nova
earnest phoenix
#
module.exports = async (prefix, client, message) => {
    const blacklist = require("./blacklist.json");
        if (blacklist.includes(word)) {
            message.reply("Please don't use that word here")
            await message.delete()
            then(() => message.member.kick('User kicked for sending spam links.'))
    }
}
sharp geyser
#

I don't even know the basics

still storm
ancient nova
#

based on what you're trying to do ofc

earnest phoenix
#

if im gonna ban or kick I can remove message.reply

#

right?

#

there is no need for that

split hazel
#

no tutorial will properly explain how popular ml algorithms work under the hood because if they did i'd already be a master at it

earnest phoenix
#

if the kick messages includes it

ancient nova
#

what's the then() doing?

#

try running that code and see what happens

sharp geyser
#

then() isn't even proper syntax

#

are you using notepad++ to code how are you not seeing errors

ancient nova
#

I suggest downloading vsc

#

and grabbing some intelisense extension in the process

earnest phoenix
#

let me try to run it

sharp geyser
#

you will see issues

ancient nova
#

I regret making the error handler

earnest phoenix
#

damn

#

I cant even run it

ancient nova
#

and you're using .then on literally nothing as if it was a method

sharp geyser
#

not even using a .

#

also delete does return a promise

#

but using await and .then is useless imo

oblique palm
#

If you want to set an welcome message for new members example:

#

how do we mention the user and guild?

#

automatically

quartz kindle
#

there is no guild mention

oblique palm
#

thanks buddy

woeful pike
#

I'm going in the rabbit hole wish me luck

lyric mountain
#

smooth

#

the concept of raytracing is pretty simple

#

for every light source you shoot N rays at all directions, the pixels hit by it get their lightness calculated

#

or reflection in the case of glossy surfaces

simple stump
#

I'm using useState for React in order to create a search function. However, whenever I use setResult, result get's overridden and not updated. Either that, or it says that result is null (because I set it to that of course, but I'm not sure how to approach useState).

const [result, setResult] = useState(null);
let types = ["array_of_links_here"];

for (let type of types) {
  const requestOptions = {
    ...
  };
  // Fetching works fine.
  fetch(config.api_server + "/search", requestOptions).then(async res => {
    let json = await res.json();
    console.log(result); // Always null. Never a JSON object.
    setResult(json); // Overrides result.
  }).catch(err => {
    console.error(err);
  });
}

// Display the results if there are any. Works fine, but since result is overriden, the results that are displayed are innacurate sometimes.
{result ? result.map(item => <Feature key={item.id} title={item.title} link={item.id} path={item.path} views={item.views} likes={item.likes} cover={item.cover} />) : ""}
ancient nova
#
fetch(...).then(res => res.json()).then(data => {
const json = JSON.stringify(data);
console.log(json); //output as json
});
#

at least that's how I would do it

simple stump
#

The problem isn't the output more-of just having issues with useState. But thank you fetch(...).then(res => res.json()).then(data) is a lot more efficient actually then what I have right now.

ancient nova
simple stump
#

Ah nw. I'm learning React atm so I'm quite confused myself haha

ancient nova
#

hope you resolve it! gl with learning

pale vessel
#

you're using setResult() inside a loop, that'll overwrite any previous type

#

is that what you want?

#

you should use arrays instead

#

useState([])

setResult(previousValue => [...previousValue, json])

wheat mesa
#

Why are you require()ing the json every time the function is ran ๐Ÿ˜ญ

pale vessel
#

does it really matter when it's cached

delicate zephyr
#

^^

#

node naturally caches it

wheat mesa
#

No but the problem is still the same

pale vessel
#

lmfao hi luke

delicate zephyr
wheat mesa
#

No need to require it every time the function is ran

delicate zephyr
#

I mean

wheat mesa
#

Just makes it more confusing

delicate zephyr
#

it literally doesnt matter and not really

simple stump
# pale vessel you're using setResult() inside a loop, that'll overwrite any previous type

That's the issue I'm having atm. Just switched to an array, but unfortunately now the array just stays empty.

const [result, setResult] = useState([]);
let types = ["array_of_links_here"];

for (let type of types) {
  const requestOptions = {
    ...
  };
  // Fetching works fine.
  fetch(config.api_server + "/search", requestOptions).then(async res => {
    let json = await res.json();
    console.log(result); // Array is always empty.
    setResult(result => [...result, json]);
  }).catch(err => {
    console.error(err);
  });
}

{result ? result.map(item => <Feature key={item.id} title={item.title} link={item.id} path={item.path} views={item.views} likes={item.likes} cover={item.cover} />) : ""}

json returns an array of JSON objects:
[{ id: "something", cover: "something", title: "something" }]

pale vessel
#

what happens when you log json? does it log the proper object?

pale vessel
#

i see

#

i honestly never used fetch without useEffect(), maybe try wrapping that whole code inside a useEffect()

simple stump
#

Ah okay. I'll try that.

#

I think it might be more of an issue with joining the two arrays together, so I'll first see if setResult(json) does anything

pale vessel
#

All right

#

it's also not asynchronous

#

it continues the loop without waiting for the previous type to be done fetching/setting

simple stump
simple stump
pale vessel
#

yeah you definitely need a useEffect()

#

it will rerun ALL the loops when it gets rerendered

#

it's a mess

pale vessel
#

and you also have to wait for all the requests to be done first

sharp geyser
#

doesn't useEffect just make it easier to make outside calls from the current react app?

#

I can't remember entirely what useEffect does

pale vessel
#

seems to be working

pale vessel
#

it could be used for that

#

but it also can be ran if one of the dependencies provided gets updated

#

in this case it runs once since i provided an empty array

sharp geyser
#

I see

simple stump
# pale vessel

Thank you! The issue though is that I only want to send a request when the user clicks the button. I believe useEffect is called on render.

#

wait nvm

#

oops

#

actually wait yea i thought i was missing smth. useEffect is only called on render. i cant call it on click

wheat mesa
#

what's you guys' favorite vscode themes

#

looking for suggestions

pale vessel
#

been rocking with dracula soft for a while

solemn latch
#

I use default dark ^_^

wheat mesa
#

cron job scheduler

#

and then just use date math to calculate the days left

spark flint
#

Or do what I did

#

Get the dare

#

Date

#

Compare to one in a text file

#

If different, send the message and update the date

#

And check every 0.5 seconds

wheat mesa
#

that works too

spark flint
#

Very badly

wheat mesa
#

if you want a consistent time each day though then use cron jobs

spark flint
#

This was really bad at coding era

pale vessel
wheat mesa
#

you can use a cron job in a discord bot...

#
sharp geyser
#

@lyric mountain got my cmd handler working thanks to ur code

lyric mountain
#

Nice, reflections?

wheat mesa
#

questionably so

sharp geyser
wheat mesa
#

(to the best of your ability ;))

lyric mountain
#

That's good, you'll eventually get the hang of it really well

sharp geyser
#

I honestly didn't expect it to work at first

wheat mesa
#

me when his command handler looks the exact same as yours moment

sharp geyser
#

I mean ๐Ÿ‘€

#

The best is the model of the worst

lyric mountain
#

Another good usage of reflection is getting variable data without referencing the variable

wheat mesa
#

a good usage of reflection is completely breaking all java semantics and repurposing the language for something completely unsafe ๐Ÿ˜‰

sharp geyser
#

Sounds like what you do on a daily basis

#

unsafe things

#

Idiot is typing...

wheat mesa
#

๐Ÿค“ I'll have you know I'm using rust recently

sharp geyser
#

๐Ÿท "I'll have you know I'm using rust recently"

lyric mountain
#

Like, let's say u have

public enum Stuff {
	A, B, C, D, E
}
var aColor = new Color(255, 0, 0);
var bColor = new Color(0, 0, 0);
var cColor = new Color(255, 255, 0);
var dColor = new Color(0, 0, 255);
var eColor = new Color(255, 255, 255);
sharp geyser
#

What are enums?

lyric mountain
#

you could get the proper color using the variable name as in <enum>.name().toLowerCase() + "Color"

sharp geyser
#

@wheat mesa the piggy told me they are different from ts enums

lyric mountain
#

Pr something like that

lyric mountain
#

They're basically final variables that can represent stuff like states, bitfields, keys, etc

sharp geyser
wheat mesa
#

"Look at his category enum"
Misty: "ok... wh-What the fuck?!"

lyric mountain
#

Enums are also O(1) access

lyric mountain
#

But well, those are command categories

#

With some additional info

#

Enums can have variables too, like classes

wheat mesa
#

never knew java had a Function<> generic class in the standard lib

#

Is that relatively new?

lyric mountain
#

Nope

wheat mesa
#

Thought I tried to look for something like that sometime and couldn't find it

lyric mountain
#

It's from the same batch as Consumer and Callable

#

Consumer gets a value, Callable returns a value, Function is the fusion of both

wheat mesa
#

Ah it's java 8 then

#

explains it, I think we use an older version in my cs class somehow

#

no stream api :C

sharp geyser
#

Imagine taking a CS class that actually teaches you something

lyric mountain
#

It literally represents a function, as in void aName(int n) = Function<Integer, Void> aName

sharp geyser
#

All mine did was teach me how to be more of an idiot

#

my CS teacher didn't even know what an algorithm is

wheat mesa
#

Used that same concept in a scuffed math parser I made in C# before I made a proper parser

lyric mountain
#

Ah

wheat mesa
#

let's just say it was... not a very good codebase

#

hence why I have since private-d it

#

Didn't work after I tried adding boolean expression support into it

lyric mountain
#

Triple booli check is valid in c#?

wheat mesa
#

wdym

lyric mountain
#

a = b > c < d

wheat mesa
#

that's lambda

lyric mountain
#

A

wheat mesa
#

c# uses lambda syntax similar to js

simple stump
wheat mesa
#

ok my brain is dying trying to understand rust lifetimes

#

this syntax looks like shit and I don't understand it at all rs pub enum Something<'a> { Something(&'a str), Nothing } like what does 'a even do

lyric mountain
#

Somethingn<'t> mmulu

sharp geyser
lyric mountain
#

Sure

sharp geyser
#

My idea was to use generics to give types to what my arguments could be. e.g

package dev.misty.interfaces;

import net.dv8tion.jda.api.entities.Message;

public interface Executable<T> {
    void execute(Message msg, T args) throws InterruptedException;
}
package dev.misty.commands;

import dev.misty.interfaces.Executable;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;

public class TestingCommand implements Executable<TestingArgs> {
    @Override
    public void execute(Message msg, TestingArgs args) {
        msg.getChannel().sendMessage("Hello " + args.target.getUser().getAsTag()).queue();
    }
}

class TestingArgs {
    Member target;
}

But when passing the stuff to the execute method in the message received event I have no idea how i should parse the args to be what they should be

#
        try {
            Main.cmdManager.getCommand(cmdName).command().execute(event.getMessage(), content.substring(prefix.length() + cmdName.length()).trim().split(" "));
        } catch (InterruptedException e) {
            System.err.println(e.getMessage());
        }
#

Right now this is how it looks.

#

I know if I want to use Member as a type for the argument i'd need to properly parse what the args given to into a Member but that is just an example

#

really i'd want to support any type for arguments

#

I'd likely need to make a parser of some sort

lyric mountain
#

Look at my rewrite branch command handler

#

It's hard to explain without some example backing it

sharp geyser
#

Are you talking about the SignatureParser?

lyric mountain
#

Basically you want to use regex to validate and parse the input into the proper type

lyric mountain
sharp geyser
#

Yea I tried looking at it but got very confused

#

aha

lyric mountain
#

It indeed is lmao

#

But well, you can either use space-delimited positional args and throw an error if the type doesn't match

#

Or use regex which can validate without attempting a cast

sharp geyser
#

I think I wanna use regex

#

I notice you make a Signature annotation

lyric mountain
#

The first thing you need to do is isolate the prefix

#

After that, the very first word before space will be your command name

#

Anything after that should be treated as arguments

sharp geyser
#

Yea

lyric mountain
#

My parser basically works based on a pattern matcher declared in the Signature annotation

sharp geyser
#

I see

lyric mountain
#

Based on that pattern, it can extract named parameters, and allow optional arguments too

#

Which is noted by :R on it

sharp geyser
#

I see

lyric mountain
#

This is just how I do it, you have a myriad of ways to parse your input

#

I like the pattern structure because it feels easier to read and work with

#

(also I spent 3 hours writing a custom linter for it)

sharp geyser
#

This all does seem a bit more complex for me to handle rn

lyric mountain
#

Start for the bottom, simple space-delimited params

sharp geyser
#

Waffle was right about this being a complex situation aha

lyric mountain
#

Thrn work your way to the top

sharp geyser
lyric mountain
#

!!command param param param

sharp geyser
#

Ah yea

#

Btw, if you were to use a command in ur bot that took in input how would it look?

#

Say the kick command

lyric mountain
#

The pattern?

sharp geyser
#

like how would the use of the command look

lyric mountain
#

Idk, like s!kick @user

sharp geyser
#

I see

#

I was wondering cause I am not entirely sure how you actually use the @Signature annotation when parsing

lyric mountain
#

Like, let's say I have a mute command

#

s!mute @user time
Patterm would be
<user:user:r> <time:text:r>

sharp geyser
#

user:user:r

lyric mountain
#

The parser would look at the command's signature and see if the input matches

sharp geyser
#

first I assume is the name of the argument, second is the type, and r is required?

lyric mountain
#

Ye

#

That in the case of my parser

#

Yours can be any structure u want

#

But as I said, no need to write a whole parser yet

#

Start simple

#
String input = ...;
String prefix = <get from db>;

if (!input.startsWith(prefix) return;

String[] args = input.replaceFirst(prefix, "").split(" ");
String cmdName = args[0];
args = Arrays.copyOf(args, 1);
#

Something like this

#

Obv u need to case-proof it, but that's just an example

#

(note: it might be worthy to use \\s+ in split in case of multiple spaces)

sharp geyser
#

I am already sorta doing that

#

a space delimited argument

lyric mountain
#

An easy way to do a type-checking (only for primitives) would be an array of classes

#

Like [String.class, Integer.class, Integer.class] for 1 word param and 2 int params

#

Just compare the arg index with the type array entry

#

There are really a ton of ways to check types

sharp geyser
#

Yea I might make an actual parser though as I want to support any types, primitives, JDA's or my own

lyric mountain
#

Jda gives u the regexes for all mentionables btw

#

I don't remember in which class tho, but they're constants

sharp geyser
#

Oh nice

pine nova
sharp geyser
#

I kind of like your method of parsing arguments

lyric mountain
#

Lul ty

sharp geyser
#

but ima try and come up with my own way to challenge myself

lyric mountain
#

If u want I can give u a commented version of SignatureParser

#

So u can understand what each line is doing

sharp geyser
#

If you are free to do so

#

It would be rather helpful

lyric mountain
#

Sure, I'll resume the rewrite tomorrow anyway, so I can do it befote I start

sharp geyser
#

kk

#

ty

compact pier
#

is there anyway to trim the length of a string?

#

because I want to post my console error to discord webhook

#

but max char is 2048

cinder patio
pine nova
#

๐Ÿ’€

compact pier
#

server perfomance

#

but it is good?

#

like the perfomance?

cinder patio
#

yeah I don't know why u guys are laughing lmao

compact pier
#

because I think it would be unefficient

pine nova
#

loop through first 2048 charas of string and concat them weirdsip

cinder patio
#

It's definitely more efficient than whatever you'd write

#

because it's an in-built method

compact pier
#

okk

spark flint
#

no

#

@ivory siren

ivory siren
#

-needdev @round crow

gilded plankBOT
#

@round crow

You seem to be asking for something you don't have experience for or something that hasn't been done yet, but really need for your bot/server.
You can hire developers from Fiverr or Freelancer to code the things you need for your bot/server.

ivory siren
spark flint
sacred aurora
#

does ephemeral response only work with slash command?

spark flint
#

with any interaction

#

works with button clicking, select menus etc

round crow
spark flint
#

That would class as advertising

#

Because you were trying to recruit users for your platform

ivory siren
#

Yep, this isn't right place to advertise

#

If you have any problems related to development you can ask here Yay

round crow
#

got it ๐Ÿ™‚

#

any ideas where could I reach out for fellow discord developers? looking to work closely with some builders giving them the platform for free in turn of quality feedback

spark flint
#

post on reddit or something

#

or a forum

#

just not in discord servers, as it would count as advertising

round crow
#

thanks!

spark flint
#

also my dms isnt a good place to advertise

boreal iron
pine nova
#

๐Ÿ’€

spark flint
sacred aurora
#

is it possible to await a component from an interaction reply?

const msg = await interaction.reply({content: "..", components: [...], ephemeral: true});
msg.awaitMessageComponent(...)

it says msg is undefied if i do that

#

maybe i should fetch the reply first

pale vessel
#

yeah set fetchReply to true

vale garden
#
    await interaction.showModal(modal);

    const collector = interaction.channel.createMessageComponentCollector({
      componentType: 'TEXT_INPUT',
      time: 15000
    });

    collector.on('collect', i => {
      if (!i.isModalSubmit())
        return;
      // .... more code ....
    }

i have this code, but the collector isnt listening to the values typed in the modal and im not able to submit the modal itself, any help?

(using a seperate interaction listener did work but i want to know if its possible to listen to the submit within the same code where it is sent)

boreal iron
#

Not sure if a modal is treated like a normal component

#

Await the reply sending the modal then use the following method

vale garden
#

oh thanks

vale garden
# boreal iron <https://discord.js.org/#/docs/discord.js/stable/class/CommandInteraction?scroll...
await interaction.showModal(modal);

    const filter = i => i.customId === 'embedModal';
    interaction.awaitModalSubmit({ filter, time: 15_000 })
      .then(async i => {
        const name = i.fields.getTextInputValue('nameInput');
        const title = i.fields.getTextInputValue('titleInput');
        const description = i.fields.getTextInputValue('descriptionInput');
        const color = i.fields.getTextInputValue('colorInput');
        const image = i.fields.getTextInputValue('imageInput');
    
        console.log({ name, title, description, color, image });

        await i.reply("Modal submitted!")
      })
      .catch(console.error);
``` this is my code now
#

but awaitModalSubmit doesnt register the submit and ends automatically after 15s

white steppe
#

have you given it the slash commands intent in the oauth developer portal?

#

not just 'bot'

#

you will need to regenerate/re-add from URL too

boreal iron
split hazel
#

bro really made a bot that reminds him when his birthday is

#

whens your birthday

#

so i can confirm the cron

#

ah daily

#

but yeah that cron looks good

#

you can set it to a minute to test it

spark flint
#

do you not use code blocks for evals??

#

why lmao

#
this is much nicer```
#

like i do

#

b!eval js //code here

lyric mountain
#

also u get highlighting

vivid fulcrum
#

which djs version are you using

#

๐Ÿค”

#

can you post your code showing what member is?

split hazel
#

๐Ÿ’€

slender thistle
#

Isn't mentioned already a Member?

solemn latch
#

Why not getMember directly?

#

I've not used interactions much so I might be wrong, but don't you need to edit the interaction command itself aswell?

#

I'm not sure why getMember wouldn't work for you.
whats logged in that console.log(mentioned)?

boreal iron
#

I doubt timing out a member already existed when djs 13.1.0 was a thing

#

You should check the docs selecting that specific version and make sure

solemn latch
#

oh, good point

#

13.1.0 isnt even listed on the docs anymore ๐Ÿ‘€

boreal iron
#

Well

#

Canโ€™t even find it for 13.2

#

The features isnโ€™t that old tbh

solemn latch
boreal iron
#

Well to the latest tbh

#

There are quite a lot bug fixes and changes

#

I doubt there are breaking changes between 13.1 and 13.7

solemn latch
#

lowest version with timeouts 13.4.0, but yeah latest makes the most sense.

boreal iron
#

Like I said I donโ€™t think there are many changes between those versions

#

huh 13.8

#

Did I miss something

#

Hmm

#

Published 19 hours ago

#

Huh not even a changelog yet

spark flint
boreal iron
#

Should have been called 13.7.1

#

But okay

lyric mountain
#

here's the ban command in case u need an example of it being applied

pine nova
lyric mountain
#

the programming language is java, the pattern language is shirosig (my own)

boreal iron
#

God save us

lyric mountain
#

at least I get real threads u.u

vivid fulcrum
#

c# gets real enums

lyric mountain
#

real enums?

#

I think ur confusing java with ts, java does have enums that are enums

timid geyser
#

so I installed everything I needed as I'm on a new machine and

#
  • D:\bot\Main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (D:\bot\Main.js:2:17)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ 'D:\bot\Main.js' ]
    }
#

๐Ÿ’€

wheat mesa
#

Did you copy your node_modules folder from somewhere?

dusk vault
#

Java is so shit and verbose

lyric mountain
#

Tell me you don't code in java without saying you don't code in java

dusk vault
#

Uh what

#

I spent 2 years writing Java code before I switched to Kotlin

lyric mountain
#

Tsk tsk

#

Also, one of java's strong points in being verbose

dusk vault
#

There is none KEKW

lyric mountain
#

Debugging is stupidly easy because of that

split hazel
#

10 minutes to write a hello world program

dusk vault
#
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

vskt fun main() { println("Hello, world") }

#

ain't no way you prefer the former

#

besides, the latter's literally "fun" KEKW

lyric mountain
#

Ok, now what's the name of the class, and how u get cmdline args?

dusk vault
#

there is no class :P

lyric mountain
#

What is its visibility?

dusk vault
#

you don't need a class at all for Kotlin

#

files can contain functions

lyric mountain
#

But what if I want one?

dusk vault
#

you can write it the same way if you really want

lyric mountain
#

Ok, then use proper examples

dusk vault
#

welp, you're def not worth my time

#

lmao

lyric mountain
#

???

dusk vault
#

you're a skid

lyric mountain
#

Lul tf is this?

#

You come out of nowhere, with baseless arguments and call me a skid?

dusk vault
#

baseless arguments, you just can't understand basic things lmao

lyric mountain
#

I told u to use comparable examples

dusk vault
#

that was one

#

it's the same code behavior

#

if you can't see that, I don't know what to say

lyric mountain
#

The top code has visibility info, class info and cmdline argument access

dusk vault
#

Java is a broken and outdated language and VM

#

Kotlin is an attempt to fix it

dusk vault
lyric mountain
#

C++ is outdated af, yet it can't be replaced

dusk vault
#

whatever bro

#

blocked

#

not worth my time

#

any actual developers here or does everyone use Java lmao

split hazel
#

never thought i'd say that about something

dusk vault
#

C++?

split hazel
#

the aims of c and c++ are departing

#

yes

dusk vault
#

it's kind of a mess

#

low level roots with modern stuff that doesn't really fit built on top

split hazel
#

even though its born from c i think it still couldve been a great language

dusk vault
#

Rust is a lot nicer imo

split hazel
#

its mainly the std library thats a problem

#

some of the features are too modern and aim to make things simpler instead of faster

dusk vault
#

Java meets C KEKW

cinder patio
dusk vault
#

They do the same thing

cinder patio
#

the first one prints Hello, world! while the second one prints Hello, world

#

big difference

dusk vault
#

lol

#

did I forget the !

#

damn

lyric mountain
#

ok I'm back

dusk vault
#

typing on iOS

cinder patio
#

you're a skid if you forget such important details

#

get outta here

dusk vault
#

bet

split hazel
#

ios programmer opinion immediately disregarded

lyric mountain
dusk vault
#

going to be working full time for Chia before I'm 18 actually

#

:P

lyric mountain
#

going to, ok ok

#

that explains most of it

cinder patio
#

and what you're gonna be paid in crypto ๐Ÿ’€

dusk vault
#

I'm working 30hrs/wk rn

lyric mountain
#

wait, there's a meme for this scenario

lyric mountain
#

lemme see if I find it

dusk vault
#

irdc

split hazel
#

1 dogecoin payment

wheat mesa
#

oh no no no overconfident dev moment KEKW

dusk vault
#

how so

wheat mesa
#

god complex

dusk vault
#

how so

wheat mesa
#

as a developer you're legally required to have imposter syndrome

#

not the opposite

dusk vault
#

lol

split hazel
dusk vault
#

im also particularly edgy rn cus im sick

#

ยฏ_(ใƒ„)_/ยฏ

dusk vault
cinder patio
#

that's false. just use smart pointers

#

and boom you're writing JS

split hazel
#

(they sometimes dont write good code)

dusk vault
#

lmfao

cinder patio
#

shared_pointer everywhere

dusk vault
#

cringe

split hazel
#

smart pointers ๐Ÿ’€

cinder patio
#

yeah

#

not dumb pointers

#

like u

dusk vault
#

LOL

split hazel
#

you give: performance and speed
you receive: sanity

lyric mountain
#

nah cant find it, don't know exactly what to type to search for it

dusk vault
#

skill issue

cinder patio
#

unique_pointer is most likely just as fast as the regular pointers

#

and it prevents so many issues

dusk vault
#

unique as in borrow checked or what

cinder patio
#

unique as in one owner only

dusk vault
#

ah like it can't be copied

split hazel
dusk vault
#

sounds harder to make a major mistake with

wheat mesa
#

imagine thinking c++ has memory safe borrow checking ๐Ÿ’€

dusk vault
#

lol I'm sure there's a macro for that

#

that takes 6 hours to expand

cinder patio
#

I mean if you fuck up with smart pointers then you're just dumb๐Ÿ˜ฉ

#

and that's ok

dusk vault
#

I tried C++ for a while and just switched back to Rust

lyric mountain
#

anything can be fucked with if you try hard enough

dusk vault
#

couldn't handle the spaghetti

dusk vault
#

lol

split hazel
#

rust developer realizing some things just cant be performed safely and you have to use unsafe code sometimes

cinder patio
#

When 90% of the rust std is inside unsafe blocks ๐Ÿ’€

wheat mesa
#

i need to learn how rust lifetimes work

#

I don't understand it

dusk vault
#

It's just the language itself I dislike

split hazel
#

rust making you mark operations to a static global integer as unsafe just because of race conditions even though you dont use any threads

wheat mesa
#

I understand when variables go out of scope and are therefore destroyed but I have no idea what this 'a syntax does

dusk vault
#

tells the compiler how long a variable is alive

wheat mesa
#

I know but I have no idea how to use it

dusk vault
#

it's a bit of a mess

#

lifetime elisions are great tho

wheat mesa
#

someone told me to do this ```rs
pub enum TokenValue<'a> {
String(&'a str),
Number(f64),
}

dusk vault
#

the str reference lasts as long as the enum itself

cinder patio
#

It means the string will live at least as long as TokenValue lives

wheat mesa
#

This seems almost like the async await curse in c# where it spreads throughout your code like a disease

dusk vault
#

you can also just use String if you don't want to use a reference

cinder patio
split hazel
#

rust users when you turn a reference into a pointer: ๐Ÿ’€

wheat mesa
#

Oh you don't need to bother with actually doing anything special once the struct is instantiated?

dusk vault
#

Raw pointers kinda defeat the purpose of the borrow checker if you don't need them

cinder patio
#

rust doesn't have safe pointers

split hazel
#

rust out here making you define every field of a struct with no way to assign default values

dusk vault
#

there's #[derive(Default)]

#

but it's basically only for zeroed values

#

I think

wheat mesa
#

Ok so what I'm understanding here is the reason I need to use a lifetime here is because the reference to the string could potentially be dropped in the code and when I try to reference it in the struct for say a function or something, it's unsafe?

dusk vault
#

yes

cinder patio
wheat mesa
#

And this is a practice I should follow for all reference fields in a struct?

dusk vault
#

in some cases the compiler infers that though

#

yeah it'll require you to generally

#

but you can reuse the same lifetime parameter

wheat mesa
#

Ok ok

#

I think I understand now

cinder patio
#

any data in the struct cannot be freed before the struct itself

cinder patio
wheat mesa
#

Yeah that makes sense

#

I didn't understand it because last night was the first time I actually tried to understand what lifetimes do

dusk vault
split hazel
#

c developers realizing rust has no malloc: ๐Ÿ˜ฑ๐Ÿ˜จ๐Ÿ˜ฐ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ฎโ€๐Ÿ’จ๐Ÿคฌ๐Ÿคฌ๐Ÿคฌ

dusk vault
#

I've been learning Rust bc of the Bevy game engine

wheat mesa
#

c developers realizing they don't get to cast 30 different void pointers to 20 different types in rust

dusk vault
#

it's a pretty based language

#

C developers realizing Rust doesn't pollute the global namespace

lyric mountain
#

it's actually not recommended to namespace std

dusk vault
#

that's not a Rust nor C thing

wheat mesa