#development
1 messages ยท Page 178 of 1
because most existing builds have major flaws for the api, they ignore/merge historical data from before 1970 timezones
which i need in the api
I see
the idiot lead maintainer thought that was a good idea
if you search for a date for example, in 1948 in stockholm, sweden
you get the timezone for berlin
which is stupid (and wrong)
highhighhighhighhigh
but he says "we onlyguarantee accuracy starting from 1970, evertything before that is out of scope for this project"
dumbass
new phone who dis
Okay so like tf is this
that view
insert no hori bonk meme
-b 1192795369193623673
michaelbyk103_18600#0 was successfully banned.
im sick of you already
lel
is this sleepy nodejs or is this fucked up
ok so like
i think it just sets globals or something
dam
you have to add user to the type of Request
interface CustomRequest extends Request {
user: SomeType
}```
you canโt just assign a variable to an object which isnโt typed to hold that key
declare module 'express-serve-static-core' {
interface Request extends AuthProps {} // Auth props is a type
}```
declare module 'express-whatever' {
export interface Request {
customProp: Type
}
}
Its better to do it that way as you know for sure that it will show up on intellisense
Thats the way I always do it anyways
hadn't figured this out
Also just hope you know that it only adds intellisense auto fill
Some people think differently 
yea
speaking of TypeScript typings, is this the correct way to write typings for a library? https://github.com/null8626/tio.js/blob/master/typings.d.ts
this one lacks the declare module thing, i'm not sure if that's required or not for Intellisense
cc @sharp geyser
jesus fucking christ
weird question should some one mind helping me with somthing
Why would you need the usage of declare module? You aren't overwriting any library types

not sure if its bc it seems top.gg is down bit i keep getting a error code 500 the site will load but if i look up anything like a bot i need it just give me a 500code error
me too
500 is internal server error so yes
One message removed from a suspended account.
site is down
oh ok
i'm quite noob when it comes to typescript typings sorry 
is that why some bots are down too?
im gussing so
if the bots are coded bad, yes
half of my bots all the sudden stoped worked once the site went down then
wdym? what's the purpose of it
no error handling lols
Yea nah, declare module is only useful when outlining what a module should look like without implementing said module, or in most popular use cases overriding interface/classes of other modules
im using dino apply giveaway and a couple others
oh alright
for example when discord.js devs want to add their own things to the client and have auto correct for it they would
declare module 'discord.js' {
export interface Client {
someDevShit: Type
}
}
ooo icic thanks ts god 
you can even expand the library functionality iirc with declare module though I don't remember
I havent used ts in ages

i'm not sure if that huge type alias is necessary or not but i hope it help devs so that they get the right keys 
760+ just from one type is crazy

Thank god you have that in a typings file and not in code

right?
it used to be in code


code go brrr
honestly prettiering that file took ages 
tbf I don't know everything about how declare module works either I just know its intended usage

It seems like declare module is really meant to be used in .d.ts files but I break that rule all the time
yea?
the main script
imports /middleware/auth
note: no file extension
i run the main script
it errors, because it cant find /middleware/auth
Can you not make multiple small messages and put more than 4 words into a sentence
nah ๐
"then fix the no workie" is my response
relative imports without file extensions aren't working
// tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"lib": ["esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"outDir": "dist",
"baseUrl": "./src",
"paths": {
"@/*": ["./*"]
}
},
"include": ["src"],
"exclude": ["node_modules"]
}
@radiant kraken
The declare module syntax in TypeScript is used to declare the shape or structure of an external module or library for which there are no TypeScript type definitions. It allows you to tell the TypeScript compiler about the existence of a module and provide type information for its components.
According to chat gpt
i dont trust chatgpt
its correct though
thats generally what declare module is used for
you can do it with your own modules though as well
every ts file that exports something is considered a module iirc
so you can use declare module on your own files and just modify it in a d.ts file if need be or for some other reason idk
scrollin through node docs and found this
async function * generate() {
yield 'a';
await someLongRunningFn({ signal });
yield 'b';
yield 'c';
}
What's the * before generate()?
And to confirm, yield in promises basically trigger .then everytime? (What about await generate()?)
first .then is 'a'
second 'b'...
it's to signify that the function is a generator function
that's the *
Similar to returning IEnumerable<T> in C#
interesting
and guess what
generator functions are about 30% slower than making your own iterator pattern
lmao
well its been a few years since i tested them tbh
but js has a looong history of adding new/better ways of doing things that are slower than the old way of doing things
I never understood why people complicated iterators so much
This is another one of those things that rust does very well
Ranges and iterators
i recently saw this shitcode
const obj = {}
const keys = Object.keys(obj)
for (let i in keys) {
const value = obj[keys[i]]
}```
ok anyways i've got a little problem
i'm doing mongoose model work and I have a static function
(this is typescript btw)
and I want to return the model as document, I just don't know what to set the types to
lmao
export interface User {}
interface IUser extends User, Document {}
function stuff(): Promise<IUser>
but there's this entire shitheap of an error
Type 'Document<unknown, {}, FlatRecord<{}>' is not assignable to type 'IUser | null'.
then another alike
got it
you could make a union type no?
type IUser = User & Document
or smth like that
unless you are going to be adding stuff to the IUser interface
also can't remember if its & or |
help i'm addicted to rust macros
https://github.com/top-gg/rust-sdk/blob/4fa4b1dd8b308234194b22eb980cc6bbc7568af6/src/util.rs#L8
i feel like i'm writing php at this point
& joins 2 types together. | is or
& is weird
ts is weird
but very cool
Also, if you use the keyword type, the properties are shown in intellisense and depending on the Record's property count, it could be insane and with the keyword interface, it will just show the name of the interface
has anyone used aws sso?
i want to link an aws account from my web app
i checked sso but it looks too complicated
for no reason at all
Welcome to AWS where everything takes a rocket engineer to use
hey does anyone know how to fix this problem? I already enabled cors on my api but for some reason my site doesn't allow http requests back:
[blocked] The page at https://.. was not allowed to display insecure content from http://...
like do i need to go to my domain hoster and enable http requests as well or..?
the api itself (the http) is just locally hosted from my vps, so i am unsure if i can even add a https to it.
how to add images to the bot page on top.gg
from where are you accessing your api
The fix for mixed content is quite simple: Web developers need to ensure that every resource on their page is loaded over HTTPS. In practice, this can prove tricky, as modern websites often load several different resources from various places.
you can containerize your api so it only exposes itself onto localhost
use nginx with certbot and tunnel it to your api that's running on localhost
it's a tedious process but it works
i mean i have a domain name
but i have no clue how to change my api that's currently runnng on my vps using express to my domain name
like tsfeerhuysch.nl/api...
can i maybe change my dns to my vps ip? (my api is currently running using express)
no
you need to configure nameservers on your vps, which provider are you using?
also if your domain name is already in use, you cannot use tsfeerhuysch.nl/api, but rather api.tsfeerhuysch.nl
for the subdomain, just add a new A record on your domain management dashboard
you would set NAME to api and point the ip address to your vps
you might still have to configure nameservers on your vps though
generally you should wait a few hours to see if the changes applied, DNS caching is a pain
there's also another approach with which you can technically achieve your api pointing to tsfeerhuysch.nl/api
with nginx
hostnet
hmm i see
i will try to use api.tsfeerhuysch.nl
it's my first time doing all this
my api still just runs locally on it's api. Idk what i am doing wrong
i already did, but somehow doesn't work
i am sorry, it's an A record
i will just wait it out in the hope that the dns works
you're probably going to benefit from reading https://webhostinggeeks.com/guides/domains/
it should clear up some confusion, the guide is thorough
can a bot input a command to another bot through discord?
mmkay so i'd need to make an API for the other bot if i want them to communicate
thanks
Is there a way to 'synchronize' my mongoose in runtime
I want to make a change to a document
The document is elsewhere in a socket (as socket.user), I want the change I just made here too
switch (condition) {
case value:
{
// my mind goes from, na na na na
}
break;
}```
What?
nothin
I just love it says my mind goes from, na na na na
How much time i need to wait to the page of my bot get refreshed?
I changed the name of my bot and his photo
-refreshdata
Fetching Your New Bot Data
To fetch your bot's new name or avatar, please follow these steps:
Click the Refresh Data button in the sidebar on the right.
Click Edit on your bot page and then Save.
๐ก Please note: If it still doesn't seem to change, make sure you actually changed the bot's avatar / name on your Discord Developer Portal and not the application's icon / name.
But it does not work
Did you do both steps?
Sorry, it has already been updated, although I did the 2 steps I did not realize that it could take 5-10 minutes to update, sorry for the inconvenience.
@radiant kraken So before hand I was using once_lazy or whatever to make globals but idk if thats the proper method.
I want to have a global db connection variable that can be used anywhere in the application
do you really have to use a global variable
How else would I share connection?
They get created then destroyed right after you are done using it
it is asynchrnous yea
its a actix-web app
oh wait
actix web allows you to share data across the app anyway iirc
๐ญ
yup
The top-level builder for an Actix Web application.
Oh yep
thats exactly it
I wonder
Can I just pass in my connection function but give the Data a type of PgConnection
wdym
like this:
HttpServer::new(|| {
App::new()
.service(index)
.app_data(actix_web::web::Data::<PgConnection>::(init_connection))
})
.bind("localhost:2053")?
.run()
.await
or is it Data::<TYPE>()
Application data wrapper and extractor.
so it can take a type
nice
HttpServer::new(|| {
App::new()
.service(index)
.app_data(actix_web::web::Data::<PgConnection>::new(init_connection()))
})
.bind("localhost:2053")?
.run()
.await
so something like this then should work right?
implement something then
Actually before that
How the hell am I going to create a postgres user from this rust app
Cause I am creating a user when they sign up
i've never used postgres before
what
I have to do frontend for this project 
frontend aint that hard bud
It will look ass!
it wont
or sayuri
@civic scroll you free?
on a budget here
yeah true
sayuri would add animations to literally everything
rip the roblox devs on their 200$ laptop
๐ญ
i use a $300 laptop and sayuri's websites run perfectly fine with barely any lag
i'm sure it's pretty well optimized 
doing backend in rust is both annoying and fun
i can help you out of the annoying parts
I have to be careful with rust cause the ownership and borrower is quirky
Right now just trying to figure out the best way to make a user
time to bust out postman
somethin I haven't used in ages
the compiler's error messages are like the most readable thing ever
compared to things like C++
very true
which is why I love C++ but hate its error messages
I've honestly been using rust more than c++ as of late tho
very good
I am just wondering if I should bother making my own mini orm built on sqlx
cause using just sqlx queries all the time without any structure is going to be aids
I think I can use serde with sqlx and parse the select data into readable/accessible data
I will worry bout that later tho
you can always ask for feedback
react is good

use yew as a practice
it's like rust react
A framework for creating reliable and efficient web applications.
rust react
EH?
i've heard mixed opinions about it tho
it uses wasm I assume then?
yup
yea idk how I feel about using yew
if ima be doing front end rather stick with what I know more of
yup
if I try and do smth new ima just stop the project and quite frankly I think mine is a rather smart idea
Make money off those roblox devs 
so what is your project about again
Making an external database tool for roblox game devs
DataStores suck as proven by people expanding on datastores themselves
roblox? .-.
Yes
Roblox games have seen a skyrocket in the industry and are becomming very successful
and where there is success there is money
Why not skimp a few bucks off the top myself?
Free for small games
Paid for anyone who needs more resources
This tool will be purely rest api as you can't do anything else really cause roblox only allows Http calls of Post and Get
I think they might allow you to do some custom ones
but I can't remember
poggers
Only thing I am worried about down the road is performance
but thats a problem for the future me :)
since it's just a database i don't think it does really need that much frontend
bruh
I will have to end up making a database viewer
not everyone will know how to use tools like dbeaver to view their databases
ofc those who do can still choose to do so
they have a connection string, they just need their user + pass and the db name they want to connect to
or I can make a fool proof tutorial on how to use dbeaver 
you wont be crying with my help though (hopefully) 
hello
can you help misty when it comes to frontend
static geometry is boring geometry
based
๐ญ
but roblox devs have potatoe pcs
i have a potato pc and sayuri's websites run fine
not if i abuse css
and canvas
canvas can get quite performant with heavy animations
i see
and svgs :^)
real
Well before I even add a frontend ima at least get sign up and login working
What should I use for auth tokens? I was planning on using UUID but idk if thats unique enough
i haven't seen you play with canvas before tho
yeah
i'm not used to... render engines
what should i say...
ah
i'm used to declarative (state) animation rather than imperative animation
like i declare what state to transition to
for raw geometry manipulation, i will have to specify what to render every frame
Wait
aka. doing the interpolation myself, which is pain
Why am I bother signing up with user/pass
I will just use roblox oauth
I think that exists
but you are literally a render engine
you render svgs
animated svgs
@radiant kraken This is a thing?
I was playing around
and this seems valid
Its just dereferencing a reference and then making it a reference again no?
Nvm roblox oauth is useless
access token is only valid for 15m unless I immediately cache the information as soon as they login I can't fetch anything new (which I will likely need to do if I went this route)
actually nvm wont ever need new info as I can only really access the profile or so to say the profile is the only useful data roblox supplies
yup
what were you planning to do
it's usually used for conversion between rust references and raw pointers

my engine is declarative ๐
declarative and imperative are barely any different
plus you said that canvas is very performant so
rip
F
Love it when has an unplanned maintenance
happened to me several times with stackoverflow
refresh tokens
Refreshing every 15m is annoying
The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf. This specification repla...
I dont think you understand how oauth2 works
access token and refresh token are different
Once an access token expires, you have to refresh it
The access token is what allows you to request data on behalf of a user
refresh tokens don't expire on roblox
i know how oauth works
roblox expires the access tokens, not the refresh tokens
only refresh when needed ๐
this
roblox oauth is just bad
no?
like tokens limited to that short is just unneccesary
you update userdata when e.g. they log in
yes, refresh when a new update is absolutely needed, and store the data where possible
otherwise ratelimits are your worst enemy
i think they're set high for oauth
should be tbh
got a big site with lots of users logging in? no more! 5 logins per minute ๐
it's often 2 requests at once for oauth (login)
getting the access & refresh token
then user info
pretty sure you have to get your app approved for that
which is same for over 100 users
yea
yeah
bound to happen sometime
neko atsume my beloved
best part of the VR g ame is the close ups
Who knows, he may have inserted the token in the wrong place and not inserted it where the new token is supposed to be inserted.
thats not how it works
diff localhost port doesn't load
this is firefox dev edition
on vivaldi it does load
the socket server is not the issue
i can connect just fine with postman
it's cors (cors that doesnt work on other browsers) or firefox
hmm
unrelated but so many people set their DNS A records to 1.1.1.1
its funny
๐ค
chrome
because i've used it all my life and i really cba to migrate from it
switched from vivaldi (too buggy :() to firefox dev
my school uses MS edge
ewww
and blocks everything on it
can't even use inspect element
or screenshot
its not bad
its just annoying
each tab is a new window on alt tab
anything michaelsoft sucks
michaelsoft binbows
name 1 thing
true
got me there
cracked ps
it honestly worked great
name 1 company: Apple
and binbows
@surreal sage can i know your bot name and serevr ??
i dont have any
i had many

ohk
ok
There is also one for FTP
@sharp geyser how's your web app been going
@radiant kraken
error[E0277]: the trait bound `&PgConnection: Executor<'_>` is not satisfied
--> src\routes\auth.rs:37:20
|
37 | .fetch_one(pool.get_ref())
| --------- ^^^^^^^^^^^^^^ the trait `Executor<'_>` is not implemented for `&PgConnection`
| |
| required by a bound introduced by this call
|
= help: the trait `Executor<'c>` is implemented for `&'c mut PgConnection`
= note: `Executor<'_>` is implemented for `&mut PgConnection`, but not for `&PgConnection`
note: required by a bound in `QueryAs::<'q, DB, O, A>::fetch_one`
--> C:\Users\dyeaaaronjr\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sqlx-core-0.7.3\src\query_as.rs:140:17
|
137 | pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>
| --------- required by a bound in this associated function
...
140 | E: 'e + Executor<'c, Database = DB>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs::<'q, DB, O, A>::fetch_one`
help
please
me no understand
you need a &mut PgConnection and not a normal reference
The error is saying that the get_ref function is defined by the trait Executor, but Executor is not implemented on &PgConnection, it is only implemented on &mut PgConnection
What ur making
So something like this ```rs
trait Executor {
fn get_ref(&mut self) -> Something;
}
impl Executor for PgConnection {
fn get_ref(&mut self) -> Something {} // Notice the &mut self here
}
(internally)
I see
But wait
Am I to just use &mut PgConnection as my data type in the generics?
#[get("/login")]
pub async fn login(pool: Data<&mut PgConnection>, data: Json<UserLogin>, session: Session) -> impl Responder {
let result = sqlx::query_as::<_, User>("SELECT * FROM users WHERE email = $1")
.bind(&data.email)
.fetch_one(pool.get_ref())
.await;
match result {
Ok(user) => {
Redirect::to("/").permanent()
},
Err(err) => {
HttpResponse::BadRequest().json({
["successful"] = false;
["reason"] = err.to_string();
})
}
}
}
Alright I will try it
error[E0277]: the trait bound `&&mut PgConnection: Executor<'_>` is not satisfied
--> src\routes\auth.rs:37:20
|
37 | .fetch_one(pool.get_ref())
| --------- ^^^^^^^^^^^^^^ the trait `Executor<'_>` is not implemented for `&&mut PgConnection`
| |
| required by a bound introduced by this call
|
= help: the trait `Executor<'c>` is implemented for `&'c mut PgConnection`
note: required by a bound in `QueryAs::<'q, DB, O, A>::fetch_one`
--> C:\Users\dyeaaaronjr\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sqlx-core-0.7.3\src\query_as.rs:140:17
|
137 | pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>
| --------- required by a bound in this associated function
...
140 | E: 'e + Executor<'c, Database = DB>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs::<'q, DB, O, A>::fetch_one`
๐
I am confusion
I mean you could technically do .get_ref_mut() and it's the equivalent but you should prefer using &mut Whatever
That's some pretty common rust syntax that you should get used to
pub async fn login(mut pool: Data<PgConnection>, data: Json<UserLogin>, session: Session) -> impl Responder {
let result = sqlx::query_as::<_, User>("SELECT * FROM users WHERE email = $1")
.bind(&data.email)
.fetch_one(&mut pool)
.await;
so like that?
I made the pool param mutable cause it wont let me do it otherwise
Close but not correct
Do pool: &mut Data<PgConnection>
Unless you absolutely have to own the pool connection
Usually you should always prefer borrowing over owning something unless you need ownership
Well in this case I dont see why the connection should be owned here
So yea, that should work
error[E0277]: the trait bound `&mut Data<PgConnection>: Executor<'_>` is not satisfied
--> src\routes\auth.rs:37:20
|
37 | .fetch_one(pool)
| --------- ^^^^ the trait `Executor<'_>` is not implemented for `&mut Data<PgConnection>`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `Executor<'c>`:
<&'c mut PgConnection as Executor<'c>>
<&'c mut PgListener as Executor<'c>>
<&'c mut AnyConnection as Executor<'c>>
<&Pool<DB> as Executor<'p>>
note: required by a bound in `QueryAs::<'q, DB, O, A>::fetch_one`
--> C:\Users\dyeaaaronjr\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sqlx-core-0.7.3\src\query_as.rs:140:17
|
137 | pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>
| --------- required by a bound in this associated function
...
140 | E: 'e + Executor<'c, Database = DB>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs::<'q, DB, O, A>::fetch_one`
Okay wth man, I get that it is not satisified but the rest of the error is what confuses me
Also even if you do that it still errors which honestly makes no sense Cannot borrow immutable local variable `pool` as mutable
Because you're not doing pool: &mut WhateverType
I am though?
Show me your full ode
no
there's a difference between
fn thing(mut a: Type)
and
fn thing(a: &mut Type)
^
let thing = &mut ... is a reference to a mutable variable, but the reference itself is not mutable
just pass in thing
fn thing(a: &mut Type) { ... }
let mut x = ...;
thing(&mut x); // ok
let y = &mut x;
thing(y); // ok
thing(&mut y); // not ok
fn other(mut a: Type) { ... }
let mut a = ...;
other(a); // ok
other(&mut a); // not ok
Even if I pass just pool it wouldnt work
the libs you're using have complicated generics and lifetimes and shit so it's difficult to debug without actually doing it myself
what is the type for the argument of fetch_one
oh nvm
Imagine how I feel even with it in front of me ๐ญ
@sharp geyser try pool.into_inner()
wth does that do
Application data wrapper and extractor.
Okay
Roughly the same error
```error[E0277]: the trait bound Arc<PgConnection>: Executor<'_> is not satisfied
--> src\routes\auth.rs:37:20
|
37 | .fetch_one(pool.into_inner())
| --------- ^^^^^^^^^^^^^^^^^ the trait Executor<'_> is not implemented for Arc<PgConnection>
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait Executor<'c>:
<&'c mut PgConnection as Executor<'c>>
<&'c mut PgListener as Executor<'c>>
<&'c mut AnyConnection as Executor<'c>>
<&Pool<DB> as Executor<'p>>
note: required by a bound in QueryAs::<'q, DB, O, A>::fetch_one
--> C:\Users\dyeaaaronjr.cargo\registry\src\index.crates.io-6f17d22bba15001f\sqlx-core-0.7.3\src\query_as.rs:140:17
|
137 | pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>
| --------- required by a bound in this associated function
...
140 | E: 'e + Executor<'c, Database = DB>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in QueryAs::<'q, DB, O, A>::fetch_one
into_inner() returns an Arc<PgConnection>, and that Arc can be converted to a &PgConnection
does the fetch_one() method supports a reference as the argument?
Raw SQL query with bind parameters, mapped to a concrete type using FromRow. Returned from query_as.
Honestly these docs are confusing wtf is all those letters
woah that's a lot of lifetimes
are those all lifetimes?
oh the PgConnection must be mut
@sharp geyser try this!
let mut pool_mut = pool.into_inner();
.fetch_one(pool_mut.get_mut().unwrap());

What in the fuck
uh it should
should be implemented on all Arc<T>
pool_mut is an Arc<PgConnection> yes?
but nothing else
Correct
but looking at the props provided get_mut is not one of em
and errors
No field `get_mut` in type `Arc<PgConnection, Global>` [E0609]
wtf is this then https://doc.rust-lang.org/std/sync/struct.Arc.html#method.get_mut
A thread-safe reference-counting pointer. โArcโ stands for โAtomically Reference Countedโ.
OH
error[E0599]: no method named `get_mut` found for struct `Arc<PgConnection>` in the current scope
no
yes
it doesnt have an extends keyword
it has "inheritance"
but you can simulate inheritance
but it's not designed to be used the same way as in OOP
"inheritance" is achieved using traits
I mean it would suck to make another struct that is similar to another one with an extra field
But dynamic dispatch is slow and should be avoided
You should not use traits for this
Rust has like Box<dyn Trait> which is more or less designed to be used for errors, not for inheritance
#[derive(Serialize)]
struct SignupStatus {
created: bool,
time: i64,
reason: Option<String>
}
I will just use this, and if there is no need to supply a reason it wont error yea :D
what's the problem?
A lot of traditional OOP is avoided by rust because of performance reasons, dynamic dispatch is expensive and often times completely unnecessaru
use core::ops::Deref;
struct A {}
impl A {}
struct B<'a> {
a: &'a A,
}
impl<'a> B<'a> {
fn new(a: &'a A) -> Self {
Self {
a,
}
}
}
// the trick
impl Deref for B<'_> {
type Target = A;
fn deref(&self) -> &Self::Target {
self.a
}
}
let a = A {};
a.a_funcs();
let b = B::new(&a);
b.a_funcs();
b.b_funcs();
@misty.dev
ig this is inheritance
you can store structs in each other
What me no understand
here's a less janky trick ```rs
use core::ops::Deref;
struct A {}
impl A {}
struct B {
a: A,
}
impl B {
fn new(a: A) -> Self {
Self {
a,
}
}
}
// the trick
impl Deref for B {
type Target = A;
fn deref(&self) -> &Self::Target {
&self.a
}
}
let a = A {};
a.a_funcs();
let b = B::new(a);
b.a_funcs();
b.b_funcs();
deref() lets you implicitly also use the reference inside B, which is A
"traditional" inheritance is more or less implemented like so ```rs
trait Pet {
fn speak(&self) -> String;
}
struct Cat {
some_field: String
}
struct Dog {
some_other_field: String
}
impl Pet for Cat {
// impl speak
}
impl Pet for Dog {
// impl speak
}
// Then, you can store stuff like so
let pets: Vec<Box<dyn Pet>> = vec![];
pets.push(Box::new(Cat { some_field: "Something".to_string() }));
pets.push(Box::new(Dog { some_other_field: "Something".to_string() }));
But this is super inefficient performance wise and will 99% of the time end up with borrow checker conflicts
So, composition over inheritance is really what rust tries to promote
You would rarely use Box<dyn ...> tbh
Deref is way better, though it only limits to one Type
Deref is used in things like Arc<> and Box<>, so that you don't have to call into_inner() whenever you want to call methods of the inner variable
I edited it, I should've said "traditional" inheritance
@wheat mesa @sharp geyser here is the documentation for String, you could say that String inherits &str
because you can also use methods from &str in a String
This is a special case though and I don't see this often
it's used very often lol
though i recommend you play around with traits more often misty
you will see a lot of it everywhere
it's an easy way to do operator overloading
making let res = my_struct + my_other_struct; possible
and yet somehow with all this fancy operator overloading I still fucking hate adding strings together
me when println!("{s}{s2}");
if you want to add a &str to the beginning of a String, you can do
second.insert_str(0, first);
i appreciate Rust's way of differentiating string slices with owned strings tho
And yet this is still annoying because I should just be able to add them together without the hassle of calling special methods
me when format!
I should not need to use a macro to concatenate two strings
Every other language on the planet has figured it out
besides Rust is not a very high-level language anyway
Itโs honestly my biggest complaint about rust
Which is probably a good thing considering itโs a minor issue
same goes for C++
I suppose thatโs true for some scenarios but I donโt find myself using C strings super often anyways
use Strings instead of &str then 
I do most of the time
But adding a string literal with an owned string is annoying
Same goes for c++
well either using a macro, a special method, or an overloaded operator is the most you can get out of these languages
it's not that bad
I feel like with the trait system, these operators should be implemented by default
traits are like interfaces
trait Thing {
fn do_thing(&self) -> i32;
fn do_other_thing_default_impl(&self) -> i32 {
69
}
}
struct MyType { a: i32 }
impl Thing for MyType {
fn do_thing(&self) -> i32 {
self.a + 69
}
}
let t = MyType { a: 5 };
println!("{}", t.do_thing());
println!("{}", t.do_other_thing_default_impl());
you can do
fn func<T>(input: &T) -> i32
where
T: Thing,
{
input.do_thing() + input.do_other_thing_default_impl()
}
(you can also do fn func<T: Thing>(input: &T) -> i32, which does the same thing)
Whatโs the benefit of using traits over just making functions normally
Thanks
they are basically like interfaces in other languages
smh
Then what is the difference between a struct and a trait?
Explaining a trait like an interface, but to me it seems structs are more like interfaces
structs, are... structs?
they are datatypes
just like classes
you can't store properties to a trait
how hard is it to get a bot to message all members an info pack about our service?
Not that hard
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i was about to ask that
its relevant info as to why they have joined so in their best intrests
not spam so to speak
like a guide and info
can i send here what i was thinking to see if thats doable, im not promoting ๐ค๐ป
Something like this
With links to channels
Ratelimit is ratelimit, no matter what kind of message you send to the user, you have to be careful not to exceed it because discord will block your bot for some time. You definitely won't send it at once
dmming every member is a great way of being flagged for spam
Im a noob at all this so I appreciate the help
Automod moment

could it be set to say a daily limit over some sort of time frame
your bot will be marked as spam regardless of ratelimits
my bot, even tho its verified, got marked as spam by Discord for sending out too many welcome DMs to users
that was like 300 in a day
discord has a strict antispam when it comes to bots
so be careful
appreciate it guys
๐
might just leave it as the welcome set up and everyone else can figure it out 
how about a bot that kept a tally
say i imput - 2
and another person with the right role could +5
and it kept count in a channel
feel free to dm if anyone has any ideas, appreciate the help legends
im hoping 1 of the 2838 bot developers might have an idea , will pay
just save on the database the ID of the score message
but several ppl could use a command and imout their score for the day
it can technically work if you use an update queue
like, the message update every X seconds (best to use minutes), whenever someone uses that command you modify the tracked message
idk how to explain this tho
they would update the score daily across 10 ppl and give an overall score + or minus
Okay but the idea of traits donโt exist in any other language Iโve seen. Interfaces in typescript for example can have properties or outline a function
rust has many keywords as well that donโt make much sense to me
Such as impl
Iโve noticed it used in combination with structs and I think traits as well
impl stands for implement
with this you can implement your own methods for structs (impl StructName) or implement other traits for your structs (impl Trait for StructName)
๐ค
So let me get this straight, I can use impl to implement methods for my structs or make a trait and use impl on a struct to do the exact same thing?
Sounds to me traits arenโt useful at all
Only thing I can see traits being used for is if multiple structs can have the same methods
But beyond that it seems rather pointless
pretty much, but not really the same methods, but does the same thing
traits can be complex
The core trait for handling events by serenity.
traits can also have default implementations too
for example see https://doc.rust-lang.org/std/iter/trait.Iterator.html
A trait for dealing with iterators.
if you implement this, you can do for elem in your_struct { ... }
you should read the rust book
especially chapter 5 https://doc.rust-lang.org/book/ch05-00-structs.html and chapter 10 https://doc.rust-lang.org/book/ch10-02-traits.html
that sounds a lot like interfaces, are they equivalent?
yup, except Rust traits don't support required properties - they only allow functions/implementations
thus, impl Trait for Struct
wdym required properties?
e.g require classes that implement such interface to have a specific attribute/property
ah yes, I was using java interfaces as a reference, we dont have that either
dont know much about rust
Traits are extremely useful for extendability
You can add methods onto structs that you didnโt create yourself
Without the mess of extending things like in traditional OOP
Qucik question
<here could be your answer if you just asked the question>
One message removed from a suspended account.
Hi
It would elate me if you were to provide the solution to a problem I have been having. I do believe the problem will be resolved quickly. As such, I will refer to this as a quick question
One message removed from a suspended account.
?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
May I request service
503 service unavailable
just finished generating 99 combinations of images to represent all possible professions, races and genders in my bots game.
realised I would need a way to allow already established players to set or change their gender now.
what a huge feature I'm exhausted, babysitting midjourney for hours.
trying to tell midjourney what an enslaved lesser orc looked like without hitting their nsfw filters (they really don't like the terms used in the prompt lol)
imagine using ai art smh
and?
can you afford 99 photorealistic art pieces? and have them delivered same day? it would cost tens of thousands and take months.
the amount of images I have in this bot is staggering
many more than you can generate on their free trial
you're just frustrated that it's no longer only accessible to people who can afford to hire an artist, im through with paying someone a commission or using stock art
yes :^)
One message removed from a suspended account.
i can pay @civic scroll to make 99 art pieces for me 
anyone able to help me with this? i cant get the spotify card to align with the stuff above the spotify card im not too good w front end ๐ also its not fully aligned vertically and i also want the stuff above the card to bne all the way to the left aligned with about me and i want the spotify card to be all the way aligned with the end of the line on the right
https://sourceb.in/4Tnq6BUmR6
https://sourceb.in/yhtzVNKurQ
excuse the aids of a css file
essentially i want it to look like this
and if spotify has display: hidden; i want it to still remain the same
Like this?
Some content wont load for me, as I dont have all the files
Op, I didn't see the part about hiding spotifys card
I dont think i'll need the link.
oh alrighty, what isnt loading then?
Oh just the images, nothing I need to play around with it.
lemme make a gist, and play around with it to make sure this is right.
I might spoonfeed a little here, but only because you seem to really be trying ^-^
thank you, and i really have ๐ฅฒ ive been trying to deal with this problem for almost 2 hours now
I'm still learning too, so playing around with this is good practice
yeah i mean ive defintely learned alot so far with css just today alone with this site its defintely good practice BUT VERYYYYY IRRITATING
1000%
Have you played around with figma?
Using figma auto layouts helped me with learning flex.
i have not actually but i think i should, i really wanna get into front end but everytime i attempt to i remember why i didnt last time ๐ฅฒ
So, there's a small issue with what I'm giving you.
Without the spotify thing the heights change, just set the parent div to a min height above the spotify height(solving everything would make me feel bad, but I can help if you cant figure it out)
https://gist.github.com/Team-Woo/1d26cf45dcc3b398ef65fb071c573f36/revisions
I did delete a few things that looked un-needed, but wasn't sure how much you need for other things.
alrighty thank you so much and i actually appreciate the challenge its the only way to learn. ill def try to fix it tmr since its getting late here and see what i can do! thank you so much for your help and ill keep you updated :D
thank you again for your help
did I succeed in making the ai think it has feelings https://fs.rjns.dev/v/cvBPsTWZAVAHhLYfwk
finally got around to making a faq page, feedback welcome. anything i missed thats obvious, ping me and let me know
https://www.ssod.org/frequently-asked-questions/
youll only know when the robot apocalypse begins
"you hurt my feels now you must die" 
Why no dark mode 
because no ๐
i wanted to concentrate on the bot this time around, not websites, so ive used my old wordpress site and its theme, instead of spending weeks designing a new site. it does the job and has mighty seo
Understandable
i will need to do some custom web work when i roll out the premium sub
im still not going to use discord's monetization
The website itself is quite understandable and readable, I have no objections to that, but what really irritates me is the fact that at the very top there is such a nice background and below it there is no background, only these black bars
@radiant kraken @wheat mesa so I have a struct that is for use when I am giving status information such as if something succeeded or failed, and if something succeeded I dont need a reason so I made that field an Option<String>, thing is when I go to use the struct and give the reason field a value that has the type String I get the whole type expected to be Option<String> but got String instead thing, should I use Option::from(value) or Some(value)
Some(value)
Whatโs so wrong with asking questions
Sorry if Iโm inconveniencing you I wonโt ask anymore
it's okay, i'm just advising that you should read the book
since it gets to the basics in a simple manner
its fine misty i barely read the book either
i just asked my friend for stuff and read the rest of the docs
i read the book until i got to the chapter that talks about lifetimes 
and then i quit from learning Rust for about a year
I don't read the book simply because thats not how I learn
I can read it all day long but I won't remember or actually understand any of it
oh alright
how do you learn? just wondering
by examples im guessing
which is the same for me
theres RBE, maybe he'd be interested in that
I learn by doing, as with most people I think
I learn by just experimenting
I read the basics and go from there
Playing around with the language is more helpful then reading a book on how it works.
ah ic
honestly i used to do the same too
It's what I have always done and it seems to work out.
whenever i read docs i would just scroll down to the example codeblock
and read the passage before it
I look at a lot of examples as well, but most of the time trying to do something and looking at the error to see what I did wrong then fix it is more helpful
Cause I learn what I did wrong, how to identify it, and how to fix it
it's at the bottom of almost every error stack 
Honestly with rust I find myself spending more on structuring the data then actually coding ๐ญ
I look at the top
:D
kekw
use std::sync::Arc;
use actix_session::Session;
use actix_web::*;
use web::{Data, Json};
use sqlx::{Executor, PgConnection};
use serde::{Deserialize, Serialize};
use argon2::{self, Config, hash_encoded};
use chrono::offset;
use uuid::Uuid;
trait HttpResponder {
fn get_time() -> i64 {
offset::Local::now().timestamp()
}
}
#[derive(Debug, sqlx::FromRow)]
struct User {
id: i32,
username: String,
email: String,
created_at: i64
}
#[derive(Serialize)]
struct HttpError {
time: i64,
reason: Option<String>
}
#[derive(Deserialize)]
struct UserSignup {
email: String,
username: String,
password: String
}
#[derive(Deserialize)]
struct UserLogin {
email: String,
password: String,
}
#[get("/login")]
pub async fn login(pool: &mut Data<PgConnection>, data: Json<UserLogin>, session: Session) -> impl Responder {
let mut pool_mut = pool.into_inner();
let result = sqlx::query_as::<_, User>("SELECT * FROM users WHERE email = $1")
.bind(&data.email)
.fetch_one(Arc::get_mut(&mut pool_mut).unwrap())
.await;
match result {
Ok(_) => {
},
Err(err) => {
HttpResponse::BadRequest().json(HttpError {
reason: Some(err.to_string()),
time: HttpResponder::get_time()
})
}
}
}
#[post("/signup")]
pub async fn signup(pool: &mut Data<PgConnection>, data: Json<UserSignup>) -> impl Responder {
let salt = Uuid::new_v4().as_bytes();
let config = Config::default();
let hashed_pass = hash_encoded(&data.password.as_bytes(), salt, &config).unwrap();
let result = sqlx::query_as::<_, User>("INSERT INTO users (username, email, password, created_at)")
.bind(&data.username)
.bind(&data.email)
.bind(&hashed_pass)
.bind(offset::Local::now().timestamp())
.fetch_one(pool.into_inner())
.await;
match result {
Ok(_) => {
let create_user_role = format!("CREATE USER {} WITH PASSWORD '{}'", &data.username, &data.password);
sqlx::query(&create_user_role).execute(pool.get_ref()).await?;
HttpResponse::Created().json(HttpError {
status: 201,
time: HttpResponder::get_time()
})
},
Err(err) => {
HttpResponse::InternalServerError().json(HttpError {
reason: Some(err.to_string()),
time: HttpResponder::get_time()
})
}
}
}
this looks so bad
๐ญ
is your rust project still in one file ๐ญ
oh okay good
First thing I learned how to do was make mod files

No way was I going to make a 4000+ line project
this looks okay, but why is HttpResponder not implemented by any type
hm?
I orignally had it with HttpError cause that is the big place that I would be using it
but idk too much about traits and it seemed useless to do so if I wasn't going to be doing much else
you should remove the HttpResponder trait and make get_time as a standalone fn
I can yea
I plan on having multiple util functions so I might as well move it to a whole new file all together
this is a good example
pub trait Summary {
fn summarize(&self) -> String;
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle {
fn summarize(&self) -> String {
format!("{}, by {} ({})", self.headline, self.author, self.location)
}
}
pub struct Tweet {
pub username: String,
pub content: String,
pub reply: bool,
pub retweet: bool,
}
impl Summary for Tweet {
fn summarize(&self) -> String {
format!("{}: {}", self.username, self.content)
}
}
pub fn notify<T: Summary>(item: &T) {
println!("Breaking news! {}", item.summarize());
}
So dont actually implement the function in the trait just outline what it should look like?
you can call notify with a &NewsArticle or &Tweet
Gotcha
not really
@sharp geyser
those are default implementations so that you don't have to include it whenever you do impl MyTrait for MyStruct, doing so would override the default implementation
You can't avoid it, only learn from it 
can you tell me the error?
There has to be a better way
Arcs (atomically reference counted types) are very useful when sharing data between async threads, especially between async/await code
I see
bro
reading the shit off of the error explainer is more confusing then the error ngl
I get the value is freed and since its being borrowed thats bad
send the error
error[E0716]: temporary value dropped while borrowed
--> src\routes\auth.rs:70:16
|
70 | let salt = Uuid::new_v4().as_bytes();
| ^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
71 | let config = Config::default();
72 | let hashed_pass = hash_encoded(&data.password.as_bytes(), salt, &config).unwrap();
| ---- borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
I understand the error
but clicking the error code (as you can in the ide terminal) and reading the page it takes you too is more confusing
let uuid = Uuid::new_v4();
let salt = uuid.as_bytes();
.as_bytes() here doesn't consume (immediately drops it after being called) the Uuid type, so you can't use it in one line
I see
So what exactly does consume mean here?
I thought once something reaches the end of the scope it is gone
fn thing(consumed_value: i32) {
// consumed_value drops after this function ends
}
let value = 5;
thing(value);
// you can't use value after this, because it's already dropped/no longer exists
// therefore it's 'consumed' by thing()
// borrowing is the same thing as referencing
fn thing(borrowed_value: &i32) {}
let value = 5;
thing(&value);
// you can still use value after calling thing()!
Man I am actually bout to throw my pc, I am crying ๐ญ
Why is async rust so fucking annoying
Also using postgres in rust
btw i32s (or any primitive number type) cannot be consumed so it's actually fine to call thing(value);
but not for other things like Strings
I see
Honestly tempted to start this project over from scratch
I've gotten too messy with it
and cleaning it up is going to be annoying
because when you make a copy of it, it doesn't matter because the value doesn't change (not the same story for things like Strings, which have to point to a specific memory location)
It's fine misty
we all went there before
as you understand more you will constantly want to rewrite the entire thing
Rust is the lang I prefer to use for this, but by golly is it so fucking annoying
it's fine, i can always help you
Honestly I think I am just overthinking the entire thing
I am trying to do multiple things at once
And I am also trying to make everything perfect and worrying too much about how it will work
sameeee
this is basically one of the things preventing me from making any new projects 
that perfectionism
Yea
Not to mention that I have grown to hate working on things by myself
I am more of a team player now 
So doing shit by myself is a big reason I lose motivation
oooooof
you can always have me on the project 
If you want to, i'd love the help
A lot of it has to do with my need to seek praise from people who use my services 
I like making things that help people
SAMEEEE
i tend to make libraries more than actual standalone applications

on god
maybe because they're simple in nature
I used to do the same
but then I saw no one was using em
and got depressed
I will say though I had a guy add me years ago and ask me questions about a lib I made for tracker.gg
so that was kinda exciting
i've had several people port my library to other languages with their wrappers before
my lib was featured on a reddit thread and stackoverflow post once ๐ญ
oh nice
though it's only one guy saying it
when i can vote 
hey all it takes is one guy
@radiant kraken honestly no idea why I am overthinking the database.
I myself am only going to be having a single model to hold user data, the rest will be them creating their own.
it's okay, happens to me often too







