#development
1 messages · Page 2057 of 1
NGINX
only nginx or nginx -> node/whatever?
so yeah you need to raise the limit in both
so uh
I have GameObjects stored in the components field as such in my main struct: ```rs
pub struct Simulator<'a> {
fps: u32,
components: Vec<Box<dyn GameObject>>,
ctx: &'a Sdl,
canvas: Canvas<Window>,
}
And then I add them kinda like this: ```rs
let mut hollow_box = HollowBox::new(
0,
0,
20,
20,
Some(50)
);
self.components.push(Box::new(hollow_box));
Which works fine, but the problem arises because the vector is taking ownership of the gameobject
when I want to be able to use hollow_box below that
For example when I want to add a force on a keypress: ```rs
Event::KeyDown {
keycode: Some(Keycode::Space),
..
} => {
hollow_box.add_force_angle(150.0, 45.0);
}
(Formatting got weird)
But I can't use it because the vec already took ownership
Would this be the right time to use an Rc or something like that
Instead of a box?
Oh maybe I need to store them as a HashMap or something similar so I can borrow them from the struct when I need to do things to them
You could save the index and access it via the index
problem is that they're listed as dyn GameObject but I need to access specific methods on the component
hmmm well
Shouldn't add_force_angle be on GameObject?
Not everything is going to need that though
I might be able to add a default implementation
I feel like that's going to clutter GameObject with a lot of useless methods eventually
You could use an enum instead of dyn GameObject
enum GameObjectTypes {
Box(...),
...
}
And keep them generalised
I think I'm walking closer and closer towards falling into the ECS rabbit hole
What's the cause of this? https://cdn.hamoodihajjiri.com/FFXxMMvuYE
Most of the servers are returning undefined?
Why do you need to store each component in a vector anyways
rendering and updating
shouldn't your framework be doing this
fn update(&mut self, dt: f32) -> Result<(), String> {
for component in &mut self.components.values_mut() {
component.render(&mut self.canvas)?;
component.update(dt)?;
}
Ok(())
}
I'm just using SDL2
so you're making your own game engine
Attempting to make my own physics engine yes
is the Simulator struct a singleton?
yes
if so you could just use a global vector to store everything. That actually doesn't solve any of ur issues actually why I am suggesting that
Yeah the vector would still own it lol
But I need mutation :C
Then use RefCell
whats the code that logs that
Slash commands aren't working either.
module.exports = async bot => {
let activities = [`${(await bot.shard.fetchClientValues('guilds.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} servers!`, `${(await bot.shard.fetchClientValues('users.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} members!`, `attitudebot.com`], i = 0;
setInterval(() => bot.user.setActivity(`${activities[i++ % activities.length]} || /help`, { type: 'PLAYING' }), 60000);
bot.shard.broadcastEval(client => console.log('Shard ID', client.shard.ids[0], client.guilds.cache.map(guild => guild.name)));
console.log(`Attitude is now online serving ${(await bot.shard.fetchClientValues('guilds.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} servers, ${(await bot.shard.fetchClientValues('users.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} members (${(await bot.shard.broadcastEval(client => client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)).then(results => results.reduce((a, b) => a + b, 0))).toLocaleString()} members uncached) & ${(await bot.shard.fetchClientValues('channels.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} channels.`);
};
I guess Rc<RefCell<dyn GameObject>>?
yup
hmm
actually
RefCell needs the type to be sized I believe, try it
actually it doesn't
Yeah I'm just updating my loop to work with those types rn, hold up
Yeah no still not gonna work unfortunately
I probably need to just come up with a different solution than the gameobject garbage, it's going to be too difficult to fight the borrow checker over it
Or, I could make a mess and just add a ton of methods to gameobject with default implementation lmao
And use a hashmap
I think I'm going to redesign into an ECS
I don't know how using a hashmap will solve your issue
the hashmap has ownership of the game object
Why not give each GameComponent a on_key_down method, and call it when a key is pressed down?
Or even better, just make it so a component can check if a key is down in their update function
that means the shard you are evalling is not ready yet
let mut output = Vec::new();
let mut streak = 0;
for &item in arr {
if item == 1 {
streak += 1;
} else if item == 0 && streak > 0 {
output.push(streak);
streak = 0;
}
}
if streak > 0 {
output.push(streak);
}
output
So what is this guy doing with the whole &item thing?
uh that doesn't seem right? I think it's meant to borrow the item from the arr, but then it should be &arr not &item
I see, what is the point tho cant you just do for item in arr like normal?
I am still new to the idea of borrowing and ownership
That will take ownership of the collection and everything inside it
so it'll be freed after the loop is over
so you won't be able to use it afterwards
I see
So all this does is delete it from memory once it is over or?
yes
I also notice if you do for num in &numbers num is now &i32 which you can't compare against a normal int anymore can you?
so you can't do if num == 1
you can compare rust automatically dereferences them
let me try one sec
error[E0277]: can't compare `&i32` with `{integer}`
--> src\main.rs:9:16
|
9 | if num == 1 {
| ^^ no implementation for `&i32 == {integer}`
|
= help: the trait `PartialEq<{integer}>` is not implemented for `&i32`
Unless I am doing something wrong?
why do for num in &numbers
interesting why it doesn't dereference it here
you can do num == &1
or you can do num.clone() == 1
or *num == 1
that too, same as clone
what does * do in rust?
(well actually copy but in this case clone == copy)
gets the value of a reference
dereferences
Also I'm going to refactor my engine to allign with something more like this: https://youtu.be/oHYs-UqS458
I see
This was an absolutely fantastic video on state and such, currently I'm going down the OOP road of it which is very bad
I keep learning more and more about rust every time I do these small code challenges
if the data type can be copied it copies it, it doesn't dereference it
So I need to refactor to represent state better and closer to an ECS
yes, that's good
The more mistakes you make, the better you'll become at rust
Yeeee
I've rewritten my engine 3 times from the ground up already, but I've learned a shit ton along the way
rust has amazing pattern matching and I've done the parser thing 3 times before
(In other languages)
enums + match statements made my interpreter like 5 times shorter than it was in C#
I do wanna kinda challenge myself a bit more tho with these rust challenges
you can try rustlings
That's a good start for an overall introduction into a lot of features in rust
give me ideas on how to stop memory leaks 
use rust
no
get more ram
is 2 gb good enough
i currently have 1 gb
and i only get memory leaks when someone ddos
You could also not write code thatcauses memory leaks
lol
its in the package
wait no my english today sucks I was right the first time
no you are wrong
Don't use that package
what package are you using for https
Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.. Latest version: 4.0.3, last published: 2 years ago. Start using greenlock-express in your project by running npm i greenlock-express. There are 66 other projects in the npm registry using greenlock-express.
👀
so getting more ram is the solution
I mean we're back to the issue we talked about two months ago.
misty say yes
@feral aspen what are your thoughts on this
1gb should be fine for a small website
yea
gotta love when websites don't know what a memory leak actually is
you don't need an npm package for this
then how else would i do it
you can use reverse proxy with nginx
using a reverse proxy allows you to handle DOSing a lot better than an express middleware can
but am not sure if its that package causing that error
i cant find whats causing it
Is your server storing a lot of stuff in memory
in the system?!?!1
or just that process
it does use a lot of memory in the process when there is a ddos
more than half the ram
and now its out of memory
its most likely because when you're not being ddosed the memory leaks arent apparent due to the traffic
could i just change the max listeners to infinity?!?!1
not easy to fix them or even tell if its because of a module but generally you should make sure you remove every single reference to objects
node out of memory crashes arent very helpful would be nice if they provided an overview of whats using most memory
@earnest phoenix take notes
V8 heap snapshots exists which can help, but in this case it can be more difficult to locate where the memory leaks occur
volty would increasing ram help stop the event listener error?!?!1
No, that warning is given out because something is constantly adding more event listeners to an event emitter in your program, that reaches the maximum set event listeners
yea but an overview would be nice
i hate snapshots and the chrome remove debugger
not necessarily event listeners
maybe my memory went to like 500 mb because i logged every request during the ddos
the chrome node debugger actually crashes node for me often
its now at 100 mb without logging
Well yes, event listeners aren't always the cause of the program running out of memory, but I suppose it's the event listeners in this case because apparently burber didn't show the initial warning
the full warning?!?!1
Yes
burbur pov:
app.get("/", () => {
something.on("event", () => {});
});
💀 💀 💀 💀
thats bad code
mf speedy predicted correctly
well where did you put that???????
bro just show the whole thing lmao
Nothing in that sparks something that is adding event listeners to an event emitter, not directly at least
are you importing app in another file? show that other file
that library is looking hella sus rn
It's either the proxy.web() call doing something suspicious there, or it's the greenlock-express library being the impostor

try running with node --trace-warnings
yes
that library has a ton of nested event listeners so i can see its easy to fuck up
Goody ahh library
that code is so spaghetti its not even funny
a
which code
the library
thought you were talking about mine
no event listener warnings?
God borrowing is still rather confusing to me in rust 😔
no 
I think you've stress-tested it a bit too much before it was able to show the warnings
My guy runs on almost Nintendo 3DS RAM
1GB RAM is most likely enough for your program, but becomes a lot confusing with less RAM in case of debugging
so do i upgrade to 2 gb?!?!1
I would say stress-test it again but stop at a early stage so it doesn't ran out of memory
Where I can ask question about launching bot on top.gg
and how can i do that
yeah its defo the library
do i stop it at like X mb or just change the amount of seconds the attack runs
the library assigns error listeners like theres no tomorrow
Yeah it's definitely the library
Use something else or implement your own I suppose
It wouldn't really ramp up if you use something else
but if i still use that
Because your program seems simple enough
ram it down its throat
Don't use that, because it's not written properly
i dont know what to move to 
nginx
does that auto renew certs
you can literally do the entire proxy thing in pure nginx, you dont even need node
you can autorenew with cerbot or acme.sh
use certbot to generate a letsencrypt certificate then use this answer to start a https express server with it https://stackoverflow.com/a/70443344/11138133
tho i think you can also make nginx handle the https for you
if you proxy
what if i use nginx and express
if thats possible
is there any way when someone votes for the bot my bot can know?
you can set it up with the @pliant gorge bot im pretty sure
what page
dam
do i have to put it in index.js?
yeah
this is to show who voted?
nodejs mfs if events didnt exist:
while (true) {
if (event) {};
}
"why is my program using 100% cpu when idle"
What’s the definition of "not working"?
You just defined a function
Do you even call your "crazy" function?
What does it do?
Because you just defined some_crazy_function for whatever reason and you don’t call/execute the function
Why do you even define that?
It automatically posts your Discord bot's stats (such as guild count, shard count, etc etc) based on an interval to Top.gg's API
and where do you publish?
What do you mean?
and where do you publish?
?
It posts your Discord bot's stats to Top.gg's API if that's what you're asking
I feel like he means where to put it in his code
@earnest phoenix wait volty about that error, could i just leave it how it is and just let pm2 restart?!?!1
I told you way
nah you need to be banned from code
Don’t randomly ping people for no reason
@boreal iron
Well yes you could, but you'll just outright run into your program running out of memory all the time, so I would recommend using something else than that library to fix it

so this will do something like this?
what bot is that
If you don’t know what you did, you need to learn the basics of python before working with it
xenon
Because you defined a function for no reason and you don’t call/execute it
Copy and pasting usually doesn’t work
_They all must have won the green role in a lottery _
What the hell do you expect to achieve here?
# CREATES A NEW BOT OBJECT WITH A SPECIFIED PREFIX. IT CAN BE WHATEVER YOU WANT IT TO BE.
bot = commands.Bot(command_prefix="$")
# EXECUTES THE BOT WITH THE SPECIFIED TOKEN. TOKEN HAS BEEN REMOVED AND USED JUST AS AN EXAMPLE.
bot.run("the token")
bot = commands.Bot(command_prefix="$")
@bot.command(name="ping")
async def some_crazy_function_name(ctx):
await ctx.channel.send("pong")
I'm not telling you to try that, that's your code
You're logging in with the bot, but then reassigning the bot variable to a new bot instance
I feel like you’re using the google translator or worse, bing translator
They're not telling you to delete that, you're declaring a function to be executed when that command is run, but that part is never even reached because the the bot instance you logged in with is destroyed, and you're creating a new one after logging it
And I would recommend setting up your commands before logging in
(Also fake he doesn’t need to execute it, python is a little bit different because of annotations)
That’s more than I wanted to know about python
🔫
Try removing the second
bot = commands.Bot(command_prefix="$")
My God, you should follow up on what I said
Also you shouldn't just outright copy code that you don't understand what it does
gonna try that
even though its published 8 years ago
last published: 8 years ago
I wouldn't recommend trying it at all, it will definitely not work, probably has security issues or haven't adapted to newer versions of Express
so i try nginx instead?!?!1
Yeah
You absolutely can, just read up on the documentation
Dude you need some basic knowledge before working with any programming language
Things don’t work by copy and pasting stuff
8 years ago 💀
dont tell community managers to give me code jail role
but anyways
Nope, I don’t need to, thanks
D:
:D
That’s part of getting into any programming language
Once again, once you know the basics of your program language you’re using, things will get a lot easier
Why would it be an event when you say you wanna make it a command?
You should probably read some not-outdated guides on how to start with python and a discord bot in python
i cant find a way to do it
One message removed from a suspended account.
Postgres is really nice
You don’t need experience with SQL, you can use an ORM which would make your life easy
What language do you use if I might ask?
an orm I recommend then is sequelize if you want something basic and if you are using typescript at all I highly suggest typeorm
https://stackoverflow.com/questions/1279613/what-is-an-orm-how-does-it-work-and-how-should-i-use-one
It’s essentially an abstraction of methods for you to interact with an SQL database in a way that doesn’t require you to manually write SQL (most of the time)
sometimes you can write your own sql though if you wanted to
a lot of orms provide what is known as a query builder which allows you to use sql keywords and such
Actually I did that in the past, too but after years moved away from it again
Even if it’s nice to build and use dynamic functions you can pass non, one or multiple parameters to, to insert or update data dynamically
But i somehow felt more comfortable writing the sql queries down where I need them and adjust them if needed
Instead of editing my functions which sometimes caused a rewrite and a different structure which also caused a rewrite of any line of code where I was calling the function
But you should somehow still build a wrapper which takes all sort of queries also prepared statements for example and which handles errors etc
Without the need to use multiple functions for queries, either it’s insert, update … etc or prepared statements
many words but a short meaning

I wrote my own query builder mainly for typings
I always get this Error when trying to get a json file to a variable:
SyntaxError: Unexpected end of JSON input
My code is:
const filePath = statistics.json
function updatedata() {
var data = JSON.parse(fs.readFileSync(filePath))
windows = data.win;
mac = data.mac;
linux = data.lin;
discord = data.discord;
total = windows + mac + linux + discord;
datad = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Statistics')
.setDescription('Total: ' + total + '\nWindows: ' + windows + '\nMac: ' + mac + '\nLinux: ' + linux + '\nDiscord: ' + discord)
.setTimestamp()
client.channels.cache.get('XXX').send(datad);
}
can anyone help?
I was trying to create a mini rpg game but it loops forever and ignore the collection, I was using recursive function, What should i change to not ignore the collection?
https://sourceb.in/00dYJGkujC
First of all, replace that var with let
Second, your entire setDescription can be replaced with an interpolated string
Third, did you check what is being read?
wdym ignores the collection?
you want to wait for the collector before the fights() function?
yep, wanted to wait the callback before it runs the function again
even im not using any .includes command the callback() will lunch agian
the only way is to wrap the collector in a promise and resolve the promise when the collector "end" event fires
but from looking at your code you shouldnt even be using collectors in the first place, since you're only collecting 1 message
just use channel.awaitMessages()
I would make the entire game run inside a single collector, that way you don't need to re-run the command again and again for each action
so if u mean, if i wanted to call the function again, should i call it by using collection (end)?
if you want to go the callback hell route, yes, put all the code that is supposed to be run after the collector inside a collector.on("end", () => {....}) event
i see isee, gonna try it thanks for the tips
I think the error is really obvious...
Your code you posted has literally nothing to do with the error
You need to actually read the error
my friend sent me the code
You cannot keep copy pasting code without understanding it
it’s his bot
Read the error and tell me what you think it means
i’m helping him
Does anyone know a text to image api that just takes text and returns an image url?
Not sure, thought I found one for a second but turned out to be an ai thing
like https://dummyimage.com/1920x1080/000/fff.png&text=hello+world ? i'm not sure what you mean by "text to image"
It's probably difficult to search for something like that given the hype surrounding ai art rn
that's literally all i was searching for lol
thank you
Yeah xD
thanks

Hello. I made a bot that handles NS*W categories like NS*W channels. Basically it works like if they are already official. It does not contain any NS*W content. It just toggles some channel properties. (it is an utility bot)
I already submitted the bot and it didn't get accepted. Is there any way to censor some text or anything to make it get accepted?
it's because of your bot page
i know
You need to not mention anything about NSFW in your bot page
does it get accepted if i put* everywhere?
You cannot mention NSFW in your page
ok thanks
i am unfortunately forced to use another bot list website
Why's that?
from his bots name it looks like it would be focused on nsfw?
so if he can't mention any nsfw then it's kinda missing the point of advertising the bots features
I guess so
happy bday btw
ty
quick question: can i recover the bot's description after it has been declined?
pretty sure if u just try reapplying the bot you can take the description cause it saves
at least that was the case for me
can i cancel the submission right after? i do not remember
just click reapply, it won't send the application unless u click the apply button
just copy the description and close the site
where is the reapply button
sorry for all of these questions
just try adding the bot again, there is no button for that
i just tried it. submitting a bot requires a description. can any admin / dev help me with recovering declined bot's description please?
So I was trying to figure it out on how to bring back on the first callback when the content does not the proper answer? Like yes and no
fixed xd
guys, how can I create role with djs?
and also, how can i check if role with same name exist on server
ok i realized...
hey. how do i make my bot see and reply to commands in voice channel chats
i think it should work same as in the normal chat, im not sure?
ok new Question: Can I use if() statement to get choices in slash commands?
like: ```js
if(interaction.choice === "30") {
// Do Something
}
How to resize thumbnail?
I don't think you can
Unless you were to use a bigger sized image but iirc that even has limits
so I get this error when i try to execute my timeout command:
and here is part of the code where error happen
so "remove" is undefined, so that mean that .roles dosent exist?
why that happens?
ahh so i think i know how to fix it
if its User Structure, that itself doesnt have .roles
only Member Structure does.
hello, is there anyone who used azure sql vm?
and is it a product that i can use if i want to have an sql database and also do things with it on a virtual machine?
ok so I resolved that problem, but...how can I assign role that I created to the memebr?
roles.create should return the Role Object.
so you can reassignment MutedRole to roles.create
and then your code should work
or do its intended purpsoe
reassignment so to use MutedRole inside the name? in the roles.create
bcz that wil lthrow err
are you deleting the role each time you test?
nope, it dosent even look like it is created
also, It need to check everytime of role exist on server, if not then it will create new one, if yes, it will just add it to member
can you repost the current code you have
second
const { SlashCommandBuilder } = require('@discordjs/builders')
const { MessageEmbed } = require('discord.js')
const Schema = require('../../models/timeout-schema')
module.exports = {
data: new SlashCommandBuilder()
.setName('timeout')
.setDescription('Timeout a user for a set amount of time')
.addUserOption(option =>
option.setName('user')
.setDescription('The user to timeout')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('duration')
.setDescription('The amount of time to timeout the user for')
.setRequired(true)
.addChoices(
{ name: '30 minutes', value: "30minutes" },
{ name: '1 hour', value: "1hour" },
{ name: '24 hours', value: "24hours" },
{ name: '1 week', value: "7week" },
{ name: '1 month', value: "1month" },
)
)
.addStringOption(option =>
option
.setName('reason')
.setDescription('The reason for the timeout')
.setRequired(true)
),
async execute(interaction, client) {
try {
if(!interaction.member.permissions.has('DEAFEN_MEMBERS')) {
interaction.reply('You are not allowed to use this command!!')
return
}
const user = interaction.options.getUser('user')
const member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).cache
const time = interaction.options.getNumber('time')
const reason = interaction.options.getString('reason')
let MutedRole = interaction.guild.roles.cache.find(role => role.name === 'Timeouted');
let embed = new MessageEmbed() // embed for the timeout
.setTitle('Timeout')
.setDescription('You have been timed out for **' + time + '\n**Reason: ** ' + reason + '**')
.setColor('#F66969')
.setTimestamp()
user.send({embeds: [embed]})
if(!MutedRole) {
MutedRole = interaction.guild.roles.create({
data: {
name: 'Timeouted',
color: '#000000',
permissions: [
'VIEW_CHANNEL'
]
}
})
}
else {
member.roles.add(MutedRole.id)
}
/*
setTimeout(() => {
member.roles.remove(MutedRole.id)
}, time)
*/
Schema.findOne({ Guild: interaction.guild.id }, (err, data) => {
if(data) {
data.User = user.id,
data.Time = time
data.Reason = reason
data.save()
}
else {
new Schema({
Guild: interaction.guild.id,
User: user.id,
Time: time,
Reason: reason,
}).save()
}
let embed = new MessageEmbed()
.setTitle('User Timeouted')
.setDescription(`${user.username} has been timeouted for **${time}**.
**Reason**: ${reason}`)
.setColor('#A7FFBE')
.setTimestamp()
.setFooter({ text: `${interaction.member}` })
interaction.channel.send({embeds: [embed]})
}) // end of Schema
}
catch(err) {
console.log(err)
}
}
}
this is basicly whole file
and here is part for role... ```js
const user = interaction.options.getUser('user')
const member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).cache
const time = interaction.options.getNumber('time')
const reason = interaction.options.getString('reason')
let MutedRole = interaction.guild.roles.cache.find(role => role.name === 'Timeouted');
let embed = new MessageEmbed() // embed for the timeout
.setTitle('Timeout')
.setDescription('You have been timed out for **' + time + '\n**Reason: ** ' + reason + '**')
.setColor('#F66969')
.setTimestamp()
user.send({embeds: [embed]})
if(!MutedRole) {
MutedRole = interaction.guild.roles.create({
data: {
name: 'Timeouted',
color: '#000000',
permissions: [
'VIEW_CHANNEL'
]
}
})
}
else {
member.roles.add(MutedRole.id)
}
/*
setTimeout(() => {
member.roles.remove(MutedRole.id)
}, time)
*/
after i removed timeout
i think it should work...THEN
thats so weird.
ok...new role is created, BUT, it have default name new role
and it didnt even assigned it
oooh that makes more sense.
roles.create is following a different format
than what you do
peretty sure you dont need the: data: { on roles.create
ok ok, progress
role created, now...hmmm
it dosent assign...
...I think i know what i can try
ok, it didnt created new role, it assigned role to memebr, and i still have this
xd
ah nvm fixed it
sooo i changed code a little bit and i got this...
Here is my whole code: ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { MessageEmbed } = require('discord.js')
const Schema = require('../../models/timeout-schema')
module.exports = {
data: new SlashCommandBuilder()
.setName('timeout')
.setDescription('Timeout a user for a set amount of time')
.addUserOption(option =>
option.setName('user')
.setDescription('The user to timeout')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('duration')
.setDescription('Duration of the timeout (In Minutes) ')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('reason')
.setDescription('The reason for the timeout')
.setRequired(false)
),
async execute(interaction, client) {
try {
if(!interaction.member.permissions.has('DEAFEN_MEMBERS')) {
interaction.reply('You are not allowed to use this command!!')
return
}
let user = interaction.options.getUser('user')
let member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).cache
let duration = Number(interaction.options.getString('duration'))
let reason = interaction.options.getString('reason')
if(!reason) reason = "No reason given"
let MutedRole = interaction.guild.roles.cache.find(role => role.name === 'Timeouted');
// need to get choices from option
let embed = new MessageEmbed()
.setTitle('Timeout')
.setDescription('You have been timed out for **' + duration + ' minutes.' + '\n**Reason: ** ' + reason + '**')
.setColor('#F66969')
.setTimestamp()
user.send({embeds: [embed]})
if(!MutedRole) {
MutedRole = interaction.guild.roles.create({
name: 'Timeouted',
color: '#000000',
permissions: [
'VIEW_CHANNEL'
]
})
}
if(member.roles.cache.has(MutedRole.id)) {
return interaction.reply('This member is already timed out')
}
else {
member.roles.add(MutedRole)
member.timeout(duration, reason)
embed = new MessageEmbed()
.setTitle('User Timeouted')
.setDescription(`${user.username} has been timeouted for **${duration}** minutes.
Reason: ${reason}`)
.setColor('#A7FFBE')
.setTimestamp()
interaction.channel.send({embeds: [embed]})
setTimeout(() => {
member.roles.remove(MutedRole)
}, duration)
}
Schema.findOne({ Guild: interaction.guild.id }, (err, data) => {
if(data) {
data.User = member,
data.Duration = duration
data.Reason = reason
data.save()
}
else {
new Schema({
Guild: interaction.guild.id,
User: member,
Duration: duration,
Reason: reason,
}).save()
}
})
} catch(err) {
console.log(err)}
}
}
so i saw that i can use member.timeout() to timeout members so I used that
in brackets i passed duration and reason
setTimeout(() => {
member.roles.remove(MutedRole)
}, duration)
``` should remove muted role after time that has been passed inside duration
if(member.roles.cache.has(MutedRole.id)) {
return interaction.reply('This member is already timed out')
}
``` this should check if user alredy have this role (if it is alredy muted)
member.roles.add(MutedRole)
member.timeout(duration, reason)
``` bot give role to the user and then time out him
{ name: '1 week', value: "7week" },
interesting...
i deleted that...cuz there is easier reason
const EventEmitter = require('events');
class VoteWatcher extends EventEmitter {
constructor(apiKey) {
// code
VoteWatcher.emit("vote", data)
//code
}
}```
why emit an event inside the constructor?
if you want to emit, use super() and this.emit()
is there a way to check if member on the server is muted, if I dont use roles for mutes?
you can check for timeout
You will most likely need to fetch the audit logs
<guildMember>.communicationDisabledUntilTimestamp
if it doesn't return null, they're timedout
muted and timeouts are different things
if I dont use roles for mutes?
Also I don’t see how somebody should effectively be muted without roles
(without using timeouts)
How would you overwrite his permissions in the channels to prevent him from sending a message?
You can’t.
Needing some help with my manifest.json file for my chrome extension
{
"manifest_version": 3,
"name": "Test Extension",
"version": "1.3",
"icons": {"128": "images/logo128.png"},
"description": "description.",
"background": {
"service_worker": "page.js"
},
"content_scripts": [
{
"matches": [
"https://www.facebook.com/*",
"https://www.twitter.com/*",
"https://www.instagram.com/*",
"<all_urls>"
],
"js": [
"content.js"
],
"run_at": "document_end",
"all_frames": true
}
],
"content_security_policy": {
"extension_pages": "script-src 'self' https://ajax.googleapis.com; object-src 'self'"
},
"action": {
"browser_style": true,
"default_icon": {
"16": "images/logo.png"
},
"default_title": "tester",
"default_popup": "popup.html",
"theme_icons": [{
"light": "images/logo.png",
"size": 16
}, {
"light": "images/logo64.png",
"size": 64
}]
},
"options_ui":{
"page": "options.html"
},
"permissions": [
"storage",
"unlimitedStorage",
"tabs"
],
"host_permissions": [
"https://ajax.googleapis.com/"
],
"incognito": "split"
}```
That's the file but my error is : 'content_security_policy.extension_pages': Insecure CSP value "https://ajax.googleapis.com" in directive 'script-src'. Could not load manifest.
how can i make fetch to work infinite times? as long as bot is alive
i tried making an infinite loop but it didn't work on discord.js
You will have to respect the rate limit in order to fetch data continuously
But I doubt it takes long until you get banned from using the API if you only fetch data
wdym i get ban?
im using yt api
You may wanna provide more details when asking a question
What data do you wanna fetch?
explain what you want to do, show code examples
What are the prerequisites to make a dashboard for a discord bot?
Continue?
I mean those are the biggest ones
Once you have oauth2 you can do virtually anything those other dashboards do with discord related stuff
Like getting the users guilds to add a bot to, getting their username, avatar, etc
learning how to setup websockets
you can do without websockets, depending on your needs
Ahh, web sockets, lemme search that.
I mean yeah, you could do with rest requests (or god forbid, direct database transactions), but it'd risk desync no?
Why desync? Save all your personal settings in your database the bot also uses
depends on what they want to do with their dashboards
Uhh, just explanation on what you mean with desync? A scenario, like, please.
not all dashboards have live updates and shit
What’s the sense of interact with your bot directly via sockets and the bot stores the settings you set in your database
One step less
Correct
You fetch your data on request when loading the site
if ur gonna do a simple dashboard u can live without websockets, but once you start exploring live stuff you'll need to use websockets
What does websockets do exactly?
Not any data has to be available in a cache at any time
they allow you to send and receive data in real time
without reloading the website
Ohh, that's websockets??
basically a direct connection between two points
like a tether or smth
that way you can receive events without sending requests
basically what happens with bots <--> discord
That's really a good thing to add for websites especially for dashboards,
Absolutely unnecessary but okay
I mean, I know most websites use "websockets".
the main difference between websockets and ajax, is that all ajax updates have to be initiated by the user, ie, you cannot receive an update from your server if you dont request the update from the browser of have the browser request for updates every x time
with websockets the server can send you stuff and trigger updates in the browser without the user doing anything
websockets are still technically a request, just the tcp socket isn't closed once the initial data is finished transferring
Fair enough, fair enough. So how does it work, is it some sort of add-in code which functions or do you need to follow such documentations?
there is a websocket built into the browser
you need a websocket server on your server
As I'm currently looking for a simple video idea on getting started with Discord.JS dashboards to get the main idea of trying to use a websocket server on my server.
it doesn't really matter what lib u use for the bot
On my server as you mean the VPS?
wherever you website is going to be hosted
If you're trying to make your own client/server for backend, you need a ws library installed or use the sockets attached to your req you send/receive and follow the websocket specification
also keep in mind that not all websocket libs are interchangeable
for example ws is not 100% compatible with browser websocket
Or simply build a dashboard without websockets and request your personal settings from your database once the user loads the website
Instead of over complicating things
Polling is a bad idea for frequently changing data
but not the worst idea
websockets can have more overhead
I don't think dashboard data is frequently changing
Depends on the dashboard
Maybe once your project reaches an huge scale
I allow users to view music queues in realtime on my bot's dashboard and that requires websockets
That guy saidhe's following a tutorial
Doesn't seem that serious
Alright, for now I have a web-hosting plan.
And instead of using the file manager in the plesk to host my website, I want to use a VPS.
I will be able to achieve so by changing my DNS records, by the looks of it.
I feel like he simply wants to show some personal settings user can set for their guilds
I can still host the website on the same VPS the bot is hosted in, I believe.
You never know someone's situation. Just providing facts they can apply to their desired use case
I got a better idea
Just ask him
Eww
@feral aspen What functions do you need for that bot dashboard ?
Functions? What do you mean "functions"?
Features
features
What do you wanna do with it
I mean, for now, I just want to set it up by at least having it to show the server count and the member count on the website.
do you want these counts to update automatically without refreshing the page?
If we're using web-sockets, sure.
Websockets are an option, but might be overkill
i mean, you first decide if you want that or not, so you can decide if you need websockets or not
I mentioned they have more overhead than polling in certain situations
I mean, I want to use web-sockets, yes.
You know you don't even need a server for that
That data is available publicly throw the api
Just fetch it
but you want to use them because you need them or because they sound fancy?
Polling as in what, what do you mean?
No, not for the fanciness or something, I just want them to show so I could setup my website/dashboard that displays the basic information before I, for example, work on the oauth2, and the logging in, etc.
Not for something unnecessary like a bot
Other than that, I want to make the dashboard to, for example, change the prefix of the server we're configuring.
In addition to the checks I'll have to program, such as:
- Making sure the bot is in the server.
- You logged in.
- etc.
Skip the websocket and polling
Just load the content every time the user refreshes
Query your database to get the current settings like the prefix, then push the changes to your database once the user edits it
That is what I'll do, yes.
Alright, I won't display the bot count and member count, supposedly, but I do want to use web-sockets.
However, not sure what "polling" is.
Requesting the server every 5 minutes
Aha.
Let your bot update the total counts in your database for example every 15 mins and pull this data on your website once an user visits it (and/or cache it)
Polling, or polled operation, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity. Polling is most often used in terms of input/output (I/O), and is also referred to as polled I/O or software-driven I/O. A good example of hardware implentation is a watchdog timer.
It’s literally exact the same like updating your guild count on topgg
Ohh, fair enough. 👍
While you can update it like every few seconds the website pulls the data every hour from the database
Live stats are simply an unnecessary resource waste
For something unnecessary like a discord bot
Alright, looks like the prefix change feature is one way to setup the website.
Over complicating stuff especially if you start building stuff to get experienced isn’t really needed
But yeah, just my opinion
Alright, for sure. I'll just need to build the files for now and know what I'm doing.
Also, should I use next.js, express.js?
I went for pain and did no middleware

middleware shouldn't be as bloated as some of them are
realistically, it should just be some utility stuff like providing path and query string
bc http server doesn't give that to you straight up
raw http > *
does anyone know how to implement a generational index
(as simply as possible preferably)
I got some boilerplate from online, but I have no idea if the methods I implemented are correct (especially allocate) ```rs
#[derive(Eq, PartialEq)]
struct GenerationalIndex {
index: usize,
generation: u64,
}
impl GenerationalIndex {
pub fn new(index: usize, generation: u64) -> Self {
GenerationalIndex { index, generation }
}
pub fn index(&self) -> usize {
self.index
}
}
#[derive(Debug)]
struct AllocatorEntry {
is_live: bool,
generation: u64,
}
impl AllocatorEntry {
pub fn new(is_live: bool, generation: u64) -> Self {
AllocatorEntry { is_live, generation }
}
}
#[derive(Debug)]
struct GenerationalIndexAllocator {
entries: Vec<AllocatorEntry>,
free: Vec<usize>,
}
impl GenerationalIndexAllocator {
pub fn new() -> Self {
GenerationalIndexAllocator { entries: Vec::new(), free: Vec::new() }
}
pub fn allocate(&mut self) -> GenerationalIndex {
if self.free.is_empty() {
self.entries.push(AllocatorEntry::new(false, 0));
GenerationalIndex::new(self.entries.len() - 1, 0)
} else {
// fix
GenerationalIndex::new(0, 0)
}
}
pub fn deallocate(&mut self, index: GenerationalIndex) -> bool {
self.free.push(index.index);
match self.entries.get(index.index) {
Some(entry) => true,
None => false
}
}
pub fn is_live(&self, index: GenerationalIndex) -> bool {
if self.free.contains(&index.index) {
false
} else {
if let Some(entry) = self.entries.get(index.index) {
return entry.is_live;
}
false
}
}
}
struct ArrayEntry<T> {
value: T,
generation: u64,
}
struct GenerationalIndexArray<T>(Vec<Option<ArrayEntry<T>>>);
impl<T> GenerationalIndexArray<T> {
// pub fn set(&mut self, index: GenerationalIndex, )
}
I have no idea if any of that is right
HEY GUYS, so i making my "own verison" of reaction roles, and i ran onto this error, idk why it is happening, seriously.
This is ss of error and my code: Error appears ob line 57
then GuildData.roles is undefined
well i have ```js
const GuildData = await Schema.findOne({ Guild: interaction.guild.id})
Have you tried logging the value of the GuildData variable?
Also making a reaction roles feature in your bot nowadays is pointless, Discord has made a built-in feature that does the same thing but much better, it's called "Role Prompts"
hah, never heard of that. tnx man
still in dev no?
It's still experimental yes, but it's going to be released very soon
really loved when this happens xd
Son of a b
how can I create a category and inside that category create a channel?
creating a channel inside the category is with the parent id, right?
creating a category returns a channel
What library are you using?
create a channel inside it
discord.js
yep
first I would like to create che category
just chain requests
but idk how to create a category
You can use this method to create a channel with the type of category
https://discord.js.org/#/docs/discord.js/stable/class/GuildChannelManager?scrollTo=create
oh, ty
Well GUILD_CATEGORY to be precise
what can i do about this, bcz it is only happening at one command, other commands that are using mongo, they doing good
review ur data structure
kuuhaku you're a data structures man right
that means u have something like ```json
{
"something": {
"abc": {
"something": {
"abc": {
...
}
}
}
}
}
no, like a horse pulling a car that's pulling a horse that's pulling a car that's...you get it
you have a looped structure
ahh, got it
It's like ```
A has B in it
B has A in it
doesn't make sense, because then there would be an infinite structure
to visualize
hah this is what i have:
sooo, Guild: is string and saves guild id,
user is array and it should save multiple users
like u can have them more muted
that shouldn't cause that issue
but duration, reasons are string
you probably have something else
like this
GuildData.roles has GuildData.roles
but GuildData.roles also has GuildData.roles
either way here I'd be doing GuildData.roles.push(newRole) instead of that
thats diferent command
that is for self roles
i deleted it
@fathom sonnet The first statement in that if statement is also wrong, because you're trying to reassign a constant variable
You've declared the roleData variable with the const variable, so it's constant but you're reassigning it there
nah man, thats for self roles, i deleted that command, as you say it is kinda pointless
Oh
xd
this is basicly all for timeout.js ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { MessageEmbed } = require('discord.js')
const Schema = require('../../models/timeout-schema')
// const { OWNER_ID } = require('../../config/cfg.json')
module.exports = {
data: new SlashCommandBuilder()
.setName('timeout')
.setDescription('Timeout a user for a set amount of time')
.addUserOption(option =>
option.setName('user')
.setDescription('The user to timeout')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('duration')
.setDescription('Duration of the timeout (In Minutes) ')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('reason')
.setDescription('The reason for the timeout')
.setRequired(false)
),
async execute(interaction, client) {
try {
if(!interaction.member.permissions.has('DEAFEN_MEMBERS') /*|| !interaction.member.id === OWNER_ID */) {
interaction.reply('You are not allowed to use this command!!')
return
}
let user = interaction.options.getUser('user')
let member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).cache
let duration = Number(interaction.options.getString('duration')) // Getting number from string
let reason = interaction.options.getString('reason')
if(!reason) reason = "No reason given" // If no reason is given, set it to "No reason given"
let embed = new MessageEmbed()
let embedPublic = new MessageEmbed()
// need to get choices from option
// DM Embed
embed = new MessageEmbed()
.setTitle('Timeout')
.setDescription('You have been timed out for **' + duration + ' minutes.' + '\n**Reason: ** ' + reason + '**')
.setThumbnail(member.user.avatarURL({dynamic: true, size: 512}))
.setColor('#F66969')
.setTimestamp()
user.send({embeds: [embed]}).catch(() => { interaction.reply({ content: `I am unable to send message to ${user} because they either blocked communication with the BOT, or they have closed DM's.` }) })
// Add the role to the user
member.timeout(duration, reason)
// remove role from user after duration has passed
embedPublic = new MessageEmbed()
.setTitle('User Timeouted')
.setDescription(`${user.username} has been timeouted for **${duration}** minutes.
**Reason**: ${reason}`)
.setColor('#A7FFBE')
.setTimestamp()
interaction.reply({embeds: [embed]})
Schema.findOne({ Guild: interaction.guild.id }, (err, data) => {
if(data) {
data.User = member,
data.Duration = duration
data.Reason = reason
data.save()
}
else {
new Schema({
Guild: interaction.guild.id,
User: member,
Duration: duration,
Reason: reason,
}).save()
}
})
} catch(err) {
console.log(err)}
}
}
how can I set the permissions for the category for only administrator?
Well the reason that error occurs is because you're literally passing a GuildMember class instance to the database for it to save, which would fail because not only is it non-serialized that the database probably doesn't understand how to represent as a value, and that class instance also contains cyclic data
Yeah, it's recommended to rather save the ID and fetch it when needed, or save other information if necessary, not the whole instance
he's probably checking if it's cached before attempting a fetch
The fetch() method checks for the cache first, so it's better to just call the fetch method
there is a difference in the speed?
if fetch didn't check the cache, yes, a huge one
all is cached in discord.js lmao
yea, about that, that never made any problems
It's kinda useless in my opinion
on any other cmd
It's actually wrong though, because you're accessing the property of a promise
soo to just fetch?
const member = await interaction.guild.members
.fetch(user.id)
.catch(() => null); // To handle the error if the member is not found.
Should be enough
const action = await modal.guild.channels.create(`${nomeCategoria}`, {
type: 'GUILD_CATEGORY',
permissionOverwrites: [
{
id: modal.user.id,
allow: ["ADMINISTRATOR"],
}]
})```
How can I properly set the permissions? never did that in my life, I want to set the category only for admins and the channels created for admins and the user that used the button (it is a ticket system)
definetly
You should set the everyone role to not be able to see the channel, and set the role that has the administrator permission to do whatever, but it's not really needed since admins can already see all channels by default
so not to everyone : js deny: [Permissions.FLAGS.EVERYONE],?
For that, you would need to set the id property to the guild ID, as the ID of the everyone role is the same as the guild ID
REALLY? wow, that's cool
And for the permissions, set the deny property to an array that includes the VIEW_CHANNEL permission
const action = await modal.guild.channels.create(`${nomeCategoria}`, {
type: 'GUILD_CATEGORY',
permissionOverwrites: [
{
id: modal.guildId,
deny: [Permissions.FLAGS.VIEW_CHANNEL],
}]
})
?
excel is a game engine not a database
That's correct, if the modal.guildId property is actually the ID of the guild of course
modal have the same properties of interaction
ur right, i goona use Unity
tnx
Oh it's a modal instance, then yeah; I thought you assigned it to something else
🤣
last question, when I will cre ate the channel in the category, allowing the user that presse the button I'll have to do ```js
const action = await modal.guild.channels.create(${nomeCategoria}, {
type: 'GUILD_CATEGORY',
permissionOverwrites: [
{
id: modal.guildId,
deny: [Permissions.FLAGS.VIEW_CHANNEL],
}, {
Id: modal.user.id,
allow: [Permissions.FLAGS.VIEW_CHANNEL
]
})
?
sorry for the how the code is invented, I wrote it from my phone 💀
Yeah that should work, just Id to id 
Id != id
yo got a question, what should i do if i got rate limited
i have a bulkassign role, it got rate limited
bot still works but the it doesnt assign roles
All you can do is wait
Ratelimits all go away after a certain amount of time, it's better to assign the roles in-between timeouts so it doesn't get ratelimited
yeah cool how many should i send per second?
it can range from a few minutes to an entire day
Ratelimits are not entirely constant to be shown in the documentation as they're dynamic, so this tells you how to check it
https://discord.com/developers/docs/topics/rate-limits
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
It would be better to assign roles in-between every 10 seconds or more, usually up to 1 minute just in case
But 20-30 seconds should also be fine
the property in the channel creation for creating it in a category?
I'm confused, they changed it from await createConnection({}) to what? https://cdn.hamoodihajjiri.com/hXZZyrE7TS
It's called parent
https://discord.js.org/#/docs/discord.js/stable/typedef/GuildChannelCreateOptions
For the other option, you can follow the CategoryCreateChannelOptions hyperlink above it
Cool cool thanks
Basically what they're telling you is that, currently the Connection class isn't actually a real connection, it's just a place where information is stored for other connections, and QueryRunner class is the real connection which is created by the createConnection() function, but in the future the Connection class will be renamed to DataSource to reflect what it actually is and what it is used for, and the QueryRunner class will be renamed to Connection, to reflect that it's the real connection, so the new real connections will be created with the create() method of the Connection (renamed QueryRunner) class in the future
Ohh, so if I would want to create a connection, it would be what, particularly?
QueryRunner.create()?
It would look something like this
import { Connection } from 'typeorm'; // Or whatever it's name is.
const connection = Connection.create(/* options */);
As the QueryRunner class will be renamed to Connection to make it less confusing and reflect what it actually is, as mentioned
Ohh, fair enough. 👍
However, Connection is deprecated? https://cdn.hamoodihajjiri.com/X65NzMAJXP
No no no, that's not the point; they're saying it'll happen in the future, currently the Connection class is not the real connection, it's the place information is stored for other connections
Hey, so... Ive got some questions regarding permission checks...
Send message
Checks if the bot has the permission
if (message.guild.me.permissions.has("SEND_MESSAGES"))
Checks if it has permission for that channel
if (message.channel.permissionsFor(message.guild.me).has("SEND_MESSAGES"))
Are those correct/enough?
Managing roles
Checking if the bot can manage roles
if (message.member.guild.me.permissions.has("MANAGE_ROLES"))
Then after that I check to see its hierarchy and only if the bots role is higher will I add the role
Would that be enough to make sure roles are always able to be assigned if if has permissions and doesnt error out?
So how can I initiate a connection to my database?
Since createConnection() wouldn't work, either.
That should be enough, it's correct as well
The current way is the createConnection() function, does it throw an error? What's the problem with it exactly?
It's deprecated.
You can see how it's also deprecated: https://cdn.hamoodihajjiri.com/LkeHugBFZN .
I think they screwed up the way they're explaining how it'll be treated and what you should use
Yeah, unfortunately.
thanks for the response 🙂
hmm thats good to know but strange because there are a few odd times when it errors out, i get a "missing access" when dealing with the roles, which I dont understand
That error usually occurs when the bot doesn't have access to a channel, settings tab, feature, or anything similar
I suppose in this case it's probably the channels, the bot also needs the VIEW_CHANNEL permission to view the channel in the first place
Well, what if a bot can already read a persons message? would it not already be able to view the channel?
In that case yes, it's able to view the channel; if it's not because of the channels then it's caused by one of the others I mentioned
hmm okay thank you, i'll debug it a bit more and check to see what permission it might be
still rate limited dang, i should fix that code asap
what yall do to run the command slowly and assign roles slowly not to get rate limited
sleep
ECS is melting my brain
just wrote 314 lines of code, the render system works first try
But now I'm wondering how I'm meant to actually use the ECS
Ecs sucks , it happens with me too
I'm trying my very best to avoid OOP type stuff
So I'm currently hosting my site and on the DNS records my Content on cloudfare is 35.186.245.55 for repl hosting but how do I change that so I can host it on vsc?
hosting on vsc? or you mean hosting on vps?
vsc
well
putting it on vsc and then making it connect to the domain
then i host it on my vps
well you'd need to run a webserver on your pc, then you'd need to port forward your router, then point the dns records to you pc's ip address
alr thanks
hence its recommended to go directly to vps
Yeah
you can test your website on your pc without the domain
yeah
just by going to localhost
yeah
It is highly recommended to make a DataSource now and initiate it
Unless you are talking about something else when creating a connection to your database
import { DataSource } from 'typeorm'
const datasource = new DataSource({
host: blah
user: blah
})
await datasource.initialize() // or initiate can't remember
I don't use TypeORM so better to tell that to the other guy asking it 
what is GATEWAY_GUILD_MEMBERS Intent and GATEWAY_MESSAGE_CONTENT intent?
this
thanks
funny (atrocious) typescript/typechecking moments: js let resolver; const promise = new Promise(resolve => { resolver = resolve; }) resolver() // error using variable before assignment ```js
let resolver;
const promise = new Promise(resolve => {
resolver = resolve;
})
(() => resolver())() // works
Makes sense
Although wouldn't that error since there is no semi after defining what promise is?
yes it would lel
but ignoring that, both work fine in js
but for some reason ts doesnt see the variable defined if you use it directly
even tjough it is
but if you wrap it in something, then suddenly it sees the definition
ts is weird like that, it doesn't recognize what it's new type is even after reassignment
I've had times where I had to cast what it should be after reassignment cause it still think it is it's original definition
shit like this is why i hate ts
I'm really hating rust rn 
I am starting to think trying to make a parser is a bit too much for a beginner
even with a well displayed book on how to do it
I mean rust looks nice and I do really love it
But sometimes it's concepts can be a pain to wrap my head around
something about not knowing the callback is called on the same loop
because if it wasn't called immediately, then that would error
Borrowing and ownership was a circus for me
lifetimes also make virtually no sense to me
rust mfs realizing you cant own something in a computer
No but I can own you
user with root/admin account: I OWN YOU
tim do you like cashews?
now im trying to figure out why my diffie hellman exchange produces two completely different secrets
stupid database
stupid c++
why are /tenor and /giphy not available on mobile dafuq
stupid openssl
cause they do it to anger you
angery
I was thinking of looking at C
but I am unsure if I wanna go down that rollercoaster yet
so far I think ima stick with rust for a while and see what I can accomplish
i would use c if it wasnt for the fact is has like no built in features
I honestly could but I am not smart enough yet to do anything advance in rust
I haven't even interacted with dbs yet
beauty of C make the features yourself

love reinventing wheels
isn't that what you do with C?
make everything yourself even if it has already been made
i have a bunch of objects written in c for my os so I can use them but i dont know how reliable they are yet
so i only use them for my os
os = operation speedy
top secret shit tim how'd you know?
looks like we gotta take you out
i also written a flexible array class
and no my os isnt dead i work on it all the time i just dont update the repo 💀
Isn't that what happened to TempleOS dood
meh
i like cashew juice and cashew nuts, the fruit not so much
windows suffers a bsod, mac suffers a kernel panic, speedyos suffers an operation speedy
:^)
i also did what most computer science majors cant do https://github.com/SpeedyCraftah/speedy-os/blob/master/src/cpp/structures/linked_array.h
make bad code?
btw i let copilot write a single function for me for the linked list and it completely fucked it up
i wasnt paying attention so i just went "ok"
even copilot cant make a linked list
lel
copilot absolutely sucks with c/c++/assembly
it cant even move a number into a register in assembly without fucking it up
Still rate limited dang
ask discord to stop
learning about typescript+jsdoc shenanigans
before (tons of type errors)
after
have to add extra variables to type cast stuff correctly
otherwise you have to do shit like (type bla (type unknown (value)))
👀
can't you just give type to timeout and then add the values you need then set timer to timeout?
why make a new variable
adding properties to existing objects is a pain
typescript first complains that property X does not exist in object Y
then you type X with & { props }
and it complains object Y cannot be assigned to type X with props because it lacks the new props
tf
ex ```js
type bla = Error
const myvar: bla = new Error()
myvar.code = 10 // error, type bla does not have prop "code"
type bla = Error & { code: number }
const myvar: bla = new Error() // error, Error object does not have prop "code"
one way to fix is type bla = Error & { code?: number } but i dont want code to be optional, because then i have to type guard it everywhere
another way is to do shit like const myvar: bla = new Error() as unknown as bla
but in jsdoc syntax it looks like hell
cannot simply do const myvar: bla = new Error() as bla because it errors again with "object Error cannot be assigned to bla because its missing property code"
I mean one hacky way to do it is to override Error
well yes, in some places i have a class that extends error
but i dont wanna to that for every single little thing
I don't mean by extending it
well i dont think jsdoc has that
The @override tag indicates that a symbol overrides a symbol with the same name in a parent class.
Ah I see
only works for stuff with the same name
There's gotta be a better way to do it
welcome to typescript
you spend more time trying to fix language issues rather than writing code
yup
i switched type checking to strict (i thought i already had it on, turns out i didnt)
and i got 100+ errors
lmao
a statically typed language running on a dynamically typed language just doesnt work well
I think ts is fine
if you're fighting the compiler a ton then you're either doing something obscure or doing something wrong
i often do obscure things
same
you cant lie though ts limits the full potential of javascript
because it's supposed to
like taking variables out of their scopes, ie promise resolvers and http req/res objects
that's the tradeoff
whether its for the better or worse
you sacrifice unsafe assumptions for a safer type system
for obscure/advanced things, sure, probably gets in the way. For things like react and any sort of API wrapper? A miracle
i came across this article, and it explains exactly what i feel about ts very nicely https://gils-blog.tayar.org/posts/jsdoc-typings-all-the-benefits-none-of-the-drawbacks/
typechecked js in action:
I really want to write my own mini ECS but this is hard :C

he thought execute meant kill in this context