#development

1 messages Β· Page 180 of 1

civic sundial
#

idn't understand

#

okee

warm surge
#

client.on('ready, async () => {
await client.application.commands.set(arrayOfSlashCommands)
})

warm surge
deft wolf
# civic sundial idn't understand

There are 2 types of commands: global and server. Your code tries to create server commands on a server where your bot is not allowed to do so. You most likely added the bot without application.commands

civic sundial
#

@deft wolf still same

deft wolf
#

Then I can't help you if the bot is on the server where you want to create commands and you added it again with the appropriate permissions. This is something you have to deal with yourself because all I could do was already done

civic sundial
deft wolf
#

Yep, command name must be lowercase

civic sundial
#

and worked

#

thanks dude

lament rock
#

sql has a time and place which isn't always. Object storage is no place for sql and is more suited for solutions like redis

#

by "Object" I mean ephemeral data which is usually a json encoded string

#

The Object storage that people refer to when talking about cdns is its own monster

solemn latch
#

How am I just now discovering ??= In nodejs.

lyric mountain
#

aka a cache

#

but yeah, I do agree that no-sql is the best option when you need to store a lot of arbitrary data with no relationship whatsoever

lament rock
#

yup I said ephemeral for a reason

#

redis does have persistence but it isnt meant to be persistence

tulip ledge
lyric mountain
#

assigns if null

solemn latch
#

It's an null coalescence assignment

It's like x ?? y
But it assigns Y to x if x is null.

let x;
const y = 2;

x ??= y

x is now 2

#

Great for default values.

lyric mountain
#

it works especially great for web/app frameworks like react or flutter

#

because it'll assign a component to a variable on the first render, and then use it without recreating

lament rock
#

null or undefined

#

not just null

flat copper
#

im getting: error on saving mongo data


    let Guild = client.mongoManager.Guild;
    let id = int.guild.id;

    let guild = await Guild.findOne({ _id: id });
    if (!guild) {
      guild = await new Guild({
        _id: id,
      }).save();

      guild = await Guild.findOne({ _id: id });
    }

    guild.roles.push({
      contract,
      role,
    });

    await guild.save()
lyric mountain
#

in your case, if I'd have to bet, it'd be ```json
{
guild_id: "12345",
members: [
{
user_id: "123",
guild: {
guild_id: "12345",
members: [
{
user_id: "123",
guild: {
guild_id: "12345",
members: [
...
]
}
}
]
}
}
]
}

#

the guild has members, which have that guild, which have members, which have that guild, ad infinitum

#

so either remove the guild from the member, or remove the members from the guild

#

optionally, use a proper database for relational data

flat copper
#

oh okay

#

thanks!

eternal osprey
#

but whenever i need to create a normal program that needs to store data, i usually would prefer sql over nosql anytime

lament rock
#

definitely

eternal osprey
#

i haven't used nosql a lot of times, just a few for some smaller projects. However, what i really liked about sql over any nosql database was that in sql you actually can see the whole structure of the database as a sort of table

#

which is like so easy to search through and it provides a clear overview of what you are doing

#

it's structurally well defined. Not sure whether something like mongo uses such way of storing and displaying as well?

eternal osprey
coral phoenix
#

my regexing skillz are great

eternal osprey
#

still code goofy af

#

\0/

coral phoenix
#

ik lol that's why I kept it

#

I like myself some goofy code

eternal osprey
#

we got something in common

coral phoenix
eternal osprey
#
public static void BFS(int[][] graph, int source) {
        state[] explored = new state[graph.length];
        int[] predecessor = new int[graph.length];
        Queue<Integer> frontier = new LinkedList<>();
        colors[] coloring = new colors[graph.length];
        coloring[source] = colors.RED;
        for (int i = source + 1; i < graph.length; i++) {
            explored[i] = state.UNDISCOVERED;
            predecessor[i] = -1;
        }
        explored[source] = state.DISCOVERED;
        predecessor[source] = -1;
        frontier.add(source);

        while (!frontier.isEmpty()) {
            int CurrentElement = frontier.remove();
            for (int i = 0; i < graph.length; i++) {
                if (graph[CurrentElement][i] != 0 && coloring[CurrentElement] != coloring[i]
                        && explored[i] != state.DISCOVERED) {
                    predecessor[i] = CurrentElement;
                    explored[i] = state.DISCOVERED;
                    frontier.add(i);
                    if (coloring[CurrentElement] == colors.RED) {
                        coloring[i] = colors.BLUE;
                    } else {
                        coloring[i] = colors.RED;
                    }

                }
            }
        }
        System.out.println("\nMatches and Chosen Colors:");
        for (int i = 0; i < edges; i++) {
            System.out.println("Vertex " + i + " Color: " + coloring[i]);
        }
    }```
#

goofy, but i mean it works

coral phoenix
#

if it ain't broke don't fix it

eternal osprey
#

it's slow tho

#

but i am unsure on how to fix the algo

coral phoenix
#

I only like goofy code when it's fast

eternal osprey
#

its runtime is 0(V + E)

#

yeah but this code is a 2-coloring algo

#

it's hard to make it faster than this i think

#

unless i remove bfs and move on to something faster..

#

bipartite matching maybe? Using capacity scaling or edmond karp?

coral phoenix
#

Microsoft and Mojang do have really goofy code

eternal osprey
coral phoenix
#

their backed is the goofiest

#

let me show something rq

#

goofy

#

good trailer

eternal osprey
#

code looks okay tho

#

what's the goofy part

coral phoenix
#

goofy handling mostly and easter eggs

#

and they really can't spell

eternal osprey
#

is that mojang?

#

bro i just realized, null === ... hell nah

#

why tf they checking null values like that

coral phoenix
#

descrpition

#

it's active

#

lol

coral phoenix
spark flint
#

that indentation pains me

coral phoenix
spark flint
#

why arrays

coral phoenix
#

linked creators

#

it's marketplace creators

#

when one of the creator names uploads an item the channel gets notified

#

and want only one linked channel per guild

#
  • I need to do it that way because I'm using firestore
#

it's weird

#

there are so so many edge cases that it makes me want to die faster

spark flint
#

i just find that painful

coral phoenix
#

it is

coral phoenix
#

mostly because the microsoft official library sucks ballz

spark flint
#

lol

civic sundial
#

everything was fine until i registered second command

#

@warm surge @grim aspen @deft wolf

lament rock
grim aspen
#

Man imma have to start setting a schedule in this channel of when I’m available. Was about to go to bed.

lament rock
#

You arent obligated to help. Just live your life

grim aspen
#

True

sharp geyser
#

what is that

#

Is that even possible in js

radiant kraken
sharp geyser
#

why does that look cursed

radiant kraken
#

js itself is cursed

#

@sharp geyser sorry for being inactive with your project, i've been really busy lately

#

the first half of 2024 is not really the best time to code

sharp geyser
#

all good

#

i've been inactive as well

scenic kelp
#

ngl i did not know that

sharp geyser
#

same

#

so like what is the point

pale vessel
sharp geyser
#

yea but I see no practical use outside of it

wheat mesa
#

how do I treat functions as variables guys

#

this is quickly becoming a clusterfuck of a language

#

I guess I check the type of the callee's arguments, and if it has a function I look at my functions table for what was passed in

#

I am rubber ducking because this problem is very specific to my poor design decisions and I am sorry

wheat mesa
#

so it makes sense you can define objects with variable keys like that

pale vessel
#
someFunctionCall({ [key]: "value" });`
wheat mesa
#

fuck this is disgusting

#

I guess it's my fault for having a TypeAnnotation enum and a TypeInfo enum

#

but to my actual question, what would be the "idiomatic rust" way of doing lines 42-45

#

Some combination of .iter().some_function().collect()

#

I tried .map but since from_annotation returns a result, the closure wants to collect into a Vec<Result<TypeInfo, TypeError>> when I really just need it to bubble errors up and collect into Vec<TypeInfo>

sharp geyser
#

but like

pale vessel
#

yes, that's the entire point xD

#

it's for those

sharp geyser
#

yea but like I dont see many cases where its needed so I guess i've just never seen it

pale vessel
#

same ngl

sharp geyser
#

its a cool thing to learn

radiant kraken
#

@sharp geyser ```json
{
"table_name": "test",
"columns": [
{
"name": "test2",
"columnType": "text"
},
{
"name": "test3",
"column_type": "int",
"default": 0,
"not_null": true
}
]
}

#

parsing the entire JSON here or just the column_type property?

sharp geyser
#

well I want to parse the default field into its proper rust type, so if they provide a int then it will be parsed as an int if its a string then a string and so on

eternal osprey
#

guys, i spent 4 months learning haskell. I am reasonably good at it, but is there any function use for it? Do any jobs require haskell.. it seems like an old fucking language no one uses KEKW

sharp geyser
#

no

#

not at all

#

i dont really know I am kidding

eternal osprey
eternal osprey
pale vessel
#

he's sure about the type but he doesn't know how to parse it/make a deserializer for it

pale vessel
sharp geyser
#

hm

eternal osprey
#

I mean it's a fun language don't get me wrong, it's really compact and powerful but to be fair imo imperative/oop obliterates functional programming

radiant kraken
#

i mean, if the purpose of the property is that it can handle various types, why make another enum just for handling multiple types when serde_json::Value exists

pale vessel
eternal osprey
#
buildM :: (Monad m) => m (Maybe a) -> m [a]
buildM mm = do
ma <- mm
case ma of
Just a -> do as <- buildM mm; return (a:as)
Nothing -> return []```
like the syntax is so cursed but it grew onto me and now i can't stop using haskell for computations in my code.
radiant kraken
#

true

#

millions of videos explaining what a monad is would never get into my mind

eternal osprey
#

i could explain it if you'd like

sharp geyser
#

Also

#

is it okay to be using to_owned alot?

radiant kraken
#

like in what way

sharp geyser
#

like I have a sanitize_input function that makes sure it is only a-z 0-9 and it takes in an input

radiant kraken
#

what's your code

sharp geyser
#
let data_type_str = sanitize_input(column.column_type.to_owned());
#

or is it better to make the sanitize_input type be &String instead?

radiant kraken
#

yes

sharp geyser
#

and then just do &column.column_type

radiant kraken
#

yes

#

use .clone() or .to_owned() only as a last resort

sharp geyser
#

What does to_owned actually do? I know it essentially makes a new reference

#

or at least thats what I assume

radiant kraken
#

it basically clones the string

sharp geyser
#

I see

radiant kraken
#

if a reference might outlive the original value, that must be owned

eternal osprey
#

the way i grasped the concept is just that a monad is an unpure function. Haskell basically relies on pure functions, whenever you use the same params you will always get the same output. Obviosuly in other languages that is not the case. However, suppose you want to do something unpure, say you want to generate random data or get console.input (this is something that's not always the same as haskell likes), you must use monads. See monads as regular boxes that wrap around a certain value. See it as a condom protecting the values inside \0/ while it's being passed around functions.

In the end, to be able to use and extract values from that condom you must use <- or use applied chaining (many different other ways as well). For all functions that use such unpure actions such as console inputs or generating random numbers, you MUST have as an output the same condom wrapper. that's it

#

this is for you @radiant kraken hope it helps

radiant kraken
#

hmmm

#

so monads are

#

pure wrappers of unpure values

#

like mutable variables?

sharp geyser
#

Also is it better to use Result for functions that return something that could possibly error?

radiant kraken
#

yes

sharp geyser
#

Seems like result is kinda like a try/catch mmLol

radiant kraken
#

exactly

#

it's rust's way of exceptions

sharp geyser
#

oop

radiant kraken
#

it's way better even because it requires you to handle the error before retrieving the output of a function

sharp geyser
#

Does using unwrap on a result defeat the purpose of using the result?

#

Cause doesn't the unwrap mute the error?

#

actually no

#

it panics if it runs into an error

radiant kraken
#

though you don't really have to constantly use unwrap

#

since if it panics it stops the entire program

#

i recommend you make use of the ? operator instead```rs
fn some_func() -> Result<i32, YourErrorType> {}

fn my_func() -> Result<T, YourErrorType> {
let value = some_func()?;
// value is i32, if it errors, it immediately propagates the error out of this function
// to use the ? operator, the return type of the function calling it must be a Result, and the error type matches too
}

sharp geyser
#

hm

#

it seems I can't use it on something that returns a Result<String, HttpResponse> cause String doesn't implement trait FromResidual

radiant kraken
#

wdym?

sharp geyser
#
error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
  --> src/tables/create_table.rs:38:72
   |
37 |             .map(|column| {
   |                  -------- this function should return `Result` or `Option` to accept `?`
38 |                 let data_type_str = sanitize_input(&column.column_type)?; // Ensure uppercase for consistency
   |                                                                        ^ cannot use the `?` operator in a closure that returns `std::string::String`
   |
   = help: the trait `FromResidual<Result<Infallible, HttpResponse>>` is not implemented for `std::string::String`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
radiant kraken
#

can i see the code

sharp geyser
#
use actix_web::{HttpResponse, post, Responder, web};
use serde::{Deserialize, Serialize};
use serde_json::{Value};
use sqlx::{Pool, Postgres};
use crate::database::sanitize_input;

#[derive(Deserialize)]
struct CreateTable {
    table_name: String,
    columns: Vec<Column>
}

#[derive(Deserialize)]
struct Column {
    name: String,
    #[serde(alias = "columnType")]
    column_type: String,
    default: Option<Value>,
    primary: Option<bool>,
    #[serde(alias = "notNull")]
    not_null: Option<bool>
}

#[derive(Serialize)]
struct TableCreation {
    success: bool,
    reason: String
}

#[post("/")]
pub async fn create_table(pool: web::Data<Pool<Postgres>>, table: web::Json<CreateTable>) -> impl Responder {
    let query = format!(
        "CREATE TABLE IF NOT EXISTS {} ( {} );",
        sanitize_input(&table.table_name).unwrap(),
        table.columns
            .iter()
            .map(|column| {
                let data_type_str = sanitize_input(&column.column_type)?;
                let default_clause = match &column.default {
                    Some(default) => format!("DEFAULT {}", sanitize_input(&serde_json::to_string(default).unwrap()).unwrap()),
                    None => String::new(),
                };

                let not_null_clause = if column.not_null.unwrap_or(false) { " NOT NULL " } else { "" };

                format!("{} {} {}{}", &column.name, data_type_str, default_clause, not_null_clause)
            })
            .collect::<Vec<String>>()
            .join(", ")
    );

    HttpResponse::Ok().body("Works")
}
radiant kraken
#

the map closure doesn't return a Result<String, SomeError>, it returns a String

sharp geyser
#

well yea cause it returns a format!

radiant kraken
#

does actix_web allow functions to return a Result?

sharp geyser
#

it should yea

#

Honestly I think I could be doing this all a lot better

#

but idk

#

I am not used to results even my sanitize function is probably ass KEKW

radiant kraken
#

hm

#

what's the return type of sanitize_input?

sharp geyser
#
pub fn sanitize_input(input: &String) -> Result<String, HttpResponse> {
    let pattern = Regex::new(r#"[^a-zA-Z0-9]"#).unwrap();

    if pattern.is_match(input.as_str()) {
        Ok(String::from(input))
    } else {
        Err(HttpResponse::BadRequest().json(SanitizeError {
            reason: "You provided an unauthorized character in one of your fields (can only be a-z 0-9)"
        }))
    }
}
radiant kraken
#

ah

sharp geyser
#

this is ass

#

im pretty sure even if it error it wont use the HttpResponse thing

#

😭

radiant kraken
#

you can make sanitize_input return a Result<String, actix_web::error::Error> instead

#

and ```rs
Err(actix_web::error::ErrorBadRequest(serde_json::to_string(json!({
reason: "You provided an unauthorized character in one of your fields (can only be a-z 0-9)"
}))))

#

and instead of using map, use a for loop

sharp geyser
#

huh

radiant kraken
#

why?

sharp geyser
#

oh wait

#

to_string takes in a reference

#

I was reading the error wrong and got confused

#

😭

#
        Err(ErrorBadRequest(
            serde_json::to_string(&json!({
                "reason": "You cannot use unauthorized characters such as semi colons or anything that is no numbers or letters."
            })
        )?))

this is what I had to do

radiant kraken
#

or you can just write a json string literal

#

directly

sharp geyser
#

?

radiant kraken
#
Err(actix_web::error::ErrorBadRequest(String::from("{\
  \"reason\": \"You provided an unauthorized character in one of your fields (can only be a-z 0-9)\"\
}")))
#

to use multiline strings in rust, just end your string literal with \

sharp geyser
#

yea nah

#

the other way loosk cleaner

radiant kraken
#

oh okay lol

radiant kraken
#

since the error is not worth propagating

sharp geyser
#

😭

#

you told me not to use unwrap

#

I had unwrap before but then swapped it to use ?

radiant kraken
#

serde_json::to_string should never error as the input would always be a valid json value

sharp geyser
#

fair

sharp geyser
#

:D

sharp geyser
#
pub fn sanitize_input(input: &String) -> Result<String, actix_web::error::Error> {
    let pattern = Regex::new(r#"[^a-zA-Z0-9]"#).unwrap();

    if pattern.is_match(input.as_str()) {
        Ok(String::from(input))
    } else {
        Err(ErrorBadRequest(
            serde_json::to_string(&json!({
                "reason": "You cannot use unauthorized characters such as semi colons or anything that is no numbers or letters."
            })
        ).unwrap()))
    }
}
#[post("/")]
pub async fn create_table(pool: web::Data<Pool<Postgres>>, table: web::Json<CreateTable>) -> impl Responder {
    let query = format!(
        "CREATE TABLE IF NOT EXISTS {} ( {} )",
        sanitize_input(&table.table_name)?,
        ""
    );

    HttpResponse::Ok().body("Works")
}
radiant kraken
sharp geyser
#

really?

#

😭

radiant kraken
#

and replace impl Responder with Result<String, actix_web::error::Error>

sharp geyser
#

But then the status code is gone, gotta keep up with web standards

radiant kraken
#

what status code?

sharp geyser
#

like 200, 404, 500 etc

radiant kraken
#

ErrorBadRequest already does it for you

#

it returns an actix_web::error::Error with status code 400

sharp geyser
#

that only handles bad requests not successful ones. What if I wanted to return a status code of 201 as this endpoint creates something

radiant kraken
#

hmm

#

you can return a Result<HttpResponse, actix_web::error::Error> instead

sharp geyser
#

Fair actually

#

Well

#

I have to return the input from the sanitization no?

sharp geyser
#

Well I have to return something from the sanitization either the input back or a bool value saying it is sanitized

radiant kraken
#

you can still use ? on the sanitation function and use the String output

#

the sanitation function return type just needs to be Result<..., actix_web::error::Error>

sharp geyser
#

oh okay

sharp geyser
radiant kraken
#

serde_json::Value works for any json value

#

or json property

#

it's like JavaScript any

sharp geyser
#

but how do I know what the type actually is?

#

I know you can do something like unwrap_or(Value::as_str)

#

but that casts it no?

radiant kraken
sharp geyser
#

I see

sharp geyser
#

@radiant kraken Is there an easy way to do this for loop? cause I feel like making a variable and setting it in the for loop is not the best idea

#
    let mut columns = "";

        for column in &table.columns {

            let default_type_str = sanitize_input(&column.column_type)?;



            columns = format!("{}", "").as_str();
        }
    let query = format!(
        "CREATE TABLE IF NOT EXISTS {} ( {:#?} )",
        sanitize_input(&table.table_name)?,
        columns
    );
#

also ignore the fact this is overwriting the columns variable each iteration I know that I am tired 😭

radiant kraken
sharp geyser
#

@radiant kraken Omg I am trying to do something that is requiring me to use lifetimes I think

#

😭

#

https://hatebin.com/jpdhhziizy I made a convert_default method on the column so I can convert the default value directly into a string as I don't really need it to be anything else if all I am using it for is to build an sql query

#

but I was googling and it seems that the error i was facing prior to trying to use lifetimes was because it didn't know how long the reference was going to last so I needed to use lifetimes to specify such thing

#

for context here is the error I was facing before

cannot return value referencing temporary value [E0515] returns a value referencing data owned by the current function
radiant kraken
sharp geyser
#

yes

#

😭

#

why didnt I think of it

#

@radiant kraken bro wtf am I seeing in my console rn

#

I mean I guess the only important thing is called `Option::unwrap()` on a `None` value

#

Seems to be happening on my convert_default method hm

#

OOOOO

#

Its because I don't always supply a default value

#
impl Column {
    fn convert_default(&self) -> Option<String> {

        match self.default.as_ref() {
            Some(v) => Some(match v {
                Value::String(string) => string.clone(),
                Value::Number(number) => number.to_string(),
                Value::Bool(bool) => bool.to_string(),
                _ => String::new()
            }),
            None => Some(String::new())
        }
    }
}

what do you think of this null? I have no idea what it actually is doing but internet helped me come up with it :D

#

and it seems to work

radiant kraken
sharp geyser
#

I dont understand it myself

radiant kraken
#

bru

#
impl Column {
    fn convert_default(&self) -> String {
        match self.default.as_ref() {
            Some(v) => match v {
                Value::String(string) => string.clone(),
                Value::Number(number) => number.to_string(),
                Value::Bool(bool) => bool.to_string(),
                _ => String::new()
            },
            None => String::new()
        }
    }
}
sharp geyser
#

like before yours

#

what I posted

radiant kraken
#

converts the enum to a String representation of it

radiant kraken
#

yes

#

otherwise return an empty string

sharp geyser
#

gotcha

odd citrus
#

any recommends for free hosting?

deft wolf
#

Nope

solemn latch
#

Using a computer at home is the only one id realistically use.

#

Well, oracles free vps's are actually not bad. If you don't mind arm, and don't load them up too much(they have harsher restrictions now) and you must provide a debit card even though it's free.

wheat mesa
#

This ^

#

They’re really nice for hosting a small bot

eternal osprey
# radiant kraken like mutable variables?

no not necessarily. Well, mutable variables are another monad denoted by IOREF. However, monads are a collective box of all sorts of unpure functions/usages. So think about:

IOREF -> mutable variables
IO -> for input ouput actions, hence unpure again.
And many more, you can also create your own monads to denote that a custom data type is used for unpure actions

#

the wrapper is not pure, it's basically just a box that holds values that's it. Just those values are unpure as they were generated from an unpure action/function

#

if you are really into it, hit me up in my dm and i can give you a more in-depth explanation with code etc

compact pier
#

Just made it, but kinda not happy

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

compact pier
#

I mean I can split words, breakline and then resize them, but I dunno

sage bobcat
#

One message removed from a suspended account.

compact pier
sage bobcat
#

One message removed from a suspended account.

compact pier
#

looks like this, but ik on actual mobile looks worse

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

compact pier
#

yeah, it also works too. You can access it through local ip and port

#

I will do :)

timid lintel
neon leaf
#

13 files in 4 hours

#

even with copilot

coral phoenix
#

damn I just have an api that does it for me and a /config command to pick the language

lyric mountain
#

adding it afterwards isn't doable

#

btw you have a lot of levels there, are you using a locale file or what?

neon leaf
lyric mountain
#

idk what webui is

#

but well, a thing I dont recommend is over-specializing your strings, try to reuse as many strings as possible

#

else you'll do more than double the work translating those

neon leaf
#

yeah I reuse alot

#

had to adjust my format a few times to do that

#

commands take the longest, buttons, modals, etc are pretty quick

#

so that keeps my motivation up

#

hopefully

queen needle
lyric mountain
#

try to make them as generic as possible, so you're able to reuse strings

#

you might also use template strings for things that only a few words change

#

if you want not to overcomplicate, remember that for i18n u only need 2 things: an acessor and a locale file

#

the acessor should only be acessing that file and reading the specified key (and storing it in a cache, with ttl)

#

the file should be a simple key-value structure, personally I prefer the properties structure but yaml, ini, xml, whatever also works

#

I dont avise using json/xml as you need to parse the whole file before being able to retrieve a single line, so you're forced to keep the full file(s) in memory all the time

neon leaf
#

well I use json because its easy to read and I need all in memory anyway

lyric mountain
#

you dont, some strings are accessed much more often than others

#

this becomes a problem on very big locale files, not so much on smaller ones

neon leaf
#

well I would consider ~100kb (estimated end result) small

lyric mountain
#

it grows when parsed

#

also u need to consider you'll be keeping more than 1 file in memory

neon leaf
#

yeah, compared to what else im doing its nothing

#

I think my dev instance with everything cached for later used is like 700mb

#

I have 128gb available

sharp geyser
#

@wheat mesa @radiant kraken okay so I have something regarding this I want to ask. I know previously I was thinking of not letting them use their own database urls but looking at the docs for sqlx, I can theoretically create pools for multiple databases. So I can create a pool and set it to like a map/hashmap and then call upon it whenever they are making requests.

#

Do you think this would work in your professional rust experience?

sharp geyser
#

okay good :D

radiant kraken
#

plus my rust experience aint even professional

sharp geyser
#

This makes it a lot easier as all they need to do is just provide their postgres user + pass and boom

radiant kraken
#

i've never made a full-stack rust app before

sharp geyser
#

plus I wont need to worry about sql injection as they can only affect databases attached to them

radiant kraken
sharp geyser
#

who sql injects themselves thonk

sharp geyser
sharp geyser
#

@radiant kraken should I use &'static or should I use something else? iirc you mentioned Arcs

radiant kraken
sharp geyser
#
pub struct DatabaseState {
    pool_manager: HashMap<String, Pool<Postgres>>
}

pub async fn create_pool(database_url: String, state: Data<DatabaseState>) -> Result<&'static Pool<Postgres>, actix_web::error::Error>{
    let pool = state.pool_manager.get(&database_url);


    if pool.is_some() {
        Ok(pool.unwrap())
    } else {
        state.pool_manager.insert(&database_url, PgPoolOptions::new().connect(&database_url).await.expect("Failed to connect to the database, please check your "))
    }
}
radiant kraken
#

nope that's invalid

sharp geyser
#

well I have yet to implement returning an error but what is invalid

#

and what should I do instead

radiant kraken
#

remove 'static

sharp geyser
#

it requires a lifetime

radiant kraken
#

do you really have to return a reference?

sharp geyser
#

Okay so ik the function says create_pool but it is meant to get the pool if it exists or create one then return it

sharp geyser
radiant kraken
#

the value itself

#

what's the return type of pool_manager.get?

sharp geyser
#

Option<&Pool<Postgres>>

radiant kraken
#

ah

sharp geyser
#

Should I do pool.unwrap().clone()?

radiant kraken
#

hm

radiant kraken
# sharp geyser ```rs pub struct DatabaseState { pool_manager: HashMap<String, Pool<Postgres...

try this perhaps?

use core::marker::PhantomData;

pub struct DatabaseState<'a> {
    pool_manager: HashMap<String, Pool<Postgres>>,
    phantom: PhantomData<&'a ()>,
}

pub async fn create_pool<'a>(database_url: String, state: Data<DatabaseState<'a>>) -> Result<&'a Pool<Postgres>, actix_web::error::Error>{
    let pool = state.pool_manager.get(&database_url);


    if pool.is_some() {
        Ok(pool.unwrap())
    } else {
        state.pool_manager.insert(&database_url, PgPoolOptions::new().connect(&database_url).await.expect("Failed to connect to the database, please check your "))
    }
}
sharp geyser
#

me no understand what that is

radiant kraken
#

PhantomData is a value without a size that let's you explicitly add a lifetime generic to a struct without references in it

#

hence, marker

#

to declare it in a struct initiation you just do ```rs
StructName {
phantom: PhantomData,
}

#

it's 0 bytes in memory so it has no overhead

wheat mesa
#

Yeah it’s just to make the compiler happy

wheat mesa
sharp geyser
#

So that way I can handle multiple databases?

radiant kraken
wheat mesa
#

But why do you need to handle multiple databases at the same time?

#

I also don’t really know what you’re making, I forgor

sharp geyser
#

Because I am making a service for roblox devs to store data externally rather than use datastores.

#

Each roblox dev when signing up gets their own pg user that they can use to make new databases and in turn tables on those dbs

wheat mesa
#

Sounds like devops hell ngl 😭

sharp geyser
#

The querying/mutation of those databases has to be done over rest api though as roblox is limited on what you can do

radiant kraken
#

i dont think roblox devs know what postgres even is

sharp geyser
#

Which is why they don't have to

#

I am handling it all myself, all they do is query

wheat mesa
#

So you’re building a rest api for managing data

sharp geyser
#

Essentially yes.

wheat mesa
#

I still don’t really understand why that requires multiple pools

sharp geyser
#

Well because the rest api needs to know what database to query?

#

What database to use to make new tables?

wheat mesa
#

Hmmmm maybe I understand what you’re saying now

sharp geyser
#

I can't simply use a pg user with root access

#

that is dumb

#

so I am using their already made pg user accounts

#

so they can only manipulate dbs they made

wheat mesa
#

I see

sharp geyser
#

Also if anyone tries and sql inject they are fucking themselves over

#

But yea, thats why I am creating multiple pools.

wheat mesa
#

I mean ideally you just use prepared statements to prevent injection in the first place but idk how you’re structuring it

sharp geyser
#

You can't use prepared statements with sqlx on table names and columns

wheat mesa
#

Since this sounds like something that beginner devs would use more than advanced devs, why bother letting them query the database themselves? Why not just mimic a datastore-esque API and expose it to endpoints

#

Seems like it would be a little safer and simpler to implement

sharp geyser
#

How so?

#

Like I get what you mean but I am also not sure I am understanding

#

I am pretty sure I am going for what you are talking about either way.

wheat mesa
#

Idk how datastores work in roblox but I assume that it’s not super complex, probably supports loading, mutating, and saving data

#

Sounds like supporting SQL is a nightmare for devs that likely don’t know how to use it

#

Unless I’m misunderstanding what you’re doing

sharp geyser
#

Well I am trying to mimic roblox datastores but use a relational database instead

wheat mesa
#

Why’s that

sharp geyser
#

Honestly, no idea just thought it'd be fun KEKW

wheat mesa
#

Fair enough

#

Go for it

sharp geyser
#

Though I do admit that I dislike how unfamiliar datastores are in roblox

#

it feels more restrictive

#

With a relational database I can create one-to-one, one-to-many and even many-to-many table relations where tables rely on each other and make fetching data easier

#

if I fetch a user, I can get any inventory data associated to that user as well

#

instead of how roblox right now you have to make multiple datastores

#

or you could save stringified json, but that requires you to have to use something to decode/encode the data as well

#

its a whole extra step

radiant kraken
#

@sharp geyser did the phantomdata work?

sharp geyser
#

I’ll test it here in a second after my shower

sharp geyser
#

I have thes errors now: https://hatebin.com/qwtmqtshkh
As far as the first error goes, I don't really understand what I should do to fix it, the second one is also a bit confusing on what it wants me to do as I don't see how it is borrowing anything. The third one I get it says to use .clone but you've said to stay away from it as much as possible so idk if I should listen to the compiler

crisp hedge
#

Hi

#

Gm

sharp geyser
# sharp geyser I have thes errors now: <https://hatebin.com/qwtmqtshkh> As far as the first err...

Okay so my shitty solution to some of these problems

pub async fn get_or_create_pool<'a>(database_url: String, state: &'a mut Data<DatabaseState<'a>>) -> Result<&'a Pool<Postgres>, actix_web::error::Error>{
    if let Some(pool) = state.pool_manager.get(&database_url) {
        Ok(pool)
    } else {
        let pool = PgPoolOptions::new().connect(&database_url).await;

        match pool {
            Ok(pg_pool) => {
                state.pool_manager.insert(database_url.clone(), pg_pool.clone());
                Ok(&pg_pool)
            },
            Err(err) => {
                Err(ErrorBadRequest(
                    DatabaseError {
                        reason: String::from(err.to_string())
                    }
                ))
            }
        }
    }
}

Still facing issues regarding the match statement's Ok block

error[E0596]: cannot borrow data in an `Arc` as mutable
  --> src/database.rs:43:17
   |
43 |                 state.pool_manager.insert(database_url.clone(), pg_pool.clone());
   |                 ^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
   |
   = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Arc<DatabaseState<'_>>`

error[E0515]: cannot return value referencing local variable `pg_pool`
  --> src/database.rs:44:17
   |
44 |                 Ok(&pg_pool)
   |                 ^^^--------^
   |                 |  |
   |                 |  `pg_pool` is borrowed here
   |                 returns a value referencing data owned by the current function

error[E0425]: cannot find function `sanitize_input` in this scope
  --> src/tables/create_table.rs:66:9
   |
66 |         sanitize_input(&table.table_name)?,
   |         ^^^^^^^^^^^^^^ not found in this scope
#

ugh no matter what I try I don't get why it isn't working

green kestrel
#

the ok block is not ok?

#

πŸ˜„

dull quest
#

Hey @earnest phoenix, the link to your Will of Steel support server on top.gg is expired.

grizzled halo
#

Hi

green kestrel
#

finally, the last content tag in my game's content is implemented πŸ˜„

#

saved the least common tag type till last

#

basically is a way for the user to input some information they know, from things theyve seen in-game, basically solving riddles and stuff

#

location gating based on previous knowledge

radiant kraken
#

so Arc<Mutex<T>>

eternal osprey
#

i've seen alot of people use prisma nowadays, i know it's a database client

#

is it any good?

spark flint
#

its a database ORM

#

idk how to describe it

#

but it works with many database types without having to adjust the code much

eternal osprey
#

is it sql based?

spark flint
#

nope

#

lemme get an example query

eternal osprey
#

huhhh

#

but it does support sql based databases?

#

how tf does that work

spark flint
#

this queries postgres

eternal osprey
#

i see, is it like a client that connects your code to the database model?

spark flint
#

yeah

#

you define the database structure

eternal osprey
#

what's the point of that if many databases offer standalone usage?

#

duckdb for example, othre SQL based databases etc

spark flint
#

example prisma file

eternal osprey
#

basically the same as create table i see

spark flint
#

yeah

#

you just tell it what tables already exist

eternal osprey
#

but what is the benefit of using prisma?

#

Why can't i just use a standalone sql based database

spark flint
#

honestly not sure

#

but i know its very easy to migrate databases without having to rewrite queries

#

this might help

eternal osprey
#

i see it being used a lot tbf

spark flint
green kestrel
#

orm should stand for objective restrictive mess

spark flint
#

i find prisma too complicated for what it does

green kestrel
#

they lost me at "thinking in objects"

spark flint
#

which is why i just use a regular db client / package

green kestrel
#

db rows arent and shouldnt be objects

#

theyre collections

eternal osprey
spark flint
#

yes

green kestrel
#

i'll stick to how i do it, and avoid preprocessor nonesense or similar reflection voodoo to map objects->db or db->objects.

eternal osprey
#

if it's an integration between sql and sql as well as sql and nosql then it's pretty sick for sure

green kestrel
#
void autocomplete(dpp::cluster& bot, const dpp::autocomplete_t& event, const std::string& uservalue) {
    auto rs = db::query("SELECT lower(name) AS name FROM game_users WHERE name LIKE ?", {uservalue + "%"});
    dpp::interaction_response ir(dpp::ir_autocomplete_reply);
    for (const auto& r : rs) {
        ir.add_autocomplete_choice(dpp::command_option_choice(r.at("name"), r.at("name")));
    }
    bot.interaction_response_create(event.command.id, event.command.token, ir);
}
#

i mean really, is understanding SQL that hard?

#

πŸ˜„

#

if your framework or lib protects you properly from sql injection and keeps little bobby tables away from your database, and it properly handles type safety, you dont need an ORM

#

still havent decided if i want or need to also use redis for some stuff though, i have some things that arent important enough to put in db, but i want to persist over restarts, redis seems a good plan for that

radiant kraken
green kestrel
#

mongo makes me think of mungos

spark flint
#

mangodb

radiant kraken
lyric mountain
#

if u used it before

green kestrel
#

hmmm

#

seems the only way to force this first embed to be as wide as the 2nd is to add an icon to it

#

can anyone else think of a way?

#

this has been bugging me for some time now

#

as soon as you add an image to an embed it restricts its width

lyric mountain
#

add an invisible thumbnail

green kestrel
#

hmmm, that works?

#

i'll give it a go

lyric mountain
#

wrong image

#

https://i.imgur.com/GSmUJVU.png

earnest phoenix
lyric mountain
#

support server

earnest phoenix
#

how do u guys know? :o

#

or did u just check my bot or sum

lyric mountain
#

idk, just repeated what they said

earnest phoenix
#

ohlol ok

lyric mountain
#

they prolly tried to access it

neon leaf
#

Omehhw1

compact pier
#

Safari render engine is so shit

#

my website can't even render with safari

lyric mountain
#

well, it used to be worse when IE was still alive

#

now you just need to support 2 different browsers

eternal osprey
#

what's upp peeps

quartz kindle
#

UTTP

wispy heath
#

Are we able to send voice message using bot?

lament rock
#

Yes

lament rock
trail marten
wispy heath
wispy heath
#

Even they dont show mp3 as playable on mobile

lament rock
#

I heard someone got it working before :3

deft wolf
#

Probably even a few days after they introduced it

#

I don't know if it was some undocumented endpoint or something, but I remember there was a conversation about it here

lament rock
#

It was an undoc'd endpoint

pale vessel
lament rock
pale vessel
#

sure

#

the waveform needs to be worked on though

lament rock
#

β™₯️β™₯️

#

Okay

lament rock
#

@pale vessel can the id be the same always?

pale vessel
#

the ID doeszn't matter

#

so yup

lament rock
#

Lmao that's funny

#

Also, why not just readFileSync and then use the Buffer.byteLength

pale vessel
#

yea you can do that

#

i just did whatever i thought of

#

i just thought statSync would be 100% accurate

lament rock
#

Okay cool didn't know if statSync also included like file headers which was important

pale vessel
#

it should be ogg (the file extension) anyway

#

i haven't tested any other audio file type other than mp3/ogg

#

but anything commonly supported should work? or similar containers to ogg at least

#

no clue how discord checks the audio files

lament rock
#

Discord is saying it's supposed to be ogg opus. When was the last time you checked this?

pale vessel
lament rock
#

Oh okay sweet

pale vessel
#

it's just the extension that needs to be ogg, i believe. you could try to change the extension to be the same as the uploaded file, it might just work

lament rock
#

I'm not really gonna fuck with it tbh

pale vessel
#

i'll fuck with it for u

#

yup, any audio file type works

lament rock
#

bruh?

pale vessel
#

if you do non-audio file types, it'll fail

pale vessel
lament rock
#

so like... Literally any audio file type?

pale vessel
#

we're sending it manually directly to the API so

lament rock
#

Ah. The client only sends ogg

#

would probably recommend ogg as well to users since other formats have their own quirks

#

file size as well :(

pale vessel
#

oh, interesting

#

aac does work, but it doesn't embed

#

let me try with an actual aac file

#

okay so it embeds only on mobile

#

this is similar to the webp situation where it doesn't embed on ios

pale vessel
#

just stick with ogg or mp3 and you'll be fine

pale vessel
#

so file extension does matter, not just the audio type itself

pale vessel
#

jeez

lament rock
#

lmao

#

Does only ogg and mp3 embed?

#

Also, isn't the max audio length like 60 seconds?

pale vessel
#

(another note, the file extension does not matter for the attachments endpoint)

desktop and mobile:

ogg
mp3
m4a
wav
flac

only on mobile:

aac
aiff
opus
wma

lament rock
#

Are you on apple

#

aiff is an apple format iirc

lament rock
#

Weird okay then

pale vessel
lament rock
#

Oh you mean only clients marked as mobile can upload those attachments

pale vessel
#

never mind it works xD

#

only on mobile though. on PC, it'll be marked as a normal attachment

#

wait..

#

i'm so dumb xD

#

i already tested it. i thought you were asking a question

pale vessel
lament rock
#

You're doing great

pale vessel
lament rock
pale vessel
#

ah

#

when i said it only works on mobile i meant that it only embeds properly as a voice message on mobile

lament rock
#

Alright. I'll just leave it up to the user to figure this crap out

#

Not about to write out a bunch of file types the user can choose from

pale vessel
lament rock
#

I could

pale vessel
#

it's a bit jank though

#

oh lord

neon leaf
eternal osprey
#

is it possible to lock voice channels such that people can't join anymore?

lament rock
eternal osprey
#

i see, how would i lcok it then?

lament rock
#

When users are timed out they also cannot join VCs and will be disconnected from them

eternal osprey
#

seems pretty straight forwrad

lament rock
#

remove all overrides and permissions that allow CONNECT for channel(s) and then explicitly deny on an override for "this" channel

#

CONNECT is on even when flipped off iirc for global role settings

#

just not overridden

eternal osprey
lament rock
#

you mean permission? Yes. Intents are a different key word

eternal osprey
#

though, would people within the vc automatically get disconnect? No right?

lament rock
#

No you'd have to disconnect users already in a channel

eternal osprey
eternal osprey
#

i am just looking to close the party w/o disconectting people so this sounds awesome

lament rock
#

people with the CONNECT, MANAGE_MEMBERS and VIEW_CHANNEL permissions for that channel can still move members to it

eternal osprey
#

i see, but nomal people w/o an overriden CONNECT cannot join righ?

lament rock
#

Correct

#

an alternative is to deny everyone and only allow specific people through overrides

#

If this is a guild you manage

eternal osprey
#

hmm

eternal osprey
#

and suppose i would deny each member, wouldn't it first of all take a lot of time and kick the current members

lament rock
#

override channel permission for everyone (guild ID for role ID) to deny CONNECT and then for each user you want to allow in, allow

eternal osprey
#

But if a user is already in the vc it's not needed to allow them, right?

#

if they leave, well their problem lmao

lament rock
#

Correct. They wont be kicked, but they wont be able to join back

eternal osprey
#

sounds good enough to me

#

thank you!

lament rock
#

That last approach only works if you manage the guild and your permissions dont explicitly allow anyone or a role

#

asides from mods/admins of course

eternal osprey
#

yeah i have that thankfully

flat copper
#

im having a problem hosting my bot:
whenever i host bot in vps the slash commands are not loading, but they are loading locally

earnest phoenix
sage bobcat
earnest phoenix
flat copper
#

okay, thanks!

slender wagon
#

what do you guys use to install nodejs in linux?

spark flint
#

i use nvm

#
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm```
#

then sh nvm install 20.9.0

#

etc

slender wagon
#

gotchya

#

thanks

waxen gale
#

I'm not finding anywhere else to ask for suggestions on bots, so posting here.
I'd like an automessage feature that will randomly choose from a number of messages. For example: a daily announcement for a pictures theme but it will post a random option from 10 different choices so it's a surprise for everyone. Embed options would be bonus.

lyric mountain
#

the bot fetches N messages from a channel, then choose one of them randomly and send in another (specified) channel

#

is that it?

waxen gale
lyric mountain
#

that's too specific for an existing bot, but doesn't sound too complicated to make one, you could probably find someone willing to do it (not free, likely)

#

the dashboard part cranks the difficulty from 1 to 10 tho

#

since it'd require an entire site + api to achieve it

verbal epoch
#

is there any code for yt sub count ?

waxen gale
sharp geyser
neon leaf
#

if its the first version it will auto use

spark flint
#

^

sharp geyser
#

Oh I guess I am used to using multiple versions

eternal osprey
#

how do we set the user Limit when creating channels?

sharp geyser
#

voice channels right?

timid lintel
#

lottery: TypeError: Cannot read properties of null (reading 'prize')
Anyone can help? smirk

sharp geyser
#

log something and see if it is what you think it is

harsh aspen
harsh aspen
lament rock
#

Only sometimes or all the time? You never know

#

Unknown code flow is impossible to predict :(

harsh aspen
#

true

#

!false hehe

main schooner
#

Hello can anyone help me setting up a killfeed bot for rust console ?

stark abyss
#

react native & password hashing through bcrypt

const bcrypt = require('bcryptjs');
import isaac from "isaac";

bcrypt.setRandomFallback((len) => {
    const buf = new Uint8Array(len);

    return buf.map(() => Math.floor(isaac.random() * 256));
});
    var hashedPassword = bcrypt.hashSync(password,10);
    console.log(hashedPassword);

first i get some error telling me to setRandomFallback and so i did but now i get
ERROR Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run yarn or npm install., js engine: hermes

I am positive that its from this code as i dont get error if i comment it out
obviously tried doing npm install already

#

i tried pretty much everything, like using just bcrypt instead of bcryptjs but i run into errors

surreal sage
lament rock
#

call stack size is when functions are called recursively too much without pushing processing to the next ticks

#

If it's trying to compile your code and following too deep, then that would happen :(

#

processing should be deferred with setImmediate if possible

surreal sage
#

it happens with vercel

#

i next build

#

it works just fine

#

but when vercel does it

#

that error.

lament rock
#

and?

#

If it's a vercel issue doing exactly what I described then there's probably nothing you can do until they ask for your code and are able to decide if it's your fault or their fault

#

It's a general suggestion anyways. Defer processing to next ticks if you call recursively

sharp geyser
#

If that doesn't work delete node_modules and your lock file and run npm install or yarn again to re-download those modules from your package.json

lyric mountain
lament rock
#

Unless you reuse names, shouldn't make a difference

#

block scoping variables is a better idea always though

lyric mountain
#

I suppose so, but vars are always involved when something weird happens

sharp geyser
#

I didnt know var was still a valid keyword

#

I'd thought they would remove it by now

lament rock
#

legacy code support

sharp geyser
#

old code should die

lament rock
#

Stuff like the GH arctic code vault exists for a reason lol

lyric mountain
# sharp geyser old code should die

js: "we must protect old code at all costs, nothing can break"
npm: "stupid old code, get out of my way you pleb so I can update this package from 2.0.1 to 2.0.1b"

sharp geyser
#

lmao

radiant kraken
#

@sharp geyser how's that rust app been going btw

sharp geyser
#

Oh uh about that

#

Well actually

#

I scrapped the pool idea cause yknow after some thought and messages in the rust discord realized I dont need pools

#

I can just make a connection and close it each request.

#

No one will be accessing their data that often, it'd be in a cache logically

#

After I figured that out it actually became smooth sailing

sharp geyser
radiant kraken
#

ah icic

green kestrel
#

i decided to make my admin section on-theme as far as its messages goes.... what do you think?

radiant kraken
green kestrel
#

the guard?

radiant kraken
#

yup

#

make it slightly bigger

green kestrel
#

scaled him up a bit

radiant kraken
#

nice

sharp geyser
#

cheeseburger bicmac whopper

green kestrel
#

im thinking if an unauthorised user does log in, it will first warn them "i dont know you, stranger, don't come back or we won't be so merciful"

#

then 2nd attempt, they actually kill your in-game character forcing you to respawn

#

it DID warn you

radiant kraken
#

i love it when games go meta

#

though how can it know the user's in-game characeter?

lament rock
#

IP and/or cookies if any

sharp geyser
#

or probably by idk, the fact they login through discord?

#

I can only assume it will see if they have the proper permission by querying when they login

#

which you could easily get their character as well

green kestrel
#

and can look up their in game character by user id

radiant kraken
green kestrel
#

logged out of where

#

πŸ˜„

radiant kraken
green kestrel
#

as in, not playing?

radiant kraken
#

logged out of the website

green kestrel
#

you dont play via website

#

you play via discord

radiant kraken
#

i know

#

i mean what if you try to access the admin thing in the website while you're not logged in

green kestrel
#

and there are only two login parts of the website: admin panel, and premium sales page (not made yet)

sage bobcat
green kestrel
#

oh, if youre not logged in you get that page i pasted earlier

#

"stop, who goes there"

#

its pretty unlikely that anyone will find the page anyhow

#

not like i'll put a link to it anywhere on the site

#

the kill thing is more for nosey people who probe around at subdomains

radiant kraken
#

icic

radiant kraken
eternal osprey
#

hey guys i need some website design help. I am sadly not a designer, only a programmer... i got this so far, and the test that reads test should be a list of specications of the product. I am using bootstrap, how would you guys go about designing the specifications list

#

you might ask why the fuck i went with such a strange background, the product is named to a city in turkey so i figured to set a theme of that city as a background

sharp geyser
#

Okay sorry but what prompted the usage of the sunrise/set

#

It looks out of place

eternal osprey
#

if you scroll down you actually see the city lmao

#

let me set the object position to center, one sec

sharp geyser
#

Yea that’s too much. Background images are fine if used correctly but I personally hate when they take up the entire background

#

Especially when there’s so much open space that content isn’t taking

eternal osprey
#

i mean what else can i do in this case

#

i wanted to incorporate istanbul a bit more as that's what my product basically is inspired from

radiant burrow
#

it could be a nice like header kinda thing or something

eternal osprey
#

but idk once again i am not a designer hahah

sharp geyser
#

Again asking for design help will get you subjective answers so mine won’t always be correct for you

eternal osprey
#

any subjective answer is better than mine, i don't have a lot of web experience to go against it.

sharp geyser
#

I’d try and either make the content take up a larger space or shorten that image to be like what Brady said

#

That image is overpowering and distracting

eternal osprey
#

what i figured to do, is to have the product image in the upper left corner, the rhs contains a list of descriptions and then under the product image i wanted to incorporate a drop down menu with specifications of the product

#

though i am not sure

eternal osprey
#

don;t worry about the unreadable text on the top for now. Suppose we went like this, what else could i use to make it look more appealing. At the moment, i feel like there's just a too harsh of a border between the image and the white bg below it

#

i might completely change the design cuz idk this shit looks ugly af

sharp geyser
#

Hm

#

Working with background images is always hard to get right

#

Is there a reason it needs to be so prominent?

real rose
#

could just lower the opacity on it/put a dark overlay

eternal osprey
#

okay it's. getting better

eternal osprey
#

i want to show the customers the differences between them, as each product brings it's own ambiance

#

i moved the button away from the image as well, it seemed out of place

#

idk i think it looks good! What do you guys think?

paper jay
#

hey

surreal sage
#

wow

#

i thought winscp was good

#

but no

#

only 9 concurrent transfers

#

transfers suddenly just stop

#

disappear

ionic schooner
surreal sage
#

is it just me

#

as in sell-your-data unreal

#

no account required

#

there is no contact page

#

the "issues" on their vsc extension goes to their site

#

there it's Blackbox, here BlackboxAI, over there BLACKBOX

civic scroll
surreal sage
stuck dawn
#

Anyone knows a good rich text editor for React? I want something like I select the text and it appears a menu when select is hover

stuck dawn
#

Something you’ve used

surreal sage
#

its funny how employers/recruiters commonly refer to js as java and not knowing the different

#

"Java Back End Developer with Node JS"

pale vessel
# stuck dawn Anyone knows a good rich text editor for React? I want something like I select t...

i've used tinymce for a php project before, but they also have a package for react https://www.npmjs.com/package/@tinymce/tinymce-react

#

you can also try ckeditor, i heard it's good

eternal osprey
#

is it possible to already work as a junior developer while still being in year 3 of uni bachelor?

#

every fucking job offer i see requires 5+ years of work experience

#

and even their junior positions need 2+

surreal sage
#

@eternal osprey You can still try

#

If you have actually coded projects

#

Proof of concepts

#

etc

#

Then imo (and hopefully the employer's) you can be a good fit

wheat mesa
#

@slim heart didn’t you get a job out of high school?

surreal sage
#

@slim heart ^ if you did, how πŸ₯Ί

pale vessel
#

connections

#

well, that's one of em

earnest phoenix
#

which is most demanding bot type

civic scroll
#

the ones you thought were the most demanding - are frankly, quite saturated

grim aspen
#

i'd say most demanding bots are the ones that are interactive or security related

slim heart
lament rock
#

probably object depth related

frosty gale
#

companies cant really vet everyone because theyd run out of time if they tried everyone that said they could do it

surreal sage
#

is it front-end or front end

ionic schooner
lyric mountain
#

Fend

radiant kraken
#

people still crave for multipurpose - especially fun discord bots

#

but not by much

#

since multipurpose bots often peak at around 200 to a few thousand servers

half laurel
#

Hello

#

Am new here

civic scroll
surreal sage
#

@dense flame?

dense flame
#

Hi @half laurel we dont allow advertisements here

dense flame
radiant kraken
#

hai cosmic

#

hai misty

hidden gorge
#

someone please explain what the fuck this error is

spark flint
#

google it as afirst check

#

also what were you doing to cause that error

#

are you on a school wifi or a wifi which uses a login / auth system? i get that sort of errror at school when i haven't logged into the wifi

hidden gorge
warm surge
spark flint
#

its likely school wifi blocking it

hidden gorge
solemn latch
#

It's possible it's been blocked since

#

It's scary how much a schools IT will watch what you do and stop from happening.

spark flint
#

yup

grim aspen
#

at my college, IT comes to me for last resort if they can't fix something

sharp geyser
#

I bypassed their search filters by unchecking a box

#

they couldn't think of a smarter way to do it

#

😭

grim aspen
#

my old school's IT was ddossed by a student and had a ransomware attack

sharp geyser
#

I also put 1.1.1.1 on a thumbdrive and ran that on my school laptop to access blocked sites

grim aspen
#

oh yeah i forgot someone zip bombed the computers in the tech lab

sharp geyser
#

Lmao someone set all the computer's homescreen to cursed shrek

radiant kraken
radiant kraken
hidden gorge
#

it got blocked on accident during an outage

solemn latch
#

Oop

hidden gorge
#

also since the outage our filter broke itself

real rose
#

Fortnite

north cairn
#
const Discord = require('discord.js');
const token = there is a token here dont worry;
const channelId = "1174021581710823444";
const client = new Discord.Client({intents: 32767});

client.on('ready', async () => {
  console.log(`Logged in as ${client.user.tag}!`);
  const channel = await client.channels.fetch(channelId);
  client.on('message', (msg) => {
    if (msg.content === '!start')  {
      let intervalId = setInterval(() => {
        channel.send('Sending message every 1 second');
      }, 1000);
    } else if (msg.content === '!stop') {
      if (intervalId) {
        clearInterval(intervalId);
      }
    }
  });
});
client.login(token);```
#

bot is not sending msg when i am doing !start

#

can someone help?

deft wolf
#

Why are you listening to message event inside of ready event?

#

You can paste this message event in a similar way to the ready event, plus depending on your discord.js version it may be a message or messageCreate event, so keep this in mind

north cairn
#

v is 14.41

#

so messageCreate?

deft wolf
#

Yep

north cairn
deft wolf
#

You should do it this way

client.on("ready", async () => {
// your ready event
})

client.on("messageCreate", async (msg) => {
// your message create event
})
north cairn
#
const Discord = require('discord.js');
const token = token is here
const channelId = "1174021581710823444";
const client = new Discord.Client({intents: 32767});
let intervalId;
client.on('ready', async () => {
  console.log(`Logged in as ${client.user.tag}!`);
  const channel = await client.channels.fetch(channelId); 
  });
  client.on('messageCreate', (msg) => {
    if (msg.content === '!start')  {
      intervalId = setInterval(() => {
        channel.send('Sending message every 1 second');
      }, 1000);
    } else if (msg.content === '!stop') {
      if (intervalId) {
        clearInterval(intervalId);
      }
    }
     });

client.login(token);```
#

like this??

deft wolf
#

Should work

quartz kindle
#

i cant even begin to say how much wrong that is

#

lmao

north cairn
#

u both just contradicted each other?

quartz kindle
#

he said "you should do it this way"

#

and you did the opposite

#

and a lot of other very bad things

#

lmao

north cairn
#

alr then start saying whats wrong

quartz kindle
#

actually nvm, its not that bad

#

just your indentation is fucked up

#

so at first look the person who sees your code thinks the messageCreate event is inside the ready event

#

but it isnt actually, its just hard to read

north cairn
#

ohk?

#

but code still not working

#
const Discord = require('discord.js');
const token = cant show this
const channelId = "1174021581710823444";
const client = new Discord.Client({intents: 32767});
let intervalId;
client.on('ready', async () => {
  console.log(`Logged in as ${client.user.tag}!`);
 
  });
  client.on('messageCreate', async(msg) => {
     const channel = await client.channels.fetch(channelId); 
    if (msg.content === '!start')  {
      intervalId = setInterval(() => {
        channel.send('Sending message every 1 second');
      }, 1000);
    } else if (msg.content === '!stop') {
      if (intervalId) {
        clearInterval(intervalId);
      }
    }
     });

client.login(token);```
#

this good?

#

permissions are all given btw

#

@quartz kindle so.. whats wrong ?

grim aspen
#

Remind me what version of discordjs you’re using?

quartz kindle
#

intents: 32767 does not include the MESSAGE_CONTENT intent

north cairn
#

14.14

quartz kindle
#

which is required to access msg.content

north cairn
#

ok so what do i put

#

3268?!

quartz kindle
#

32767 is all intents, except message content, scheduled events and auto moderation

#

65535 is all intents except scheduled events and auto moderation

#

meaning 32767 + message_content = 65535

north cairn
#

give the one for all ig?

quartz kindle
#

all intents possible = 3276799

#

although you should just use what you actually need

#

otherwise your bot is wasting internet, ram and cpu for no reason

#

more intents = more events = more internet/ram/cpu used

quartz kindle
north cairn
#

btw code works now

#

thanks a lot

quartz kindle
#

there are a lot of random calculators

#

like this one

#

also

quartz kindle
#

if you do it in 2 channels, you will break it

north cairn
#

its actually a private bot for one server only

#

my friend needed it

quartz kindle
#

ok

#

just tell him to never do it in 2 channels at once then

#

if he does, he will not be able so stop one of them

#

until you restart the bot

north cairn
#

yea sure,or mayb will develop a system of db where i will ask owner to set up a channel in server

quartz kindle
#

you dont even need a db

#

you just need to save different variables

#

you have only 1 variable for channel id

#

so a new channel id will replace the old one