#development

1 messages · Page 259 of 1

bitter granite
#

i keep getting

#
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)```
bitter granite
#
package backend;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class Connect {

    String username = "dbadmin";
    String password = "dbadmin";
    String database = "quiz";
    String host = "localhost:3306";
    String connection = String.format("jdbc:mysql://%s/%s", host, database);

    private static Connection con;
    private Statement st;
    private static Connect connect;

    public static Connect getInstance() {
        if (connect == null) {
            connect = new Connect();
        }
        return connect;
    }

    private Connect() {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            con = DriverManager.getConnection(connection, username, password);
            st = con.createStatement();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public boolean insertUser(String userName, String email, String password, String gender, String role, String dateOfBirth) {
        int newUserId = getNextUserId();
        String sql = "INSERT INTO MsUser (UserID, UserName, Email, Password, Gender, Role, DateOfBirth) VALUES (?, ?, ?, ?, ?, ?, ?)";

        try (PreparedStatement preparedStatement = con.prepareStatement(sql)) {
            preparedStatement.setInt(1, newUserId);
            preparedStatement.setString(2, userName);
            preparedStatement.setString(3, email);
            preparedStatement.setString(4, password);
            preparedStatement.setString(5, gender);
            preparedStatement.setString(6, role);
            preparedStatement.setString(7, dateOfBirth);
            int rowsInserted = preparedStatement.executeUpdate();
            return rowsInserted > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }


    private int getNextUserId() {
        String sql = "SELECT MAX(UserID) AS maxUserId FROM MsUser";
        try (Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(sql)) {
            if (resultSet.next()) {
                return resultSet.getInt("maxUserId") + 1;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 1;
    }

}```
#

is it the code issue or what, my brain is not working now

pearl trail
#

have you added mysql-connector-java in dependency?

bitter granite
#

yes did not work

#

the lib is downloaded and compiled

pearl trail
#

maven -> reload project

bitter granite
#

i amma cry, ill just make it into array local storage for now....

#

i need to reask them if i can do that

#

Like they should atleast allow you to use any lib coise in real life, they use dont always use the same lib

pearl trail
#

oh

#

to make gui?

bitter granite
pearl trail
#

💀

#

do you like hash password?

bitter granite
#

Like from them even the lib version if i use 8.0.23
When its supposed to be 8.0.24

#

Thats a min -20% total score

pearl trail
#

what the fuck

bitter granite
pearl trail
#

oooo

bitter granite
#

And this project call for 70% of your total score

#

More then the exams

lyric mountain
#

I really hate such tests

lyric mountain
#

If it doesnt, then the path is wrong

bitter granite
#

I am too dumb

lyric mountain
#

The driver path you put in Class.forName is an actual class in java

#

Just type it out, as if importing

#

If the path becomes red then the driver path is wrong

bitter granite
#

Ah ill try it in a bit (moving class irl)

raven nexus
#

is there a way to make mongodb to dont create new database file if there already and exist one before?

#

i just want it to upload the same file but just update the timing

lyric mountain
#

"upload the same file"?

raven nexus
#

here i give you how the bot save

New session started for user 263941845590081538 at Tue Oct 22 2024 023355 GMT+0000 (Coordinated Universal Time) in channel 126498329177436

Session ended for user 932286343869005884. Total time: 131.897 seconds.

#

so it save something like this

#
_id
671710349f99bd1d213b1df9
userId
"263941845590081538"
guildId
"1204272641306005514"
channelId
"1214550847770337300"
joinedAt
2024-10-22T02:38:44.206+00:00
totalOnlineTime
0
__v
0```
lyric mountain
#

Ok but wdym upload same file?

raven nexus
#

so once i reconnect to driifent vc in the same guild

#

the file above

#

it create another files same structure i highlight

#

i want it to update
totalOnlineTime 0

lyric mountain
#

I...still don't understand, are we talking about files or documents?

raven nexus
#

uh idk how it call but is like this

lyric mountain
#

That's a document

bitter granite
raven nexus
#

it keep recreating new one and not update

#

owh

lyric mountain
#

If the last part in the resulting text is red then the classpath is wrong

lyric mountain
bitter granite
#

this? my brain is too dead

raven nexus
#

guild and user id Yes same

lyric mountain
raven nexus
# lyric mountain How are you saving it? Are you using the same id?
const mongoose = require('mongoose');

const onlineTimeSchema = new mongoose.Schema({
  userId: {
    type: String,
    required: true,
    index: true, // Index for faster queries
  },
  guildId: {
    type: String,
    required: true,
  },
  channelId: {
    type: String,
    required: true,
  },
  joinedAt: {
    type: Date,
    required: true,
  },
  totalOnlineTime: {
    type: Number, // Online time in seconds
    default: 0,
  },
});

// Check if the model already exists
const OnlineTime = mongoose.models.OnlineTime || mongoose.model('OnlineTime', onlineTimeSchema);

module.exports = OnlineTime;

it save from this

lyric mountain
#

But it's enough already tbh, see how Driver is red?

#

It means the class wasn't found

#

Thus forName won't work either

bitter granite
#

hm so do i have to redo the global lib?

lyric mountain
#

com.mysql.cj.jdbc.Driver is an actual class, you could just import it for all we know

#

But anyway, the path is wrong or you didn't install the lib correctly

bitter granite
lyric mountain
#

Yes, see, not found

bitter granite
#

but it seem like other import work

lyric mountain
#

What import?

bitter granite
#

the one above com.mysql

lyric mountain
#

The others up there are java's std lib

#

They always exist

bitter granite
#

oh...

lyric mountain
#

Show me ur pom

#

Or build file, if gradle

#

Or are u doing it raw?

bitter granite
lyric mountain
lyric mountain
raven nexus
lyric mountain
#

I mean where u call .save()

lyric mountain
raven nexus
#
const OnlineTime = require('../models/OnlineTime'); // Ensure the model is correctly imported

/**
 * Function to handle when a user joins or reconnects to a voice channel.
 * @param {String} userId - The ID of the user.
 * @param {String} guildId - The ID of the guild (server).
 * @param {String} channelId - The ID of the voice channel.
 */
async function handleVoiceChannelConnection(userId, guildId, channelId) {
    try {
        // Check if the user already has an entry
        let onlineRecord = await OnlineTime.findOne({ userId, guildId });

        // Get current time and set milliseconds to 0
        const currentTime = new Date();
        currentTime.setMilliseconds(0);

        // If a record exists, update the `channelId` and `joinedAt`
        if (onlineRecord) {
            onlineRecord.channelId = channelId;
            onlineRecord.joinedAt = currentTime; // Set to current time without milliseconds
            await onlineRecord.save();
        } else {
            // Create a new record if one doesn't exist
            const newOnlineRecord = new OnlineTime({
                userId,
                guildId,
                channelId,
                joinedAt: currentTime, // Set to current time without milliseconds
                totalOnlineTime: 0, // Start with 0 total time
            });
            await newOnlineRecord.save();
        }
    } catch (error) {
        console.error('Error handling voice channel connection:', error);
    }
}

module.exports = (client) => {
    client.on("voiceStateUpdate", async (oldState, newState) => {
        // Check if the user has joined or reconnected to a voice channel
        const userId = newState.id;
        const guildId = newState.guild.id;
        const newChannelId = newState.channelId;

        // Only proceed if the user has joined a new voice channel
        if (!oldState.channelId && newChannelId) {
            // User has joined a voice channel
            await handleVoiceChannelConnection(userId, guildId, newChannelId);
        } else if (oldState.channelId && newChannelId && oldState.channelId !== newChannelId) {
            // User has switched to a different voice channel
            await handleVoiceChannelConnection(userId, guildId, newChannelId);
        }
    });
};
lyric mountain
#

Download the lib from there, it'll configure classpath properly for u

raven nexus
lyric mountain
#

You need to fetch it then update the value before saving it back

lyric mountain
#

The format is group:name:version

bitter granite
#

java: package com.mysql.cj.jdbc does not exist

lyric mountain
#

It's cuz u left the import there

bitter granite
lyric mountain
#

It's still the same error but compile-time now

lyric mountain
#

But well, use maven central to get the package

#

Oh wait lmao

#

U got the wrong file

#

It's a zip

#

Java libs are jar

#

I believe the jar is inside it, unpack

raven nexus
#
const OnlineTime = require('../models/OnlineTime'); // Your OnlineTime model for tracking voice state

module.exports = (client) => {
    const GUILD_ID = process.env.GUILD_ID; // Get the GUILD_ID from the .env file

    // Track user voice channel join/leave times
    client.on("voiceStateUpdate", async (oldState, newState) => {
        if (newState.guild.id !== GUILD_ID) return; // Only track if in the specified guild

        // User joined a voice channel
        if (!oldState.channel && newState.channel) {
            const userId = newState.member.user.id;
            const joinedAt = new Date();
            const channelId = newState.channel.id; // Get the ID of the channel the user joined

            let session = await OnlineTime.findOne({ userId: userId, guildId: GUILD_ID, totalOnlineTime: 0 });
            if (!session) {
                session = new OnlineTime({
                    userId: userId,
                    guildId: GUILD_ID,
                    channelId: channelId, // Include channelId
                    joinedAt: joinedAt,
                    totalOnlineTime: 0, // Initialize total online time to 0
                });
                await session.save();
                console.log(`New session started for user ${userId} at ${joinedAt} in channel ${channelId}.`);
            } else {
                // Update the session with the new channel and joinedAt time
                session.channelId = channelId;
                session.joinedAt = joinedAt;
                await session.save();
                console.log(`User ${userId} reconnected at ${joinedAt} in channel ${channelId}.`);
            }
        }

        // User left the voice channel
        if (oldState.channel && !newState.channel) {
            const userId = oldState.member.user.id;
            const leftAt = new Date();

            const session = await OnlineTime.findOne({ userId: userId, guildId: GUILD_ID });
            if (session) {
                // Calculate the duration in seconds
                const durationInSeconds = (leftAt - session.joinedAt) / 1000;

                // Update the totalOnlineTime by adding the session duration
                session.totalOnlineTime += durationInSeconds;
                await session.save();

                console.log(`Session ended for user ${userId}. Total time updated to: ${session.totalOnlineTime} seconds.`);
            }
        }
    });
};
#

i am not sure why it recreated new doc

lyric mountain
#

Cuz ur fetching only with totalOnlineTime = 0

#

Remove that from findone

lyric mountain
# bitter granite

When downloading libs always get it from maven central, it's guaranteed to be correct

#

The text inside quotes there is what u put in Download from URL in intellij

#

Optionally u just download the jar from there, works too but more work

#

To find just type "[package name] maven central" on google

raven nexus
#

is it common to get timeout 10000ms for mongodb?

lyric mountain
#

No

bitter granite
#

still dosent work on finding the lib

#

bot error

raven nexus
# lyric mountain No

i have use the same database with the main bot and testing bot maybe could that cause a timeout?

lyric mountain
#

Javadocs are, well, the documentation

#

Is the lib listed under Sources? If not then u probably just added to download the docs

bitter granite
lyric mountain
lyric mountain
#

Now the import will become white

#

Which means that forName will also work

raven nexus
lyric mountain
#

See if it allows connecting if you stop other connections

bitter granite
#

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.```
#

oh wait

lyric mountain
#

If it does then ur SOL

bitter granite
#

forgot to start the sql

lyric mountain
#

It did work then, since it found the class

#

Maven central is a godsend for when u need a package, it's like npm or pub but even better

#

Since it indexes all packages from all main repositories

bitter granite
#

ah yeahhhhhhhhhhh finaly it work

#

Thankyou so much now i can do the backedn of this program

lyric mountain
#

Nice

bitter granite
#

if only i know about mvn central

#

when i setup my javafx

#

-# (that setup took almost 2 week+ of debuging)

lyric mountain
#

Wait till u meet maven/gradle

#

It's basically the java equivalent of package.json

bitter granite
#

i missed js npm ngl doint this lib

lyric mountain
#

Yeah, you'll very rarely ever need to work on java doing libraries raw like that

bitter granite
lyric mountain
#

With a package manager u just put the lib path and they'll get from mvncentral for u

lyric mountain
bitter granite
#

.....i am at the back of class....

#

i saw the guy infrount of me

lyric mountain
#

I could even guess they told u to use java 8

bitter granite
#

he is readinng henti..... in class

bitter granite
lyric mountain
lyric mountain
#

Java's at 23 now

#

24 by feb next year

bitter granite
#

i mean mysql connectorhas ver 9 and we use 8
and javafx is 17

lyric mountain
#

Also that mysql connector has CVE warnings of severe class

bitter granite
#

let me get the versheet

#

Eclipse 2020.6 R
Java 11.0.18
JavaFX 17.0.7
MySQL Java Connection Library 8.0.24
XAMPP 8.0.7

#

althou i dont use the eclipse couse it can be same with intelij

lyric mountain
lyric mountain
bitter granite
bitter granite
#

thats a -20%

#

SO no latest

lyric mountain
#

Which also goes against a proper project planning

bitter granite
#

and best part of this.... they have not even teach javafx or mysql code

lyric mountain
#

As using outdated libs is a liability

bitter granite
#

it will be teach in the last week before i have to submit this assiment

#

so i had to self learn all of this

#

good thing there is docs and stackoverflow

lyric mountain
#

Yep, java has a long track record, plenty of Q&A around

bitter granite
#

ngl this would be eazyer if its in py and using mongodb, couse i somehow know more then java+mysql

#

also i really dont wanna make a documentation on this project

lyric mountain
#

I mean, technically you'd be using JPA not raw connectors, or at least some connection pool like hikari

#

Nobody does raw connection managing like that anymore

bitter granite
#

Fun fact: This is supposed to be a group project with 7 member

#

and i am somehow the onlyone that does the work

lyric mountain
#

Always like that lmao

bitter granite
#

couse my team member
Member 1: me
Member 2-7: No one

#

somehow i become solo in the group...

lyric mountain
#

And you're forced to carry the group, else you also fail the assignment

bitter granite
#

atleast i made a deal with the teacher
as long as backend work and use the correct lib
100%

#

they will ignore the frount end design and such

bitter granite
bitter granite
#

also that i know out of 12 group, i am the only one that has progress

lyric mountain
#

My teacher used to ask questions individually after assignment completion, to ensure everybody participated

bitter granite
#

it used to be like
they give out a list
and we write what we do
and if we lie, other member can argue it

#

i want the old system back

#

they change it to the new system couse there is too much complain

lyric mountain
#

Yep, it sucks and puts a high value target on your head for any assignment, everybody will want to hitchhike on you

bitter granite
#

i bet the one who complain is the one who dosent do the work

bitter granite
#

bro.... he is still reading that thing iin class

lyric mountain
#

But don't let uni turn you down on java, try to do some side projects with it, it's quite enjoyable

bitter granite
lyric mountain
#

At worst you get to learn a language that can go into resumee

#

At best you like it

bitter granite
#

imagie that guy bluetooth earphone disconected

bitter granite
lyric mountain
#

Like, what if you need to stand up?

bitter granite
lyric mountain
#

Coding should be about writing code, not dealing with packages

bitter granite
#

indeed

#

i would say i spend like 80% of my time dealing with lib,setup

lyric mountain
#

Btw you should apply from intellij ultimate while ur still in uni

bitter granite
#

on this project

bitter granite
lyric mountain
#

Also embedded DB tools

bitter granite
#

Code with me*

#

i used Code with me so i can code on my laptop then run the code in my gaming laptop

lyric mountain
#

Oh, in case u didn't know u dont need to do that

#

In intellij folder there're 2 executables

#

One is for server, one for client

bitter granite
#

wait what?

#

so you can run on cloud?

lyric mountain
#

Yep

bitter granite
#

ok i need to learn that

lyric mountain
#

U can code entirely remote

bitter granite
#

is the code saved in cloud too?

#

couse i change device if i am outside or at home

lyric mountain
lyric mountain
#

Like, u could rent a vps and host the server there

bitter granite
#

so basicly you need a vm right?

#

i have a vm so would be fine

lyric mountain
#

It's mostly for the scenario u said, the gaming pc would run the server

#

Then ur laptop would connect using the client

bitter granite
#

rip vm broke

outer crater
#

The input field has gone behind this control bar...

lyric mountain
#

Lmao

bitter granite
#

time to fix it in ovh

#

aaaa

#

i forgot ovh is blocked in my uni wifi

lyric mountain
outer crater
#

I'm using css jss 💀😭🙏

lyric mountain
#

Js can get safe zones

#

I THINK html has it too

bitter granite
#

btw what ver is the best for vm

#

i am going to just rebuild

#

out of this option

#

sending sc in a sec

lyric mountain
#

Nvm css

lyric mountain
#

Btw, in case ur using mysql workbench there's no need to

bitter granite
lyric mountain
#

Just click the db icon at the left sidebar

bitter granite
#

is the dns good?

lyric mountain
#

Connect to the db there

lyric mountain
bitter granite
#

got it

lyric mountain
#

If google fails cloudflare for sure wont

bitter granite
#

Building

#

i dont have the paid version

#

so i have to like rebuild every 6mo

raven nexus
#

i have try to create an ai reply using chatgpt modules

Failed to load event aichat.js: TypeError: Configuration is not a constructor

require('dotenv').config(); // Load environment variables from .env
const { Configuration, OpenAIApi } = require('openai');
const { EmbedBuilder } = require('discord.js');

// Set up OpenAI API with the key from .env
const configuration = new Configuration({
    apiKey: process.env.API_KEY,
});
const openai = new OpenAIApi(configuration);

module.exports = (client) => {
    client.on("messageCreate", async (message) => {
        // Ignore messages from bots and non-text messages
        if (message.author.bot || !message.content) return;
        if (message.channel.id !== '1298129194693165066') return; // Filter for specific channel if needed

        try {
            // Send the user's message to OpenAI to generate a response
            const response = await openai.createChatCompletion({
                model: "gpt-3.5-turbo",
                messages: [{ role: "user", content: message.content }],
            });

            // Extract the response content and modify it to add "หนูคิดว่า..." to every sentence
            const aiResponse = response.data.choices[0].message.content;
            const modifiedResponse = aiResponse.split('.').map(sentence => sentence.trim() ? `หนูคิดว่า...${sentence.trim()}` : '').join('. ').trim();

            // Send the AI's response as an embed
            const embed = new EmbedBuilder()
                .setColor('#0099ff')
                .setAuthor({ name: 'AI Chat', iconURL: client.user.displayAvatarURL() })
                .setDescription(modifiedResponse)
                .setTimestamp()
                .setFooter({ text: 'Powered by OpenAI' });

            message.channel.send({ embeds: [embed] });
        } catch (error) {
            console.error('Error generating AI response:', error);
            message.channel.send('เกิดข้อผิดพลาดในการสร้างคำตอบจาก AI, กรุณาลองใหม่อีกครั้ง.');
        }
    });
};

The API_KEY is in .env

lyric mountain
#

Paid version of what? Intellij?

#

Didn't u apply for student license?

bitter granite
lyric mountain
#

Ah

bitter granite
#

damn fast rebuild

#

i thought it will take like atleast 15min

lyric mountain
#

Win server is technically just win11 with some booleans set to true

bitter granite
#

i rather have a win server always on stendby tbh

#

couse there is somebot i rather try on vm

lyric mountain
#

Ur using hyperv?

bitter granite
#

but i can just rebuild anytime

#

since i dont store importent data there

lyric mountain
#

Ic

bitter granite
#

plus my build is setup so it has all the nesesery stuff (discord, vsc, chrome, steam, java, js, py and few more)

#

well its just script

lyric mountain
#

Why not linux btw?

bitter granite
lyric mountain
#

Ah

bitter granite
#

for example my bot clone detection bot is on my linux server

#

most used app in my vm

bitter granite
#

used on dms more then 50+ since it has been made

lyric mountain
#

Lul

#

Btw that Discord choice is weird, like, you can manage channels but can't change its permissions?

bitter granite
lyric mountain
#

And then you can manage roles but also change who can do what in certain channels

#

Lmao

bitter granite
#

I know this. Couse there is quite abit that use this arguement
"But acording to this ripo, you need manage channel"

lyric mountain
#

I don't even get why submit clones

#

Like, it likely already exists there working, maintained and hosted for you to use at will

#

Why bother with a clone, and even attempt to list it on the same place

#

Bragging maybe?

lament rock
#

I can see some edits or using it as a way to learn how to use a language, but posting it to a bot list is insanity unless it's totally different. The only case I can see is music bots for multiple VCs, but like... Why though?

#

Just use a private instance(s)

bitter granite
#

Couse i have ask some

#

They just want the bot to be in the site

#

To flex that they are "top.gg developer"

#

By having bot dev role

#

They flex it to non-tech friends that dont know anything

#

I know this is a fact couse i know one person irl ||old me|| who does that

lyric mountain
#

Lul

bitter granite
# lyric mountain Lul

Here is another thing
Alot of non dev discord user
Think that topgg is own by discord/opperate by discord
Including some of medal volenteer/staff (i think medal own topgg)

#

So it works becouse of it

#

They think
Bot get accept = auto verified

civic scroll
#

unpeak fp

thorn torrent
#

Guys I have a problem with the location measurements on the phone How can I solve it?

lyric mountain
#

define "problem"

wheat mesa
#

It’s going to depend on what way you’re adding it, but usually there is a .lib file alongside include files (.h/.hpp), and potentially DLLs. You can look up a tutorial of linking something like GLM since it’ll show the process

#

Also, if you want to make an efficient HTTP Server, try out Go. It’s very good at multithreading and reduces the complexity you’ll encounter with C++

#

It is

earnest phoenix
#

hence why people in cpp write everything from scratch

#

meh

wheat mesa
#

C++ has many use cases still

#

Rust will not see widespread adoption for a little while longer, it still needs to be more supported by the enterprise community

#

That’s why languages like Java are still so popular, decades of enterprise infrastructure was built on it

pearl trail
#

i prefer use java rather than c/c++ (beside my curriculum)

sharp geyser
#

haku is biased

warm surge
#

@quartz kindle can you explain little bit about session limit to @minor epoch

minor epoch
minor epoch
warm surge
#

yea

minor epoch
#

Doing what

warm surge
#

idfk

minor epoch
#

Lmfao

pearl trail
#

ok

craggy pine
#

I seen this exact message from a different member in a different server. I'd suggest @solemn latch prolly should delete this (sry for ping) as its prolly a new typa scam

quartz kindle
green kestrel
#

you want a package manager

#

consider vcpkg or conan

#

it makes things a lot easier

#

if you're new to C++ don't try integrating libs by hand

#

also get an ide that helps you by maintaining your cmakelists.txt for you, e.g. clion

warm surge
warm surge
bitter granite
#

The one time...that autocorrect did not Work is when i did typo

copper inlet
lament rock
#

been learning blender py and its kinda fun ngl

#

Still not a huge fan of py syntax but it is what it is

solemn latch
lament rock
#

hell yeah

solemn latch
small tangle
#
pub enum Token<'a> {
  #[regex("V[0-9]+(\\.[0-9]+\\[[0-9]+\\])?", |lex| lex.slice())]
  MemoryLocation(&'a str),
}

I love lexer generator

quartz kindle
# minor epoch Just found out about them to be honest, I knew they existed, just thought it was...

so, as per webster's request, i shall now explain session limits:
once upon a time there was big mountain called Discord, which then turned into a fancy building with magic rocks and somehow learned telepathy.
366 days later an elephant tried to let the sink in but we dont know what happened after that.
They then decided to install a special door and call it a session, and they slapped a little paper on it with some text written in chinese.
the text said something something about documentation. whatever that means... you need to reach a certain level of drunkness to be able to read it.
so after a night of drinks i went to check it out and it said the following:

depending on the size of your bot (number of server), you are allowed a certain number of "logins" per day (they reset every 24 hours), usually 1000 for small bots.
these "logins" are basically successful "identify" requests over the websocket, meaning every time your bot connects it counts as a "login".
each shard counts as a separate "login", so if you have 10 shards, every time you start your bot, it will use 10 logins.
if a shard disconnects and is able to "resume", that will not count as a login and will not count towards the limit, only if the resume fails and the shard needs to reset completely.
if you go over the 1000 logins per day, your bot will be locked out for the remainder of the time until the next reset. you can see how many logins you have left and much time is left until the next reset if you make a GET request to /gateway/bot
when your bot becomes very big, ie 150k+ servers, discord will increase this number, usually to 2000 and first and then more if needed.

lament rock
#

resuming sessions where possible is critical

#

I need to add cold session resumes into my lib. I currently bypass a lot of lib logic just so that I can apply the session ID and sequence number after a process restart

#

wondering if anyone has ever hit the Number.MAX_SAFE_INT for seq on a session

#

@quartz kindle Do you have any idea what might happen when someone reaches such a point?

quartz kindle
#

if you go past max_safe_int it will start getting rounding errors, like n+1 returning n again

lament rock
#

I mean. My shards used to receive a LOT of messages when those werent privileged

quartz kindle
#

still

#

its 9 quadrillion

lament rock
#

My cluster has been alive for over 2 months

#

Idk if the sessions the cluster started with are the same ones but they likely are

#

Time to make a bot that gets insanely popular and ensure the gateway sessions last for as long as possible

ruby ermine
#

👋

quartz kindle
#

very very far from 9 quadrillion :^)

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

frosty gale
#

000000000000000000

#

ive seen bigger

lyric mountain
#

that's what she said

warm surge
deft wolf
warm surge
#

lmao

steady saffron
#

how does top.gg calculate "more like this"?

#

im trying to determine "similar forums" for my forum website, but i cant seem to get it to be fast and accurate, its one or the other

lyric mountain
#

probably tags? maybe tracking which bots IPs access then finding the overlaps

steady saffron
lyric mountain
#

you can gather which pages a specific IP accesses

#

if an IP accesses page A then page B this means they're related in some way, or just means B caught the interest of A users

#

this enters the big data analysis area, but you can "guess" which pages an user is interested in by grouping similar users

#

add tags to the equation and you get things that are similar

steady saffron
#

but i dont think top.gg would go through the process of all of this, it sounds as tho this would probably hurt performance

lyric mountain
#

it hurts performance if you're doing this in real time

#

you can simply process in the server then use the preprocessed data in the site

#

the "data cruncher" is never in the frontend

neon leaf
lyric mountain
#

pretty good yeah

earnest phoenix
#

took ages to load for me for some reason but looks nice

lyric mountain
#

tho u could not make version dropdown a 50% flex, same for search

neon leaf
earnest phoenix
#

maybe the graphics should go full width

lyric mountain
#

like, they're way too big

neon leaf
lyric mountain
neon leaf
#

ah

#

done

lyric mountain
#

also add a looking glass button to the right

#

makes it easier to find the search bar

earnest phoenix
#

oh and one small feat you could add is that when click "browse" and get that sort of popup

#

make "esc" also a way to close it

#

eventually clicking outside as well

#

having to use the mouse and slide down is kinda annoying

neon leaf
#

alr ill do that

#

alr done

lyric mountain
#

version dropdown still pretty big

#

u can use 15em for the width, basically 15 "M"s side by side

#

in my print I used 120px

lyric mountain
#

looking good now

neon leaf
#

would it be a good idea to do 2 versions per row on desktop?

lyric mountain
#

try it to see how it ends

#

oh actually

#

on desktop u could use card layout

#

this way bigger monitors get more items per row

neon leaf
lyric mountain
#

for me it looks better, but might go from person to person

#

u could add a "display mode" button on top right corner

#

to switch between single-list, 2-columns and card

sharp geyser
#

I dislike the gap at the right

#

maybe thats just me though

neon leaf
sharp geyser
#

I don't like uneven things iara_lul_haha

sharp geyser
neon leaf
#

no

sharp geyser
#

Im curious what was your solution

neon leaf
#

flex

sharp geyser
#

ah

#

so you can use justify-center and items-center

neon leaf
sharp geyser
#

I see

#

interesting

neon leaf
#

its so I can make the last rows grow dynamically

sharp geyser
#

yea

neon leaf
sharp geyser
#

I dislike that

#

It should all be same size

#

Maybe I do have OCD

earnest phoenix
#

nah that's not really good tbh

neon leaf
#

well I dont really know if it should be

earnest phoenix
#

you can center them but keep the same size

sharp geyser
#

even centering is a stretch for me

#

I usually leave them all the same size, and keep them in their positions

earnest phoenix
#

or just let the right one be empty, not a big deal and that's how it's usually done

sharp geyser
#

I'd rather it look like one is mising, than trying to fill it in

neon leaf
earnest phoenix
#

yeah that's perfectly fine

neon leaf
#

alright

sharp geyser
#

Also, why the choice of making a button you have to click to view the information on that release?

neon leaf
sharp geyser
#

Ah

#

Yea that's how I usually do it, though im not completely against using a separate button

earnest phoenix
pearl trail
#

🔥 🔥 🔥 🔥 🔥 🔥 🔥

surreal sage
#

holy moly

lyric mountain
#

what is a cucumber tree structure?

small tangle
earnest phoenix
#

it's pain

small tangle
#

Looks interesting tho

quartz kindle
#

i once participated in a java class where the instructor was teaching about cucumber

#

the whole thing did not make any sense

#

i mean, i understood the concept, but like, why?

eternal osprey
#

Hey guys, does anyone know a free or paid api that shows a constant stream of web3 tokens that are being created?

#

I am trying to make an automatic buy/sell bot and got pretty far already, but i just need to find a realiable streamer, which i for some fucking reason cannot seem to find.

surreal sage
raven nexus
#

is there a way to put in the logo to php
the file are in images/facebook.png

images/instragram.png

frosty gale
#

if you want something more fancy like importing images and referencing them without explicitly making them public youre going to need some library probably

raven nexus
#

Correct?

frosty gale
toxic siren
#

Am I able to edit any information on my bot on top.gg so that it'll be up to date

earnest phoenix
#

"Edit" button

#

@radiant kraken Why do rust generics restriction only work with traits? weirdsip

#

hate having to do something like

impl MyTrait for i32 {}
impl MyTrait for f32 {}
radiant kraken
#

what do you mean?

earnest phoenix
#

Like I can't do

fn blah<T: i32 + f32>(b: T) {}
wheat mesa
#

You can

earnest phoenix
#

No

#

Not working with primitive types, it expects traits

#

So you can get around it by making a trait which implements both, but it's kinda shit

wheat mesa
#

Ah I thought you just meant generic restrictions on functions

earnest phoenix
#

Nah

#

I have to do something like

trait Allowi32f32: std::fmt::Display {}

impl Allowi32f32 for i32 {}
impl Allowi32f32 for f32 {}

fn blah<T: Allowi32f32>(b: T) {
    println!("{}", b);
}

fn main() {
    blah(3); // works
    blah(1.3); // works
    blah(std::i64::MAX); // fails, i64
    blah("hello"); // fails, &str
}

And I personally find that horrible

radiant kraken
earnest phoenix
#

yeh found that as well, it's just unfortunate you can't do it :c

earnest phoenix
#

but something like

fn blah<T: i32 | f32>(b: T) {}

could be cool

#

I mostly use traits for the few generics use cases i have but now facing one where i'd need two normal types

radiant kraken
#

that would make a cool crate idea tho, something like

#[alias_trait]
fn thing<T: i32 | f32>(b: T) {}
#

i wish Rust had a built-in trait like As<T> for types that can be type-casted by the compiler with as _

earnest phoenix
#

definitely

earnest phoenix
radiant kraken
#

those are procedural macros, they modify the AST of the code fragment next to it, in this instance, the entire function thing

#

which is very useful for doing magical things like that poggythumbsup

#

one of the things i wish more languages had tbh

earnest phoenix
#

yeah definitely not for me KEKW

earnest phoenix
surreal sage
#

yeah uhm im not sure what this is, this is a .mp4 hosted file over http

#

actual mp4 size is around 300mb

#

but it just repeatedly tries to fetch 5 mb chunks, network resources going into the gigabytes

#

18gb for 300mb to be exact

#

appears just with this though

#

content-length: 305482274
content-range: bytes 0-305482273/305482274
content-type: video/mp4

split owl
#

i have a very broad question
how to do sharding and is it necessary

#

google says its only necessary for bots in 2500+ servers

digital swan
#

Are you anywhere near 2500 servers?

earnest phoenix
split owl
split owl
#

my bot's very new so it looks like i dont have to worry about sharding for a long time

earnest phoenix
#

Usually libraries have this auto sharding thing, where they use the recommended number of shards that discord gives for your bot

split owl
#

i see

digital swan
#

Discordjs you can add literally 1 thing to your client and have auto sharding up to a certain extent

earnest phoenix
digital swan
#

Not a clue

earnest phoenix
#

Auto sharding will just make one shard for your case

earnest phoenix
split owl
#

💀

#

is that it

earnest phoenix
#

yup

split owl
#

wow

earnest phoenix
#

Shards are just multiple connections for specific guilds - libraries make that easier for you by just simplifying stuff

split owl
#

thanks 💯

earnest phoenix
#

You also have new events you can listen to like on_shard_ready(shard_id)

#

This will get triggered when a shard is ready as the name suggests

#

For your case, you'll likely just have a single shard with ID 0

#

And your bot variable has new attributes like bot.shards or bot.shard_ids

split owl
#

so i can use like len(bot.shards) to show the number of shards

earnest phoenix
#

bot.latency uses the average latencies between the shards and you can get all the latencies separately with bot.latencies

Lots of cool stuff to play with

earnest phoenix
split owl
#

interesting

earnest phoenix
#

Consider shards as being different connections to discord.

Each of these shard/connection handles events for a set list of guilds.

So if one day you have 2 shards, and one shard cannot connect for some reason to discord, then you won't receive the events for the guilds on that shard, but the other shards will be perfectly fine.

Hence why sometimes big bots work in some servers but not all

#

There's a formula on the docs to know which guild will send its events on which shard, but you don't really need to know that - it's just to show that Discord splits the guilds into the shards to lower the workload per connection as each connection will receive a more normal amount of events, and not all for every single guild

shard_id = (guild_id >> 22) % num_shards
surreal sage
#

I'm experiencing something really weird

#

I have a debian server, 192.168.1.250

#

I try to SSH into it, I get timed out

#

I ping it, clean response

#

I ssh into another server, 192.168.1.251
And then ssh into 192.168.1.250, it works fine

surreal sage
quartz kindle
#

ghosts

surreal sage
#

And it works sometimes

quartz kindle
#

idk it could be stale dns shenanigans

#

but also ghosts

surreal sage
#

ipconfig /flushdns
netsh interface ip delete arpcache

#

did both

#

such big question mark

quartz kindle
#

subnet mask shenanigans? idk

surreal sage
#

It's just ssh though

#

192.168.1.250 also is running a sharex server that I upload to directly

#

and it works just fine

#

😭

quartz kindle
#

that ip is in your local network right?

surreal sage
#

yes

quartz kindle
#

i've seen this happen before, stuff being unaccessible from inside the same network for some reason

surreal sage
#

I'm on a different vlan, 192.168.178.20

quartz kindle
#

but working fine when accessed from outside/vpn

surreal sage
#

Weird as I can ssh into 192.168.1.251 just fine

quartz kindle
surreal sage
#

Port forwarding as in public ip -> network?

quartz kindle
#

as in pc -> router -> server

#

or vlan1 -> vlan2

surreal sage
#

oh.

#

wait

quartz kindle
#

wat

surreal sage
#

my router thinks im ssh scanning

#

within my network

#

so it blocked me on that port

#

lmao

quartz kindle
#

xddddd

surreal sage
#

i dont get this though

#

it should allow 192.168.x.x

quartz kindle
#

why does it say 192.178?

surreal sage
#

i love you

quartz kindle
#

@_@

surreal sage
quartz kindle
#

lmao

neon leaf
surreal sage
#

and ofc it immediately starts working

quartz kindle
#

xD

earnest phoenix
#

Mutex<Vec<Arc<Box<dyn Module>>>> much fun

eternal osprey
#

Hey guys why the fuck am i blocked by a chinese internet provider

#

i swear i did an internet check as my mailing service was not working for some customers, i found out that 9 providers in china have blocked my vps's ip 😭

#

i did nothing to deserve all that

earnest phoenix
#

average china moment

#

you can send them an email asking why

#

they may unblock it, who knows

eternal osprey
#

whahahah i will try to, but idk it seems so strange

earnest phoenix
#

probs because it's not gov monitored idk

toxic siren
#

Does anyone know if I need DBOTS_TOKEN, DBL_TOKEN and BOD_TOKEN, or do I just need the topgg API token

earnest phoenix
#

?

toxic siren
#

I'm trying to finish my bots coding but I'm not sure if I need all 4 tokens

earnest phoenix
#

Well considering you coded it, you should know?

toxic siren
#

I didn't finish coding it genius

earnest phoenix
#

????? then why do you have 4 variables/tokens if you don't know for what they're used

#

Either you use them or not, if you don't there's no point in having them

#

And whether you use them, you should know it because you're coding it

digital swan
#

hes on a higher plain of thinking than us

lyric mountain
#

but well, those tokens are from other listings

#

dbl is how topgg was called years ago

#

dbots is a brazillian listing

#

bod idk

toxic siren
lyric mountain
#

because you're asking whether u should fill those variables

toxic siren
#

On the template

lyric mountain
#

templates usually have a list of variables and an explanation of each for forkers to fill

lyric mountain
#

it doesn't really matter the name

toxic siren
lyric mountain
#

it...depends on how they implemented it

#

a good template will have all tokens optional, as in, it'll only attempt to execute dependent code if it's filled

#

but bad templates could simply outright crash if not filled

#

they aren't mutually exclusive mind you, you can have all filled if you're listed on those too

#

the template should include a README.md file with instructions for setup

#

give it a read

toxic siren
earnest phoenix
#

Debugging is a murder mystery where you're the victim, the detective and the murderer

Love that

steady saffron
deft wolf
#

It should work but not in this case I guess peepoShrug

slim gate
#

Hey, I use NodeJS, and i can execute my bot commands in channels where he can't see (he don't have the permission ViewChannel), how to make him handle that ? He gives me DiscordAPIError[50001]: Missing Access

lyric mountain
#

like this

#

in html head

lyric mountain
#

or for promises .except()

slim gate
lyric mountain
#

is your bot crashing on error?

#

or does it just log to the console?

slim gate
#

yup it crashes

lyric mountain
#

ok, then u dont have a global catch, good

slim gate
slim gate
lyric mountain
#

are you using some sort of command handler?

slim gate
#

like one file for one command?

lyric mountain
slim gate
#

client.commands = new Collection();
const commandsFoldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandsFoldersPath);

for (const folder of commandFolders) {
    const commandsPath = path.join(commandsFoldersPath, folder);
    const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
    for (const file of commandFiles) {
        const filePath = path.join(commandsPath, file);
        const command = require(filePath);
        if ('data' in command && 'execute' in command) {
            client.commands.set(command.data.name, command);
        }
        else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}```
i think this is my command handler
lyric mountain
#

that's for registering them, idk how d.js cmd handler works, on my own I just put a try-catch where I call cmd.execute(), but that's in my case

slim gate
#

and on interactionCreate event, i have :

const { Events } = require('discord.js');

module.exports = {
    name: Events.InteractionCreate,
    async execute(interaction) {
        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 executing ${interaction.commandName}`);
            console.error(error);
        }
    },
};```
#

so i got the try {} catch {}

lyric mountain
#

on the global catch you could prevent the crash, but you'd not be able to send an error message on the console

lyric mountain
slim gate
#

yeah

#

but it still crashes

lyric mountain
#

a try-catch wont work there, since it's a promise

#

you need to use .except() after the execute

slim gate
#

i need to use .except ig

#

and itll be fine ?

lyric mountain
#

yep, the issue is that promise errors happen in another execution, so the regular try-catch can't catch those

#

since for it, the execution is no longer there

slim gate
#

try catch doesnt mean anything here so?

lyric mountain
#

well, it's good to have

#

since non-promise errors might happen

#

and those wont reach .except()

slim gate
#

okay thanks a lot!!

#

learnt smth new today lol

lyric mountain
#

do add a global catch tho, so your runtime doesnt crash from tiny errors

wheat mesa
lyric mountain
lyric mountain
wheat mesa
#

Am I missing something or do u mean .catch

neon leaf
#

its .catch

lyric mountain
#

.catch it is then

slim gate
#

oh okay

lyric mountain
#

I hate how I work with 3 different js-like langs and each has their own names KEKW

lyric mountain
slim gate
#

idk why i didn't learnt python and i wanted to make it in js too 💀

lyric mountain
#

with a global catch u can handle the exception

slim gate
#

but where am i supposed to put this global

lyric mountain
#

in your index.js

#

as in, the first file executed

slim gate
#

it looks like that

#
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

client.commands = new Collection();
const commandsFoldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandsFoldersPath);

for (const folder of commandFolders) {
    const commandsPath = path.join(commandsFoldersPath, folder);
    const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
    for (const file of commandFiles) {
        const filePath = path.join(commandsPath, file);
        const command = require(filePath);
        if ('data' in command && 'execute' in command) {
            client.commands.set(command.data.name, command);
        }
        else {
            console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
        }
    }
}

const eventsFolderPath = path.join(__dirname, 'events');
const eventFolders = fs.readdirSync(eventsFolderPath);

for (const folder of eventFolders) {
    const eventsPath = path.join(eventsFolderPath, folder);
    const eventFiles = fs.readdirSync(eventsPath);
    for (const file of eventFiles) {
        const filePath = path.join(eventsPath, file);
        const event = require(filePath);
        if (event.once) {
            client.once(event.name, (...args) => event.execute(...args));
        }
        else {
            client.on(event.name, (...args) => event.execute(...args));
        }
    }
}

client.login(token);```
#

it just registers commands right ?

#

and events

#

so i don't really understand where it executes them

lyric mountain
#

yep, somewhere there add the uncaughtException event handler

slim gate
#

oh wait

lyric mountain
#

shouldn't matter where

slim gate
#

i know what it is

lyric mountain
#

just dont simply mute the errors, let them stay verbose so u dont ignore them

#

then fix them when you can

slim gate
#
process.on('uncaughtException', function (err) {
  console.log(err)
});```
lyric mountain
#

yep

#

console.error tho

slim gate
#

isnt that the same?

lyric mountain
#

.error uses ERROR level and is more apparent

#

.log uses INFO level, and is meant just for informational log

slim gate
lyric mountain
#

you should lul

slim gate
#

nobody really use it

#

i need to wait topgg to validate it etc

lyric mountain
#

I mean, you're the one supposed to be seeing it

#

not the users

#

the console I mean

slim gate
#

yeah i know

#

but for error appear in console, users need to use the bot KEKW

lyric mountain
#

ah

slim gate
#

but i mean, missing permissions is the only error i encountered

#

and it's in very specific conditions, so not fixable lol

lyric mountain
#

in those cases u should check beforehand and send on the channel so the executer knows it's missing perms

slim gate
#

it do it lol

#

and i dont really understand why

#

cause the bot isn't supposed to see the channel

lyric mountain
#

well, it needs to to be able to interact with it in any way

slim gate
#

it's a channel for admin only

#

and my bot isn't in it

#

but it can still answer etc

eternal osprey
#

i can't clear all this channel gotta be the hardest shit i ever heard

steady saffron
sage bobcat
#

One message removed from a suspended account.

solemn latch
#

@midnight valve No ads please

pearl trail
#

want a break from the ads?

slim gate
#
  • im pretty young lol
unique heron
#

Need app testers for my discord bot, wont take too long just need to enter commands, report any discrepancies, make a list of commands that need work and give feedback. Need 4-5 people. DM me if you are free and Interested.

And also, this is just voluntary help i am asking for so please dont ask for money T_T

lyric mountain
#

just need to enter commands, report any discrepancies, make a list of commands that need work and give feedback
Need 4-5 people
you want a literal QA team

unique heron
#

T_T

#

but i dont even have money for the hosting T_T

lyric mountain
#

btw mods will warn you the moment they see that message

unique heron
#

oh?

#

invite link?

lyric mountain
#

yep, and looking for testers

unique heron
#

what should i do then?

lyric mountain
#

well, if you have users then they'll kinda test them for you already

#

just setup proper logging to report errors to you

unique heron
#

the issue is that i want to make sure everything baseline works then i can start advertising and putting it on top.gg

lyric mountain
#

if it passed verification then you're good to go

unique heron
#

?

lyric mountain
#

topgg verification

unique heron
#

oh

lyric mountain
#

the bar is very low for bots, dont be afraid to fix/implement things along the way

#

very few software launches bugless

unique heron
#

the biggest issue i have is that i am building a game system and a lot of thought needs to be put in that, a lot of logical loopholes etc.

#

so that needs testing and i alone am not enough

#

also i have spent so much time on this that i have started to become lazy -_-

lyric mountain
#

ik, I also made a game for my bot, sadly the best way until you have enough users is to do it yourself

unique heron
#

T_T

#

sad

lyric mountain
#

once users start gathering you can open applications for a tester team

unique heron
#

hmm

#

ok i guess i'll hav to do it myself

lyric mountain
#

just launch it as-is, fix bugs as they happen

unique heron
#

ok

lyric mountain
#

depending on what kind of game you created it'd be impossible to find every bug yourself anyway

unique heron
#

hmm

#

its kind of basic - exploring, gathering, battles, pets etc. really common stuff

lyric mountain
#

not as common as you'd imagine, most game bots are just cookie clickers or simple pokemon-like (with just attack/defend buttons)

#

you're already above the average if you have more than that

unique heron
#

oh ty

#

first i'll complete the all command version then i'll try to get into the nitty-gritty

wheat mesa
#

Bugs are a part of software. No project is ever complete

unique heron
#

true

#

i had a bot earlier as well but the update to d.js v13 f'ed it up

primal fog
#

Hey fellow bot developers. Quick question since I am about to launch my bot, how much is the exposure with your bot being in the "new section" of topgg?

#

I will be trying for trending but I dont think I will have enough userbase to support that

unique heron
#

but still if anyone wants to help with app testing, please dm me 🙂

lyric mountain
primal fog
lyric mountain
#

I mind

primal fog
#

How would you recommend to start the growth?

#

To break into trending you will need 20-30ish votes to begin with

#

After that it's easier as word of mouth does the trick

lyric mountain
#

well, the slower but steady way would be to bring the bot in topic when the conversation allows

#

the probably faster but gamble-y way would be to bid on spots

primal fog
#

Its a mini game. Its not another AI, waifu or anime or pokemon game

lyric mountain
#

It's the same for every bot, or product in general. Just have the presentation be good enough to grab people's attention

#

If you were looking for a bot, what would make you look at your bot?

#

The answer to this is what you need to do to gather more users

primal fog
#

Valid points

#

Thanks

lyric mountain
#

And always remember, the first 20 words are the most important of your description

#

If they fail to grab the attention then they'll likely move to the next bot

primal fog
#

Do you have your bot listed?

lyric mountain
#

yep

slim gate
#

hi, i have a discord bot who use puppeteer. i tried to host it on koyeb, but i get this error when puppeteer is needed


Instance created. Preparing to start...
Instance is starting... Waiting for health checks to pass.
Listening to health check on port 8000
Ready! Logged in as Crackwatch#4718

Error executing search
Error: Could not find Chrome (ver. 130.0.6723.69). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: /app/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (/workspace/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserLauncher.js:292:27)
    at ChromeLauncher.executablePath (/workspace/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:210:25)
    at ChromeLauncher.computeLaunchArguments (/workspace/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:91:37)
    at async ChromeLauncher.launch (/workspace/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserLauncher.js:71:28)
    at async search (/workspace/commands/all/search.js:7:18)
    at async Object.execute (/workspace/commands/all/search.js:123:16)
    at async Object.execute (/workspace/events/required/interactionCreate.js:16:4)

#

someone got an idea ?

#

(doing the npx command in the console doesn’t work too)

lyric mountain
#

did you try reading the guide mentioned there?

deft wolf
lyric mountain
#

most errors usually explain themselves at the very first few lines

slim gate
#

nothing what can help me

lyric mountain
#

did you install the puppeteer browser as directed by the script over there?

eternal osprey
#
async function createButtons(allNames: string[]): Promise<ActionRowBuilder[]> {
  let rows: ActionRowBuilder[] = [];
  let currentFill: number = 0;
  let currentRow: ActionRowBuilder = new ActionRowBuilder();
  for (let i = 0; i < allNames.length; i++) {
    if (currentFill == 5) {
      rows.push(currentRow);
      currentRow = new ActionRowBuilder();
      currentFill = 0;
    }
    currentRow.addComponents(
      new ButtonBuilder()
        .setCustomId(`${allNames[i].toLowerCase().trim()}`)
        .setStyle(ButtonStyle.Secondary)
        .setLabel(`${allNames[i]}`)
    );
    currentFill++;
  }
  return rows;
}

async function sendAndSave(
  allNames: string[],
  channel: GuildChannel,
  Embed: EmbedBuilder,
  status: any
) {
  if (channel.isTextBased()) {
    const rowArray: ActionRowBuilder[] = await createButtons(allNames);
    let sentMessage = await (channel as TextChannel).send({
      embeds: [Embed],
      components: rowArray,
    });
    status.status = sentMessage.id;
    fs.writeFileSync("./status.json", JSON.stringify(status), (err) => {
      if (err) console.log(err);
    });
  } else {
    console.error("Channel is not a text-based channel.");
  }
}```
pretty long one.
Why do i have an error that ```js
Type 'ActionRowBuilder<AnyComponentBuilder>[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | ```
#

I swear TS combined with Discord api is literal cancer

lyric mountain
#

why not just java

unique heron
#

isnt java a pain to handle?

sharp geyser
#

That's why they use cups

#

You aren't meant to touch it with your bare hands

lament rock
#

such a dumb joke lmao

lyric mountain
#

some say it's a pain cuz it enforces very strict typing, but I find that to be an upside

scenic kelp
#

i whine about it all the time cause it feels like it hasn't kept up with the features of modern languages

#

doesn't have string templating, doesn't have async/await, uses type erasure for generics so making T[] arrays is a pain, etc

lyric mountain
#

doesn't have string templating
it does on java 22 (in preview atm - https://openjdk.org/jeps/459)

doesn't have async/await
well, we have futures instead, java doesn't use event thread so async/await wouldn't work anyway

scenic kelp
#

> C#

#

C# compiles async/await into a state machine

scenic kelp
wheat mesa
#

As much as I love C#, the reason it’s able to have all these features over java is that it took the stance of being adaptable. Java is very set in stone because they don’t want to mess with their standards all the time. It can be verbose, but it is very consistent

scenic kelp
#

which is fair but i absolutely still have the right to complain about it

#

f u java

wheat mesa
#

Java hasn’t changed a lot in the last 20 years, which is another reason why I think it’s a great language to learn on. There’s no new “best practices” coming out with every new release. That’s something that C# does a lot, which is great for those people paying attention to the changes but not so great for legacy code that should be rewritten

scenic kelp
#

there's a balance to be struck between feature creep and being stuck in stone though

#

C# pushes too far one way and Java too far the other

wheat mesa
#

I see C# as the experimental ground for language features that other languages may choose to implement later, it’s very bleeding edge and it’s constantly having something new added. Not a bad thing, just depends on your circumstances

lyric mountain
primal fog
#

When starting out what stats should i track. Users & Servers should be more than enough right

#

Or should I track invite origin as well? (App, directory, topgg etc)

harsh nova
lyric mountain
#

not only is it inaccurate, but it wont tell how many USERS you have either

#

command usage + invite origin + servers are the ones that are useful

primal fog
#

By users I meant records in my database

lyric mountain
#

seconds per command might be relevant too

primal fog
#

so people who have interacted with the bot

lyric mountain
#

interacted as in used a command? or do you have XP/currency system?

primal fog
#

No its a mini game not a moderation bot

#

Interacted as of having complete >5 levels

#

which is 10min of gameplay

lyric mountain
#

ok, then it's a relevant stat

primal fog
lyric mountain
#

how many seconds a command took to execute

primal fog
#

To point out bottlenecks

#

makes sense

vivid fulcrum
#

I'm still siding towards C# as my favorite though, love the advancements in the native AOT

earnest phoenix
#

One thing I find funny about C# is that sometimes people don't need to comment code because the function names are comments already

prime cliff
#

vibecat Not even portainer has support for docker plugins but now i do

prime cliff
scenic kelp
#

also named parameters can help SO much with readability

earnest phoenix
lyric mountain
#

it depends, for js it'd be impossible for the ide to guess

prime cliff
#

^

earnest phoenix
#

yeah because it's js and it sucks, but that's a language issue so no ide can do anything against it

#

say you use ts, you get the same

lyric mountain
#

well, yes that's the whole point of ts

earnest phoenix
#

just like any typed other language

#

no honestly nothing really something cool about c tic tac toe tbh

#

that's just the ide doing fancy stuff because the language is typed

#

and the function names being comments was more a meme about them being super long

vivid fulcrum
#

I usually see that in Java

#

naturally verbose

prime cliff
#

Depends how you want to use those functions instead of long parameters you could create them as builder methods like what discord.net does with embeds

new EmbedBuilder()
  .WithTitle("Test")
  .WithDescription("Hello");
lyric mountain
#

pretty much the same as JDA lul, but set instead of With

dry frost
#

how me changes my discord bot profile in top gg?

warm surge
dry frost
#

tq

#

if guys need website for bot u can see in my repo include mdx blog

prime cliff
#

REEEEEEEEEEEEEEE Whoever though this was a good design choice in docker is a masochist

unique heron
#

O_O ew

surreal sage
#

somehow, my tauri project's setup exe

#

has the same sha256 hash

#

as a probable trojan

deft wolf
lyric mountain
#

happened with me too, one of our company apis is flagged as trojan by windows

eternal osprey
#

hahahah i had the same shit was fun to encounter.

quartz kindle
#

add random semicolon somewhere in the code, recompile, done

#

:^)

pearl trail
#

const ; val = 5;

lyric mountain
#

in a perfect world, the code wouldn't let you compile because it's clearly an error

but js isn't perfect world, so it executes anyway

prime cliff
#

vibecat Now this is how you do a permissions system

outer crater
#

I want color of this to be #3b3f8c I tried applying filter to image but didn't turned good? is there any method or online tool to this thing? sorry I'm not a math guy.

filter: invert(30%) sepia(67%) saturate(275%) hue-rotate(190deg) brightness(95%) contrast(90%);
lyric mountain
outer crater
lyric mountain
#

well, you'll need to fiddle with the values till the color reaches what you want

#

it'll take a while of trying

outer crater
toxic siren
split bane
#
import { VoteUser } from './VoteUser';
import { getCollection } from '../mongo';
import { addEvent } from '../functions';

module.exports = async (data: VoteUser) => {
    await getCollection("votes").findOneAndUpdate({
                    id: data.user_id
                  }, 
                  { "$set": {
                     votes: {
                        at: Date.now(), 
                        source: data.source
                     }
                  }
              }, 
              {
                  upsert: true, 
                  new: true
              }
    );
    addEvent({
        type: "vote",
        command: "vote",
        source: data.source
    });
}
#

can anyone help with this

#

nothing gets added

deft wolf
#

Because your database is empty

split bane
deft wolf
#

findOneAndUpdate looks for a document and updates it. It won't update the document if it doesn't find it because it doesn't exist

split bane
#

if the person does not exist

deft wolf
#

The code you sent doesn't indicate this

split bane
#

wait thats jnust event logging

#

im stupiud

split bane
# deft wolf The code you sent doesn't indicate this
import { VoteUser } from './VoteUser';
import { getCollection } from '../mongo';
import { addEvent } from '../functions';

module.exports = async (data: VoteUser) => {
    const result = await getCollection("votes").findOneAndUpdate(
        { id: data.user_id },
        { 
            "$set": { 
                votes: { at: Date.now(), source: data.source }
            }
        },
        { 
            upsert: true, 
            returnDocument: 'after' 
        }
    );

    // make new thing here
    if (!result.value) {
        await getCollection("votes").insertOne({
            id: data.user_id,
            votes: { at: Date.now(), source: data.source }
        });
    }

    addEvent({
        type: "vote",
        command: "vote",
        source: data.source
    });
}
#

still doesnt work

delicate zephyr
deft wolf
#

Ok

delicate zephyr
#

But yea, it should work

#

However it may be better to check it exists first then create or update instead

surreal sage
#

chatgpt just thought xyz is xzy

#

smh

radiant kraken
#

can someone help explain how this outputs 4? @pearl trail @lyric mountain @wheat mesa ```c
#include <stdio.h>

int main() {
int a = (25, 4.61);
printf("%d\n", a);

return 0;

}

#

found this question in the C basics quiz (that i failed 😭) and i really need to know how this works because i'm about to have final exams next week topggSob

pearl trail
#

it takes the last value

#

which is 4.61

#

then converted to int, which is 4

radiant kraken
#

wait is it just that

pearl trail
#

yes

radiant kraken
#

BRUH i failed to this

#

😭

#

i suck at c

pearl trail
#

try int a = (25, 5.61); it'll return 5

pearl trail
radiant kraken
#

well my grades state otherwise

#

😔

#

like i hate my professor so much

#
// omitted scanf

for (int i = 0; i < n; i++) {
  if (data[i] == input) {
    printf("The data is in index no. %d\n", i + 1);
    break;
  }
}

Given a data with the size of 10 and the inputs of 12, 14, 15, 16, 15, 14, 11, 10, 15, 17.
In which index is the number 15?

A. 2
B. 2 and 4
C. 3, 5, and 9
D. 2, 4, and 8

#

what is the answer to THIS??????

#

even IF you know what indexes are or you understand everything, you still wouldn't be able to answer it properly

#

i answered 3, 5, and 9 but i don't think i got it right because my grades are shit

#

i don't know they never tell me in WHICH questions i got wrong

#

ffs

#

😭

pearl trail
#

should be D imo

#

it doesnt ask "in which index based on the printed text is the number 15"

#

¯_(ツ)_/¯

frosty gale
radiant kraken
radiant kraken
#

its so annoying

frosty gale
radiant kraken
#

he would put the most cursed code in a quiz for a C basics lecture

frosty gale
#

it allows for stuff like
int a = (printf("this is supposed to be 50 ig"), 50);
but you can just do

printf("this is supposed to be 50 ig");
int a  = 50;  
#

saves a line maybe

pearl trail
#

one liner 😍 😍 😍

radiant kraken
#

why tf would anyone write like that 😭

#

js basics quiz:

what does this output ```
[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]]

frosty gale
#

most clear JS code

radiant kraken
#

boom everything in one line

pearl trail
#

pro code

radiant kraken
rose relic
queen needle
quartz kindle
lament rock
#

Everyone else is sane and starts at 0

lyric mountain
#

Sql

prime cliff
#

😔 This is so much better than Portainers current "roles" system

lyric mountain
#

not really

#

you can kinda guess the raw value tho

#

varchar takes 2+n bytes, boolean takes 1 byte zoneless timestamp takes 8 bytes and idk what a loader_type is

#

4 bytes then

#

postgres is fine

#

but wdym "lots of rows"? what will that table store?

#

that sounds very wasteful tbh

#

but that table wouldn't have which launcher was used right? only which loader

#

wouldn't it be better to assign an unique id to each player (hashed) and then update their entry with the last played date instead?

#

like, a composite key with (id, mc_version) since some people play multiple versions

#

at least you limit it to a few rows per player, instead of unbounded

#

that's true

unique heron
#

Pls help me

wheat mesa
#

Thank you for asking a specific question and indicating what your problem is

raven nexus
#

i have question i am trying to create /reload ping without to put .js and it show out the command not found

the structure are in
commands/subfolder/command.js

here is the code

const { ApplicationCommandType } = require('discord.js');
const fs = require('fs');
const path = require('path');

const commandsDir = path.join(__dirname, 'command'); 

module.exports = {
    name: 'reload',
    description: "Reloads a specific command file.",
    type: ApplicationCommandType.ChatInput,
    options: [{
        name: 'command',
        description: 'The name of the command to reload (without .js)',
        type: 3, 
        required: true
    }],
    run: async (client, interaction) => {
        const commandName = interaction.options.getString('command'); 
        await interaction.deferReply(); 

        try {
            const commandPath = path.join(commandsDir, `${commandName}.js`);

            if (!fs.existsSync(commandPath)) {
                return await interaction.editReply(`Command "${commandName}" not found.`);
            }

            if (client.commands.has(commandName)) {
                client.commands.delete(commandName);
            }

     
            delete require.cache[require.resolve(commandPath)];
            const command = require(commandPath); 
            client.commands.set(command.name, command); 

            await interaction.editReply(`Successfully reloaded the command: ${commandName}`);
        } catch (error) {
            console.error('Failed to reload command:', error);
            await interaction.editReply('There was an error while reloading the command.');
        }
    }
};

it give me result command not found
what did i do wrong ?

lyric mountain
#

does it say command not found or Command "" not found.?

eternal osprey
#

hey guys is anyone here familiar with the Gale-Shapley Algorithm

frosty gale
#

so my attention was diverted

coral pagoda
earnest phoenix
frosty gale
#

its already been debunked they have enough money to last for a long while

frosty gale
#

thought it was a bit odd they include the exact day in the message but thats fully intentional

coral pagoda