#development
1 messages · Page 179 of 1
looking at my old code I was doing it entirely wrong to begin with
Then again I also can't tell what I should return in my connect function as it can be a number of things
I mean .connect returns a Pool<Postgres> but when using that with the app_date that actix_web has I think it will cause some funky stuff again and I will have to use Arcs
Honestly if possible i'd love to avoid Arcs until I fully understand them 
It's fine misty
though i dont think you can avoid Arcs imo
can you elaborate
use sqlx::{ConnectOptions, Pool, Postgres};
use sqlx::postgres::{PgPoolOptions};
async fn init_db_connection() -> Pool<Postgres> {
PgPoolOptions::new()
.connect("postgres://no:andno@localhost")
.await
.unwrap()
}
``` returns a ``Pool<Postgres>`` right
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(async || {
App::new()
.service(index)
.app_data(Data::<Pool<Postgres>>::new(init_db_connection().await))
})
.bind("localhost:2053")?
.run()
.await
}
Then I use it here
but as in my old code I have to do
async fn handler(pool: &mut Data<Pool<Postgres>>) {}
and use arcs to even make use of the pool
All this is very confusing to me as I still don't even know what &mut Data<Pool<Postgres>> is
I always thought it was mut pool: Data<Pool<Postgres>>
didn't know you could make a type mutable
fn thing(mut value: Type) {}
// value is mutable ONLY in this function
// value.thing = 2;
// value = 2;
fn thing(value: &mut Type) {}
// value is immutable, but it's a reference to a mutable value
// value.thing = 2;
// *value = 2;
yup
@lyric mountain any resources you recommend for learning flutter? Gonna try to get back to working on that app
well, honestly dont know where to point at, I've been jumping between stackoverflow and official docs whenever I needed something
didn't follow a tutorial at all, and besides, it looks very similar to react (before it became FP)
I struggle a lot with aligning things and what containers to use etc
I also need to just learn dart bc my knowledge of it is very limited
Even though it’s similar to Java, I should probably still learn it outside of flutter
dart is more akin to c# tbh
while inheriting the async/await thing from js
but u can learn it along with flutter, since it literally has no use outside of it
as for the containers, they're quite literal, columns for vertical lists, rows for horizontal lists
container for...containing (like a div)
sizedbox for making a sized box
singlechildscrollview for making a single element scrollable (usually used with columns/rows since they dont have scrolling by default)
all languages are designed to solve a specific problem, they just happen to be turing-complete
dart could likely fit as a drop-in replacement for a ts project if u wanted
it's just that dart was made for flutter and flutter made for dart
weird circular dependency
site always down 
just watch the notification channel, every now and again when the sites up you'll get a ping so you can use it 
o seriously omaigot 
uff time
Do you can recommend me a bot hosting platform which host bot 24/7 ?
Yes, any VPS that has at least 1GB of RAM
Such a VPS probably costs a few dollars per month
I pay 5 euros for 12gb of ram, so you probably won't have any difficulty finding cheap hosting
1gb is tight for most bot devs, unless ur tim
tho I never see offers lower than 8gb tbh, unless it's some rando host
germany is full of <8gb
It's been a while since I've last hello here. 👋
@lyric mountain What are your thoughts on APCSA?
never hear of 'er
looks like our first semester in my former university
Yeah, it actually is a course offered in universities.
it's a good roadmap I think, start from the base and build up
I see java mentioned there, personally I'd start with C for the fundamentals
then move up to java for learning oop
I mean, CollegeBoard only offers, in terms of Computer Science, Principles & A (as in Java).
Hmm, what are the orders of the programming languages you would suggest someone who wants to get in programming?
c then java
I've, personally, always suggested individuals to start with a dynamic language, not immediately static.
which is the order I did
Aha, I actually did JS, TS, then Java.
by starting with dyn langs you get unhealthy habits
Honestly, I started with JS and get interested in static more 😂
learn through suffering lmao
@feral aspen very very cool website
just a bit sad that there is only one blog post
It's broken, at this moment :/ (blogs don't show up in home)
why is that? it looks perfectly fine to me
the only thing odd is that the blog section is empty, while there is one featured blog post
Exactly. ^
I think people tend to learn static easier after learning dynamic, no?
btw, a language I'd really recommend is groovy
Looks like Java
well, it is java
dynamic is easier than static for beginners
What is it, the TS of JS sort of?
but it's easier to run into errors
by errors i mean runtime errors
Isn't Java already getting more lenient somehow?
I haven't been into programming for a while actually.
kinda, but it's still very strict
Isn't the class x, public static... going away?
I'd say it's getting more qol
only one specific case
Yeah, not efficient for large applications, I believe.
public class Main {
public static void main(String[] args) {
...
}
}
becomes
...
for the rest it stays the same
i would suggest newcomers to understand the concept of a variable, ifs, loops, and functions first before jumping to a language
Hmm, what do you think of this change
given I always have other shit in the main class, doesn't make much diff to me
Yup, the foundations
but can be useful for testing or very simple inits
Fair enough. But, I feel like there's huge disadvantages I'm not aware of
what makes groovy differ from things like kotlin
Since I've never really made huge projects using Java, pretty much
groovy is a java superset, so it's 1:1 compatible and requires zero code change to migrate to
same goes for kotlin, no?
nope, the structure is different
I have been learning Swift the past couple of months...
groovy was intended as a webserver and scripting language for java
and as such, it has a helluva of syntactic sugar
nice
but when it compiles, it becomes java, so u lose nothing to it aside from a bit longer compilation time
i wish could learn swift but i dont have any apple device
I was, actually, given one by an Apple Competition hosted.
In a nutshell, in Dubai, Apple hosted this one competition that had almost 4,000 students, across many schools, create prototypes for an app that promotes resilience, tolerance, and what not.
very nice
Out of the 4,000 students who participated, and 2,000 who sent their prototypes, only 200 were eligible to win a MacBook and one of them was me and my team. :)
i wish i had any of that in my country
my school doesn't even have a computer science subject

Neither does my school, I'm having to continiously suggest them AP courses to offer us.
I'm like the only individual in my entire school who takes APCSP as a course, no one else.
i've never taken any computer science course before
100% of all of the things i've learned are from the internet lol
Yup, & to be fair, school is limited in what they teach you when it comes to computers.
I mean, I know for a fact they're just giving us opportunities to test out fields that interest us.
Yeah, but you're still self-studying most of the time
wha
I'm not a uni student, yet, but that's what I was told, too.
which is why most people come out of CS colleges clueless and mad that they haven't become steve jobs
What are your thoughts on students entering CS major with no clue how computers work in the first place?
basically, they teach you what to look at when researching programming topics
dw, they would learn how to code eventually
they can't realistically teach you how to code because they'd need to refactor all their material every few months


is it just me thats having problems voting? it keeps on saying "attention required", its been around 2 days
I was told a pretty good point, despite the fact you know how to code and such, universities won't remove certain courses from you, regardless?
what do i have to do
Didn't touch any of my code, but all of a sudden my message collector stopped working? I checked an even hardcoded in the channel value and my bot doesn't read any message sent in the channel even though it's correct any clue why?
I mean, the only way to remove such courses is if you prove it to them by taking an international exam, such as APCSP, APCSA or any other CS exam.
Send code.
let collector = channel.createMessageCollector({
filter: (msg) => {
console.log(msg)
return msg.author.id === userId
},
idle: 30*1000
});
expire works
but it doesn't collect a single message
I hate that I need to use that shit at my job

no really, you'd be grateful about using java "My name is " + name + ", and age " + age + ", escaped quote \""; after having to use ```pascal
'My name is ' + name + ', and age ' + IntToStr(age) ', escaped quote ''';
admittedly, this aint the biggest issue, which is the fact that the only IDE u can use constantly freezes or decides not to allow ctrl + space at random
...and then string templates
Nicely done! Congratulations

Thank youuu. 
what prototype did your team sent?
I think they mentioned the reason in #announcements yesterday :)
yeah read that before , but i thought votes wouldnt get affected
sad though
i thought i had a chance this month to get 101 votes xd
"which unfortunately led to a (deliberate) reset of votes. I made a backup - but it's a massive file and restoring votes may take a while. "
damn i did miss that lmfoa
ty for clearing this out
hey how to report im unable to access top.gg with message "Sorry, you have been blocked"
and any other channel
this issue is known
The have an announcement that clears this up
so i just have to wait?
yes
oh ok thanks
"The site will automatically unblock when the attacks stop"
When will the attacks stop?
No but They are annoying
I mean, medal is topgg too
why isn't this channel locked too at this point
Because most people probably don't even know it exists
fr
We can simply ignore them because none of this news will change the fact that things are the way they are
It is being normal atm
DDOS attacks
what's that mean
And something with proxy
Looks very normal
Artificially generated traffic numbering hundreds of thousands or millions of simultaneous visits to the website
so basically what uhh that one hacker group did a while back
DDOs isnt even "hacking" its just spams
literally can just spoof and change a packet size
nothing crazy
oh it's cyberbunker
no\
that's what this is talking about
literally google 50 min of networking and youll have the knowledge
the issue would be getting bots
so how does the situation get better then
cause top.gg usually functions right the past 4-5 years ive been voting on it
roughly^
its up now
Dirtibuted Denial of Service attacks. In simple terms, It sends many tens of thousands of bot IPs to one ip address to overload the ip and cause it to crash.
Can i ask: how long will it be till the blocked be lifted?
I'll surprise you, but we don't know that either
after five hours of pain, i've successfully made my first procedural macro
@wheat mesa
Try using opera mini it's work except chrome
reminds me of the hello_world("print") thing
ive tried on mini and on gx
none work
Read the latest message in announcements.
But my chrome blocked
ignore the println! below 
I don't want to lock this channel too as people are using it for actual development things
put "site down" and "blocked" as automod triggers 
but yeah it's akin to a decorator 
i've been planning on making a Notepad++ plugin framework in Rust
Gl
vp works
vpn works
@long whale read #support and #announcements
it says its ok in announcementsd
i mean status
they probably blocked all of asia for the ddos attacks ngl im having to use vpn from a place across the world

no
Nope, there #announcements
Ty
Thank God, these Nonsense Access Block Message effects only some People and not all Users around the World
i have a question someone help me out
what
@oak cliff
i mean standard time
There are several time zones
what's this blocked things 
+0 ?
so just an issue? 
ye
#make Webster support staff
@oak cliff
Why me cant type in general
because people dont read announcements
In my opinion, they should be timeouted for 30 minutes for not reading the announcements 
is that another com.netbeans.net.channel.TextChannelFactory
I can't timeout that many people 
unless...
_ _
not with that attitude
Read #announcements
Hmm, it seems one of their rate limit rules got tripped out on Cloudflare, so its limiting everyone. AKA another DDoS attack.
That's specifically what that screen means.
Unlucky
I'm unsure why they aren't just captcha/JS challenging every non-API request, then again who knows with a site as big as Top.

Bots can
how to fix it?
Fix what?
just fix it
just fix it damn it
If it isnt broke, dont fix it
Hey guys
I am trying to create a new site, how can I make sure that it works for all devices and on all platforms?
I use media tags but problem is that it looks way worse on safari then google etc due to headers etc
I always use vw and vh, but is it better to just stick with pixels instead?
And then just use media queries to fix different screen sizes
Fuck this I am learning bootstrap
Yes
Execution failed (exit code 101).
C:/Users/dyeaaaronjr/.cargo/bin/cargo.exe metadata --verbose --format-version 1 --all-features --filter-platform x86_64-pc-windows-msvc
stdout : error: failed to load manifest for workspace member `C:\Dev\robase-2\src/account/create_account`
Caused by:
failed to read `C:\Dev\robase-2\src\account\create_account\Cargo.toml`
Caused by:
The system cannot find the path specified. (os error 3)
stderr :
bro wtf
what in the hell is it looking for
okay fixed it
for some reason it added a workspace thing to my cargo.toml
how to escape from blocked websites

how can i fix npm not saying fuck you when i want to use pnpm
(i have it installed as dev dependency)
oh great discord's down
"preinstall": "only-allow pnpm",
it doesnt do anything
is only-allow installed globally
dev dep
why are you using npm in your terminal
use pnpm
this seems to be related
https://github.com/prinsss/just-pnpm is a viable alternativa
mate
bruv
i want to use pnpm
but im still used to npm
so i want to use the fucking preinstall script
but it isn't running
so npm isnt aborted
firefox bugging..?
doesnt work
One message removed from a suspended account.
what
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.
One message removed from a suspended account.
i aliased pn to pnpm and it made it easier to not accidentally type npm
would bootstrap also be any good?
idk it seems easier to learn than tailwind
Easier in the sense that i just don't want to take on too much as i am currently also diving into more haskell and some ML techniques.
What is the difference between using yarn, bun, pnpm and npm
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.
One message removed from a suspended account.
One message removed from a suspended account.
bun includes a fast package manager
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
if you can make it not look generic, probably okay
is there a good dev that know fortnite apis acces_token and stuff
/*
recurrence relation:
found sequence: {2,2,4,6,10}
a_0 = 2 (month 1)
a_1 = 2 (month 2)
if n >= 2 then a_n = a_(n-1) + a_(n-2)
*/
let array = []
function fib (n)
{
if(n == 0 || n == 1) return 2;
if(array[n] != undefined) return array[n];
let result = fib (n-1) + fib(n-2)
array[n] = result
return array[n];
}
i found this implementation of a fibonacci sequence. Does anyone else know a faster way to solve this sequence? I don't think there's any but not sure
i used dp together with memoization to reduce extra computational work
to be fair, we could actually compute it in linear time using a different equation but that's cheating 
Usually recursion is pretty bad for performance
I would use just a regular loop here
And yeah there’s an approximation that’s pretty damn accurate but if you’re looking for exact results this is probably the closest you’ll reasonably get
You also really don’t need an array unless you plan on using it for caching values, in which case that’s fine
is work using vpn?
Huh?
hello i want to make a website but i dont like writing html is there any alternatives to html?
like ejs maybe
One message removed from a suspended account.
ejs isn't an alternative to anything it's an implementation of a web server in js
and no there are no alternatives to html
ohh right
I use php with bootstrap but it has some html and css.
what is the purpose of nextjs and react?
have you considered just installing a wordpress site or using a site builder like that one they always shill on YouTube
I forget it's name (sponsorship failed)
even with the amount of experience I have with web dev sometimes it's not a good use of time to spend ages making site design by hand, the reward is purely academic
"I made my bots site by hand only took me 4 weeks"
vs
"I got my bots site up in a day to go alongside my bots release date"
end user does not care what tech you used and how neat the html is
the site i'm planning on making is like truth or dare but anonymous will wordpress work for something like that?
Anybody know a better way to handle "rotating prescenes" - This works fine for a while but gets stuck after like 4/5 hours... Possible API limit?
# List of presences
presences = [
discord.Activity(type=discord.ActivityType.watching, name=f"{num_servers} servers"),
discord.Activity(type=discord.ActivityType.playing, name=f"with {num_cards} cards"),
discord.Activity(type=discord.ActivityType.listening, name=f"{num_users} users")
]
# Rotate through the presences
for presence in presences:
await self.bot.change_presence(activity=presence)
await asyncio.sleep(30)```
I don't get why it'd get stuck only after 4/5 hours, I'd see it getting stuck after only 60 seconds
You're looping over the array only once
use a while loop or something else
that for loop will loop exactly 3 times and that's it
using a for loop with await seems a weird way to do this, why not a timer?
or why not put all that info in one presence line, and not rotate? what if you want to know how many servers and it's currently showing cards, you gonna stick around 3 mins?
The rate limit for all gateway message sending is 120 per minute.
The way you're doing this is once it goes through all of the presences in the array, it stops as there is no repeating. If you want them in order, make sure there's a way to repeat the loop. If you want random, do what brain suggested and have them on a scheduled interval and then choose a random entry from the array.
Non of it is important information
async def update_presence(self):
while True:
# Get the number of servers the bot is in
num_servers = len(self.bot.guilds)
# Get the number of cards from the 'cards_table'
num_cards = self.cards_table.count_documents({})
# Get the number of users from the 'users_table'
num_users = self.users_table.count_documents({})
# List of presences
presences = [
discord.Activity(type=discord.ActivityType.watching, name=f"{num_servers} servers"),
discord.Activity(type=discord.ActivityType.playing, name=f"with {num_cards} cards"),
discord.Activity(type=discord.ActivityType.listening, name=f"{num_users} users")
]
# Rotate through the presences
for presence in presences:
await self.bot.change_presence(activity=presence)
await asyncio.sleep(30)
entire snippet btw
Sorry, pasted wrong thing was having 2 conversations at once, it is a while loop
So yah back to question one, anybody know why is getting stuck after like 4/5 hours?
it's basically queueing up a ton of awaits until the heap overflows
isn't it?
because the whole function takes 90 secs to run
idk, something smells fishy
but python isn't my jam
while loops should wait until all of the code is executed to run again
key word should
Hey I had a question about how I'm handling my database. My friend who back in the day (like 4 years ago) helped me set it up but now I kinda wanna redo it but want to know if it's good idea or not. So how it is right is - really inefficient. It's a mysql database using keyv where the key is the user and the data is a JSON object - but it's compressed. I don't like this approach as each user has profiles so first I have to query the user then decompress it then take the selected profile then query the database for that profile then decompress the profile. I've been using prisma a lot with another project and was wondering how hard it would be to migrate to that. I'm thinking I should probably do it now as I only have around 400 entries in the database atm. Anyone with an opinion on this? And how hard would it be?
It all heavily depends on your needs and what you're willing to compromise. If you need relational storage like being able to join multiple tables together and add properties from those other table queries then a relational/sql based approach would be best in which I would recommend Postgres (sql based) just for performance and query optimization opportunity. If you only need to store objects or simple K,V then something like Redis would be ideal. The thing with Redis is that it isn't made for persistence across restarts but has some form of it. There may be disk based K,V storage to look into, but Redis is a go to for ephemeral K,V storage because access times are low because of being stored in memory. Another downside with Redis is that you have to store the Objects as JSON encoded strings and decode, though this process is trivial if you have a helper function.
I have personally use both and still use Postgres since I have to have relations like being able to query multiple tables and include their data in the response
I should probably move back to Redis for voice states and the likes
Would give postgres some breathing room
yeah I'm introducing guilds soon so relations would probably be optimal so I can query everything at once. I'm already using mysql, would that be fine or do you suggest going to postgress? Because I already have it set up on my vps
Postgres has some different syntax like prepared statements no longer use ? but instead use $index where index is the 1 based index of the prepared statement array, though like this, you can optimize your insert statements and omit duplicate prepared statement array entries. If you wanted to keep your sql lib the same and interface with your db the same way, I'd actually recommend MariaDB over MySQL since Maria is open source and tends to perform better and it's just MySQL
If you do choose postgres, I have an ORM I made which does support query optimization. It isn't as complex as some other ORMs, but gets the job done. Table joining will have to be done raw though.
https://github.com/AmandaDiscord/Amanda/blob/restart/packages/sql/src/orm.ts
Ye it's screaming at 4% usage
With about 20 other docker containers
quick question: where the actual fuck is the device manager tab? I remember having this problem a while ago
I can't find it anywhere
yeah I'm actually using maria
Then you can stay there should you choose. Postgres is just an option. It can handle caching like guilds, though I'd recommend using Redis for that as that data should be ephemeral
@lyric mountain have you ever had any problems with device manager? I'm going Tools > Android > Device Manager but when I click on it, nothing pops up and nothing happens
nvm ofc as I ping you I fix it by rolling back my intellij version
lmao the moment when the computer fixes itself just as you show a technician
had that happen a lot with printers
yo by chance does anyone know how long it takes for the site to update the name of a bot after changing it? i changed the name 2 days ago and it still displays the old one on the site. idk if there’s something i have to do or if it just takes a while..?
you have to click refresh data and edit and save your bot description
actually recursion was the best performance here that i could possibly achieve
and that array was important for memoization
this way i only computed each element in the sequence once than having to compute each element multiple times in the sequence
if i used a regular for loop here i would have to fill in tabular data and work ffrom there, but in reality that would just have more memory overhead for minimal or maybe no gain in runtime at all
well, you basically did what quickdb does
and yeah, it is a good idea to refactor the structure
if you're fine working with key-json structure, then perhaps mongo would be a better option
otherwise use columns and relationships
been busy with some stuff so I couldn't show up as usual
Fair enough
hmmm, that "other popular bot list" is down atm, but i learned something interesting
theyre hosted on heroku lol
theyre not
thats the nuxtjs error page
google shows others having same page
It’s same / similar error message and design
@real rose wanna buy some bitcorn
-b @slim kite btc scam
hamid0962#0 was successfully banned.
HE JOINED MY SUPPET SERVER
just ban him...
has anyone used websockets with cloudflare?
Does anyone have an approx count for the number of websockets on the free/pro plans?
https://developers.cloudflare.com/network/websockets/#availability
They just list low and medium
It seems you can do more stuff with discord.js than discord.py. Is this correct? I have zero familiarity with js but it looks like it has better customization for bots.
Second question. Does it work good with postgresql?
I have my bots based off discord.py
Depends on what you mean by "you can do more". You can do anything with any language. Whether it's javascript or python or java
Everything is based on the Discord API which, in the case of discord.js, is so idiot-proof that you practically don't have to think because the Internet is full of guides and so on
I'm unaware of anything you cant do in discordpy that is doable in discordjs
The only thing I have so far is voice activity. Discordpy doesn’t have anything native build in and looks like discord js it does. This is why I was wondering if there is more stuff.
To detect when user speaks I mean. Not necessarily listen to the convo but detect voice activity and discord js it does.
I might over look as well since was last night I was looking for it and couldn’t find anything on discord py
Had a long night 🤣 looking for that
Voice activity is a voice ws thing unfortunately, so you'll need something for that
Also, unless you're server deafened, the voice data is still sent to you regardless
Py likely has something for that
With discord.js, it used to be included in the main lib, but it's now a separate package for modularity
voice stuff kinda fell out once Discord started cracking down on music bots anyways
Ok Ty. I think I found a way. This info was helpful. It’s called voices_states.
i did
Is the bot able to know how a user joined a server?
Because I saw that it exists when you activate the community tab but the bots have this information?
yes, it is possible.
How ?
bots can't access that endpoint
not really sure. but there are bots that tell you what invite link they joined from.
you have to cache invites and poll what invite changes when a user joins
its unreliable
js implementation
Maybe one day they will add, for example, in the Member object what source he joined from
how do you display how many servers your bot is in on the website?
some bots look like this with the server count
then mine's like this
oki thanks :D
we dont allow browser cookies to be used as authorization
what who the declined my bot limao is a skin checker bot so it need autorization 🤦♂️
what
giving a random bot your cookie is the most dodgy and unsafe thing ever
is like aqua bot limao
is the same think is not cookies is epicgames auth think
what no
It does not pop up cookies bs
look bio limao
what limao
that is epic games store
the bot is using a auth link not cookies
your bot?
ye

wtf is wrong with u
im saying bullshit
u need to read documentation g
for your bot?
🤦♂️
nah i aint getting my cookies grabbed
epic games
i have read it
i don't think so
i dont think so about your bot does not use cookies
auth code

mhm
There is no hard limit publicly available. Also this will only apply when you proxy the websocket through cloudflare
Anyone that can help me or recommend a freelancer to style my bot page? Want some custom stuff similar to https://top.gg/bot/675996677366218774
looking at how Mac does it for Pixxiebot
its primarily CSS styling
if you are good with HTML you can style it and design it with that
you can test with making it as a website (no js tho)
then adapting it to fit top.gg
@radiant kraken Does rust not have any equivalent to union types like ts has? for example
struct Something {
something: "text" | "int" | "bigint"
}
googling leads me to enums but idk if that is the correct approach
yup, use enums
enum Something {
Text,
Int,
BigInt,
}
Oh also, is there an equivalent to the type any in rust?
I have seen mixed answers on what to use
why do you want to do that
well as you know I am making a database service for roblox
hmmmmmm
what's the idea?
and I right now I am parsing the lua tables into json and then parsing that into sql queries
well on roblox the default value of a column can be anything a string, int, bool, whatever
Rust does have an Any trait but it's barely needed
make an enum for it
😭
enum Thing {
Bool(bool),
Int(i32),
String(String),
// ...
}
I see
yknow what I just realized
Its going to be a bitch to parse this into an sql query if they supply any of the optional params
I will have to make multiple formats 😭
why am i doing this project again?
I am suffering so much
what?
Say if they want to give a default value for that column
I would have to then include that when formatting the column
but if they don't I need to leave it out
Default value?
let me show you how I am doing it rn

yes cause you know postgres columns can have default values
so when you insert something into the table that column gets defaulted to that set value
a combination of enums and structs can do the job
https://hatebin.com/kdgdomvqqw this is what I am doing rn (mind you I have no idea what the data.columns.iter() stuff really is doing cause I simply looked at stack overflow)
say... ```rs
struct Element {
key: String,
value: YourValueType,
default_value: Option<YourValueType>,
}
or something like that
What you think of this? @radiant kraken
Any opinions on what I am doing right now to parse the request body into a sql query
#[derive(Copy, Clone, Deserialize)]
enum PostgresType {
Text(String),
Int(i32),
Serial(SerialType),
Json(serde_json::Value),
Boolean(bool),
Uuid(UuidType),
Date(DateType),
}
#[derive(Deserialize)]
struct Column {
name: String,
column_type: PostgresType,
default: Option<PostgresType>,
primary: bool,
not_null: bool
}```
What about this?
hey
also, what is not_null for?
In postgres you can set wheather the table should be allowed to be null or not
Honestly doesn't matter if I include that or not so ima probably remove it
primary, default, type and name are the big ones
Why not
#[derive(Copy, Clone, Deserialize)]
enum PostgresType {
Text(String),
Int(i32),
Serial(SerialType),
Json(serde_json::Value),
Boolean(bool),
Uuid(UuidType),
Date(DateType),
Null,
}
#[derive(Deserialize)]
struct Column {
name: String,
column_type: PostgresType,
default: Option<PostgresType>,
primary: bool,
}```
Well, that wouldn't really work that way no?
CREATE TABLE table (
something TEXT NOT NULL DEFAULT "";
)
is how a sql query using NOT NULL and DEFAULT would look
ooo
what if it's NULL then? it holds no values, no?
man parsing a lua table to json to an sql query is so fucking annoying
precisely, if NOT NULL is removed from the query then it can be null e.g blank or no value needing to be provided at the time of inserting
then it will use that default value when inserting
ah
technically you don't need to use NOT NULL with DEFAULT
so if it has no default values set, it defaults to NULL
yep
providing NOT NULL is not there
if it is and you try and not insert something for that column it will return a not null constraint error
because you tried inserting with a column value missing
oddly enough postgres doesn't actually have a NULL datatype though
then you can just
#[derive(Deserialize)]
struct Column {
name: String,
value: Option<PostgresType>,
default_value: Option<PostgresType>,
}```
so you have no real way of representing what null is
if value is None, then it's NULL
you can only specify that it shouldn't be null
(And if default_value is also None)
Actually wait
I guess you can do stuff like
INSERT INTO blah (field) VALUES (NULL)
``` iirc
what does that do
basically just makes field null when you insert it
the only reason i'd see you do that is if you want to set it to null
inserting with null is not common, I just forgor how to alter entries

Yeah mac have done a great job for sure! I tried to chatgpt it haha, however I need a frontend dev to fix it. thats why im asking 😉 I guess I can wait untill someone in our team has time
I guess something like
UPDATE table SET field = NULL```
so yea maybe postgres does have a way to reference null
anyway this skewed from my original question
is there seriously no better way to format strings than using format!() or whatever?
cause how I am doing it now is definitely not going to work
it does
they use \u0000 as the null character (which is also why u cant have that character in a text)
iirc mysql/maria also do that
why?
what's wrong?
Also code may work but you can still sql inject the shit out of this

finally can voting
Are you still able to make a custom page for your bot? Like custom css and html etc
Yea
Awesome ty
i started with cs at my uni 2 years ago
how the fuck did it negatively impact my social life
i swear i got no friends left
One message removed from a suspended account.
people go out, chill together do activities while my lonely ass sits at home doing combinatorics and or machine learning
One message removed from a suspended account.
One message removed from a suspended account.
gett outta here leave me alone 😭
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.
yeah that's good to hear tho
definitely a positive point
what degree are you following?
when did they bring back the option to reply to review?? also, I notice an edit button.
today
nice!
what is it with people who add a bot then remove it literally 2 secs later
seems to be a recurring pattern, im not doing anything like sending a message on join that would make people instakick it
and a lot of the time, its the same guilds repeatedly
2024-01-16 23:58:14.031 [I] [th#935950] : New guild: 1196944438598041610
2024-01-16 23:58:16.090 [I] [th#935950] : Removed from guild: 1196944438598041610
2024-01-16 23:59:14.333 [I] [th#935950] : New guild: 1196944438598041610
2024-01-16 23:59:43.315 [I] [th#935950] : Removed from guild: 1196944438598041610
like that
anyone else able to shed any light on why this is the case
Maybe there’s some sort of automod behavior with another bot that just instantly kicks it?
Or can bots not kick other bots
pretty sure they can, as long as the other bot is higher in the permission hierarchy
yup no commands are being run
define verified
but it is discord verified 
idk what else then
and the snowflake of my bot is dated 2019
i have a feeling theres a wick like bot that kicks all bots not on an admin defined whitelist
to stop compromised mods inviting nuke bots
@radiant kraken I am trying to santize the input from the json to make sure there are no special characters in it like semi colons and such. Yet I think I am doing something wrong, 1. PostgresType doesn't implement Display so
let query = format!(
"CREATE TABLE IF NOT EXISTS {} ( {} );",
sanitize_input(data.table_name.to_owned()),
data.columns
.iter()
.map(|column| {
let data_type_str = parse_types(&column.column_type.to_uppercase()); // Ensure uppercase for consistency
let default_clause = match &column.default {
Some(default) => format!("DEFAULT {}", sanitize_input(serde_json::to_string(default).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(", ")
);
this is not possible. I feel I am missing a lot as well because I made a fucking enum for it but I am not even using it to parse it cause I really don't know how enums work that much. I don't understand em
Like what is the point of having this
#[derive(Deserialize, Debug, Serialize)]
#[serde(rename_all = "snake_case")]
enum PostgresType {
Text(String),
Int(i64),
Serial(i64),
Json(serde_json::Value),
Boolean(bool),
Uuid(String),
Date(String),
Null
}
if I dont use it
@wheat mesa as well since you are also a rust nerd

impl Display for PostgresType then
Okay but like that isn't the problem I am facing that is just a minor issue
Okay so I have a question
#[derive(Deserialize, Debug, Serialize)]
#[serde(rename_all = "snake_case")]
enum PostgresType {
Text(String),
Int(i64),
Serial(i64),
Json(serde_json::Value),
Boolean(bool),
Uuid(String),
Date(String),
Null
}
with this enum how would I parse this json
{
"table_name": "test",
"columns": [
{
"name": "test2",
"columnType": "text"
},
{
"name": "test3",
"column_type": "int",
"default": 0,
"not_null": true
}
]
}
so that if there is a default value it will be typed appropriately based off the column_type (as I can only assume if someone is wanting the type to be text they wont store an int)
I can only assume i'd use enums for this cause nothing else makes sense to use
use serde_json
to serialize it you can make your own deserialize implementation or you can do it manually
fn deserialize_default<'de, D>(deserializer: D) -> Result<Option<PostgresType>, D::Error>
where
D: serde::Deserialize<'de>
{
let value: Value = Deserialize::deserialize(deserializer)?;
if let Some(column_type) = value.get("column_type").and_then(Value::as_str) {
match column_type {
"text" => Ok(Some(PostgresType::Text(value.get("default").and_then(Value::as_str).unwrap_or("").to_string()))),
"int" => Ok(Some(PostgresType::Int(value.get("default").and_then(Value::as_i64).unwrap_or(0)))),
"serial" => Ok(Some(PostgresType::Serial(value.get("default").and_then(Value::as_i64).unwrap_or(0)))),
"uuid" => Ok(Some(PostgresType::Uuid(value.get("default").and_then(Value::as_str).unwrap_or("").to_string()))),
"date" => Ok(Some(PostgresType::Date(value.get("default").and_then(Value::as_str).unwrap_or("").to_string()))),
"json" => Ok(Some(PostgresType::Json(value.get("default").and_then(Value::as_str).unwrap_or("").to_string()))),
"boolean" => Ok(Some(PostgresType::Boolean(value.get("default").and_then(Value::as_bool).unwrap_or(false)))),
_ => Ok(Some(PostgresType::Null))
}
} else {
Ok(None)
}
}
``` tried this lets see if it will work

I give up
fuck it
lmaooo
well this is like an extremely advanced project for you smh
especially for like a beginner
i can help you
please for the love of god
but i dont think you would understand at this level
or you can just yk have me in ur project
in an hour or two
y tho
as I have yet to do any version control
go to bed misty
personal reasons I dont want to speak about in public
isnt it like 2am or 1am for u
11:21pm rn
yea
i understand, but it will be fun once you know what's up
i quit from learning rust once for a year
I hope so cause im crying inside when I look at my code
i decided to up the ante a bit on my new bot by offering nitro to anyone who kills the big bad. bring it. lol
im confident nobody can.
offering nitro worked for triviabot, it can work for this
One message removed from a suspended account.
One message removed from a suspended account.
nah he said that he's confident that it's so hard barely anyone can beat it
nobody said unbeatable
😉
if you cant beat it, thats a skill issue, theres no RNG in this game you cant overcome with cheesed stats
One message removed from a suspended account.
make unbeatable boss.
make the same boss but beatable just really hard
Have a really really good player beat the boss, record it and upload it to social media.
Release the unbeatable boss map and tell everyone its the same boss.
Have everyone try to beat it and lose.
free marketing
people will analize all possible things frame by frame and even decompile the code to prove the boss is different from the video
and sue you
Nooo
all it takes is a highly motivated speed runner
One message removed from a suspended account.
let buyerr = await interaction.guild.members.cache.find(
(r) => r.user.username.toLowerCase() == string1.toLowerCase()
);```
hey, so the member is not cached sadly
how can i fix this?
can i somehow fetch a member based on name instead of id??
the string1 is basically a channel that contains a name
this is the closest you could get https://discord.js.org/docs/packages/discord.js/14.14.1/GuildMemberManager:Class#search
Manages API methods for GuildMembers and stores their cache.
search by name, and filter the result properly
i think that my old bot is still running on v13 tho
should still have it
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
is there an example of how searhc would be used?
guild.search(r => r.name === ...)?
i suppose it just takes a lambda function
0|index | TypeError: interaction.guild.search is not a function
I guess not heheh
huh what's the matter
search exists on member not guild
no need for await here, cache is in-memory and doesn’t need async operations
that's not really what i was looking for
i want to search members in the guild based on a certain username
i mean i want to search that member property, i don't have that
the member is new in the server
so not all members are being cached properly
what should i do??
by default guild members wont be cached unless you fetch them, you an ofc change that by enabling member caching as soon as the bot starts but that will use up more resources
Map the users to a database table
Tho if the user just joined, they should've been cached
As the event would trigger it
As of my last knowledge update in January 2022, Top.gg uses an API to interact with Discord bots. To use the Top.gg API, developers typically need to obtain an API key or token. This token is used for authentication and authorization when making requests to the Top.gg API on behalf of a Discord bot.
If you're a bot developer and you want to integrate your bot with Top.gg, you would typically find the API token in your Top.gg account settings after adding your bot to their platform. The specific process might change, so it's recommended to refer to the latest Top.gg documentation or developer guidelines for the most accurate and up-to-date information.
To obtain the Top.gg API token:
Go to Top.gg: Log in to your Top.gg account.
Navigate to Bot Dashboard: Find the dashboard for the bot you want to get the token for.
API Settings: Look for an API or Developer Settings section. This is where you should find your API token or instructions on how to generate one.
Always keep your API tokens secure and do not share them publicly. If there have been changes or updates to the process since my last knowledge update, please refer to the latest documentation or contact Top.gg support for assistance.
Ty
np
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i replied with a ping?
One message removed from a suspended account.
what is the problem
Well, can someone look into my problem? #topgg-api
Whyd you ping me
so that you reply back
these were normal images gathered from an attachmentoption. How come that they disappear after a few months?
Does discord automatically do it to preserve space? Any way to fix this?
maybe someone deleted the attachments?
nvm it was the cdn. It automatically deletes the images to preserve space
only way to fix this is creating my own web storing server
how will you do that
probably discord api being drunk again
why my "nodemon" not working
you’re on djs v14
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
nodemon isnt the issue here btw
its bot code
look above at Webster's response^
show the code
same issue
you have defined it by putting GatewayIntentBits next to Client in discord.js line
same issue
Change it to GatewayIntentBits
Thx for token
do whatever you want
discord made a button called reset token
@warm surge should i remove intentsbitfield
it fine hold on
What version are you using for djs
try this instead:
const { Client, GatewayIntentBits } = require('discord.js');
the code i provided above imports 'GatewayIntentBits' instead of which you had originally 'IntentBitsField'
it has updated in v14 from IntentBitsField to GatewayIntentBits
latest
guyz something happen and then it worked
token was on line 11 but now its moved to a new file idk why
and now its working
is that atom?
atom ?
the program you're using to code.
what dose it mean
VS
It's VSC
oh visual studio
yup
i wonder what were to happen if you cut the code from the new file and paste it back into the index.js file and remove the new file?
no idn't
you don't need to define client again
you don't need this
You should not use .login on Client but on client
Unfortunately, letter size is important
Also the second error tells you that you cannot declare the same thing twice
dude how did i forget that
got it
worked @deft wolf
One message removed from a suspended account.
One message removed from a suspended account.
not first 
@deft wolf@grim aspen thanks for help
const { Client, GatewayIntentBits } = require('discord.js');
Just use this. You don’t have to have this
There we go
yea i did
Trying to get the background to appear a bit better.
One message removed from a suspended account.
One message removed from a suspended account.
I've tried different pix/sizes, it's dark no matter what
One message removed from a suspended account.
hmm, not sure how'd I do that.
One message removed from a suspended account.
One message removed from a suspended account.
correct.
One message removed from a suspended account.
yeah, I saw that.
One message removed from a suspended account.
One message removed from a suspended account.
hmm, ok
One message removed from a suspended account.
nice bot name, you need a separate bot called TenFootPoleBot
yeah, which is why I always warn my users that their profiles might randomly lose the background image if they use a discord-posted image
happens especially if you post image -> get url -> delete image
why not download the image and host it on an s3?
I do that
file type and file size
however it's important to note that you can embed stuff inside an image
there was a name for that, dont remember now
Hiya
hm?
I download the user's images, "cover" them to a lower resolution and then store them
you can put arbitrary files inside image files, and they'll still work as usual
ah found the name, steganography
Steganography ( STEG-ə-NOG-rə-fee) is the practice of representing information within another message or physical object, in such a manner that the presence of the information is not evident to human inspection. In computing/electronic contexts, a computer file, message, image, or video is concealed within another file, message, image, or video...
but where's the issue with that
I mean if they want to
If necessary just shoot the image through something like sharp
And convert to webp
that involves even more processing
i once had to create an anomaly detection algorithm for some input data regarding code behavior that also included steganography. It was really fun. If you're into this type of malware i would highly suggest doing such an algo for fun, i have some spare datasets we had to use of my teacher.
Well yeah, 300ms once
spam command
my bot already handles quite a lot of images all at once, better not add a way for people to clog it
kuu you remember the algorithm you helped me with a few weeks back
the box fitting shit
what topic did your classes NOT touch?
yep
i got an 8 lmao
apparently we used a greedy algorithm, but we had to use bipartite matching. Teacher was okay with our result tho
yeah we got put through hell these past 2 years. Idk they try to touch every topic out there and after that we can specialize ourselves in the 3rd year.
does discord limit the number of roles that it sends in the resolved object?
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
4 languages out of 8 done, gettin slowly there 
no american english?
malaysian english?
singaporean english is infinitely better https://youtu.be/mo4ufPKTq0E
Well, you have to be careful with the typos because it should be applicationGuildCommands. You're missing an s at the very end
lol they're all about the same
No pirate English?
Supporting multiple languages is pretty easy. Just gotta have translators willing to help. I have English US and GB, Russian, German, Polish, Spanish, and Dutch
Trying to get Korean and a few others since my bot's usage base is mostly from there, but the only person ik who speaks Korean is too busy all the time ;w;

i can volunteer for translating 
i may say it took me a lil bit of time doing it, first time handling multiple languages so was a back and forth between docs and vsc
bot is relatively small luckily, just 13 commands, mainly focused on music, so translating in more languages doesn't take that much time
🫡
You can host databases like mongo and mysql on your vps
So it depends on you what you want to choose
Speed and various query options
With more data, definitely
youre relying on read/write speeds for files
Mongodb is a good start, its structure is not that different from json files and it is relatively fast and simple
They have very well-developed documentation and plenty of guides, so you will definitely find what you need
i personally hate no-sql databases
idk i find the structure of sql databases so nice to work with
very concise as well
but ig it's also easier. One universal way of accessing data is so cool instead of learning different docs for each fucking database
insane of you to skip out on google
lol
i dn't understandd
I have already written to you what your problem is
Here is my reply
i literally can’t, im at school currently.
wait
Your bot is not permitted to create commands on this server
Im gonna make it easier for you




