#development
1 messages · Page 190 of 1
because im not sure compression is worth the overhead if most of the messages are gonna be tiny
effectively just binary data
what are you trying to send?
most of Miki runs on protobuf internally and we dont use compression
most payloads are <1kb
its worth it if you have a shared context
otherwise no
normal compression starts being worth at around 200+ bytes
shared context is already worth at as little as 20 bytes
that is, if your goal is reducing bandwidth/size
cpu-wise its probably only worth on bigger payloads
think discord websocket messages, similar in concept
and some odd events here and there
protobuf is possible but i fear added complexity and reduced accessibility for developers
and added development time
proto does add a bunch of weird rules since you pipe json to proto and i assume back?
e.g. proto does not allow for undefined properties
... well it kinda does?
not all languages handle it as well
are you intending to expose it to other developers?
just use json then
if discord is able to scale on json then you can too 🤓
but whether they are doing it well is another story
i think their websockets are relatively stable now but they used to be spotty
especially since introducing intents
i don't think that's a matter of how they serialize their data though
but that doesnt really affect users since they should get all events anyways so theyre probably doing a decent job
yes
my main goal is to reduce events as it is
either way, json is a great developer-focused decision because it has a super low buy-in cost
if you need to sell your solution to other developers, that's important
json with compression is usually more than enough
you can also go for some alternative schema-less formats like messagepack
are you working with node/js?
front-end performance wont matter since it only runs a single client
backend performance is whats important
you can stay with raw json, compress it in an nginx reverse proxy, and let the browser decompress it by itself
does the browser decompress on a websocket level?
not sure tbh
theres a websocket extension for compression: permessage-deflate
there is some source code about it in chrome
i believe the native WebSocket api does support it
looks like it but I don't see a lot of talk about it
what are you using for ws server on node?
the ws lib?
yep
have you tried uwebsockets.js?
ws goes woosh
uwebsockets.js goes wooooooosh
welll, they self-advertise it as being 8-10x faster, but it always depends on individual workloads
µWebSockets.js is a web server bypass for Node.js that reimplements eventing, networking, encryption, web protocols, routing and pub/sub in highly optimized C++. As such, µWebSockets.js delivers web serving for Node.js, 8.5x that of Fastify and at least 10x that of Socket.IO. It is also the built-in web server of Bun even though µWebSockets.js for Node.js runs 80% faster than Bun.
Neat
uwusockets.js?
lol express is so mid in terms of performance
why does a websocket library come with a http server though
because http is a pre-requisite
yes but do they let you build an entire http server with it
if so why don't they just bundle it in another library
besides ws doesn't need the entire http spec implemented (at least I don't think so)
it's only a hello I would like ws connection, ok 101 status we have ws now send me your config frames or whatever
isn't it necessary for the handshake?
Like a websocket uses tcp, but for that it usually intiates a 3-way handshake over http after which it will switch over to the tcp protocol, after the communication "tunnel" has been created.
i could be wrong, but i don't think so

they do actually
http spec is pretty simple compared to websocket
there are quite a few http libs on npm that use uws under the hood for "performance"
Not using uwusockets that’s why
It was a joke based off what egg said lol
more like ewsockets
More like ezsockets
oWOOsockets
Websockets ez
hey guys i need some design help with my backup bot. Like it stores messages of users (which opt-in user data collection, and opt-out features as well). Members can then load this backup. But what if the channels that these messages were sent in don't exist? Would it just create those channels THEN send the messages?
It's gonna send all the messages?
I mean why do you want to preserve messages
Unless it’s important don’t that’s too much work
It will also likely be api spammy
i cache only 5 messages at the time
and it kinda is importante
Setting up Mongo as a sharded replica set config server and when forking I get the attached error. When not forking, it hangs at starting and the logs say nothing useful.
yes but I mentioned the entire http spec doesn't need to be implemented unless I'm wrong
it feels illegal a websocket library to also happen to be one of the fastest http servers for node
depends on the purpose
is it simply to backup user messages?
if so you could maybe do with an embed that lets you scroll through messages with pagination
and maybe have a button that lets you do what you said and print the messages to that channel (although the volume might be large)
then you can have additional handling for if the channel does not exist anymore like making a new one or using current channel
A bot that can store and send 1000s of messages that were deleted? That sounds very unrealistic to accomplish for a bot that's in a lot of servers
If you really are willing to do that then pagination might be the go-to.
Maybe a embed with 5-8 fields per page, field name is the name of user and field's value is the message that was deleted.
There can be a next and previous button to swap through pages.
A search button which allows you to search messages with specific words in them like "hello" so messages with hello will be shown per page
Search button can have more filters like filter with specific user so only the user's messages are shown etc.
Regardless of whatever you do, it's kinda useless for a public backup bot and too messy to manage imo.
Eitherway, can someone gimme a walkthrough on how do you customize your discord bot's page like this https://prnt.sc/i4-beJ9kHaoK
I didn't even know that half of it was possible before checking this page 
using css
Oh so there's no way to do it on the website
there is
you can use most html tags in your description and edit some of the css classes
When it comes to css I can barely do anything significant
unless someone has documented all the classes then you will have to view the page yourself and find the classes you want to edit
Probably will have to ask someone to assist xD
makes sense
Got it, I'll most probably reach some friends out to setup the page then

hey i have shifted from replit to vsc
And encountering some issues
pls help
const {readdirSync}=require("fs");
const ascii = require("ascii-table");
const client= require("discord.js");
let table= new ascii("Commands");
table.setHeading("Command Name", "Loaded Status");
module.exports =(client)=>{
readdirSync("./commands/").forEach(dir => {
const commands = readdirSync(`./commands/${dir}/`).filter((file)=>
file.endsWith(".cjs")
);
for(let file of commands){
let pull = require(`../commands/${dir}/${file}`);
if(pull.name) {
client.commands.set(pull.name,pull);
table.addRow(pull.name,"✅");
}else{
table.addRow(
pull.name,
`❌`
);
continue;
} if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name))
}
});
console.log(table.toString());
};```
this is the code currently
output is coming like this
location of files
so can someone help
The code shows that something like this can only happen when there is no name value in the command
Are you sure these commands have this value?
I assume it's a command requirement problem then
wdym
I mean let pull = require(path)
Have you checked what happens when there is one dot instead of two in path?
There is one dot in path in the rest of the code, so why are there two?
well still same issue
Then conole.log all values and check what they really are
It's hard to reproduce this problem without having all the files
thats illegar
nope, its raw
but there are many libs that are built on top of it that do
speaking of fastify, i made a small api for a client and i went with fastify
and it leaks ram like crazy idk why
It’s bad
like its not even receiving any requests, just idle for days
:)
and ram growing to 200+mb
im sticking with node:http servers for now
Yea only you
lmao
I’ll be happy with my https://rocket.rs servers :)
Rocket is a web framework for the Rust
programming language that makes it simple to write fast web applications
without sacrificing flexibility or type safety.
go back to the junkyard if ya wanna be rusty
No you
hows your api coming along

o neat
const { readdirSync } = require("fs");
const Discord = require("discord.js")
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token } = process.env.token;
const ascii = require("ascii-table");
const client = require("discord.js");
const { clientId } = process.env['applicationid'];
let table = new ascii("SlashCommands");
table.setHeading("SlashCommand Name", "Loaded Status");
const slashCommands = []
module.exports = (client) => {
readdirSync("./slashCommands/").forEach(dir => {
const commands = readdirSync(`./slashCommands/${dir}/`).filter((file) =>
file.endsWith(".cjs")
);
for (const file of commands) {
const pull = require(`../slashCommands/${dir}/${file}`);
slashCommands.push(pull.data.toJSON());
if (pull.data.name) {
client.slashCommands.set(pull.data.name, pull)
table.addRow(pull.data.name, "✅");
} else {
table.addRow(
pull.data.name,
`❌`
);
}
}
console.log(table.toString());
});
client.on('ready', async () => {
const rest = new REST({ version: '9' }).setToken(process.env.token);
try {
console.log('Started refreshing application (/) commands.')
await rest.put(
Routes.applicationCommands(process.env.applicationid),
{ body:slashCommands },
);
console.log('Successfully reloaded application (/) commands.')
} catch(error) {
console.log(error)
}
});
}```
this is my current code
slashCommands.push(pull.data.toJSON());
^
TypeError: Cannot read properties of undefined (reading 'toJSON')
at C:\Users\DELL.vscode\Programs\Test_JS\handlers\slashcommands.cjs:28:36
at Array.forEach (<anonymous>)
at module.exports (C:\Users\DELL.vscode\Programs\Test_JS\handlers\slashcommands.cjs:22:35)
at C:\Users\DELL.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:49:42
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\DELL.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:48:40)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
gettin this error
I am so confused
if you are alrady setting the slash commands to the client slashCommands map
why are you also pushing to a local array
👀
no
I don't even know where to begin with this
also this is likely forked or chatgpt code 
const pull = require(`../slashCommands/${dir}/${file}`);
^ this line is saying that you are loading the contents of a command file. this line is repeated for all of your commands, so you're loading all your commands
slashCommands.push(pull.data.toJSON());
^ this line is saying that you want to access the data of each loaded command, and then run the function toJSON() inside the data of that command
Cannot read properties of undefined (reading 'toJSON')
^ this error means that one or more of your commands do not have a data at all, so the code cannot access the toJSON() function if the data doesnt exist in that command
so your problem is not in that code, is that you made it so that ALL your commands must have a data property, and if one or more of them dont have it, it will fail
so you need to check all your commands, and find which one does not have a data and add it
only have one right now
i dont think anything wrong with this
Well then it’s probably not in every file
just before this line slashCommands.push(pull.data.toJSON()); add this: console.log(dir,file,pull)
const pull = require(`../slashCommands/${dir}/${file}`);
console.log(dir,file,pull) // <---- add this
slashCommands.push(pull.data.toJSON());
and show what it logs
nothing logged
i said i only have one right now
it has to log something, should appear right before the error
nah nothing fr
just the table
you should really use table.addRow(file, '❌'); instead of table.addRow(pull.data.name, '❌');
because, as you can see in the console, it'll print nothing in "Command Name" if it wasn't able to load it
also check if pull has data before using toJSON(), or at least try-catch it
From this it’s very clear that you have 2 files being loaded, whether you meant to or not. I’d take another look, or maybe screenshot your file structure
bro thats different
thats for commands
and right now i am talking about slashCommands
either attach a debugger or do console.log(file) before slashCommands.push(pull.data.toJSON());
that error was caught by a debugger only btw
lemme log file
I think asking for a debugger is a stretch here lol
nothing logged yep
const { readdirSync } = require("fs");
const Discord = require("discord.js")
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token } = process.env.token;
const ascii = require("ascii-table");
const client = require("discord.js");
const { clientId } = process.env['applicationid'];
let table = new ascii("SlashCommands");
table.setHeading("SlashCommand Name", "Loaded Status");
const slashCommands = []
module.exports = (client) => {
readdirSync("./slashCommands/").forEach(dir => {
const commands = readdirSync(`./slashCommands/${dir}/`).filter((file) =>
file.endsWith(".cjs")
);
for (const file of commands) {
const pull = require(`../slashCommands/${dir}/${file}`);
//console.log(dir,file,pull)
console.log(file)
slashCommands.push(pull.data.toJSON());
if (pull.data.name) {
client.slashCommands.set(pull.data.name, pull)
table.addRow(pull.data.name, "✅");
} else {
table.addRow(
pull.data.name,
`❌`
);
}
}
console.log(table.toString());
});
client.on('ready', async () => {
const rest = new REST({ version: '9' }).setToken(process.env.token);
try {
console.log('Started refreshing application (/) commands.')
await rest.put(
Routes.applicationCommands(process.env.applicationid),
{ body:slashCommands },
);
console.log('Successfully reloaded application (/) commands.')
} catch(error) {
console.log(error)
}
});
}
you sure nothing logged?
yes
silly question, but did you save the file?
cuz it's impossible for it not to log
put console.log("here") above it
show ping
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Shows Latency Of Bot!'),
async execute(client,interaction) {
let pingem =new MessageEmbed()
.setThumbnail(client.user.displayAvatarURL({dynamic: true}))
.setDescription(`**🏓 | Pong**
🔴 **Current Ping Of Bot-**\n **__${Math.round(client.ws.ping)} ms__**`)
.setFooter("Use /help To Know More About My Commands")
.setColor("GREEN")
await interaction.reply({embeds: [pingem]});
},
};```
is ping saved
what happens if you do console.log(pull)?
it wont print ping.cjs if it wasn't saved coz i have not made any changes there since i copy pasted from my previous platform
i just logged dir,file,pull
yes but what is the result of it?
ik the issue
you're doing readdirSync("./slashCommands/"), but you're also doing const commands = readdirSync('./slashCommands/${dir}/')
and i think same issue is there with commands
this means you're looking for the command at the path ./slashCommands/slashCommands/${dir}/${file}
module.exports = (client) => {
readdirSync("./slashCommands/").forEach(dir => {
const commands = readdirSync(`./slashCommands/${dir}/`).filter((file) =>
file.endsWith(".cjs")
);```
inside readdirSync you're already inside that folder
also there's require('../slashCommands/${dir}/${file}'), which is double-dotting backwards one folder
oh wait, ignore my previous comment, I'm thinking bash-like regarding dir moves
but this one is for sure, remove one dot
yes
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './slashCommands/Bot Info/ping.cjs'
Require stack:
- C:\Users\DELL\.vscode\Programs\Test_JS\handlers\slashcommands.cjs
- C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at C:\Users\DELL\.vscode\Programs\Test_JS\handlers\slashcommands.cjs:28:20
at Array.forEach (<anonymous>)
at module.exports (C:\Users\DELL\.vscode\Programs\Test_JS\handlers\slashcommands.cjs:23:35)
at C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:49:42
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:48:40) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\DELL\\.vscode\\Programs\\Test_JS\\handlers\\slashcommands.cjs',
'C:\\Users\\DELL\\.vscode\\Programs\\Test_JS\\mini-cricket\\src\\index.cjs'
]
}```
try it
same issue
well, return to what it was then
anything wrong with this(handler path)
require(`../../handlers/${handler}.cjs`)(client);
});
but based on this log, your command has nothing inside it at all
yes
see the {}
i just showed u code
just as a test, add test: "abcde" as one of module.exports properties
see if it appears on that console.log
nothing logged
did you uncomment the line?
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Shows Latency Of Bot!'),
test: "abcde", ```
which one
whatever logged this
yea yea
then save the file
its saved
const pull = require(`../slashCommands/${dir}/${file}`);
console.log(dir,file,pull)
slashCommands.push(pull.data.toJSON());
``` it should look like this
.------------------------------.
| Commands |
|------------------------------|
| Command Name | Loaded Status |
|--------------|---------------|
| | ❌ |
| | ❌ |
'------------------------------'
.---------------------------------------.
| Events |
|---------------------------------------|
| Event Name | Loaded Status |
|-----------------------|---------------|
| interactionCreate.cjs | ✅ |
| messageCreate.cjs | ✅ |
'---------------------------------------'
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './slashCommands/Bot Info/ping.cjs'
Require stack:
- C:\Users\DELL\.vscode\Programs\Test_JS\handlers\slashcommands.cjs
- C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at C:\Users\DELL\.vscode\Programs\Test_JS\handlers\slashcommands.cjs:28:20
at Array.forEach (<anonymous>)
at module.exports (C:\Users\DELL\.vscode\Programs\Test_JS\handlers\slashcommands.cjs:23:35)
at C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:49:42
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:48:40) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\DELL\\.vscode\\Programs\\Test_JS\\handlers\\slashcommands.cjs',
'C:\\Users\\DELL\\.vscode\\Programs\\Test_JS\\mini-cricket\\src\\index.cjs'
]
}```
return the double dot on the require
.------------------------------.
| Commands |
|------------------------------|
| Command Name | Loaded Status |
|--------------|---------------|
| | ❌ |
| | ❌ |
'------------------------------'
.---------------------------------------.
| Events |
|---------------------------------------|
| Event Name | Loaded Status |
|-----------------------|---------------|
| interactionCreate.cjs | ✅ |
| messageCreate.cjs | ✅ |
'---------------------------------------'
Bot Info ping.cjs {
data: SlashCommandBuilder {
options: [],
name: 'ping',
name_localizations: undefined,
description: 'Shows Latency Of Bot!',
description_localizations: undefined,
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
test: 'abcde',
execute: [AsyncFunction: execute]
}
ping.cjs
.-----------------------------------.
| SlashCommands |
|-----------------------------------|
| SlashCommand Name | Loaded Status |
|-------------------|---------------|
| ping | ✅ |
'-----------------------------------'
Started refreshing application (/) commands.
[READY] Sheru#1721 has logged in.
Successfully reloaded application (/) commands.
listen can u share smth about those paths
i am troubling with them
some docs os vids
or*
well now it has data somehow
what did u change besides test: 'abcde'?
./ means "same folder", ../ means "parent folder"
even the command works btw
yes ik, that's because data appeared there
nothing? that dot only
what if both are not same
but you're at exactly the same state you were when we started
I think u didn't save the file at all before
?
../../foo/bar/../baz/file.js reads "Go back 2 folders, inside foo, inside bar, back 1 folder, inside baz, read file.js"
whats up with above and below?
you need to navigate to the file you want
yea ik ,i mean what to do if below
there's no below
there's only "above" and "inside"
or parent and child whatever
if i want to go from command to handlers
you're viewing it as if it was vertical, it isn't
yes yes
right left?!
module.exports =(client)=>{
readdirSync("./commands/").forEach(dir => {
const commands = readdirSync(`./commands/${dir}/`).filter((file)=>
file.endsWith(".cjs")
);
for(let file of commands){
let pull = require(`../commands/${dir}/${file}`);
if(pull.data.name) {
client.commands.set(pull.data.name,pull);
table.addRow(pull.data.name,"✅");
}else{
table.addRow(
pull.data.name,
`❌`
); ```
vscode makes it harder by barely adding any indent to subfiles
anything wrong with this/?
also no right and left *sigh*
imagine as if it was a json, yes yes
this should make it easier to understand
json doesn't have above or below, left or right
only properties, which can also be json
try to figure out yourself
TypeError: Cannot read properties of undefined (reading 'name')
this is very weird
ok lemme try logging
and if i cant solve
i'll get back
go save your files first
saved bro
save again to be sure
wait, what if a shard server fails (or all of them are lost)? is there not a way to have failover when a shard goes bye bye?
"bye bye" 💀
I imagine it'll attempt to reconnect, but you can also probably listen to shard status updates
ok but what if a natural disaster completely kills the shard? that data goes missing?
data's probably redundant among shards
ctrl+s saves the file in vs cdoe right?
"probably"?
meaning if one falls, the others have it
yes probably, because I dont use mongo
but that's how it works on postgres
you don't shard for storage reasons, you shard because a single server wasn't able to coup with the demand
yes i know why sharding exists
wouldn't want to hedge my bets ngl
just shutdown one of your shards and see if you can access the data
i don't have any shards yet lol
dot reperesents what
same folder
make some
"up"huh?
triple dots exists?
or doube max
double*
In simple terms, one traverses out of the current folder the other accesses the current folder
You can chain them to keep going further out
It’s not rocket science
just tell me what to do if i have to go from commands to lets say node_modules
../../node_modules 💀
relative file paths are always where you are currently, the answer depends entirely where you are
You should not be programming if you don’t even understand the file system
a few hours on (headless) linux would help understanding it easily
./ current folder
../ previous folder
../../ previous previous folder
../abc/ previous folder then inside folder "abc"
../abc/../ previous folder, then inside folder "abc", then back to previous folder again
Tim that will likely confuse them more 😭
tho windows would solve this too, but people rarely use windows through cmdline
Told you
you're on windows right?
press Win + R and type cmd
ok go ahead
Win is the key with windows logo
ye
yes
now type dir again to see what's inside it
yes
type cd .. to go back
This video demonstrates how to use the "change directory" (cd) command to navigate around the Windows file system, as well as describing the difference between absolute and relative paths.

dir again to see you're back in the initial folder
i am starting to understand a bit
now do dir .\thatFolder\..
it'll do exactly what you just did
but in a single line
excuse me for 20 mins
gtg for food
It’s really not that hard to understand
./thatFolder/../../../../../../../../../../
:)
lul
that's part of why I think every dev should at least once in a lifetime have a linux vps
He’s not even a developer bro
you don't get gui so u must navigate through cli
very likely
laptop is not mine bro
?
chads do
cd ..
cd ..
cd ..
cd ..
cd ..

fr
I write scripts to do it for me cause I’m a script kiddy
🙀
eval 'cd ' $(yes ".." | head -8 | paste -s -d '/' -) 
Ayo
is there any way anyone knows of to make all fields in an embed the same height, being the height of the tallest item?
looks a bit skew-wiff otherwise...
https://www.ssod.org/wp-content/uploads/2024/03/inv-2-589x1024.png
e.g. so that each row's height for its code block is the same height
i cant know how many chars fit on a row, so i cant guess it
only way is by padding the smaller blocks
if you dont know how many lines there'll be...well, you're SOL
yeah, its just free flowing text
and the width of the box varies depending on device
because responsive
and based on how many other items are in that row
i think theyre using flex boxes under the hood or something
yeah
i cant even use images in the fields
if each field could be an image, theres a solution, albeit a resource heavy one
wait how would that work?
because surely there would still be no failover?
because the config servers still refer to the same shards???
wdym?
simply manually create some shards and kill one or two to check if the data is still available
because each of the confjg servers still point to all of the shards, right?
if you only run the command on one of the config servers
not sure I get what you mean
you want to know whether shard downtime affects data availability, so simply make some shards, kill half and try to fetch the data
imagine if there's a new property
what would come after z?
z
C# moment???
hell yeah
we LOVE C# casting
i made this tiny parser and i love it https://github.com/velddev/mipa
veldev
yes
my dissapointment is immesurable
lowkey cool tho
true
become astrology
we love our astro brokie
also can i do a webserver in vs console app template
just wondering, since my backend class uses c# and i wonder if i can reuse my playground for it
ah
package manager?
or
yea
on console app template?
where
if you have enough time to spare
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>cs_playgorund</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RestSharp" Version="110.2.0" />
</ItemGroup>
</Project>
usually it says "<Project Sdk="Microsoft.NET.Sdk">"
but u want "<Project Sdk="Microsoft.NET.Sdk.Web">"
yeah
how do i start off making a discord bot?
at /home/container/index.js:40:82
at /home/container/index.js:110:11
at /home/container/node_modules/@top-gg/sdk/dist/structs/Webhook.js:106:23
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:26) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
what could the reason of the issue
whatever you are accessing id on id null
start by learning how to program at all, try making a calculator or smth as a first project
huh? anything wrong over here?
const Discord = require("discord.js");
const { MessageEmbed, MessageCollector, Collection } = require("discord.js");
//const Discord = require('discord.js');
//const client = new Discord.Client();//const Discord = require('discord.js');
const client = new Discord.Client();
exports.client = client
const express = require("express");
const app = express();
const User = require('./models/user.js');
const Guild = require('./models/guild.js');
const config = require("./config");
const Topgg = require("@top-gg/sdk");
const axios = require('axios')
const webhook = new Topgg.Webhook(config.topgg.auth);
const jsonParser = require("body-parser").json();
//const color = "70fffb"
app.get("/", (request, response) => {
response.status(200).send("I AM ALIVE MAN :D");
})
.post("/dblwebhook", jsonParser, webhook.listener(vote => {
(async () => {
let votes = await axios.get("https://top.gg/api/bots/" + client.user.id + "/votes", { headers: { 'Authorization': config.topgg.token } });
that way you'll have a much easier time learning how to make a bot
formatting is a suggestion 
nvm i sorted that
now it gives 403
(node:26) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
at createError (/home/container/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/container/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/container/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1333:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
ig
yes, as I said, nothing was solved, the site is simply saying "Please stop trying, fix the code first"
you can't client.user.id before you connect the client
i just changed client.user.id to client.id
yes, you cant use anything from client before connecting
because those data dont exist yet
uh
aka your bot isn't online
not online = no data about the bot
no data = no id either
no first the server file runs and the bot goes online after it ive another file indexjs which runs this topgg api
so ig that shouldnt cause it
what?
you're initializing the client in that file ```js
const client = new Discord.Client();
exports.client = client
considering the amount of attempts at getting the client, I suppose they're following a tutorial ```js
const Discord = require("discord.js");
const { MessageEmbed, MessageCollector, Collection } = require("discord.js");
//const Discord = require('discord.js');
//const client = new Discord.Client();//const Discord = require('discord.js');
const client = new Discord.Client();
exports.client = client
yikes
or well, I hope they are following something
following intellisense 
anyway, tl;dr you cant get the bot id before you connect the bot to discord
so connect FIRST and then send that request
also you dont need to send a request for getting bot vote count, you already have it inside /dblwebhook
you have to wait
print the body of the response, it should have the timeout
ok
got there in the end
trial and error is the name of the game
even the 10x developers do it
DAMN
does that usually work
to be fair they never said it works
If it doesn't work, you're not yelling loud enough
I have stopped programming so I am a little rusty.
<h1>My Quotes</h1>
<br />
<div class="row gy-5">
<% constants.quotes.forEach((quote) => { %>
<div class="col-6">
<div class="p-3 border"><%- quote %></div>
</div>
<% }); %>
</div>
</div>``` `constants.quotes` WAS just an array of quotes and it worked as expected no problems. However, I want to key each quote so I can do `website.com/quotes#whatever` to link a specific quote. so `constants.quotes` now looks something like this: `[{ 'key': 'value' }]`
and I am getting this:
I understand what object object is, but to work around this in the frontend (i have never been good at) is difficult for me. can anyone assist me please & thanks
you're right, that semicolon DOESN'T need to be there
What about quote.value?
🤔
Let me try
removes it completely:
Okay, can you send a screenshot of an example quote object?
why's it an array?
It was an array so I can just add [ '...', '...'] as I please. however this doesn't seem to be working as intended anymore now I am trying to key - how do you suggest I frame it instead?
right now u have an object that contains all the quotes inside an array
u can remove the [] surrounding the object to turn it to an object
sure
either that or this
u can use Object.keys(quotes) to access the keys and Object.values(quotes) to access the values
or even simpler, just have an array that contains the quotes, like ["quote 1", "quote 2", ...]
hm, so that is working inversely which is a good sign I guess.
I had it like this, but I want to be able to website.com/quotes#whatever instead of just the /quotes
Also for this ^ how would I make it add a new text box like previously ?
fragment urls like #whatever are designed for client side navigation, so to use that you'd need to load all quotes then use browser js to show the desired quote
if you want the quote to be loaded server side, use a parameterized url or a query parameter
im not sure about parameterized but for query parameters, it seems inefficient I believe the word is? would there be no way to automate?
how would parameterized url work?
parameterized url is what a lot of libraries do
for example .get("/quotes/:id")
the :id is the parameter url
https://timwisdom.js.org/api/v1/quotes?query=your+skill+issue+solution&limit=1000&sort=asc
ah, I believe I got query parameters and this mixed up then I believe
i assume you're using a nodejs server, since youre using EJS
yes
query parameters would be /quotes?id=something
huehuehuehue br br gibe me money please or i report you
mordekaiser es #1
The latency on this API is appalling
lmao
it only handles 1 concurrent request
Rip
and sometimes each response takes several seconds
which would be easier to just add in the future? lets say I want to add a new quote in 3 days doing this seems long and surely there has to be an easier way even if it will require me to write a larger peice of code now
?
Needs to move to uwusockets.js
why would it be long?
should be pretty straight forward
facts
pretty straightforward and not necessarily long, however I would most definitely prefer just adding to the constants.quotes
im sure there is a way to do this as well. the idea im trying to materialise isn't something out of this world i dont believe and is very doable
const quotes = {
abc: "my quote",
xyz: "my other quote"
}
server.get("/quotes/:id", (req, res) => {
const quote = quotes[req.params.id];
// build EJS with quote
});
are you referring to the programming language, Rust by any chance which is powered by the LLVM compiler toolchain which vouches for memory safe programming while having minimal to no impact to performance?
I appreciate the abstract thinking, however was a metaphor to explain my programming skills.
How would I access this on the browser btw. because of the /:id I am getting a cannot get /quote. simple question its been a while
fek off rust fanboy
lmao
in the browser you would do /quotes/abc
i dont actually mind rust but i hate that rust people keep rewriting perfectly good libraries written in c/c++ in rust "just because its rust"
that works - now constants.quotes[req.params.id] is undefined. Apologies if these are very simple questions
which is strange i believe, it should return hi ? i done /quotes/hi
that assumes that constants.quotes is formatted like this { hi: "my hi quote here" }
Got my app working for users now. Big Discord W
What even is going on
Regarding?
a code exchange session (aka cex)
sex?
Yes - and I am struggling to display it in this way in the frontend. When I make it [ { hi: 'hi' } ] I get object object
I am totally stuck
I don't know how you do this
why do you want to make it [ { hi: 'hi' } ]?
An array of objects?
Probably wrong but how I view: to display correct number of text boxes, I need to use an array so I can just do forEach
If you’re handling multiple quotes sure
you can do that using Object.values()
But you’re only handling one no?
Then all quotes compile into one text box, instead of induvidual
first of all you need to think of how to structure your data based on what makes the most sense for the data itself.
arrays are good if you have data that dont have direct access, like lists
objects are good if you have data that has direct access, like accessible with a key
Well from the looks of your example you were only handling one
so if you want your quotes to have direct access, for example using an url
its better to use an object
or a Map
from there on, doing what you want to do is just a matter of adapting
I have always been terrible with frontend and to display multiple textboxes using objects is incomprehensible to me
for example you have an object like this:
{
a: "abc",
hi: "oeufhouwf",
brazil: "huehuehuehue"
}
you can access it directly like you're already doing, with the :id parameter
and if you need to list all of them, for example in another /quotes route, that doesnt have a :id parameter
you can convert it to an array
using Object.values()
or Object.keys()
<% constants.quotes.forEach((q) => { %>
<div class="col-6">
<div class="p-3 border"><%- Object.values(q) %></div>
</div>
<% }); %>``` this works for arrays, not objects however. Let me try the map
Same with map
<% Object.values(constants.quotes).forEach((q) => { %>
<div class="col-6">
<div class="p-3 border"><%- q %></div>
</div>
<% }); %>
Thank you, let me try
heres how it works
const quotes = {
a: "abc",
hi: "oeufhouwf",
brazil: "huehuehuehue"
}
Object.values(quotes) // ["abc", "oeufhouwf", "huehuehuehue"]
Object.keys(quotes) // ["a", "hi", "brazil"]
Object.entries(quotes) // [["a", "abc"], ["hi", "oeufhouwf"], ["brazil", "huehuehuehue"]]
im gonna take you to brazil
You have a deep understanding of basic things. I respect it
Let me try comprehend, one moment
It’s propaganda
in programming, the basics are the most important
once you understand the basics, there is nothing you cannot do
preach
lmao
Just code one
I enter this and still I get the object object
i never said anything about storing and sending 1000s of messages? Nor messages that were deleted. If your read my requeust, i actually also said that i only tops cache 5 messages per guild... But the overall design principle you discussed in your message was pretty neat, thank you. Decided to use that in the end.
that happens if you're still using your old format [ { hi: 'hi' } ]
you are smart
it works, thank you.
now I switched from arrays to objects, half the job done. I'll probably be back - thank you.
personal apps are kinda weird but cool
idc about the app itself, moreso use it as a status thing irl
losers call it shallow; I call it playing the game to my advantage
Im talking about this
I'm talking about me
@quartz kindle Running into an issue. Haven't really progressed been stuck most of this time,
I have got the key,
if (keys.includes(req.params.id)) {
console.log('yes' + req.params.id)
key = req.params.id;
} else {
console.log('no')
}``` and and I send `key` to the frontend. How do I change`key`s css ?
Struggling slightly to articulate my problem but I think it makes sense
ty
lmao
exactly
went from shit discord bots to kernels
the shit discord bots somehow provided that foundation
its actually fun you don't understand until you try it
yes it's hell at the beginning but it becomes easier as you implement things
I don't even touch assembly or io ports anymore in the system there's a function or structure for whatever I wanna do
it becomes like developing a Windows/Linux app but on your own custom system
i stop having fun programming whenever things get too complex
i like to overoptimize small functions instead
shoot tim, you for hire and if so whats your rates?
in js microoptimizing does have a big impact in performance actually
but try that in c or any compiled language it becomes extremely hard because the compiler does such a good job at optimising shit code
your 3+ weeks refactor might only speed your program up by 2 milliseconds
so it becomes more important in identifying if there's an actual problem before optimising
Depending on the app, 2ms might actually be huge
in VR rendering, you only have like 11 or 12ms to hit 90fps (which is accepted as a great framerate to have close to your eyes)
hey guys I'm so confused, what is better ig?
ampere cpus are weaker but cheaper
isnt that ARM?
ye
aight let's stay with intel
ampere is better if you get more cores
4 cores should be more or less same price than intel 2 cores
interesting, so that is better?
+4 GB ram also
pretty much yeah
technically it depends on what you're gonna use it for
but overall, that will give you a much bigger bang for the buck
the only thing intel cpus are better at is cryptography and code that is optimized with complex instructions like AVX
but still 4 cpus will beat 2 cpus by far if multithreading is used
I need that AVX too lol for mongodb
that's a nice idea
(node:26) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
at createError (/home/container/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/container/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/container/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:412:35)
why an i getting 403?
mongo again... Invalid shard identity document found when initializing sharding state :: caused by :: Invalid shard identity document: the shard name for a shard server cannot be \"config\"" what on earth is this error???
const { MessageEmbed} = require("discord.js")
const Discord = require("discord.js")
//import fetch from 'node-fetch'
const fetch = require("node-fetch")
module.exports = {
name: "meme",
aliases: [],
description: "This command sends you random memes",
run: async (client, message, args ) => {
try {
const url = await fetch("https://www.reddit.com/r/memes/random/.json");
const meme = await url.json();
const permalink = meme[0].data.children[0].data.permalink;
const memeURL = `https://reddit.com${permalink}`;
const upvotes = meme[0].data.children[0].data.ups;
const downvotes = meme[0].data.children[0].data.downs
const comments = meme[0].data.children[0].data.num_comments;
const embed = new MessageEmbed()
.setTitle(meme[0].data.children[0].data.title)
.setURL( `${memeURL}`)
.setColor("RANDOM")
.setFooter(`👍 ${upvotes} 👎 ${downvotes} 💬 ${comments}`)
.setImage(meme[0].data.children[0].data.url)
.setTimestamp()
await message.channel.send({ embeds: [embed] });
} catch (error) {
console.log(error);
}
}
}```
this is the current code
const fetch = require("node-fetch")
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\DELL\.vscode\Programs\Test_JS\node_modules\node-fetch\src\index.js from C:\Users\DELL\.vscode\Programs\Test_JS\commands\Fun\meme.cjs not supported.
Instead change the require of index.js in C:\Users\DELL\.vscode\Programs\Test_JS\commands\Fun\meme.cjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\DELL\.vscode\Programs\Test_JS\commands\Fun\meme.cjs:4:15)
at C:\Users\DELL\.vscode\Programs\Test_JS\handlers\command.cjs:12:12
at Array.forEach (<anonymous>)
at module.exports (C:\Users\DELL\.vscode\Programs\Test_JS\handlers\command.cjs:7:29)
at C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:49:42
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\DELL\.vscode\Programs\Test_JS\mini-cricket\src\index.cjs:48:40) {
code: 'ERR_REQUIRE_ESM'
}```
getting this error
and even if i use import
it then says cannot use import outside a module
what version of node are you using?
16.15.
1
using old versiona s it matches the version i was using on previous platofrm(replit)
in that case you'll need to install an older version of node-fetch
iirc their docs say which version
but why do you need the version to match replit?
i did download the version that matched the previous one
in replit the node-fetch version was 3.3.0
and i same i downloaded
coz if i use older or newer versions it might cause me issues
so currently i want to stick to what i was using before
shouldn't do
ok so
- try to switch to esm it'll really help you
- failing that, use node-fetch@2
- are you sure you weren't using esm on replit?
it will be a huge work load for me
not really
i dont want change so many files man
i mean that i would have change require into import
in many files
which i want to avoid
any alternative options?
yeah vsc would do that for you
huh
say how do i do
in all files automatically?
no but if i can do it you can
....
it literally tells you what replit did
it installed @replit/node-fetch instead of node-fetch
so just install replits version, or install version 2
btw on node 18+ fetch is built in, there is no need to install node-fetch anymore
node-fetch is a defunct library
node is not like discord.js, upgrading to newer versions will not break your code
Ctrl + Shift + H
enable RegExp
thank me later
why do they have their own fetch
thank god
discordjs devs need to seriously read up on why standardisations exist and what happens if your updates break syntax constantly
not syntax but api 😔
i guess their system prefers/requires cjs
so they made the default node-fetch install compatible
how
i cant use node version 18 coz then i'll have to change many things in the code
so trynna stick to 16.15.1 only rn
i think its working fine
yep it does after i installed replits version
thanks guys
what would you have to change on yoru code?
the only change is that you can use fetch without installing anything
everything else should be the same
wait you sure?
i would then install the most latest version simple
i hope there should not be any issue with other packages coz they are of older versions
take an advice from someone who went through dependency hell - DO NOT STAY OUTDATED
👀
struggle as much as needed, stay awake as long as required but
UPDATE. THE. STUFF.
but i have no knowledge of djs v14
then re-learn djs v14 if needed, but do it
there'll be a point where everything breaks and you wont find a single reliable source of info
or versions will simply cease to exist
Djs changing dramatically for every update speedrun
hi sayu
hey btw can i have some dc bot ideas
i can't type today
Hello
but truly, I kid you not, never let your versions stay below latest
my former coworker did
and now I'm rewriting the entire corpo app from scratch
ok i will learn 😩
because turns out the entirety of packages.json is broken
um u mentally ok bro?
pls?
doing it in flutter because to the hell with react, so it's a breath of fresh air
but still, the app is big
if it can do anims, it is my area
guys dont ingnore
bot ideas pls
i mean
bot idea: a bot that draws anime girls
sayu visual novel in discord activities when?
by hand
if you dont wanna use djs v14, you can keep using v13
you can still use v13 in node 20+
more say
i'm not good yet to draw multiple drawings over and over
cmon guys spit out creativity
also hi tim
this, is not my area of creativity
hi css jail
😔
:^)
how is tim
how is your husbando
like, you draw a handful of poses for characters and the environment, u dont need to draw a new pose for every single frame
the rest is dealing with renpy
unfortunately, we parted ways
ayo ppl here are married
sayuri's programming club 😔
am good, how is you?
recovering, but is well
i'm exhausted today
rain
and c#
but atlas, i'm getting used to it
welcome to exhausted club
ive been carrying bricks all morning
working on my house's construction
should have used css
oh wait the html is not done yet 
bro trynna bully tim
actually you know what would be cool
if you could build irl like minecraft
with 1m x 1m x 1m blocks
gravity of minecraft hell naw
i can see that
in this day and age, bullying people is pretty much flirting
99 missed calls from structural strength

i doubt that
people bully you because they love you
what country are u from
from the amount of bullying you get here, i'd say you are very loved
Can confirm
India is different then
i was talking more towards irl phsyical bullying and cyber bullying
saying things on internet is easy
and yea then i agree to this
😔
guys since many of you are software developers here,can you guys say where to actually start from
like learn beginner language and then get into web dev?!
thats a book?
yea so after javscript what should i do
yes
make bots or like what
do javascript first then we talk
if you want to explore more though
ik javscript tbh
but i cant really write my own code sometimes
do you really know js after saying that sentence
uhm idk
cmon man say it
see the link above
i dont understand anything there
you can confidently say you know js when you feel like you can do anything with it
for example can you look at some RFC standard and reimplement it in js?
idk what that means
💀
for example
The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host that has opted-in to communications from that code. The security model used for this is the origin-based security model commonly used by web browsers. The protocol consists of an opening handshake followed by ...
you can say you are a good programmer when you can look at something like that, understand it, and code it in your language of choice
without any lib
i'll be honest
i still dont understand that
i am very beginner (i have seen codes of js so i say that ik some js)
for eg ik about classes a bit and general knowledge of objects,variables etc
thats good
start with the basics, if there is anything that you know how to use, but dont know how it works inside, study that
you know objects, arrays, variables, etc
yes
but do you know how they work inside the engine? under the hood?
variables are like storing smth in a specific container?!
somewhat
this sort of knowledge takes you a bit out of the language itself, and into computer science
sometimes its not enough to know the language, sometimes you must know the computer as well
for example, using js is one thing, using js to manipulate bytes and memory blocks directly is another thing, it requires computer science knowledge
yea so master a language first right
btw the thing u said RFc,that has smth to do with building protocols?!!
it goes hand in hand, you can only truly master a language if you know how the language works
and to know how the language works, you need to know the computer science behind it
that link i sent is the specific RFC standard for websockets
it defines how websockets work
hmm basically so i need to practice what i learn and master a language yeah
there are thousands of RFCs for different things
an RFC is created by a group of people to define how something should work, so that when programmers go and code it, it works the same way everywhere, and is compatible with each other
for example there's an RFC for the PNG image format
This document describes PNG (Portable Network Graphics), an extensible file format for the lossless, portable, well-compressed storage of raster images. This memo provides information for the Internet community. This memo does not specify an Internet standard of any kind.
interesting
so technically they make something that would be used to make apps,websites or any code
ike building blocks
yes, these kinds of standards are used to create the foundations and building blocks of many things people do
and they are used to create the libraries that do it for you
very interesting but needs too much experience and knoweldge
exactly
so you start with a language, then when you're confident with the language, you need to look past the language and into the science behind the language
they code that right? or give ideas on some x thing to be made
woahh
alright so i'll dive in javascript
any preferred docs or vids?!
once a standard is created, people code it, if they find issues with it, the standard can be revised and improved
ok so first they think about some building block(like some lib )
then they code it
then they improve it
yes basically
?
thats what it takes to be a top level programmer
there are hundreds of videos on youtube
for example videos about data structures
check some videos about data structures and try to create them in js
one very simple data structure that is not built in in JS is a linked list and a rope, its very easy to make one
dsa is not smth for beginners imo?!
no its not for beginners
its looking beyond the language
once you're comfortable with it
if you're not comfortable with it yet, get some more experience with basic js
yea so i dont think i should jump in data structures right
where is that huge list of codign challenges from easy to very hard
would be helpful
calculator in js?!!
Yes



