#development

1 messages Β· Page 209 of 1

pseudo grotto
#

no its in New York

#

Dubai is 6,850 miles from it

#

speedtest cli decided to do it in dubai idk why

pine willow
#

Ah

quartz kindle
#

you forgot the parameter in the ()

pseudo grotto
#

ah so

  console.log(raw);
});
quartz kindle
#

ye

#

rawrawraw

pseudo grotto
#

alright

solemn latch
quartz kindle
#

rawr

#

basically, when you login, the first event you receive is a hello event, with an array of guild ids

solemn latch
quartz kindle
#

afterwards you will receive a number of GUILD_CREATE events equal to the number of guilds in the array

#

if there is a bugged guild, the GUILD_CREATE event for that guild will not arrive

#

after a while, djs will give up waiting and emit ready anyway

#

you can check which guild you are not receiving, that is your bugged guild

pseudo grotto
#

hmmm but if im sharding, the shard doesnt go ready

#

it times out

#

and then respawns the shard

quartz kindle
#

then thats a different issue

#

check if you receive anything at all in the raw events first

pseudo grotto
#

alright

#

i should prob store all this in a JSON so i dont lose it

lament rock
#

@quartz kindle op HELLO is just the heartbeat timeout and some other data while the client is unauthenticated. The client authenticates then receives a READY event which has the guild ID Array and the current user info. Then GUILD_CREATEs

quartz kindle
lament rock
#

Idk

quartz kindle
#

i dont remember either, but yeah, hello then guild array then guild creates

pseudo grotto
#

welp we'll find out rn once i restart

#

console going crazy

lament rock
#

why…

pseudo grotto
#

saving data in the json

#

ww

pale vessel
pseudo grotto
#

wow

#

its 19 MB

#

thats crazy for a json

#

yeah my computer is not liking this json

quartz kindle
#

lmao

pseudo grotto
#

alr im switching to txt this json is very hard to read

pine willow
#

LMFAO

frosty gale
#

what did bro put in that json file πŸ’€

quartz kindle
#

i have a geocoding database stored in 2 text files

#

one is 25mb, the other is 95mb

#

xd

pseudo grotto
#

txt is disappointing

#

i dont want to read the json 😒

quartz kindle
#

gotta stringify it bro

pseudo grotto
#

theres a heartbeat

#

then a ready

#

then it shows all the guild ids

quartz kindle
#

then the GUILD_CREATEs?

#

or it stops in the guild ids?

pseudo grotto
#

yeah i see exactly

#

513 GUILD_CREATE

#

well its working now

#

Shard went ready

pine willow
quartz kindle
#

all gucci then

pine willow
#

Ye

pseudo grotto
#

🀷 hopefully it stays this way

pine willow
#

It will stay that way

quartz kindle
#

for a whole 5 minutes

pine willow
quartz kindle
#

:^)

surreal sage
#

this seems so fake

#

(catbox.moe)

#

how is a file storage service

#

requiring 1.4k a month

#

a tb of google data storage is 23 dollars

#

server bills? you mean your rent? 😭

lament rock
#

You don't know who their provider is. For important data, you also wanna do 3-2-1. 3 different service providers with the data mirrored. 2 physical backups with 1 of them being offsite

#

Also stuff like CPU time isnt free

solemn latch
#

its a free upload service with 200mb files πŸ‘€

#

I'm spending over $100 a month for my webhook service right now... and it JUST forwards webhooks from top.gg to discord. not file storage, just redundancy and high availability makes it expensive

radiant kraken
#

good job sis

deft wolf
spark flint
#

Bandwidth is expensive

#

It’s a popular service too

#

For context, my api which literally just returns JSON uses over 1tb of bandwidth a month from a few million requests

spark flint
#

lol

pseudo grotto
spark flint
#

CF, and no attacks

pseudo grotto
#

How many unique users every month?

spark flint
#

last 24h

spark flint
pseudo grotto
#

πŸ’€

spark flint
#

last 30d

pseudo grotto
#

Must be a lot of users requesting data consistently

spark flint
pseudo grotto
#

What does the backend do

spark flint
#

just queries a datbase KEK

pseudo grotto
#

Query a database for information?

#

Ah ok

#

Are you using mongodb 😟

#

Redis πŸ˜‹

#

Mysql / mariadb is meh

spark flint
#

mongodb and redis

pseudo grotto
#

Why do you need 2 databases?

#

I see a lot of people do it I'm confused why you would need it.

spark flint
#

its not 2 databases

#

redis is for caching frequently accessed items

#

to save on expensive database queries

pseudo grotto
#

So I can use redis to cache my mysql queries?

spark flint
#

redis should never be used as a database

#

yes

pseudo grotto
#

But how does that work in the backend you query redis and it checks cache and if it's not there it asks mongodb or mysql?

spark flint
#

yes

pseudo grotto
#

Hmmm I did not know this

pearl trail
#

what is redis' min ram+core requirement?

spark flint
#
const cached = await redis.get(`cache-key`)
if (cached) return cached
else {
  const result = await db.query(`whatever`)
  await redis.set(`cache-key`, JSON.stringify(result), "EX", 60 * 10)
  return result
}```
#

etc

#

that caches it for 10 minutes

radiant kraken
#

why use redis when you can just use a {} and a setTimeout

spark flint
#

you can remove the "EX" part and make it cache forever, but that relies on you resetting the value if the intended value changes

spark flint
radiant kraken
#

wdym

spark flint
#

i can't store 1.2b records in {}

#

but i can with redis

#

!

radiant kraken
#

so

#

you use mongodb and redis for caching

spark flint
#

yes

radiant kraken
#

icic

#

why not use Postgres over MongoDB

spark flint
#

wait it depends on what API

#

the 1.2b one is postgres

#

the rest are mongo

radiant kraken
spark flint
#

because i've always used mongo

#

but people told me to use postgres for the other one

pearl trail
#

cassamdra

radiant kraken
#

so pro

pearl trail
#

nnah ez

radiant kraken
#

for u

#

cuz u pro

spark flint
#

cassandra is bloated

pearl trail
spark flint
#

yes

radiant kraken
#

you just own a $2k pc takiyo

civic scroll
#

devlopment

pearl trail
#

development

civic scroll
#

i got to channel manager

pearl trail
civic scroll
#

idk how i should store user / channel data in server side

#

as well as socket WAH

pearl trail
#

socketio if you don't want to use native websocket or whatever it called in nodejs

radiant kraken
#

u use socketio?

pearl trail
#

my bad

spark flint
pearl trail
radiant kraken
#

what

#

im not saying its bad

spark flint
#

im using socket.io for my computer science NEA project

#

just because its so easy to setup and use

radiant kraken
pearl trail
#

ooo

civic scroll
#

mfw insomnia doesn't support socket io

pearl trail
#

it's good for lazy people like me

spark flint
#

same

civic scroll
#

my last project was using that as well

pearl trail
#

ooo

spark flint
#

the auto reconnect is just... chefskiss

civic scroll
#

idk if i should switch to use postman

civic scroll
#

since postman supports socketio

#

the client frontend is not available yet and i wanna test it

frosty gale
#

socket.io users realising it's just a websocket that sends and receives json

sharp geyser
radiant kraken
sharp geyser
radiant kraken
#

Rustacean mindset

sharp geyser
#

it does all the heavy lifting for you

#

thats not fun

radiant kraken
#

might as well make your own Websocket implementation in C with OpenSSL fr fr /s

sharp geyser
#

yknow what

#

not a bad idea

#

tim knows the ws specification

#

i will just get him to do it /s

pine willow
sharp geyser
#

wait a minute

#

something aint adding up here

pine willow
#

Hm?

radiant kraken
#

@sharp geyser c++ macro abuse

sharp geyser
#

yknow I have no idea what any of that means

#

but I support it

spark flint
#

because im too lazy to properly intergrate all of that

#

since i dont get examined on the code, i get examined on the final product

sharp geyser
#

oh wait

#

what are you making

#

I didnt read any of the prior messages

spark flint
#

kahoot clone

sharp geyser
#

bro what for

#

😭

spark flint
#

computer science project

#

has to be a working project that meets their specification requirements, and i have to write a 5k word thing to go with it

surreal sage
#

and 1tb extra bandwidth is like €2

frosty gale
#

make a relatively simple but complex project that demonstrates all the cs buzzwords like oop, databases, etc

#

your report is what gets you the marks not really the project itself but you need a decent project so you can talk about it

sharp geyser
#

Unless a kahoot clone is the project

civic scroll
#

i love ai

frosty gale
sharp geyser
spark flint
#

they do mark you on the presentation of your website for this NEA

#

not the coding but just how it looks and how easy it is to use

#

and yes i am replacing the school bus with a tour bus

sharp geyser
pine willow
night oxide
#

Damn my bot literally turned off 3 minutes before someone reviewed it

neon leaf
#

why is implementing sftp so annoying tf

deft wolf
#

This is called "bad luck" kappalul

green kestrel
sharp geyser
#

Glad to see you for your weekly visit to top.gg

green kestrel
#

lol

radiant kraken
#

i decided to give up and make the top.gg C++ SDK purely use D++

surreal sage
#

electron ughhhhh

lament rock
#

It could always be worse tbh

spark flint
#

lemme record a vid

#

thats a bug

lament rock
#

Not bad

spark flint
#

thats like a few hours work

restive trail
#

can I have role bot developer ?

spark flint
#

it might seem crazy what im about to say

restive trail
#

haha I am jokking

deft wolf
#

Good one

sharp geyser
#

also they renamed the booster chat, why dont they rename the role as well

radiant kraken
lyric mountain
#

john hamburger

tired prawn
#

Hy, One question: How to Create Multi Language commands? Example: Select Eng Language slash command /help or select hun language /segitseg ?

deft wolf
#

What programming language do you use?

tired prawn
#

Node Js

deft wolf
pine willow
sharp geyser
#

as far as making sure your command names/descriptions are localized you can do so easily as discord provides this ability for you and it will use the user's settings to determine that

pine willow
#

I don't have a Booster chat

sharp geyser
#

in regards to anything you set, you will need to use i18n

sharp geyser
pine willow
#

Ty

deft wolf
civic scroll
#

script type

neon leaf
#

ai is gonna take over ‼️

frosty gale
pine willow
#

Boost

jade prairie
lyric mountain
quartz kindle
lyric mountain
#

lul

#

was referencing the long looooong man ad

civic scroll
quartz kindle
quartz kindle
#

discord rolling out some cool new features

sharp geyser
#

lame

#

what if they are trying to make friends

#

smh

quartz kindle
#

:^)

sharp geyser
#

Im just saying

#

what if they were

#

πŸ˜”

lyric mountain
lament rock
#

"I am a professional artist and my dog is dying and I have cancer I need to pay medical bills"

quartz kindle
lament rock
#

Shit if you say it's true I might

sharp geyser
eternal osprey
#

what yall think of the chatbot so far

#

me personally i think it's hella hot

sharp geyser
#

its speaking in tongues

sharp geyser
sharp geyser
#

I dislike that

#

it is unnatural

eternal osprey
#

what about this

#

i bet it's 100% real

sharp geyser
#

that one I like more

spark flint
sharp geyser
#

@oak cliff is it your birthday in 10 days?

oak cliff
#

yas

sharp geyser
#

happy early birthday

#

wait fuck wrong channel

#

I swear I clicked on general

oak cliff
spark flint
sharp geyser
#

I didnt ask for your age

oak cliff
sharp geyser
#

nah im kidding happy early bday to you as well bun

spark flint
oak cliff
#

omg bun old enough for br

sharp geyser
#

I've been old enough

#

for the past 2 years almost wahh

spark flint
#

i've been trying to apply for years

sharp geyser
#

I've applied 2 times

#

πŸ˜”

spark flint
#

mostly because i know the site so well and i want to help out KEKW

sharp geyser
#

I think I gotta apply again tbh cause all my other apps were on the old account

sharp geyser
#

i've had tht channel muted for the past 3 years

spark flint
#

i try to help in support but people always snap in before me KEKW

#

i could literally use the site with a blindfold on tbh

sharp geyser
#

I am just up at all hours of the night so I literally am available 16/7

oak cliff
#

well idk when we'll need new brs but id be happy to have yall imo

spark flint
#

just remove all mods and brs and put me and misty instead

sharp geyser
spark flint
#

got that grind

sharp geyser
#

Maybe 3rd time really is the charm

#

I'd like to see more American mods ngl

oak cliff
#

same

#

im so lonely

spark flint
#

more bri ish

sharp geyser
#

and thats when the crazies come out

spark flint
#

lol

sharp geyser
#

πŸ’€

oak cliff
#

oopsies

solemn latch
oak cliff
#

we're so lonely*

quartz kindle
#

communism detected

sharp geyser
#

πŸ’€

solemn latch
quartz kindle
quartz kindle
sharp geyser
sharp geyser
hidden gorge
#

Code always returns failure no matter what even when User and password is right

code:

const express = require("express");
const app = express();
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const session = require('express-session');
const cors = require('cors');
const bodyParser = require('body-parser');
const User = require("./schemas/PanelUser.js");
const bcrypt = require('bcrypt');
const config = require('./env.json');
const connectDB = require('./db');
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

require("./Deploy.js");



app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(session({
    secret: 'SCPWebPanel-1',
    resave: false,
    saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.set('view engine', 'ejs');
app.set('views', __dirname + '/views');

passport.use(new LocalStrategy(
    async (username, password, done) => {
        try {
            const user = await User.findOne({ username });
            if (!user) {
                return done(null, false, { message: 'Incorrect username.' });
            }
            const isMatch = await bcrypt.compare(password, user.password);
            if (!isMatch) {
                return done(null, false, { message: 'Incorrect password.' });
            }
            return done(null, user);
        } catch (err) {
            return done(err);
        }
    }
));

passport.serializeUser((user, done) => {
    done(null, user.id);
});

passport.deserializeUser((id, done) => {
    User.findById(id, (err, user) => {
        done(err, user);
    });
});

function isAuthenticated(req, res, next) {
    if (req.isAuthenticated()) {
        return next();
    }
    res.redirect('/');
}

app.post('/login', passport.authenticate('local', {
    successRedirect: '/success',
    failureRedirect: '/failure'
}));

app.get('/login', (req, res) => {
    res.render('login');
});

app.get('/success', isAuthenticated, (req, res) => {
    res.send('Login successful');
});

app.get('/failure', (req, res) => {
    res.send('Login failed');
});

const PORT = 8040;
app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
});
quartz kindle
# hidden gorge

are you doing a get or a post? because you have passport on post, but only ejs on get

hidden gorge
sharp geyser
#

imagine using passport

#

well obviously you are failing at authenticating

#

Is the user & pass correct

worn pecan
#

passport isn’t horrible

hidden gorge
sharp geyser
#

it is for oauth2

worn pecan
#

yeah

sharp geyser
#

if you are using local then its fine

worn pecan
#

Not for this though

sharp geyser
hidden gorge
#

this is to allow certain users to login into the developer pane;

sharp geyser
#

passport is failing because you are not entering the correct details

hidden gorge
#

ok this is the Local:

passport.use(new LocalStrategy(
    async (username, password, done) => {
        try {
            const user = await User.findOne({ username });
            if (!user) {
                return done(null, false, { message: 'Incorrect username.' });
            }
            const isMatch = await bcrypt.compare(password, user.password);
            if (!isMatch) {
                return done(null, false, { message: 'Incorrect password.' });
            }
            return done(null, user);
        } catch (err) {
            return done(err);
        }
    }
));
sharp geyser
#

either that or your logic is fucked

quartz kindle
hidden gorge
sharp geyser
#

Add logs after each if statement

#

That's where its most likely to fail

quartz kindle
#

add logs after each new line

hidden gorge
#

for some reason its not logging

quartz kindle
#

after each new character

sharp geyser
#

Its not being called then

hidden gorge
#

could it be bc of the 2 login urls?

sharp geyser
#

I haven't used passport in a while so this is where I step out before I mislead ya

quartz kindle
sharp geyser
#

so it will show whatever is appropriate

#

if you are visiting it will render the login page, if you are posting it will do the other one

hidden gorge
#

ok so the Post isnt being called

sharp geyser
#

check your html

quartz kindle
sharp geyser
#

^

quartz kindle
#

check network tab

hidden gorge
#

hmm its 302

quartz kindle
#

its correct

hidden gorge
#

thats normal?

sharp geyser
#

ye

quartz kindle
#

yes

hidden gorge
#

ok

quartz kindle
#

302 is temporary redirect

#

im checking the passport docs

#

in their examples they show how to define a "name" for your strategy

#

for example

hidden gorge
#

hm

#

hmm

#

i'll try it

quartz kindle
#

also

#

on the post route, try removing passport and adding a console.log for the raw body instead

#

just to check if the post route is receiving correct data

hidden gorge
#

thats something

quartz kindle
#

welp, user not found

sharp geyser
#

brody forgot to add himself

hidden gorge
#

i exist

sharp geyser
#

thats an awefully short password

hidden gorge
#

ik

#

its a testing one

sharp geyser
#

dont tell me you are storing it plaintext

quartz kindle
#

:^)

solemn latch
#

πŸ‘€

hidden gorge
solemn latch
#

Sounds like you're working out of order then

sharp geyser
#

seing capitalized db rows make me mad for some reason

hidden gorge
solemn latch
#

the password is?

hidden gorge
#

what

sharp geyser
#

make sure you aren't passing along any whitespace

#

idk if the client lib handles that or if the db can handle it

#

but better to .trim

hidden gorge
#

i read that as .trip

quartz kindle
quartz kindle
#

are the keys in the db case sensitive?

hidden gorge
quartz kindle
#

the key in the db is Username, but you search for { username }

#

try changing it to { Username: username }

hidden gorge
#

this work?

#

oh yeah!

quartz kindle
#

there you go

sharp geyser
quartz kindle
#

so user.Password

#

exdee

hidden gorge
#

this hash and data error is annoying

quartz kindle
#

why is it annoying?

#

just fix it

hidden gorge
#

I HAVE

quartz kindle
#

dafuq

#

thats not how you fix it

hidden gorge
#

oh wait

quartz kindle
#

how did you save the password in your db?

#

you're supposed to save the hash, not the password

hidden gorge
#

oh

sharp geyser
#

wait a second

#

no way bro actually stores plaintext passwords

#

😭

quartz kindle
#

not anymore im guessing

sharp geyser
#

hopefully

hidden gorge
#

bc it just creates the instance

sharp geyser
#

You should NEVER store plaintext passwords

hidden gorge
#

ok ill do it now

#

i hashed it

sharp geyser
#

thats like rule #1

#

everyone knows this

#

😭

sharp geyser
hidden gorge
#

apparently not me

quartz kindle
#

exdee

sharp geyser
#

the idea is, you hash the password, store the hash, then compare the plain text password they used to login, against the hash from the db

#

hashes are the same no matter where or how many times you hash it

#

for example you hash 123 it will always result in the same hash

#

providing you are using the same algo

#

and they aren't modifying it in someway

#

thats how bcrypt.compare works

hidden gorge
#

ok well now its broken

sharp geyser
#

it takes in a plaintext and a hashed password, it hashses the plain text and then compares the two hashes

quartz kindle
#

creating a password:
user -> "mypassword" -> hash() -> "giwuegf9w7gb99w7hg9wughowu" -> save in database

checking a password:
user -> "mypassword" -> hash() -> "giwuegf9w7gb99w7hg9wughowu" -> compare with hash in database

sharp geyser
#

thats how file checksums work as well

#

they generate a hash for the file and when you download it, you are meant to hash it as well to compare the two

#

and make sure what you downloaded is indeed the correct file

hidden gorge
#

WHY IS THIS COMMAND CRASHING

sharp geyser
#

show code

hidden gorge
# sharp geyser show code

Command code:

const { ButtonBuilder, ActionRowBuilder, ButtonStyle, SlashCommandBuilder, EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, PermissionFlagsBits } = require('discord.js');
const PanelUser = require("../../schemas/PanelUser")

module.exports = {
    data: new SlashCommandBuilder()
    .setName("adduser")
    .setDescription("Add's a User to the Web Panel (TW Only)"),
        async execute(interaction) {
            if (interaction.user.id === "919674489581731842") {
                const Modal = new ModalBuilder()
                      .setCustomId('AddUserModal')
                      .setTitle("Add a user to the panel")

                const Username = new TextInputBuilder()
                    .setCustomId("Username")
                    .setLabel("Username of the New User")
                    .setStyle(TextInputStyle.Short)

                const UserPass = new TextInputBuilder()
                .setCustomId("Password")
                .setLabel("Password of the New User")
                .setStyle(TextInputStyle.Short)

                const FRow = new ActionRowBuilder().addComponents(Username)
                const SRow = new ActionRowBuilder().addComponents(UserPass)

                Modal.addComponents(FRow, SRow)

                await interaction.showModal(Modal)

            } else {
                return interaction.reply("L you tried lmao -tw")
            }
        }    
}

interactionCreate:

const bcrypt = require('bcrypt');
const { Events } = require('discord.js');
const PanelUser = require("../schemas/PanelUser");

module.exports = {
    name: Events.InteractionCreate,
    async execute(interaction) {
        if (!interaction.isModalSubmit()) return;

        if (interaction.customId === "AddUserModal") {
            const NUsername = interaction.fields.getTextInputValue("Username");
            const NPassword = interaction.fields.getTextInputValue("Password");

            const hashedPassword = await bcrypt.hash(NPassword, 10);

            const UserData = new PanelUser({ Username: NUsername, Password: hashedPassword });
            await UserData.save();
        }

        if (!interaction.isChatInputCommand()) return;

        const command = interaction.client.commands.get(interaction.commandName);

        if (!command) {
            console.error(`No command matching ${interaction.commandName} was found.`);
            return;
        }

        try {
            await command.execute(interaction);
        } catch (error) {
            console.error(error);
            if (interaction.replied || interaction.deferred) {
                await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
            } else {
                await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
            }
        }
    },
};
sharp geyser
#

there is a lot of places it can fail

wheat mesa
hidden gorge
#

i finally started using event files

sharp geyser
#

well first off you are checking if isModalSubmit and returning if its not

quartz kindle
sharp geyser
#

so uh thats an issue

sharp geyser
#

yea

hidden gorge
#

already there

sharp geyser
#

I can read

#

thats the problem most likely

#

if they are using a slashcommand that will stop all execution

hidden gorge
#

no like it wont even prompt it

sharp geyser
#

buddy, if its not a modal submit then it returns stopping execution

wheat mesa
#

because modalSubmit is fired when the user fills out the modal

#

You can't submit the modal if you can't even trigger it

sharp geyser
#

AKA if I do /ping then that will be false and return

wheat mesa
#

A modal is a response to an interaction

hidden gorge
quartz kindle
#

lmao

sharp geyser
#

you should be checking if it is and doing something with it

quartz kindle
#

you are checking if ALL interactions are modal submit

sharp geyser
#

especially if you are wanting to handle a lot of cases

quartz kindle
#

and refusing to run them if they are not

hidden gorge
#

ok so

#

ive narrowed it down

#

its the interactionCreate file

sharp geyser
#

well obviously

quartz kindle
#

thats what we've been saying?

hidden gorge
#

cant even run another command im gonna try removing the hashing and see if it works?

sharp geyser
hidden gorge
#

oh

quartz kindle
#

lmao

sharp geyser
hidden gorge
#

HD*

sharp geyser
#

yea

hidden gorge
#

nice

sharp geyser
#

I used to do roblox game development

#

πŸ’€

hidden gorge
#

ah

sharp geyser
#

I made a postgres database wrapper

hidden gorge
hidden gorge
sharp geyser
#

hm?

#

I mean it wasn't wrapped around postgres itself

#

there was an api as the middle man

#

but it communicated with pg rather well

hidden gorge
#

wow

quartz kindle
sharp geyser
#

I mean....

#

definitely don't just show em to anyone

quartz kindle
#

yeah nobody here cares

hidden gorge
quartz kindle
#

they are also extremely hard to break

sharp geyser
#

but we aren't going to brute force your password for a roblox bot panel

sharp geyser
quartz kindle
sharp geyser
#

make sure its not undefined

hidden gorge
sharp geyser
sharp geyser
hidden gorge
#

oh yea

quartz kindle
#

lmao

#

i literally said that half an hour ago

hidden gorge
#

AHHHHH

#

oh shit

quartz kindle
sharp geyser
#

tim if you haven't noticed, this guy missed an entire conversation

hidden gorge
sharp geyser
#

where we told him the problem with his interactionCreate

hidden gorge
sharp geyser
#

yea after we told you again

hidden gorge
hidden gorge
sharp geyser
#

0 and 4000 is crazy

hidden gorge
quartz kindle
#

4000 character long password

#

ultra mega secure

sharp geyser
#

you should

quartz kindle
#

unbreakable for 1000 years

hidden gorge
#

im the only one who can run the cmd

sharp geyser
hidden gorge
#

bruh like thats the example

#

oh im a dumbass

hidden gorge
sharp geyser
#

neat

hidden gorge
#

was very easy lmao

#
passport.use('password', new LocalStrategy(
    async (username, password, done) => {
        try {
            const saltRounds = 10

            const trimmedUsername = username.trim();
            const trimmedPassword = password.trim();

            console.log('Looking for user:', trimmedUsername)

            const user = await User.findOne({ Username: trimmedUsername });
            if (!user) {
                console.log('User not found');
                return done(null, false, { message: 'Incorrect username.' });
            }

            console.log('User found:', user)

            const Password = trimmedPassword

            bcrypt.genSalt(saltRounds, function(err, salt) {
                bcrypt.hash(Password, salt, function(err, hash) {
                    bcrypt.compare(Password, hash, function(err, result) {
                        return done(null, user);
                    })
                })
            })
        } catch (err) {
            console.log('Error during authentication:', err);
            return done(err);
        }
    }
sharp geyser
#

I am so confused

#

const trimmedPassword then const Password = trimmedPassword

#

Also what are you doing

hidden gorge
#

idk

#

it works

sharp geyser
#

no

#

thats not what you are supposed to do

#
            bcrypt.genSalt(saltRounds, function(err, salt) {
                bcrypt.hash(Password, salt, function(err, hash) {
                    bcrypt.compare(Password, hash, function(err, result) {
                        return done(null, user);
                    })
                })
            })

this is wrong

#

entirely

sharp geyser
#

πŸ˜”

lament rock
#

How it should be is that you're storing a hash of the password which it seems you are doing. You then hash what the browser sends and compare that hash with the existing hash

#

Alternatively, the browser can hash the password for transport safety

lament rock
#

What you're currently doing is hashing the password the browser just sent and then comparing the password the browser just sent to the hash you just generated of said password

#

@hidden gorge

#

You don't check the result or if there are any errors of the compare

#

the only reason it works is because you continue regardless of the result

lament rock
solemn latch
#

All the passwords should be sent via https anyway, which is encrypted

lament rock
#

Also looks like you need to store the salt in the DB since that's important?? Not too familiar with hashing

#

I'll just refrain from giving advice with generation specifically

#

What someone looks like they're describing is on hashed password creation, you store the hash itself and the salt and then when you check it, the browser sends the plaintext password and you use the previously generated salt and password to get the hash and compare against the existing hash

#

Someone more experienced in the subject please correct me if I'm wrong. I've only used token based systems

#

There seems to be a lot of contradicting info on the subject. Some going as far as saying even sending over plaintext in HTTPS isnt enough

sharp geyser
#

what hes doing is incorrect either way

#

hes hashing the plaintext password then comparing the hash against itself

#

he should be grabbing the hash from the db and comparing the hashed plaintext against that

civic scroll
#

there's no need to regenerate the hash

#
compare(passwordInput, hash)
#

did you read the docs πŸ˜”

sharp geyser
civic scroll
#

yeah, there's that

sharp geyser
#

Basically he did
User Inputs Password -> Hashes that password -> Compares the user input password against the hash he generated with said password

civic scroll
#

there's not a single reference from user

#

except return [null, user]

sharp geyser
#

I mean if thats how he wants t odo it by all means go ahead

#

but he definitely is not getting hired anywhere dealing with cyber sec

#

πŸ’€

civic scroll
#
if (!await bcrypt.compare(trimmedPassword, user.Password)) {
    console.log('Incorrect password');
    return done(null, false, { message: 'Incorrect password.' });
}
sharp geyser
#

sayu

#

you use tailwind right?

civic scroll
#

@hidden gorge

const trimmedUsername = username.trim();
const trimmedPassword = password.trim();
                        ^^^^^^^^^^^^^^^
                        are those coming straight from user-controlled source?
                        or from your controller
civic scroll
sharp geyser
#

I needs help

#

πŸ˜”

civic scroll
#

may not be enough to help you lmao

#

ask away

sharp geyser
#

I am trying to get Home to align to the end

#

I am using flex and I went through all the alignment options

civic scroll
#

margin left auto

#

or justify space between

#

lemme see

sharp geyser
#

well that kind of works

civic scroll
#

wait

#

what's the html structure

sharp geyser
#
<MantineProvider theme={theme}>
          <AppShell className="dark">
            <AppShellHeader className="flex flex-row removeBorder shadow-sm shadow-night">
              <h1 className="pl-3 text-3xl">CollegeCrafts</h1>
              <div className="flex m-auto">
                <p>Home</p>
              </div>
            </AppShellHeader>
            <AppShellMain>
              {children}
            </AppShellMain>
          </AppShell>
</MantineProvider>
#

I use a comp lib called mantine

civic scroll
#

make changes as follows

AppShellHeader class:+justify-between
    div class:-m-auto
sharp geyser
#

:o thanks

civic scroll
#

m-auto will evenly space on all 4 sides

sharp geyser
#

ah

civic scroll
sharp geyser
#

ew now the text isnt centered

civic scroll
#

align-center

#

that would vertically center

sharp geyser
#

actually it might be the overhead from the div

civic scroll
#

oh

#

nah

#

the div wraps around its children

sharp geyser
#

then why is it like that?

civic scroll
#

make changes as follows

AppShellHeader class:+items-center
sharp geyser
#

thank you sayu

civic scroll
sharp geyser
#

This is the first time i've touched web dev in like 4 years

#

😭

#

Im stressing out

civic scroll
#

dw, i'm doing ws

#

i'm immensely fucked

sharp geyser
#

wanna trade?

#

i'd rather do ws than this shit

civic scroll
#

you help me, i help you

radiant kraken
#

i'm doing cmake

sharp geyser
#

cmake is nothing compared to web

radiant kraken
#

bruh

#

lets trade then

sharp geyser
#

i'd rather due cmake configuration than web development

sharp geyser
radiant kraken
#

being able to use third party dependencies

civic scroll
sharp geyser
#

huh

#

its not that hard

civic scroll
#

also remove m-auto on that 2nd div

sharp geyser
#

+ class name
- class name

radiant kraken
#

Brain happened to be very helpful with providing documentation for linking with his library, but not sure for other libraries

radiant kraken
sharp geyser
#

add/remove?

civic scroll
#

if you use git, you will know

sharp geyser
#

i've never had to use + and - in git

radiant kraken
#

git diff

civic scroll
sharp geyser
#

export default function Home() {

  const items = [
    <li>A</li>,
    <li>B</li>,
    <li>C</li>
  ]

  return (
    <div className="flex min-h-screen flex-col items-center justify-between p-24">
      <h1>{...items}</h1>
    </div>
  );
}```
is this really how you gotta do it
#

😭

civic scroll
#

hmm?

radiant kraken
#

@civic scroll sis do u know cmake

sharp geyser
#

If you had an array of items, you'd have to map it into the element you want it to list as

#

then to display it you'd have to spread it

#

right?

civic scroll
sharp geyser
#

huh

civic scroll
# sharp geyser huh

const friends = ['misty', 'sayiyu', 'nully'];

return (
  <div className="flex min-h-screen flex-col items-center justify-between p-24">
    my friends are:
    {friends.map(friend => (
       <li>{friend}</li>
    ))}
  </div>
);
sharp geyser
#
<h1>{items.map(item => <li key={item}>{item}</li>)}</h1>
```?
civic scroll
#

yeah and key as well

#

i forgor

sharp geyser
#

Alrighty then

#

thanks

civic scroll
#

gaming

sharp geyser
#

I wonder how subdomains will work

#

with next

civic scroll
#

you have to assign manually omegalul

#

or use its dns

sharp geyser
#

honestly ima just scratch that idea then

#

cause fuck that

civic scroll
#

i don't rember much, check project settings

sharp geyser
#

my idea was to give each place its own subdomain

#

but nah

#

fuck that

sharp geyser
civic scroll
sharp geyser
civic scroll
sharp geyser
quartz kindle
sharp geyser
#

why test if it fails

#

so long as it works

#

😏

sharp geyser
#

There is no possible way

#

the literal only fail point in that code is if the username is wrong

#

or it somehow generates the wrong hash

hidden gorge
frosty gale
#

i reckon there is at least 5 authentication bypass vulnerabilities in that code right there

sharp geyser
#

yea but did you enter the correct username

#

does the username exist

hidden gorge
sharp geyser
#

there you go

#

now enter the correct username but an incorrect password

hidden gorge
sharp geyser
#

does user e exist?

hidden gorge
#

FUCK

sharp geyser
hidden gorge
#

i entered my username and the wrong password and it still let me in

sharp geyser
#

yes

#

want to know why?

hidden gorge
sharp geyser
#

Well here's the thing.

#

You are literally just hashing the password they entered, and then comparing that hash against the password they entered

sharp geyser
#

Thats not how you do that.

quartz kindle
#

LAMAO

pine willow
#

LOMA

hidden gorge
#

WHAT THE FUCK DO I DO

quartz kindle
#

kappa chungus deluxe

sharp geyser
#

I literally told you several times yesterday

pine willow
quartz kindle
sharp geyser
#

you hash the password when they sign up, store that.

When they login, grab the HASHED password from the database, compare that hash against the password they entered

frosty gale
#

when i saw that code i didnt even need to look at it indepth to know it was cooked

#

but misty beat me to it

sharp geyser
#

I have to take any chance I get

#

there's not many with battleless "gone"

civic scroll
#

turns out my asumptions disappointed me

sharp geyser
#

even before that we told him as well

#

πŸ’€

#

and yet he still came up with that monstrosity

civic scroll
#

blud kept fucking around after finding out πŸ˜”

sage bobcat
#

One message removed from a suspended account.

hidden gorge
sharp geyser
#

bro

#

I've told you 3 times now

hidden gorge
#

what

civic scroll
sharp geyser
#

Each time you completely ignored what i said

hidden gorge
#

like this?

passport.use('password', new LocalStrategy(
    async (username, password, done) => {
        try {
            const trimmedUsername = username.trim();
            const trimmedPassword = password.trim();

            console.log('Looking for user:', trimmedUsername);

            const user = await User.findOne({ Username: trimmedUsername });
            if (!user) {
                console.log('User not found');
                return done(null, false, { message: 'Incorrect username.' });
            }

            console.log('User found:', user);

            const isMatch = await bcrypt.compare(trimmedPassword, user.Password);
            
            if (isMatch) {
                return done(null, user);
            } else {
                return done(null, false, { message: 'Incorrect password.' });
            }
        } catch (err) {
            console.log('Error during authentication:', err);
            return done(err);
        }
    }
));
sharp geyser
#

yea

#

but user.Password has to be a hashed password

#

so when they are signing up hash the password they used

hidden gorge
#

omfg

sharp geyser
#

the idea is, you store the hash in the db

#

then you grab the hash when they login and compare that against hte plaintext password they provide

hidden gorge
sharp geyser
hidden gorge
#

YOUR MAKING NO SENSE

sharp geyser
#

I am making perfect sense

hidden gorge
#

not to me

sharp geyser
#

you just dont understand

hidden gorge
#

could u please simplify it for me?

sharp geyser
#

Remember when I said never store plain text passwords in your database?

hidden gorge
#

yes and i dont

sharp geyser
#

well...you were

hidden gorge
#

mines hashed tho

sharp geyser
#

oh good, now you hash them

hidden gorge
#

now im confused

sharp geyser
#

well since you already hash them then its fine

#

user.Password is the hash

#

trimmedPassword is the plaintext password

#

you compare the two and if it matches return the user, if not return an error

#

like yo uare currently doing

#

πŸ‘

hidden gorge
#

why does it return failure tho?

sharp geyser
sharp geyser
sage bobcat
#

One message removed from a suspended account.

sharp geyser
#

or username is

hidden gorge
#

oh wait

sharp geyser
#

well you have 3 points of failure.

Username wrong, Password Doesn't match, or that catch block

hidden gorge
#

it works!

sharp geyser
#

πŸ‘

hidden gorge
#

thank you

sharp geyser
#

I'd definitely watch a video on password hashing just to brush up on it

hidden gorge
#

yeah im gonna

civic scroll
quartz kindle
#

finally working?

#

amen jesus

#

krishna budha allah quetzacoatl

pearl trail
#

πŸ’€

frosty gale
#

there's probably a flaw where I can still log in without touching the login page

hidden gorge
pine willow
hidden gorge
pine willow
#

ye

hidden gorge
#

its only http rn since my host hasnt proxied the url

eternal osprey
#

cuz i don't really see a way to send confirmation mails etc if it's hashed

quartz kindle
#

although reversible encryptions are useless if their keys are stored in the same server

surreal sage
frosty gale
#

though if the encryption key is in the source code and the database is encrypted with it, if your database is compromised the data is safe until it can be decrypted

surreal sage
#

aws kms

#

that sounds so wrong

#

hcp vault

wicked pivot
#

models :

const mongoose = require('mongoose');

const playerStatsSchema  = new mongoose.Schema({
    uuid: String,
    data: [
        {
            date: String,
            data: {
                faction: String,
                jobs: {
                    alchemist: {
                        level: Number,
                        xp: Number
                    },
                    farmer: {
                        level: Number,
                        xp: Number
                    },
                    hunter: {
                        level: Number,
                        xp: Number
                    },
                    miner: {
                        level: Number,
                        xp: Number
                    }
                },
                money: Number,
                rank: String,
                timePlayed: Number
            }
        }
    ]
});

module.exports = mongoose.model('PlayerStats', playerStatsSchema);```

My try

```js
const date = new Date();
const formattedDate = `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`;
const listing = await Model.find({
    'data.date': { $ne: formattedDate }
});

console.log(listing)

mongoose (mongodb) check user doesn't have date in array.
With this test it returns to me, all users even those who have the date

frosty gale
#

it doesnt make sense

#

you have an array called data which contains all of your data for each document?

#

mongodb isnt exactly designed for that kinda stuff

#

that query also makes no sense either

quartz kindle
#

thats basically storing json files in mongo

frosty gale
#

and im pretty sure you cant access and query elements inside of an array in mongo like that

#

this is extremely cursed

#

are you trying to just store statistics for each user? whats with the data array

wicked pivot
#

I want to store player data day after day.
Because she has changed in the meantime

quartz kindle
#

oh no, the government is after me

frosty gale
#

so you want to save and keep track of xp, levels, money, ranks, etc, for every day?

wicked pivot
#

For now, I just need to find the "players" who do not have a precise date in the array

frosty gale
#

do you want the latest or something else

wicked pivot
#

The last one, if the last date != formattedDate I want it to add it.

quartz kindle
#

both mongo and mongoose have options for that

frosty gale
wicked pivot
#

I didn't know I'll look thanks

frosty gale
#

for timeseries you should really move onto what tim posted above as its way more fit for purpose

#

but i personally wouldnt be happy with this answer

#

i dont really understand it either

#

mongodb also lets you insert javascript code as a where query but that only works on self-hosted mongodb (unless you paid for atlas) and it basically ruins any chances of database optimisations or indexing

#

this is partly why databases shouldnt be so lenient on schemas since it introduces problems like this and promotes terrible practices

eternal osprey
#

i mean i am using tls anyways so fack it

#

though, yeah in the database i might just use OTP.

#

The api on the backend will instead of directly saving the email, first encrypt it and then save it.

#

That way the key is not on the server side + the data stays encrypted

quartz kindle
#

hiding/generating keys inside the source code is not a bad move, makes it so compromising the database alone is not enough, would need to compromise the source code as well

#

especially if the code is compiled before deployment in a safe/private location

surreal sage
#

nextjs smh

quartz kindle
sharp geyser
quartz kindle
#

wat du yu min

sharp geyser
#

i no no

quartz kindle
#

you yes yes

pine willow
#

Both nah nah

sharp geyser
civic scroll
#

ai chan

sharp geyser
civic scroll
sharp geyser
#

no idea waht that is

#

:p

civic scroll
#

basically table

sharp geyser
#

I guess there is no channel perms like discord

civic scroll
#

one stores the metadata (id, name) and graph database stores user list

civic scroll
sharp geyser
#

ic

rough lynx
#

um

sharp geyser
#

that seems like a lot to manage

#

multiple databases

civic scroll
#

2

sharp geyser
#

what for

civic scroll
#

graph stores social relations (user -> user / channel)

sharp geyser
#

ok

pine willow
tender ermine
#

Is there someone online that could help me? I recently removed the message content intent since I have slash commands and my host can’t start my bot because it says β€œuser disallowed intents” despite reading I don’t need them. Discord keeps denying my application as well.

mighty scroll
#

You mean verification process?

#

Do they give you a reason?

deft wolf
#

You must also remove this intent from your client in the code

#

Not only on discord.dev portal

#

Discord very rarely verifies apps with this intent unless you really have a very good reason to use it

sharp geyser
mighty scroll
#

That's why im glad i got approved for all 3

tender ermine
frosty gale
#

its really not hard its not supposed to be a challenge to get all intents

#

they just want you to have a proper reason for wanting that intent

#

if you dont reasonably need it and a feature can do without it they wont give it to you

mighty scroll
#

Exactly.

#

But anyway, i see now they started to act like "they can use automod for that", we will not give you this intents

frosty gale
#

likely but automod is quite poor at the moment so it wont be until a while later

wary totem
#

hey, what permissions a bot needs to create permissions on a channel ?
in my case, the bot has ManageRoles and ManageChannels, but i have a missing permissions error, the bot can't access and edit the channels that it create

real rose
#

For example if you want to edit the permissions of a channel, your bot should only require the MANAGE_ROLES permission

wary totem
real rose
#

and whats the error

#

you're probably missing something still

urban delta
#

how do i dynamically subclass a class?

#

I'm planning to create a dynamically alocation of classes for things recepting ASCII and foreign language characters, for example:

Hiragana&KatakanaBNF = r"""
hiragana_args: ("{" (h-a|h-i|h-u|h-e|h-o|h-ka|h-ki) "}")+
h-a: "a"
h-i: "i"
h-u: "u"
h-e: "e"
h-o: "o"

h-ka: "ka"
h-ki: "ki"
"""

async def japanesescriptor(macro):
  macro.replace("か", "{ h-ka }")
  ...

class japanese_translator(Transformer):
   async def h-ka(self,cmd):
      return "か"

in this example i wanna my class inherit dynamicallt the class japanese_translator, that coming can bring arabian, corean, chinese, vietnamese, and so oh, the BNF i already have plans for it by adding it to the final of my string that is used as a grammar, and for the japanese scriptor i'm planning it to get imported in some function and it allows me to convert special characters from other languages into their interpreter form, same for arab, corean and etc. Being all of those dynamically added like how cogs are added

wary totem
real rose
#

or the api

wary totem
#

from djs

real rose
#

show me

wary totem
# real rose show me
 rawError: { message: 'Missing Permissions', code: 50013 },
0|main     |   code: 50013,
0|main     |   status: 403,
0|main     |   method: 'POST',
0|main     |   url: 'https://discord.com/api/v10/guilds/886624020580167781/channels'```
lyric mountain
urban delta
#

uhmm

#

can i see an example?

real rose
#

or the perms arent assigned properly

#

feel free to show the perms

wary totem
# real rose And what is it you're trying to get the bot to do. Just create channels perms? Y...

i create a category and text channels, but when i try to set permissions to the channel, my bot throw the error```ts
import { ChannelType, Client } from "discord.js";
import { Game } from "../models/game";
import { Roles, RolesData } from "../models/roles";

export default async function createRoleChannels(client: Client, game: Game): Promise<void> {

const roles = game.roles.filter(r => RolesData[r.type].start && game.players.filter(p => p.roles === r.type).length > 0);
const category = await (await client.guilds.fetch(game.guildId)).channels.create({name: `WEREWOLF ${game.gameId}`, type: ChannelType.GuildCategory});

for(let i = 0; i < roles.length; i++) {

    const channel = await (await client.guilds.fetch(game.guildId)).channels.create({name: `${Object.entries(Roles).find(([key, value]) => value === roles[i].type)[0]}-roles`, type: ChannelType.GuildText});
    await channel.setParent(category.id);
    game.channels.push({channelId: channel.id, type: roles[i].type});

    await channel.permissionOverwrites.create((await client.guilds.fetch(game.guildId)).roles.everyone, {ViewChannel: false, SendMessages: false, ReadMessageHistory: false});
    game.players.filter(p => p.roles === roles[i].type).forEach(async p => await channel.permissionOverwrites.create(client.users.cache.get(p.userId), {ViewChannel: true, SendMessages: true, ReadMessageHistory: true}));
    
    await channel.send(client.functions.sentences[roles[i].type.toString()](`${game.players.filter(p => p.roles === roles[i].type).map(p => `${client.users.cache.get(p.userId)}`).join(" ")}, you have the \`${Object.entries(Roles).find(([key, value]) => value === roles[i].type)[0]}\` role, here is what you need to do :\n> ${RolesData[roles[i].type].description}`));
};

client.games.set(game.gameId, game);

}; ```

lyric mountain
solemn latch
wary totem
solemn latch
#

Is it creating the category and channel before erroring?

shell tundra
#

it's the bot that i made you join vc for

#

yeah it creates the channel but no roles and just dies

pine willow
#

mhmmmm

wary totem
#

i can create channels, but can't set permissions

solemn latch
#

Manage roles is what you want I assume

#

But you have it πŸ‘€

#

hm,m

wary totem
#

yeah

#

it's very strange

#

with the admin perm, it works, but i can't for topgg

solemn latch
#

is the role you're editing below the bots highest role?

wary totem