#development

1 messages · Page 182 of 1

lyric mountain
#

just call it kevin and call it a day

slim heart
#

real

#

dismissible content?

#

maybe

queen needle
pale vessel
#

everyone just calls it announcement banner

#

it looks exactly like you described

slim heart
#

yeah

#

alright

#

thanks everyone

tulip ledge
#

I have a discord channel in the support server where a message gets sent if someone votes

deft wolf
#

Another way may be to send a "vote reminder" each time a command is used in a row. I've seen a lot of bots do something like this

#

It's probably not that pushy because they use commands anyway

slim heart
#

omg

#

@pale vessel @queen needle @lyric mountain it’s a nagbar

deft wolf
#

What a strange name kappalul

lyric mountain
#

brilliant

hidden gorge
#

cant find the VC i dont know why

 else if (DevCode === "hooligang") {
                const VCID = "1185235397266116611";
                const Song = path.join(__dirname, "../../assets/dev/hooligang.mp3");

                console.log("Attempting to join voice channel and play audio...");

                try {
                    const guild = await client.guilds.fetch(interaction.guildId);
                    const channel = guild.channels.cache.find(ch => ch.id === VCID && ch.type === 'GUILD_VOICE');

                    if (channel) {
                        console.log("Voice channel found:", channel.name);

                        await interaction.reply("Joining voice channel and playing audio...");

                        const connection = await channel.join();
                        console.log("Connected to voice channel.");

                        connection.play(Song, { volume: 1.0 });
                        console.log("Audio played successfully.");
                    } else {
                        console.log("Voice channel not found.");
                    }
                } catch (error) {
                    console.error("Error:", error);
                }
            }
#

ok now its saying this but the channel is valid

wheat mesa
#

You don’t need to use .find here

#

Just use .get('ID')

#

Channels are not always cached as well iirc

#

Fetch the channel

#

When in doubt, fetch it out

hidden gorge
#

thanks @wheat mesa

#

i updated it to use @discordjs/voice

#

new bug:

Bot joins VC but doesn't play audio

const { SlashCommandBuilder, Client } = require("discord.js");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, VoiceConnectionStatus, entersState, StreamType } = require("@discordjs/voice");
const path = require("path");
const { createReadStream } = require("fs");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("devcode")
        .setDescription("[RoSearcher Developer Command]")
        .addStringOption(option =>
            option
                .setName("code")
                .setDescription("Dev Code")
        ),

    /**
     * @param {Client} client
     */
    async execute(interaction, client) {
        const DevCode = interaction.options.getString("code");
        if (interaction.user.id === "919674489581731842") {
            if (DevCode === "dancing") {
                interaction.reply("https://cdn.discordapp.com/attachments/1191594940103413843/1201633679559106601/738440555e611e49c51b3c2bebed6edb.mp4?ex=65ca8792&is=65b81292&hm=14e0f702b249d5b9c4f444ab6044e7ff66e1dd926b56dfe008c41569a2ee4745&");
            } else if (DevCode === "boo") {
                interaction.reply("https://cdn.discordapp.com/avatars/972502840247484527/6cc277505fcd2b642936883acceccdce.png?size=1024");
            } else if (DevCode === "hooligang") {
                const VCID = "1185235397266116611";
                const audioFilePath = path.join(__dirname, "../../assets/dev/hooligang.mp3");

                console.log("Attempting to join voice channel and play audio...");

                try {
                    const channel = interaction.member.voice.channel;

                    if (channel) {
                        console.log("Voice channel found:", channel.name);

                        const connection = joinVoiceChannel({
                            channelId: channel.id,
                            guildId: interaction.guildId,
                            adapterCreator: interaction.guild.voiceAdapterCreator,
                        });

                        connection.on(VoiceConnectionStatus.Ready, async () => {
                            console.log("Connected to voice channel.");

                            const player = createAudioPlayer();
                            const resource = createAudioResource(createReadStream(audioFilePath), {
                                inputType: StreamType.Arbitrary,
                            });

                            player.play(resource);
                            connection.subscribe(player);

                            try {
                                await entersState(player, VoiceConnectionStatus.Playing, 5000);
                                console.log("Audio played successfully.");
                                interaction.reply("Joining voice channel and playing audio...");
                            } catch (error) {
                                console.error("Error playing audio:", error);
                            }
                        });

                        connection.on(VoiceConnectionStatus.Disconnected, (err) => {
                            console.error("Disconnected from voice channel:", err);
                        });
                    } else {
                        console.log("User is not in a voice channel.");
                        await interaction.reply("You need to be in a voice channel to use this command.");
                    }
                } catch (error) {
                    console.error("Error:", error);
                }
            }
        } else {
            await interaction.reply("You do not have permission to use this command.");
        }
    }
};
winged linden
#

Yoo questions

#

When do you guys believe i should start sharding?

flat yew
#

Bruh

#

WHERE DO I GET HELP FOR A RCE KILLFEED BOT

#

“Oh their discord is great they’re always lending a helping hand” IVE BEEN HERE FOR HOURS AND THIS ENTIRE DISCORD DOESNT EVEN MENTION RUST WTF

deft wolf
lament rock
# winged linden When do you guys believe i should start sharding?

Depends on what type of bot you have and your architecture.
If you're running into issues where 1 thread isn't able to process ws messages then either your gateway wrapper sucks or you have expensive logic and that's when you should shard. Benchmark it
Having to process MESSAGE_CREATE is a huge performance hit and if you can avoid it, do.

deft wolf
lament rock
#

discord.js (just using it as an example) is also a pretty bad architecture because they make use of the ws module. Thanks to good ol Tim, the gateway wrapper I maintain has a slimmed down ws implementation with its own fast etf encoder and decoder. Not plugging, just saying that your libraries play a big part of your performance and it's good to take heapdumps and run timings

#

I used djs before and ran into horrible event loop lag because of processing a ton of message creates. This was at around 7k+ guilds 3 shards

#

Now I can put all of my shards on a cluster on the same thread and things are a-o-good

#

Though I also dont have to process message creates

winged linden
winged linden
#

I am using djs💀

lament rock
winged linden
lament rock
radiant kraken
#

@wheat mesa me when my rust struct is not CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, _>, _>, _>, _>, _>, OidSha256>> 😔

sharp geyser
#

What in the actual fuck

radiant kraken
tawny lava
#

I mean they are the wrong types xd

lyric mountain
#

Uint<Uint<Uint<Uint<Uint<Uint<>, _>, _>, _>, _>, _> lmao

#

what even is the reason for such deep nesting?

harsh aspen
#

Anyone knows how vote reminders logic work?

deft wolf
#

There are probably several ways to do this

harsh aspen
#

can you tell me 1

deft wolf
#

The most logical way is to take the date from the webhook when the user voted for your bot and then add 12 hours to this date and, for example, check the database every few minutes for timestamps that have already passed, i.e. 12 hours have passed since the vote

lyric mountain
#

check every hour, then schedule all reminders within that hour as setTimeouts

#

this way u access the db only once

deft wolf
harsh aspen
#

I'm thinking about just setTimeout when the user votes
and schedule all reminders again If I restarted the bot
does this work or will consume more resources?

lyric mountain
#

consumes more

#

because you'll do an extra operation

harsh aspen
thorny cargo
#

can somebody help, I implemented this code so I can ush emojis into my db, but I am frasturated, any way I can add a check for default emojis ? :

    await Promise.all(
      emojis.map(async (emoji) => {
        const match = emoji.match(/(?:<a?:)?(\w+):(\d+)>?/);

        if (match) {
          const emojiName = match[1];

          console.log("Emoji Name:", emojiName);

          const emojiValid = interaction.guild.emojis.cache.find(
            (emoji) => emoji.name === emojiName
          );
          if (emojiValid) {
            await abot.db.push(`autoreact_${interaction.guild.id}`, {
              emojis: emoji,
            });
            interaction.editReply({ content: `Added ${emoji}` });
          } else {
            interaction.followUp({
              content: `emoji ${emoji} is not a valid emoji, I cant find it!`,
            });
            return;
          }
        }
      })
    );
#

cant find anything in the docs

wheat mesa
#

Please don’t use an async function inside of a map

lyric mountain
#

that is, if you're saving unicode emojis on the db

thorny cargo
thorny cargo
quartz kindle
#

async map combined with promise.all is a totally valid use case, nothing wrong with it

wheat mesa
#

Really?

#

I was under the assumption you never combined an async function inside of map

quartz kindle
#

using async inside of a map will essentially convert all items into promises

#

there are many use cases for that

wheat mesa
#

Perhaps I was thinking of people doing await something.map(async x => …)

quartz kindle
#

yeah that doesnt really do anything

wheat mesa
#

Since that await wouldn’t stop anything

quartz kindle
#

also those weirdoes that use map like a foreach

#

without using the return value

spark pebble
#

Random question, can you link commands, in an embed?

pale vessel
#

yes, you can

spark pebble
lament rock
#

One of the devs I worked with on my bot sent this

wheat mesa
#

people trying to use rust-level type theory in ts

#

lol

lament rock
#

They do know rust, but :)

#

Thats probably how I'd do it

#

also thats just jsdoc not ts directly. Ik jsdoc is backed by ts but

quartz kindle
#

sounds like excessive typing

lament rock
#

They avert ts because they want to skip the build step. It also complicates the file tree sometimes when there is a build step involved since we also wrote our own hot reloader and make use of it heavily so something like minification isn't an option

#

Ive also had it happen where ctor names are changed between builds

green kestrel
#

getting people inviting and kicking my bot repeatedly, this happened on a previous bot too, they invite it keep it for 30 or so seconds without doing any commands or anything then kick it,.then they repeat maybe ten times, sometimes it ends with the bot staying other times not.

I don't think they just didn't like the features as they didn't try any,.I'm thinking something like wick is fighting the inviter.

has anyone else seen this, I've seen it on several bots now and it's annoying from a retention standpoint.

deft wolf
#

It probably happens in a lot of cases, but no one pays much attention to it

#

I don't know what could be the reason for this, but let's just say that I wasn't even that interested in it

#

Situations like this are an everyday occurrence and it doesn't surprise me after a year

distant basin
#

hey can i force a user to be in specific color in my bot page? from this.
i asked that in the support channel so i know that i can do that using css but like how can i do that?
didnt see this channel so maybe someone here knows

green oxide
#

yo, is it not allowed to save recently deleted message in temporary cache

lyric mountain
#

according to discord, no

green oxide
#

dayumn

#

thats sad

lyric mountain
#

lemme guess, you were making a snipe command

green kestrel
#

you can output it to a log channel

hidden gorge
#

Quick question anyone know a good service to accept payment for a premium system?

hidden gorge
#

which idk

green kestrel
#

so do you want people to trust you to enter their details into your site and take money from them

#

or do you want to stay anonymous? there are no legit anonymous real businesses

hidden gorge
#

i mean like i dont know my own SSN

green kestrel
#

well you'll need it

hidden gorge
#

i can ask

green kestrel
#

for a great many things

#

also you need to be an adult

#

I assume you are, right?

#

you can't sign the contract and get merchant accounts and stuff <18

wheat mesa
green kestrel
#

no go then unless you get a parent or legal guardian to administrate the business side for you

#

this is one of many reasons you don't meet many 14 year old business owners

#

that and if your bot takes off running the business side takes a fair bit of free time

polar pewter
#

Beautiful flags on the website :3

#

I get that I'm probably missing noto-fonts-emoji package or whatever it's called

#

no wait it's installed

#

intereseting

lyric mountain
#

imagine wanting nitro

#

right @harsh nova?

harsh nova
#

thx

lyric mountain
#

try seeing if there's any error in F12 menu

deft wolf
hidden gorge
wheat mesa
#

Could’ve sworn I remember you saying you were 14 like not too long ago

#

Either way still too young for a stripe account

quaint rampart
#

does anyone know any good wake word engines out there? i attempted using Picovoice but when using it with Discord audio it’s not very accurate although on the browser it is.

#

i’ve also attempted to use Snowboy but it’s too outdated, couldn’t even get it to work due to a billion deprecated things and i don’t think it would be very practical

tulip ledge
# hidden gorge im 16..

Yeah you wont be able to legally charge money from people I had to wait to turn 18 before being able to use those services

#

Stripe needs you to be 18

#

Discord aswell

#

You need to be of legal age to sign conttacts, since you essentially are

#

So you’ll have to get a guardian to do that for you

arctic arch
polar pewter
#

I think the python version is cleaner, on the right is the old JS one and on the left is new Python version which is part of a rewrite

lyric mountain
#

they'll both end the same tbh

#

the extra lines are the fields TS side has that py doesnt yet

sharp geyser
#

pythons syntax was made so that 5 year olds can understand it

hot sleet
#

is there any guide of how to make html for long description

my html code just don't show right when i review the page!

lyric mountain
#

any html tutorial in general

#

dont use <body> or <head> tags tho

#

they'll prevent the inner code from working

polar pewter
radiant kraken
lament rock
lyric mountain
#

and those replaces could be swapped for map + loop

#

and as FaKe always said, just use the embed constructor instead of method chaining

solemn latch
#

👀 also a typed language vs a non typed language.
While those checks all happening inside TS are not entirely strictly necessary here they in theory make the code safer and less likely to error.

Since the post is about clean code, I personally would suggest making a getMemberJoinSettings function.

You'll need to get those settings at other points in your code anyway, and adding a function to handle getting them all will make it easier to add other potential settings later on.

#

But that suggestion is a personal preference. Not everyone likes going that route.

lyric mountain
#

you think very java

#

I like you woo

wheat mesa
#

Valid

lament rock
#

I don't think it's just a Java thing. Having it be in a function would mean JIT can happen faster for that code

knotty quartz
#

hi

quaint rampart
#

does anyone know any good wake word engines out there? i attempted using Picovoice but when using it with Discord audio it’s not very accurate although on the browser it is. i’ve also attempted to use Snowboy but it’s too outdated, couldn’t even get it to work due to a billion deprecated things and i don’t think it would be very practical

solemn latch
#

👀

solemn latch
#

With the price of picovoice I assume this is a one off single server bot, or a public bot which will be paid and will likely be intended for large communities. would requiring a high bitrate voice channel be a viable solution instead?

#

You may also want to just play around with the wake word you choose, could be more reliable

sharp geyser
#

I mean I get it

#

but no way should someone be using that in a bot

#

unless they for sure know its going to succeed

stiff dust
#

Hello, I have a cache DB and a Data Base in MongoDB now data is what I save in my cache and data[db[subCommandGroup] could be feature_auto_thread_channels or feature_auto_publish_channels now I know how to update it in cache but don't how to update it in DB and what should I write instead of AAAAA the only way I know is updating both of them like the second code

data[db[subCommandGroup]].splice(index, 1); // Update in Cache

await guildsModel.updateOne(                // Update in DB
    { guild_id: interaction.guild.id },
    { AAAAA: data[db[subCommandGroup]] }
);
data[db[subCommandGroup]].splice(index, 1); // Update in Cache

await guildsModel.updateOne(                // Update in DB
    { guild_id: interaction.guild.id },
    {
        feature_auto_thread_channels: data.feature_auto_thread_channels,
        feature_auto_publish_channels: data.feature_auto_publish_channels
    }
);
novel snow
#

Running into an odd issue, simply put:

vc.permissionOverwrites.edit(interaction.guild.id, {Connect: null,});

This ignores setting the connect value to not have a specific override anymore, is there any other way to fix this?
Discord JS v14 btw.

queen needle
#

should it be connect not Connect?

novel snow
# queen needle should it be connect not Connect?

Nope, not sure why it does need to be Connect however, but that isn't the issue, it is that it accepts both true and false statements for the appropriate permission, so to allow or deny it specifically, however assigning it null will not set it to neutral in-between.

wooden ember
#

I wonder how long it would take to program a bot in assembly

#

would that even be possible since you would have to write everything down to various messaging protocolls

#

also this was supposed to be a responce to another message but discord did the thing where it didnt scroll to the bottom

#

oh well still an interesting thought

copper cradle
#

not really, you could use something like concord and not have to reinvent the wheel for the interaction with the api

copper cradle
wooden ember
#

yeah

#

what is concord?

#

other than the cool jet

copper cradle
#

it's a C discord api lib

wooden ember
#

theres a discord api in C????

copper cradle
#

the api is language agnostic, you just need to interact with it however you want

wooden ember
#

damn that means I could program an esp32 to host a discord bot

copper cradle
#

it's just a bunch of web requests, wanna write a bot in common lisp? Then use the API directly or find a library that does most of the heavy lifting for you or abstracts everything into a nice layer

wooden ember
#

sounds fun

copper cradle
#

yk what I'll do it out of sheer boredom

wooden ember
#

would be fun

#

lol

copper cradle
#

@wooden ember bot's online

#

the bot does nothing

#

it just connects to the gateway

#

but hey

#

it's written in assembly at least

#

I'm gonna make it respond to a ping command

radiant kraken
#

congrats

radiant kraken
copper cradle
#

I mean I don't plan on turning this into my next project

radiant kraken
#

just listen to a message event -> check if the message content is !ping -> respond with pong

copper cradle
#

yeah it's pretty simple

lament rock
#

cursed

#

Gateway and rest is pretty challenging if you follow the guidelines to the T even for something like JS

radiant kraken
#

he just used a C library and use it from assembly

lament rock
#

ah ok

copper cradle
#

^^^

#

I'm not gonna reinvent the wheel

lament rock
#

Not as impressive but still

radiant kraken
#

make the bot in C and then compile that C source into an assembly file sdTroll

copper cradle
copper cradle
earnest phoenix
#

can anyone help?

deft wolf
marsh bluff
#

Does anyone have recommendations or best practices on how to test new features of a verified bot? I am trying to test the discord premium app features, and I need to keep the stable version running, but also run another version for testing. Should I implement a testing mode where the testing version does not handle any interactions besides those of testing users?

eternal osprey
#

i am using bootstrap. On pc it's awesome but on here it isn't quite what i am looking for:

<section
    class=" mt-5 container-fluid d-flex align-items-center flex-column">
   
    <p class="text-dark fs-1 fw-bold text-shadow text-center mt-5 mb-0">Maak kennis met Sivas</p>
    <div class="container-fluid w-50" style="height: 3px; background-color: rgb(219, 172, 52);"></div>
   
    <p class="text-light fs-md-6 fs-lg-5 fs-xl-4 w-50 text-center m-5">
        Sfeerhaard Sivas brengt warmte en gezelligheid in elke ruimte. Met zijn moderne design en realistische vlammen creëert
        deze haard een sfeervol en ontspannen ambiance. De gebruiksvriendelijke bediening en energiezuinige technologie maken
        Sivas de perfecte aanvulling voor een comfortabele en stijlvolle atmosfeer.
    </p>```
wooden ember
wooden ember
#

even uses / commands

#

I expect they are easyer to code for these dayse since they have their own endpoint and dont have to scan every message but either way it works.

#

how much ram does it use?

radiant kraken
#

just a few bytes

timber hatch
#

does anyone know an efficient way or storing and retreiving user guilds using next auth? my current attempt is to:

fetch them from discord api upon login ->
store them in mongodb

then when a user goes to /manage for example, i would make a request to my nextjs backend to get the users guilds rom the db.

it works but i feel as though it's nowhere near the most efficient or good practice way of doing it

vivid fulcrum
#

i'd advise you not to store guilds

lyric mountain
#

Or any discord entity whatsoever

quartz kindle
#

imma store your mom

vivid fulcrum
#

make an API request to Discord whenever you need the data and then cache it temporarily on your frontend

if you store the guilds you'll also have to ensure that guild data is not stale (i.e. update the database if the user joined more guilds or left some)

copper cradle
#

the entire thing is using 182.076MB, so still quite a lot

#

but yeah, the main process itself uses just a few KBs

#

the rest are from the external libraries

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

fun

copper cradle
#

huh, pmap is reporting odd numbers, I might need to use a different tool

#

found the culprit

#

~35.9MB For the "assembly" bot
~113.9MB For the js bot <- run using node

stiff dust
sage bobcat
#

One message removed from a suspended account.

stiff dust
#

I want to create a command to refresh my commands so that way I dont need to restart bot to update a file so basicly I set command files in client.commands collection again but there is a problem!

my bot is sharded so if I use the command it will only refresh the commands for the shard I use the command on it

soooo I should use broadcastEval to run it in all shards

this is my code

await client.shard.broadcastEval(cli => {

    const fs = require('node:fs');

    fs.readdirSync('./commands/messages/').forEach(dirs => {
        const commands = fs.readdirSync(`./commands/messages/${dirs}`).filter(files => files.endsWith('.js'));
        for (const file of commands) {
            const command = require(`../../../commands/messages/${dirs}/${file}`); // Ignore this one
            cli.messageCommands.set(command.name.toLowerCase(), command);
            delete require.cache[require.resolve(`../../../commands/messages/${dirs}/${file}`)];
        };
    });

});

and I tried all of these:

const command = require(`../../../commands/messages/${dirs}/${file}`)
const command = require(`./commands/messages/${dirs}/${file}`)
const command = require(`../${dirs}/${file}`)
const command = require(`${__dirname}/commands/messages/${dirs}/${file}`);
const command = require(path.join(__dirname, 'commands', 'messages', dirs, file));

and for all of them I get errors like these:

Cannot find module '../../../commands/messages/admin/eval.js'
Require stack:
/root/VOID/node_modules/discord.js/src/client/Client.js
/root/VOID/node_modules/discord.js/src/index.js
/root/VOID/bot.js
Cannot find module './commands/messages/admin/eval.js'
Require stack:
/root/VOID/node_modules/discord.js/src/client/Client.js
/root/VOID/node_modules/discord.js/src/index.js
/root/VOID/bot.js
Cannot find module '/root/VOID/node_modules/discord.js/src/client/commands/messages/admin/eval.js'
Require stack:
/root/VOID/node_modules/discord.js/src/client/Client.js
/root/VOID/node_modules/discord.js/src/index.js
/root/VOID/bot.js

I asked in djs server and they told me this:

That‘ll not gonna work. that code will be evaluated inside the Client class. Which is somewhere deep in your node_modules folder.

so now I wanna know how can I refresh my commands without restart the bot thinKappa

quartz kindle
neon leaf
green kestrel
#

lol im at the devils number PES_Devil

surreal sage
#

i sure do love this

#

minor configuration error

spark flint
#

☠️ I’ve had that before

surreal sage
#

luckily there was literally no data

radiant kraken
#

is this mongo

surreal sage
radiant kraken
#

rip

deft wolf
#

Mongo even has its own article describing what actually happened

stiff dust
#

I installed latest Node JS Version on the VPS but when I use node --version it shows me

root@iTzLinux:~# node --version
v16.20.0

then I try to install it again and shows me this

root@iTzLinux:~# nvm install v21.6.1
v21.6.1 is already installed.
Now using node v21.6.1 (npm v10.2.4)

how can I delete all node js versions from my VPS and install latest one

stiff dust
# quartz kindle try ```js const command = require(`${process.cwd()}/commands/messages/${dirs}/${...

1 more question with this command I can refresh my commands and events
But there is a problem after this part all events will run twice how can I stop old eventns and start new ones? thinKappa

if (context.needToUpdate.includes('events')) {

    fs.readdirSync('events/').forEach(dirs => {
        const events = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));
        for (const file of events) {
            const event = require(`${process.cwd()}/events/${dirs}/${file}`);
            cli.on(file.split('.')[0], event.bind(null, cli));
            delete require.cache[require.resolve(`${process.cwd()}/events/${dirs}/${file}`)];
        };
    });

};
pale vessel
#

u have to store ur events inside an array to remove them and then re-add them

lyric mountain
#

cli.removeListener()

pale vessel
#

cli.removeEventListener()

lyric mountain
#

ah they renamed it

pale vessel
#

they never did

lyric mountain
#

wasn't it removeListener?

pale vessel
#

nope

#

i don't think so. it's always been called that for nodejs events

pearl trail
pale vessel
#

so it's the opposite?

#

they renamed to removeListener?

lyric mountain
#

there are both lmao

stiff dust
#

removeListener
removeEventListener

pale vessel
#

lol tf

stiff dust
#

which one

#

AAAAA

pale vessel
#

which one is deprecated?

lyric mountain
#

what a mess

#

neither are marked as deprecated

pale vessel
#

okay use removeEventListener

#

it's more verbose

stiff dust
#

ok just a question what should I pass as a call back?

pale vessel
#

the function u provided

lyric mountain
#

the event name and the handler itself

#

basically whatever u passed to cli.on()

pale vessel
#

that's why u store them. im not sure if it'd work if u remove the listener using the new function

#

i doubt, they're different functions

lyric mountain
#

delete -> load events -> register

stiff dust
#

well I load them like this

// Bot.js
client.events = new Discord.Collection(); // Add this line just now!
fs.readdirSync('events/').forEach(dirs => {
  const events = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));
  for (const file of events) {
    const event = require(`./events/${dirs}/${file}`);
    client.on(file.split('.')[0], event.bind(null, client));
    client.events.set(file.split('.')[0], event.bind(null, client)); // Add this line just now!
    delete require.cache[require.resolve(`./events/${dirs}/${file}`)];
  };
});
#

then in refresh command I will do it like

// Refresh Command
fs.readdirSync('events/').forEach(dirs => {
    const events = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));
    for (const file of events) {
        const event = require(`${process.cwd()}/events/${dirs}/${file}`);
        const callback = cli.events.get(file.split('.')[0]);
        cli.removeEventListener(file.split('.')[0], callback); // Add this line just now!
        cli.on(file.split('.')[0], event.bind(null, cli));
        delete require.cache[require.resolve(`${process.cwd()}/events/${dirs}/${file}`)];
    };
});
#

is it right?

pale vessel
#

make sure the event exists before attempting to remove the listener

#

i think that would crash during first time no?

stiff dust
#

well if they didnt exists they wouldnt add in the events collectionthinKappa

#

@pale vessel was that correct?

pale vessel
#

only one way to find out

lyric mountain
#

also store those splits in a constant

#

no need to do it thrice

#

event.bind too

stiff dust
#

Bot.js

client.events = new Discord.Collection();
fs.readdirSync('events/').forEach(dirs => {
  const events = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));
  for (const file of events) {
    const event = require(`./events/${dirs}/${file}`);
    const eventName = file.split('.')[0];
    const callBack = event.bind(null, client);
    client.on(eventName, callBack);
    client.events.set(eventName, callBack);
    delete require.cache[require.resolve(`./events/${dirs}/${file}`)];
  };
});

Command

const keys = [...cli.events.keys()];
for (const key of keys) {
    const callback = cli.events.get(key);
    cli.removeEventListener(key, callback);
};

fs.readdirSync('events/').forEach(dirs => {
    const events = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));
    for (const file of events) {
        const event = require(`${process.cwd()}/events/${dirs}/${file}`);
        cli.on(file.split('.')[0], event.bind(null, cli));
        delete require.cache[require.resolve(`${process.cwd()}/events/${dirs}/${file}`)];
    };
});

okay Ig it gonna work

#

cli.removeEventListener is not a function
KEKWSmile

#

fixed

summer torrent
surreal sage
winter pasture
#

Perfect plug to move to biome KEKW

#

(Has its ups and downs tho. Not a perfect replacement)

surreal sage
#
{ "rules": {
    "prettier/prettier": "warn",
    "consistent-return": "off",
    "react/jsx-props-no-spreading": "off",
    "react/no-array-index-key": "off",
    "no-param-reassign": "off",
    "line-comment-position": [
      "warn",
      {
        "position": "above"
      }
    ],
    "import/prefer-default-export": "off",
    "no-await-in-loop": "off",
    "no-continue": "off",
    "no-restricted-syntax": "off",
    "no-console": "off",
    "import/no-extraneous-dependencies": "off",
    "import/extensions": "off",
    "@typescript-eslint/no-unused-vars": "warn",
    "import/order": [
      "warn",
      {
        "groups": [
          "builtin",
          "external",
          ["internal", "parent", "sibling", "index"],
          "type"
        ],
        "newlines-between": "always",
        "alphabetize": {
          "order": "asc",
          "caseInsensitive": true
        }
      }
    ],
    "@typescript-eslint/array-type": [
      "warn",
      {
        "default": "array-simple"
      }
    ],
    "default-case": "off",
    "no-nested-ternary": "off",
    "no-duplicate-imports": "off",
    "@typescript-eslint/consistent-type-imports": [
      "error",
      {
        "prefer": "type-imports",
        "fixStyle": "separate-type-imports"
      }
    ],
    "@typescript-eslint/consistent-type-definitions": "error",
    "@typescript-eslint/consistent-indexed-object-style": "error",
    "@typescript-eslint/consistent-generic-constructors": "warn",
    "@typescript-eslint/consistent-type-assertions": [
      "error",
      {
        "assertionStyle": "as",
        "objectLiteralTypeAssertions": "allow"
      }
    ],
    "@typescript-eslint/method-signature-style": ["error", "property"],
    "react/jsx-filename-extension": "off"
  }}```
#

if these rules can be carried over then sure

#

🫠

#
  • airbnb
winter pasture
#

What was the reason for the eslint server crashing? Any outputs

surreal sage
#

it just doesnt wanna be anymore

winter pasture
#

Tbh, same

surreal sage
#

real

#

reloaded my window, works fine now

radiant kraken
deft wolf
#

First message after lockdown EZClap

lyric mountain
#

first message after first message after lockdown

pine willow
#

first Message after the First Message after the Second Message

civic scroll
#

fourth message

royal cedar
#

💀

lyric mountain
#

wtf sayu went full darkmode

#

hi sayu

civic scroll
lament rock
#

Finally retroactively going through my code and removing alot of Array based logic where I either need indexing and/or dont need an ordered list

lyric mountain
lament rock
#

Should give a decent performance uplift at scale as I was using an array for storing websocket sessions and had to filter a lot to send events to subscribers to a guild

civic scroll
radiant kraken
#

@lyric mountain soo i am still new to Java (and especially Gradle) and i've recently been working on adding a Java binding to my Rust project as my first attempt at a Java library

How do you go about publishing and later importing a Java library? So far now i can build a jar file from it, i've scoured around github and they all have different approaches into installing and/or exporting their libraries

https://github.com/null8626/decancer/tree/main/bindings/java

surreal sage
wheat mesa
#

lul have fun

#

Java libs are… interesting

radiant kraken
#

this is my first ever java library purr_sob_cry

surreal sage
#

decancer givecancer

radiant kraken
#

funny

wheat mesa
#

Look up “how to publish a java library” I think gradle actually has a decent example

#

Surprisingly

lyric mountain
#

but once ur done setting up your credentials it's pretty easy

#

just note that mavencentral doesn't allow ovewriting versions

#

so once u publish, it's final

surreal sage
#

tbh, the more advanced you get in coding, the more configuration related shit you spend time on 😭

lyric mountain
#

but you can always just publish as another version

#

like 1.0.0, 1.0.0b, 1.0.0c

radiant kraken
#

take it or leave it

civic scroll
#

😔

surreal sage
#

e.g. react-native

#

like what the fuck

#

using expo now because the setup is way easier

#

but wtf

civic scroll
#

dw, just write scripts

#

i wrote one to auto launch the emulator

surreal sage
radiant kraken
surreal sage
#

first expo app thing, gps tracker

radiant kraken
#

wha

lyric mountain
#

yeah, permanent versions are a norm in any trustable repository

surreal sage
#

car go
plane fly

radiant kraken
#

okay?

surreal sage
civic scroll
#

but does it have yanking

lyric mountain
#

since, yk, you wouldn't want someone to break your version

radiant kraken
#

anyway

#

how do i create my maven central account or something

radiant kraken
#

alright

lyric mountain
#

read it slowly, dont rush cuz there are some details that are annoying to find if you miss them

radiant kraken
#

so do i just publish the jar file?

#

or the entire source

lyric mountain
#

it'll build an artifact during deployment

#

u dont need to manually send anything

#

oh also

#

remember to javadoc everything

radiant kraken
#

oh right

lyric mountain
#

helps building a reputation, since there's a score

radiant kraken
#

there's also tests right with @Test

lyric mountain
#

idk, I never write tests KEKW

radiant kraken
#

i see them everywhere

lyric mountain
#

I believe all javadoc features are supported

radiant kraken
#

oh btw @lyric mountain what is pom.xml for? how does it differ from build.gradle?

lyric mountain
#

pom is for maven, build is for gradle

#

they're the equivalent of pubspec.yaml or package.json

radiant kraken
#

bruh

#

so which one should i use

#

i am using gradle to publish something to maven central

lyric mountain
#

build

#

gradle is built over maven

#

mavencentral is just the name of the main repo

green kestrel
#

so ive been busy while this place was locked down

radiant kraken
#

same

green kestrel
#

the language i built to represent game locations got some bigger muscles.

lyric mountain
#

there used to be jcenter, but it closed last year

radiant kraken
#

i've spent the entire day on just learning java

#

😭

lyric mountain
#

u can put ur library in as many repos u want, tho mavencentral is the "de facto" repository

radiant kraken
green kestrel
radiant kraken
#

ah ic

#

<endif> not having a slash triggers me

green kestrel
#

lol

#

tough, theres thousands of locations of pre-existing content

#

i guess i could make a migration that changes them all to </endif>

#

but <else> will still throw out parsers

pale vessel
#

do if and fi like bash

green kestrel
#

OH GOD NO

radiant kraken
#

^

green kestrel
#

lol

radiant kraken
#

or </if>

green kestrel
#

bash is not a shining example 😄

lyric mountain
radiant kraken
#

case esac

green kestrel
#

foreach and hcaerof

#

how about at the top of the program we have to put tixe

#

backwards exit

radiant kraken
#

yes

lyric mountain
#

someone should make a palindrome language

radiant kraken
#

write rotcurtsed for constructors

lyric mountain
#

where the code can be read both ways and still compile the same

green kestrel
#

so in real world, outside of test scripts, this is what the language does

#

its called paragraph, and its about 18 years old, give or take

radiant kraken
#

so its to format embed messages

green kestrel
#

ive used it in other iterations of the same game, outside of discord

#

but the premium areas i want to make, would be an absolute ballache to do with paragraph alone, so i integrated duktape for js script tags... they run server side of course

#

which is safe because nobody but devs would add location content

#

its the same parser as Sporks, but with the restrictions removed on max memory and runtime

wheat mesa
#

Anyone know how to use bgfx with CMake?

#

This seems really complex

green kestrel
#

its to form the entire content of a game location, which is conditional based on state

wheat mesa
#

Just trying to be able to use it in my project, there seems to be an entire subreddit dedicated to just trying to compile this shit for CMake lmao

green kestrel
#

and also to form the links of where the player can go next

surreal sage
green kestrel
#

managed to pass in complex objects 🙂

#

so the idea of adding this is so that i can add self-contained minigames to locations

#

i need to add some functions that let js call tags

#

which should be easy enough

#

but for now, time for a break 🙂

surreal sage
#

fuck

#

is

#

that

wheat mesa
#

Interesting, custom language?

green kestrel
#

yes

green kestrel
#

I have 86,000 words of text content written in it

green kestrel
#

I'm quite proud of the bot

lyric mountain
#

...right?

green kestrel
#

no

#

there's no need

#

I have no intention of translating an 86000 word interactive novel

surreal sage
#

does nextjs like support databases and shit in the api routes

surreal sage
#

i forgot an android permission

lyric mountain
#

come to flutter

#

fairly similar to react but u dont need to deal with expo bullshit

surreal sage
#

it's jsx?

lyric mountain
#

not exactly

surreal sage
lyric mountain
#

but it does use a tree-like structure like react

surreal sage
#

oh changes and differences im going to go crazy with this autism

lyric mountain
#

also it supports multiplatform out of the box

surreal sage
#

sounds like expo

lyric mountain
#

yeah, but vanilla

#

and it compiles locally, not on a remote server like expo

#

so no queues

wheat mesa
#

Flutter is awesome

#

10/10

#

It hasn’t been the smoothest experience since my frontend knowledge was already shaky but I gotta say that it’s super easy to set up compared to anything else, and it’s pretty damn fast

#

Hot reloading is a nice plus

surreal sage
#

my first shitty expo app

wheat mesa
#

2 hour wait for something that would’ve taken you 10 minutes in flutter

#

Sounds like a workflow issue

lyric mountain
#

expo is too much dowtime indeed

#

idk why they made it like that, offloading compilation to a central server

surreal sage
#

it always works

#

environment etc

#

but gh actions etc is way faster

eternal osprey
#

hey cuties

#

would anyone know something i could fill this site up with?

#

it's a bit too empty, what can i do with the sides to make it look a bit better?

lyric mountain
#

add a faded-out stock photo of someone laughing at a computer screen

#

now being serious, I cant say anything as I dont know what the site is about

tulip ledge
eternal osprey
#

as soon as i am done with school i am getting the fuck out of this country.

#

I need a warm place man

whole knot
#

Is Discord doing alright? bee_angry

#

I basically uploaded an image through their handler and it says "Not a valid value" KEKW

lament rock
whole knot
#

I guess it was just a hiccup, pretty annoying though

green kestrel
#

haha, this is insane

#

so a paragraph script can have embedded js inside a script tag.... and the embedded js inside the script tag can have.... paragraph evaulated in its tag() function 😄

#

its like inception, just with programming languages kekeke

#

and all this runs inside a bot written in C++ kekeke

wheat mesa
#

trying to get opengl running with clion/cmake and linux... this is an actual nightmare

#

cannot for the life of me figure out how to link it, keep getting "undefined reference to ..."

#

Anyone know how to properly do this? I have built glfw myself and run sudo make install

#

It's in /usr/local/lib/

#

And yet for some reason trying to link with -lglfw still cannot apparently find it

#

jesus finally got it to work

#
cmake_minimum_required(VERSION 3.26)
project(GameEngine)

set(CMAKE_CXX_STANDARD 20)
set(GLFW_LIBRARIES glfw3 dl m GL GLU X11)

find_package(glfw3 REQUIRED)

add_executable(GameEngine main.cpp
        glad.c)

target_link_libraries(GameEngine ${GLFW_LIBRARIES})
target_include_directories(GameEngine PUBLIC include)
``` much more difficult than it should've been
radiant kraken
#

pog

#

why does using third party Java libraries feel like linking C/C++ libraries

#

it's sooo hard

#

😭

spark flint
#

@dense flame stare

#

these are always funny

#

why they join here out of all places to promote dropshipping will always suprise me

deft wolf
#

A better question is why "dopshipping" is not added as a forbidden word in the automod

lyric mountain
#

wdym hard?

#

if you're using gradle all you need to do is add a line in dependencies

#

if not, just open project settings and add it there

radiant kraken
#

took me an hour just to get a test runner up and running

lyric mountain
#

on gradle?

radiant kraken
#

yeah

#

with JUnit

lyric mountain
#

lul, are u using intellij?

radiant kraken
#

NO LMAO

#

i use Notepad++

#

😭

#

my computer would die if i were ever to use intellij

lyric mountain
#

...wait ur talking seriously?

#

doing java without a proper ide is very difficult, that explains it

#

if you have a remove server, you can do server-side programming

#

to alleviate the burden on your pc

radiant kraken
#

feels like i'm coding in C again with how long it takes to do things correctly 😭

#

oh btw do you know how to run javadoc on things cuz as u can see in the terminal... well

lyric mountain
#

yeah you're doing it the hardcore way

radiant kraken
#

is there a way for gradle to document things for me

#

because if i just use javadoc it doesn't recognise third-party dependencies

#

and errors

lyric mountain
#

not really, the gradle javadoc command just compiles the docs

radiant kraken
#

ooo

lyric mountain
#

like, it doesn't generate anything

radiant kraken
#

sorry i meant compiling the javadoc comments

lyric mountain
#

you can do a mock deploy to check if you missed any doc

#

the docs will be compiled automatically when you run gradle deploy

#

lemme just check which command was it

#

nvm, I used maven on my libs

#

yeah it's the javadoc command to compile indeed

#

on maven it was another name

radiant kraken
lyric mountain
#

apparently you need to set a classpath for your javadocs

#

found it weird because on maven I just run the task and it sets the classpath automatically

#

quite odd they changed the behaviour for gradle

radiant kraken
lyric mountain
#

what were u running?

#

ah, only javadoc

#

yeah anything you need to run must be done through gradle, since everything is linked by it

radiant kraken
#

@lyric mountain do you know how to make gradle display the full error message? because there's obviously no way that's possible here in a GitHub workflow

fyi the command i was running is ./gradlew test -i

lyric mountain
#

the error was dumped in the file below

#

but I think you can also make it show on screen

#

lemme check

#
test {
  testLogging {
    events "PASSED", "SKIPPED", "FAILED", "STANDARD_OUT", "STANDARD_ERROR"
  }
}
radiant kraken
#

fixed it, but thanks

#

@lyric mountain dunno if this is your expertise but found another problem here related to Java and GitHub actions

#

i'm trying to run ./gradlew inside a docker container

#

do i just install Java and Gradle manually from there?

#

i've already done ```yml
- uses: actions/setup-java@v3
with:
java-version: 21
distribution: oracle
- uses: gradle/actions/setup-gradle@v3

#

i guess i can add JAVA_HOME as a -v option here somewhere... but how so?

lyric mountain
#

idk much about gh actions

radiant kraken
#

nooo sadge

lyric mountain
#

cant you, instead of running gradlew directly, make it run a bash script?

#
#!/bin/bash

export JAVA_HOME="path/to/java";

./gradlew test -i;
radiant kraken
#

what difference does it make?

lyric mountain
#

the export

#

it'll set the env var

radiant kraken
#

nvm i fixed it by adding -v /opt/hostedtoolcache/Java_Oracle_jdk/21:/opt/hostedtoolcache/Java_Oracle_jdk/21 to docker options

lyric mountain
#

ah

radiant kraken
#

@lyric mountain do you know about java.library.path? it doesnt seem to work here

i'm trying to add the bin subdirectory to java.library.path, but doesnt seem to work

#

i've added this to the gradlew script too ```

Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.

DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m" "-Djava.library.path=$(pwd)/bin"'

obtuse owl
#

Hi, when designing the long description in your bot's page with html, do you need to make sure that the design is responsive on mobile + PC?

#

or does the webpage do it automatically?

lyric mountain
#

like this

#

never had any luck doing it on gradlew

#

you might need plugin id "application"

#

also I believe application args (-D) only work there in fact

radiant kraken
#

@lyric mountain this is fine

lyric mountain
#

There's some success in those errors

radiant kraken
#

it works perfectly in my machine™️

lyric mountain
#

why are u using javac?

#

you need to use only gradle for everything, it's what binds everything together

#

btw @radiant kraken

#

ik it's supposed to be a lightweight editor at least

pale vessel
#

might as well use intellij though?

#

i'm pretty sure all jetbrains IDEs use the same base

#

which isn't lightweight already

lyric mountain
#

fleet is built differently, it's not a fork of intellij like the others

#

at least that's what they advertised it to be - lightweight

#

didnt use it yet as I have no use-case for it

wheat mesa
#

I think it’s just meant to feel like a lightweight editor, not necessarily actually be a lightweight editor

surreal sage
sharp geyser
#

?

pale vessel
#

this is mine

sharp geyser
#

im so confused what is the point of showing off the app data folder

pale vessel
#

might be because it's taking 137.6gb

#

that's...quite a lot

sharp geyser
#

I mean depends on what he has downloaded there

#

Some apps just put their files into the AppData trollface

lament rock
#

Lemme install entire neural networks into AppData

#

I found Discord assets I wasnt supposed to

sharp geyser
#

So

#

what is your guys opinion on tiny11

#

So many youtubers are hyping it up

lament rock
#

use atlas os 11 instead

sharp geyser
#

tf is that

#

So its like tiny11 but more optimized for gamers?

lament rock
#

Once you clean install windows 10 or 11, you run a program that debloats it and allows you to do some cool stuff like disable windows defender and cpu mitigations for older cpus for spectre and meltdown since those can hit cpu performance A LOT

#

optional

#

Also removes a lot of ms spyware

sharp geyser
#

Well I definitely dont want to disable windows defender thats my only antivirus

lament rock
#

downside is that some built in apps are spyware

#

it removes the media player and photo viewer

#

good news is is that there's alternatives

sharp geyser
#

I dont think i've once used the media player or photo viewer on my pc

lament rock
#

This is what I found on a build of the iOS app once. My profile

sharp geyser
#

So Atlas doesn't require an entire other install iso?

lament rock
#

Prestige icons for nitro

#

no

sharp geyser
#

It just debloats the current windows install?

lament rock
#

distributing windows isos is against ms tos

sharp geyser
#

fair

#

So what if you want to remove atlas later?

#

I assume they have a tool for that

lament rock
#

idr

#

heart is highest level prestige

sharp geyser
#

ye idk using something like atlas or tiny 11 seem pointless

lament rock
#

Uhh

#

My cpu can finally breathe

#

its kinda a necessity on older hardware

sharp geyser
#

my cpu is already fine as is though

#

It hardly gets used even under stress

lament rock
#

Then if there is no problem, dont fix it

sharp geyser
#

I have an i7-12700kf its bad at some games but still performs pretty well due to my gpu helping on graphically intensive stuff

#

I see the appeal on old hardware tho

#

It looks perfect for something that is much lower spec

lament rock
#

once I installed atlas, I tried to go hard and add rebar support to my motherboard with a modded bios

sharp geyser
#

nice nice

#

how'd that go?

lament rock
#

asus bios flash util says invalid bios

#

I need a hardware bios flasher

#

my mobo doesnt have flashback

thorn spruce
#

Hey guys, any sql expert?

#

I'm having trouble with two models, so let me explain. My previous version has a Player table with ~200 columns, but I think it's pretty bad to have this amount of columns and I know it's going to grow quickly. So I wanted to switch to a model with two tables, the first named PlayerInventoryKey which contains all the game keys and PlayerInventory which is actually user_id, key, amount. But at this point, I've run into a huge problem: I've learned that mysql stores bigint with 8 bytes, no matter what you put in it. So I don't know what to do, because sometimes I have a huge number that really needs a bigint and sometimes I just need a Tyint for a Boolean.

So my question is which model is better in the end, the one with the right types or the one where I won't have 500 columns in 2 years?

lament rock
#

The generic one is more extensible so is more desirable

#

Having 500 columns also means having to transfer all of that data every query

#

unless you select a specific one

thorn spruce
#

Basically i only make one select and then cache manage the profile

lament rock
#

Whats the point of the database then

#

besides persistence

thorn spruce
#

good question i guess

lament rock
#

Also, the way I would actually do things is have one table which is pkey'd by the user ID and links to an ID for inventory. I'd then have a second table which b trees' off that inventory ID and the table is structured like this
item ID, amount

if order is necessary, can also have a third table which is p keyed by user ID and b trees off of item ID and has another column of slot ID

thorn spruce
lament rock
#

What are you storing that needs bigint

#

the amount of items?

thorn spruce
#

Yep

#

Or timestamp

#

I think I should change it to int and it will be 4 byte lost and not 8

#

So it doesn't change the problem

#

But I also think there's no real issues

wheat mesa
#

opengl finally starting to make sense

#

thank god

eternal osprey
#

hey finest cutie patooties:

 registerFont("./mont.ttf", { family: "Montserrat" });
    registerFont("./armad.ttf", { family: "Armad" });```
on linux the fonts look way different
#

mainly because each os has their own way of handling fonts bla die bla but how can i fix it?

#

Like how can i ensure the font looks good again because compared to the original font it looks shit

sterile lantern
#

are there any good templates for using cloudfare workers w javascript (discord one is pretty bare bones)? i tried looking but most of these are outdated

radiant kraken
surreal sage
#

bro

#

ollama + codellama>>>

sterile lantern
#

y is this not working

#

it should exist according to this

lament rock
#

You need to type narrow the union. You can usually do this with shared properties that are unique to each union member or if all else fails, you have to use the

if ("prop" in object) ...

syntax and that will type narrow to any union members it applies to within the block

sterile lantern
#

so basically

if ("attachments" in message.data.resolved) 
#

or well even if resolved in message.data

lament rock
#

I think it's safe to try on undefined, but I haven't used the syntax enough to know for sure

#

nvm

#

> if ("test" in undefined) "lmao"
Uncaught TypeError: Cannot use 'in' operator to search for 'test' in undefined

sterile lantern
#

still get same error

hidden gorge
#

does anyone know how to fix this on react?

Error:

- csvcreator.js:115 Error connecting to MongoDB: TypeError: mongoose__WEBPACK_IMPORTED_MODULE_1___default(...).connect is not a function

React code:


import React, { useState, useEffect } from 'react';
import mongoose from 'mongoose';
import csvtojson from 'csvtojson';
import Settings from '../../../../src/backend/json/database/settings.json';
import '../../css/csvcreator.css';

const CsvEditor = () => {
  const [isConnected, setIsConnected] = useState(false);
  const [tableData, setTableData] = useState([]);

  useEffect(() => {
    checkMongoDBConnection();
  }, []);


  const checkMongoDBConnection = async () => {
    try {
      await mongoose.connect(Settings.MongoDBUri, {
        useNewUrlParser: true,
        useUnifiedTopology: true,
      });
      setIsConnected(true);
    } catch (error) {
      setIsConnected(false);
      console.error('Error connecting to MongoDB:', error);
    }
  };
sterile lantern
lament rock
#

You dont need to ?? if "resolved" is definitely in message.data

sterile lantern
#

possibly undefined

#

oh

#

maybe its because message is request as any

lament rock
#

No

#

you already box it as RawInteractionData

#

attachments is just an optional property

sterile lantern
lament rock
#

you can ! if you know it's there

sterile lantern
#

attachments is required for the slash cmd

lament rock
#

Then you can just message.data.resolved.attachments!

sterile lantern
#

so i dont need the if .. in stuff right

lament rock
#

If you know it's there. The Object is possibly undefined error is remedied by !

lament rock
sterile lantern
#

?

lament rock
#

omg

wheat mesa
#

Gotta love the ts typechecker not being able to recognize the in check

lament rock
#

It does recognize it

#

its just the possibly undefined freaking out

wheat mesa
#

Ah I see now

#

undefined is true evil

lament rock
# sterile lantern

Object is possibly undefined is fixed with the ! at the end of the property access.
This error specifically is fixed with if ("prop" in object)

#

It cannot get more simpler than that

sterile lantern
#

finally worked

#

ty

lament rock
#

instead of large if else if else blocks, use switches

sterile lantern
#

yeah gonna do that once i add all the cmds in

#

just testing stuff rn

sterile lantern
#

the message stuff is just cloudfare, the actual stuff that prints is starting with { "num": {

lament rock
#

well. Log the message

#

null also could be removed attachments

#

idk

surreal sage
#

can ts errors please get more readable

eternal osprey
#

given a dns database like this, how can we now what the fqdn of printer is?

lament rock
surreal sage
#

it's just that the value doesn't match up with other properties

lament rock
# surreal sage the property did exist

you dont understand the error. The type you were trying to read from was a union of multiple types and one or more union members dont have that property. You can type narrow with if ("component" in object) {…}

fickle path
#

Why do I need this?

deft wolf
#

This is a token for using the top.gg api

#

Thanks to it, you can send the number of servers and/or the number of shards that will be displayed on your bot's page

surreal sage
sharp geyser
#

your first mistake was only getting 500gb

surreal sage
#

i got 2 additional drives

#

2tb hdd + 1tb nvme ssd

sharp geyser
#

ok

surreal sage
#

and unfortunately, wsl doesn't run on those

sharp geyser
surreal sage
#

windows subsystem for linux

sharp geyser
#

I mean so long as you have your boot loader on one of them you can run wsl on any drive

surreal sage
#

so

sharp geyser
#

Also im sure you can find a way around it

spark pebble
#

I guess ill just send a screenshot as Discord seems to be entirely unawaree of what a link is....

solemn latch
#

Bots base perms come from the everyone role, just like a user.
its possible the other issue was a bug, I'm not sure.

#

I know permissions can be a bit weird in cases.

spark pebble
#

Yeah, so the bot had a role with perms to External Emojis, but it still couldn't use External Emojis.

I asked here when that happened, and someone said "giving roles to an Application is useless, it only takes permissions from the everyone role and nothing else.

tulip ledge
#

How do you detect a raid using a bot? Is it just on mass join/bans/channel deletes/etc?

lyric mountain
#

there's nothing u can do against mass ban/channel delete

#

and mass join will be blocked by discord

sterile lantern
#

say i have three arrays:

let userRoles = ['Admin', 'Security Moderator']
let roles2 = ['Admin', 'Moderator']
let roles3 = ['Security Moderator', 'Security Admin']

how would i check if any role of userRoles is in either array, and then return that role name? i know some() exists (js) but i want it to return the role name that matches

spark flint
#

you coud use .find

#
userRoles.find(role => roles2.includes(role) || roles3.includes(role))``` for example
sterile lantern
#

oh yeah

#

thanks

spark flint
#

no worries

silver jackal
#

i need help with vps to host my discord bot

spark flint
#

you need to install node.js

#

i would recommend using nvm

silver jackal
spark flint
#
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

nvm install 20.9.0
nvm use 20.9.0```
solemn latch
#

nodejs comes with npm

spark flint
silver jackal
spark flint
#

yes

silver jackal
#

done

#

how do i check version

spark flint
#

node -v

#

it should say 20.9.0

silver jackal
#

done

#

npm is 10.1.0

#

@spark flint what now

spark flint
#

well its installed now

#

node and npm are intalled

silver jackal
spark flint
#

so do whatever you were trying to do before

silver jackal
#

i dont even know what im doing

solemn latch
#

👀 people zip before uploading?
Have I been doing it wrong this whole time?

coral phoenix
solemn latch
#

I'd follow the guide you're using.

silver jackal
#

ok

#

i probably did something wrong

#

like 10 minutes ago

#

when installing stuff

#

but ok

solemn latch
#

👀 this is an ubuntu vps right?

#

It looks like you put a windows path instead of a linux style path.

sterile lantern
#

im trying to send a webhook with an action row, i provided type 1 but i get this error

#

this is what components is btw

pale vessel
#

but that's an action row inside an action row

#

there's no need for that array in the first image, just provide components

#

JSON.stringify({ content: message, components })

sterile lantern
#

ohh i see

#

nope it worked

warm surge
#

Sureee @clear plinth what’s my wallet address again

#

@fervent shale also

#

Why there’s random email on your pfp

#

@solemn latch thank you for giving my wallet address KEKW

sterile lantern
#

how exactly do i send an attachment alongside the webhook

#

i changed the content type to multipart/form-data

spark flint
#

use formdata

#

as in the js thing

#
const formData = new FormData();
    formData.append("content", `Message Content`);
    formData.append("file-anythinghere", new Blob([`message i want to send`], { type: "text/plain" }), "filename.js");```
#

this works for me

sterile lantern
#

what if its an object from discord

#

like its a file that is uplaoded from a slash cmd

#

and i just wanna have that img send to a webhook

spark flint
#

the interaction should contain the file url which you could embed

#

but tbh im not sure how long empheral-response objects stay on the CDN for huh

sterile lantern
spark flint
#

yep

sterile lantern
#

what if i dont wanna send any msg

#

just img

spark flint
#
fetch("webhook", {
      method: "POST",
      body: formData
});```
#

you can remove the content part

sterile lantern
#

i could append components to the formData right

spark flint
#

yeah

sterile lantern
#

for file-anythinghere shouldnt it be attachments

spark flint
#

file-<anything> works for me atm

#

i upload 3 different files at once so assigning them a unique id after file- worked for me

sterile lantern
spark flint
#

hm

sterile lantern
#

img is a url

#

i tried passing an attachment obj too

spark flint
#

hm

#

honestly not sure

#

webhooks can be funky

sterile lantern
#

weird cuz it should at least send the msg

pale vessel
#

formData.append("files[0]", blob, "image.png"); for example

pale vessel
#

if u want to send an actual image, fetch the image and grab the response as a blob

#

or if u already have an image buffer, use new Blob([buffer])

lament rock
pale vessel
#

now das woke af

lament rock
#

real shit

earnest phoenix
#

const express = require("express");
const app = express();

app.listen(3000, () => {
  console.log("Atlas Network Started");
});

app.get("/", (req, res) => {
  res.send("Hello World");
});

const Discord= require("discord.js");
const client = new Discord.Client({intents: ["GUILDS", "GUILD_MESSAGES"]})

client.on("messageCreate", (message) => {
  if (message && message.content === "ping" && message.channel) {
    message.channel.send("pong");
  }
});

client.login(process.env.token);

#

why doesnt' this work

earnest phoenix
#

discord.js@14.14.1

warm surge
earnest phoenix
#

the last time i made a bot was in 2021

warm surge
lyric mountain
#

And added cache on everything

earnest phoenix
earnest phoenix
#

would they do that

lyric mountain
#

Because djs devs

earnest phoenix
#

back in the good old days of discord bot development this was simple

lyric mountain
#

It still kinda is, if you adapt to the new workflow

earnest phoenix
lyric mountain
#

That said, I don't code in js anyway, so can't say from experience

lyric mountain
#

By discord, I mean

earnest phoenix
#

nope

lyric mountain
#

Did you enable message intent in dev panel?

#

And include it at client intents

#

Also if you're returning from 2021, I believe they renamed messageCreate event

earnest phoenix
earnest phoenix
#

what is it now?

pale vessel
#

nah i think it was message -> messageCreate so you're good

lyric mountain
#

Ah

#

From the docs, they also have Events.someEvent constant, might be a good idea to use it instead of strings

earnest phoenix
#

client.on("messageCreate", (message) => {
  if (message.content === "ping") {
    message.reply("pong");
  }
  if (message.content === "!connect") {
    let embed = new Discord.MessageEmbed()
      .setTitle("Connect to our server")
      .setDescription(
        "To connect to our server make sure you're on the latest version of Minecraft and that you're using the Java edition of Minecraft.\n IP: `atlassmp.online`"
      )
      .setFooter("Atlas Network");
    message.channel.send({ embeds: [embed] });
  }
});

what is wrong with my code?

#

did they change embeds too

deft wolf
#

It depends on what version you are using

earnest phoenix
#

discord.js@14.14.1

deft wolf
#

In the latest? Yes, from now on it's called embed builder

solemn latch
#

Discordjs has really really good version upgrade guides. I'd reccomend using that if you can

earnest phoenix
#

Tysm, the last time I made a bot was in 2021

#

🤣

#

client.on("interactionCreate", (interaction) => {
  if (!interaction.isChatInputCommand()) return;

  if (interaction.commandName === "!connect") {
    const embed = new EmbedBuilder()
      .setTitle("Connect to Atlas SMP")
      .setDescription(
        "To connect to our server make sure you're on the latest version of Minecraft and that you're using the Java edition of Minecraft.\nIP: `atlassmp.online`",
      )
      .setFooter("Atlas Network");
  }

  interaction.reply({ embeds: [embed] });
});


I read the discord.js guide, followed it and got this

#

it doesn't work

#

any ideas?

pale vessel
#

what doesn't work?

earnest phoenix
#

The embed is meant to reply and it doesn't

pale vessel
#

no errors?

earnest phoenix
#

Yeah, no errors I checked

#

The bot goes online and everything

pale vessel
#

i'm surprised it didn't error

earnest phoenix
vivid fulcrum
#

because the promise isn't being awaited

pale vessel
#

no clue how it'd access embed lmao

#

it's inside the if statement

vivid fulcrum
#

also i'm pretty sure that's not the syntax for replying to interactions

warm surge
#

like this

earnest phoenix
pale vessel
#

i don't think ! is a valid character for a slash command though

pale vessel
earnest phoenix
#

I removed the !

pale vessel
earnest phoenix
pale vessel
#

use new SlashCommandBuilder() to create a slash command and register them like this

earnest phoenix
#

What is a global command?

deft wolf
#

The commands that are available in dms and on all servers are the same

earnest phoenix
#

Why would I need that

#

Is it for the embed

deft wolf
#

You can also create "per server" commands

earnest phoenix
#

or is it extra

deft wolf
#

This is how discord works now. Hardly anyone uses text commands

#

So yea, you need that

earnest phoenix
#

text commands are far superior

deft wolf
#

Not if you want discord to verify your bot

#

You must have a very good reason to be able to read user messages

earnest phoenix
#

I've done everything in the documentation and my embed still doesn't work, at this point are there any youtube tutorials on this

#

this is so much harder than it used to be

deft wolf
#

There are probably some, but I haven't seen any for a long time because it's much easier to write using documentation and stackoverflow

earnest phoenix
#

I follow everything in the documentation I've double checked it

#

and it doesnt work

#

const { REST, Routes } = require("discord.js")

const botID = "1206221292580372510"
const serverID = "1190694042409914398"
const botToken = process.env.token

const rest = new REST().setToken(botToken)
const slashRegister = async () =>{
  try{
    await rest.put(Routes.applicationGuildCommands(botID, serverID){
      body: [
        {
          name: "ping",
          description: "just a simple command"
        }
      ]
    })
  } catch (error){
      console.error(error)
  }
}

slashRegister()

youtube told me to do this, and to no surprise it doesnt work

#

what did I do wrong

earnest phoenix
#

bruh somebody help please.

solemn latch
#

What doesnt work? in what way?

earnest phoenix
#

Ok so basically

#

I've registered my slash commands, and they work the only thing that needs fixing is the reply

#

client.on("interactionCreate", async (interaction) => {
  if (interaction.isChatInputCommand() && interaction.commandName === "ping") {
    const embed = new MessageEmbed()
      .setTitle("Connect to Atlas SMP")
      .setDescription(
        "To connect to our server make sure you're on the latest version of Minecraft and that you're using the Java edition of Minecraft.\nIP: `atlassmp.online`"
      )
      .setFooter("Atlas Network");

    interaction.reply({ embeds: [embed] });
  }
});


#

this is the only thing which doesn't work

#

the slash commands are registered, but when you use it the bot crashes

#

and throws an error message

solemn latch
#

whats the error message?

earnest phoenix
#

node:events:491
throw er; // Unhandled 'error' event
^

TypeError: MessageEmbed is not a constructor
at Client.<anonymous> (/home/runner/atlasbackend/index.js:26:19)

solemn latch
#

What discordjs version are you using?

deft wolf
solemn latch
#

MessageEmbed is the old version right?

#

Its now EmbedBuilder iirc

deft wolf
#

Yea, it was a thing in v12 and v13

solemn latch
#

yeah so the youtube guide you're following isnt for the discordjs version you're using. @earnest phoenix

sharp geyser
#

Also the builder is terrible anyway it should be removed

#

Just use objects

solemn latch
#

Its easier for most newer devs

#

as much as I agree

sharp geyser
#

It’d be easier if they never did it to begin with cause it’s just more overhead

deft wolf
#

Same for command builders I guess kappalul

earnest phoenix
#

Is there documentation on this? I haven't done anything like this in years

sharp geyser
#

Itd be a lot simpler if they just stuck to using raw json data over builders

solemn latch
sharp geyser
#

That’s one thing I disagreed with