#development

1 messages · Page 33 of 1

lyric mountain
#

I mean, timezones and stuff

frigid robin
#

😅

lyric mountain
#

everything about "making a process think it can use more ram than you physically have" is a bad idea

#

offbrand pendrive vendors used to do that all the time, look what happened to ur data

boreal iron
#

If that would only work for my cars

lyric mountain
#

lmao

#

try putting water in your tank so it thinks it still have fuel

boreal iron
wooden ember
#

bruh theres a reason they recomend a lower end ram limit most of the time.

#

like yeah technically you can run the game under spec lamost always it will jsut run like shit since you have assets and crap moving in and out of ram all the time

#

beamng doent enforce you have more than 2gb

#

but you will have all kinds of graphical issues with 1g

#

was a fun time

#

had to use only modded maps that where small

#

in short yeah if you can get a resorce intensive game to open on low specs its a lottery

#

my old hd7770 got 25fps in the latest beamng cuz the vram was always full in most small maps

#

now have a gtx760, its not much more powerfull but has more vram so fps is buttery now

wheat mesa
#

You
know what requirements are
 right?

#

If the game cannot allocate the textures because your GPU doesn’t have enough left of course you’re going to have texture bugs
 that’s how a GPU works

#

I’m surprised it didn’t crash your game entirely

lyric mountain
#

I mean, it IS allocating, or at least it think it is lmao

wheat mesa
#

If he’s having weird texture bugs the likelihood is that the GPU is rejecting any sort of allocations to it until it can free some memory up

boreal iron
#

_just lower the graphic settings from poor to poorest or better black and white without textures _

wheat mesa
#

I suppose it doesn’t crash because allocations on the GPU failing aren’t really “crash worthy” since it’s not critical to the core process

#

Plus texture bugs happen all the time in big games like that so they’re designed to handle allocations failing on the VRAM

wooden ember
#

i mean it could be if its not crashing that all the textures on the lowest settings are lower than 1gig the restriction is just there cuz the devs are lazy and dont want to deal with complaints of shit not loading properly in som instances

feral aspen
#

Well, long story short, I already have my website have an A record with a let's encrypt certificate, however, I now started hosting node.js website applications and I think it's not working due to already being a certificate, present. Also, my main website is via Plesk but the node.js application is via a VPS.

wheat mesa
#

Doubtful. It’s probably less than 1gb because of other processes using it but the limit to how much GTA is allowed to take up is likely filled

#

Information stored on the GPU’s VRAM is mostly vertex buffers and such, which are only for efficiency when rendering the same textures over and over, so not much critical data other than some other stuff is stored there

wooden ember
#

why is it that when i disconect my servers internet when my bot is in vc it just hard crashes? is that normal? the error originates from "unhandled error event" in "discord.js/voice/dist/index.js"

lyric mountain
wheat mesa
wooden ember
#

bruh my net went out for a week and when it came back up no errors

#

but vc just kills it?>

#

and if thats normal why is there a section on the d.js docs on how to try to reconnect a vc session if its just gonna die befor youy can do shit

#

reference:

sharp geyser
#

Yes but you are essentially just managing the channel itself

#

so it makes little sense to be able to mess with roles as a whole

#

What if you want them to be able to change channel perms but not roles/create roles with more perms than needed

wheat mesa
wooden ember
#

wheres the fun in that

#

people take tech for granted

#

i whanna make a bot and i want it to be robust enough that it wont crash

#

even on my potato internet

sharp geyser
#

đŸ€”

wheat mesa
#

Potato internet is not good for hosting

wooden ember
#

and?

wheat mesa
#

I think that goes without saying

wooden ember
#

i know

wheat mesa
#

You need to fix the main problem

sharp geyser
#

bad internet leads to horrible uptime

wooden ember
#

but why should on litttle blip cause my whome program too die

sharp geyser
#

which in turn leads to bad bot

wooden ember
#

my bot its only on my mates server

prisma locust
#

Hi guys i have a question for you. The output I gave above is a data output, how can I create an array, object set that will give a result like this?

[
  Track {
    id: '1012466577531998208',
    title: 'Bir Derdim Var',
    author: 'mor ve ötesi',
    url: 'https://open.spotify.com/track/5UV2oqgMXvlkOvvtK3aT7f',
    thumbnail: 'https://i.scdn.co/image/ab67616d0000b27361cd6f5ad7c69b76adbc5419',
    duration: '03:24',
    views: 0,
    requestedBy: User {
      id: '615029465726320654',
      bot: false,
      system: false,
      flags: [UserFlagsBitField],
      username: 'Umut',
      discriminator: '6070',
      avatar: 'a9f1a560cabf761341f7c3cce0616d69',
      banner: undefined,
      accentColor: undefined
    },
    playlist: Playlist {
      player: [Player],
      tracks: [Circular *1],
      author: [Object],
      description: 'Senin aydınlığın, benim karanlığım.',
      thumbnail: 'https://i.scdn.co/image/ab67706c0000bebbf568ae0c6888cdff0377cd0b',
      type: 'playlist',
      source: 'spotify',
      id: '358umDe5Z8BDX8rGohoIHn',
      url: 'https://open.spotify.com/playlist/358umDe5Z8BDX8rGohoIHn',
      title: 'Karanlık'
    }
  }
]```
wheat mesa
#

That’s like having the hoover dam burst and you’re patching it up with one piece of flex tape

sharp geyser
#

You seem to already have exactly what you asked for?

wheat mesa
#

“THATS A LOTTA DAMAGE”

wooden ember
prisma locust
boreal iron
sharp geyser
wheat mesa
#

Your issues are extreme in the case of hosting. Having disconnects so often that you need an automatic system to reconnect it when you could just use a proper host is just not the right way to go about it

sharp geyser
#

:^)

prisma locust
sharp geyser
#

If libs don't swap over, there will be 10x more disconnects

wooden ember
wheat mesa
#

You could save yourself 1000 lines of duct tape code to handle complex internet issues, or you could spend 5 minutes setting up a free forever oracle VPS with pm2 that would be plenty to handle your bot

#

I have been hosting my bot on a free forever tier of oracle’s VPS for the last year. I have only ever had one disconnect that required me to restart the bot myself, and that was due to discord’s recent issues caused by cloudflare

sharp geyser
#

that would be near impossible to guarantee

boreal iron
#

Done

#

Or push the object to an existing array

sharp geyser
#

But they are skilled enough to at least guarantee uptime nearly 24/7

wooden ember
sharp geyser
#

Is it disconnecting from discord?

#

If so get a better host and or internet

wheat mesa
#

To be fair the entire ecosystem of javascript is designed around “have someone else do it for me”, so why not just let someone else handle that for you? Use a service like PM2 on a proper VPS

sharp geyser
#

you could always self host if you have good enough internet

wooden ember
#

also bruh my net isnt that bad its just short blips like once every two ish days that causes vc so storworking and i need to reload the connection

wheat mesa
#

He self hosts right now

#

He’s saying that his internet is cheeks so it disconnects and crashes the bot

sharp geyser
#

Even the tiniest blip can cause a disconnect

wooden ember
#

why cant i handle that error though

sharp geyser
#

Cause its YOUR internet cutting out for a split second

wooden ember
#

and? it reconnects

sharp geyser
#

There is no way to prevent that other than getting better internet

prisma locust
wheat mesa
#

Because you’ve completely fucked the gateway connection and interrupted the stream of packets that are being sent through said gateway to discord while it’s playing audio

boreal iron
sharp geyser
#

use a bin if its a large amount of code please

boreal iron
#

Aye

wooden ember
#

rather than it killing everything

sharp geyser
#

It should send an error if the connection is interrupted iirc

wheat mesa
#

Because it’s probably going to terminate your gateway connection

sick agate
#

ask error handling

prisma locust
# boreal iron Not to me but into this channel
let tracks = []
await music_filter.map(async m => {
 
        let Track = {
            id: interaction.guild.id,
            title: m.music_name,
            author: m.author,
            url: m.music_url,
            thumbnail: m.thumbnail,
            duration: m.duration,
            views: 0,
            requestedBy: interaction.user,
            playlist: {
                player: client.player,
                tracks: tracks,
                author: interaction.user,
                description: interaction.user.username,
                thumbnail: interaction.user.displayAvatarURL({ dynamic: true }),
                type: 'playlist',
                source: 'playlist',
                id: 'playlist',
                url: 'playlist',
                title: m.playlist_name
            }
        }
    
    tracks.push(Track)

})```
Currently this code gives data as an object { } but I want an output like 
Track { 
}
sick agate
#

i guess the process dies right? @wooden ember

wheat mesa
#

That’s
 what an object is

wooden ember
#

if i unplug my pc from the internet whilst im on vc with my mates discord will disconnect and then reconnect once i plug it back in why can in not do that with my bot?

wheat mesa
#

Ok so your first problem here is

#

Using async map

#

Don’t do that

wooden ember
#

?

sick agate
#

PM2???

wheat mesa
#

Resolve the promises and then map the results

sharp geyser
wooden ember
#

but it does

sick agate
#

like you should attempt to reconnect

sick agate
sharp geyser
#

if there is a valid session id then ofc you can reconnect

#

but if you outright disconnect then you just have to re-identify

wooden ember
sick agate
#

handle the error then

wooden ember
#

its not comming from my code

sick agate
#

i think you can still do it ?

sharp geyser
#

😔

#
  1. You can't reconnect without a valid session id, so if you just outright disconnect from the gateway you no longer have that (iirc)
  2. If this happens, you just have to re-identify (calling .login again)
#

Which means, stopping the process and re-running it

#

Which as you can see, is a bad idea

wooden ember
#

im genuinly confused if i unplug my pc rn from the internet it will not blue screen cuz all of windows telemitry, discord shit, google chrome, and whatever elce loses connection. so why is it that a i have to reboot the entire bot just for a momentary blip

#

if everything else can handle the internet dying why cant I?

sharp geyser
#

Cause djs just kills the process once it gets an error like that

wooden ember
#

or does google have to reboot data centers everytime some one drives a tracter through a fibre line

sharp geyser
#

đŸ€·â€â™€ïž

#

it could also be ws doing it and not djs

wooden ember
#

said it was from d.js in the log

sharp geyser
#

ws could be causing issues once it notices the gateway connection is no longer stable and just killing the process and telling you that

wooden ember
#

but idk literally stupid if one small thing causes the whole prosses to die

sharp geyser
#

Again, this can be solved by just getting a reliable host but whatever

#

Just keep restarting the process

#

I have no way to help you with internet issues

wooden ember
#

"oh no the breaks are worn on my car better buy a new one"

sharp geyser
#

đŸ€”

wooden ember
#

not replacing my entire host just for one small issue

sharp geyser
#

But, your analogy just stated a major issues

wooden ember
#

why is there no way of it retrying the connection

sharp geyser
#

Also idk if you ever heard of replacement

wooden ember
#

the hell are you on about

sharp geyser
#

once it encounters an error it just restarts the process itself

#

henceforth restarting the bot

wooden ember
#

yes but thats a band-aid solution

#

i dont want the bot to stop in the first place

sharp geyser
#

and you trying to force it to reconnect isn't?

wooden ember
#

im not able to do anything, it crashes as soon as its realises theres no internet

sharp geyser
#

Thats how a lot of things work.

wooden ember
#

that is actually dumb

sharp geyser
#

Either way, I can't help you with what you wanna achieve so just wait for someone who can

wooden ember
#

why is it that internet dying kills my bot but theres an entire page on how to handle disconnects on the d.js docs if i cant bloody use it

#

how im i suposed to use anyof this if i have to restart the bot anyway

#

what the fuck

#

this is why i genuinely hate software devs they single handedly have held back 30 years of hardware development.

sharp geyser
#

yes blame others for ur problems

wooden ember
#

in the 90s you could get on the internet with a 800mhz cpu now you gotta have a 2ghz cpu to do the exact same fucking thing

wooden ember
#

did i write d.js

#

no

sharp geyser
#

and back in the 90s you didn't have access to anything that has helped us as a society today

wooden ember
#

bruh what?

sharp geyser
#

Anyway, what you linked relies on a session still existing and or discord closing the session themselves

#

If none of that is possible, then you simply have to re-identify

wooden ember
#

yeah exactly, i can see that but if the prosses gets yeetes as soon as theres no internet why are they telling me how to try to recover it

sharp geyser
#

😔

#

This is going in circles

#

if it CANT reconnect then why should it bother trying further

wooden ember
#

if it knows it cant reconnect it must have tryed

#

but i cant try is if just dies

wheat mesa
wooden ember
#

what do you mean

wheat mesa
#

Strawman fallacy

wooden ember
#

whats that?

wheat mesa
#

Look it up

sharp geyser
#

A form of argument and an informal fallacy based on giving the impression of refuting an opponent's argument, while actually refuting an argument that was not presented by that opponent

#

Basically you were being irrelevant

wooden ember
#

bruh didnt mean it liek that, i was expressing my general dismay againsed most modern software in a tangent

wheat mesa
#

In this case the modern hardware has nothing to do with the internet, it doesn’t change anything

#

And in the 90s CPUs were far less than that speed

#

But that’s besides the point

wooden ember
#

if you want a more relevent tangent, the internet was invented as a nuclear prove data comunication network, i some how dont thing the US govournment would be happy with a network they have to reboot at every slight loss of service

wheat mesa
#

In the 90s the internet was fantastically slow you seem to be forgetting

sharp geyser
#

đŸ€”

wheat mesa
#

Dial up was still the most common form of internet access and that maxed out at something like 32kbps

sharp geyser
wheat mesa
#

No

#

It was slow for its time

wooden ember
wheat mesa
#

A common thing was to bring a magazine to read at your computer while you waited for your website to load

#

Internet explorer was not a thing in the 90s pretty sure

#

Apparently launched in 1995 nvm

wooden ember
#

yeah

#

idk what was before it

wheat mesa
wooden ember
#

netscape was around the 90s

wooden ember
#

i just want to fucking reload

#

that is it

#

i dont want it to crahs

sharp geyser
#

But its essentially just starting a new connection no?

wooden ember
#

yes

wheat mesa
#

An app in 1995 for windows was probably being built with C where you can access more internal low level things as well

sharp geyser
#

and....you re-identifying the gateway does what?

wooden ember
#

but i cant start shit if the program crashed

sharp geyser
#

Then go libless and control how it works, though I have a feeling it isn't djs itself that is causing this

wheat mesa
#

pm2

#

Or solve your main issue which is the disconnecting itself

sharp geyser
#

He doesn't want a "bandaid" solution

wheat mesa
#

You’re trying to fit a square peg into a circle hole here

wooden ember
#

nomatter what i do i will never have internet with 100% uptime

wheat mesa
#

But his solution is the bandaid solution

wooden ember
#

therefor it will crash at some point

wheat mesa
#

Then use pm2

wooden ember
#

but that wount stop it crashing

wheat mesa
#

You’re right it won’t

#

Some things are unrecoverable

#

In the case of gateway connections

#

It could be a thousand different things

wooden ember
#

but why? i can disconect my pc from the internet whilst in a vc call and then plug it back in later and it will reconnect

wheat mesa
#

Just use a process manager and use a proper host so that your bot will only crash like once every blue moon and it’ll restart in 15 seconds

wooden ember
#

why cant i just make it so i get a console log like "theres no insternet at the moment retry connection in 30 secconds"

wheat mesa
wooden ember
#

so why cant i do that

#

that is all i want

lyric mountain
wheat mesa
#

Because it’s a bandaid solution to a bigger problem

lyric mountain
#

except RCT, idk how tf that guy managed to make it

wheat mesa
#

Go ahead and solve it I dare you 👀

lyric mountain
#

nah I'm fine

wooden ember
wheat mesa
#

Just solve the easier problem

#

You’re making it more difficult than it needs to be

wooden ember
#

i know

lyric mountain
#

well, you could encapsulate your entire process inside another process in a way that, should the child crash, the parent will create another one

wheat mesa
#

The easier solution is to use a proper host that will take you 5 minutes to access and then another 10-15 minutes to set up with pm2

lyric mountain
#

but even then, the parent has a chance to crash, thus killing the child

wooden ember
#

true but that wont be subject to anything that the child did

lyric mountain
#

OOM is still a thing

#

and cosmic rays

sharp geyser
#

and this is starting to sound a lot more like a fantasy

lyric mountain
#

an entirely unrelated process could crash ur own too

wheat mesa
#

When malloc fails you’ve got a big issue 😉

sharp geyser
#

wym

wheat mesa
#

It will return a nullptr if it does not have any more available memory

sharp geyser
#

Then download more memory

wheat mesa
#

Which I highly doubt that everyone is checking if malloc failed in their C program each time they allocate memory

lyric mountain
sharp geyser
#

or cry yourself to sleep

lyric mountain
#

ah, misty missed the context

sharp geyser
#

hm?

lyric mountain
#

so, bae tries fiddling with regedit to make gta V think it has more vram than his gpu has

#

spoiler: it didn't went well

sharp geyser
#

Oh yea

#

hes just dumb

wooden ember
#

ok so i just edited the discord.js voice library so it doesnt crash

#

fixed now

sharp geyser
#

whatever works for you ig

wooden ember
#

it just console logs the error now

#

rather than killing the entire god damn prosses

#

literally works perfectly

#

ther was no reason for it to end the prosses at all

sharp geyser
#

I have a suspicion that it will at some point cause issues but đŸ€·â€â™€ïž

#

if you think it is the perfect solution go with it

#

Idrc anymore

wooden ember
#

i mean it hasent caused anything yet

#

but idk

sharp geyser
#

yet

wooden ember
#

lol

#

we will see

#

the only thing it does is the bot leaves the vc but still reports its in a vcin the code

#

but my disconnect command still works and after that it reconnects fine

earnest phoenix
#

What link?

whole knot
#

Something like this: https://discordapp.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot&permissions=PERMSHERE

earnest phoenix
#

Where to find it

whole knot
#

I literally gave you the link in #support

earnest phoenix
#

Where is it located?

whole knot
#

Replace YourBotID with the ID of your bot

earnest phoenix
#

Huh?

#

I don’t understand

#

Picture?

whole knot
#

Did you even do what I advised you to do?

earnest phoenix
#

Bruh

#

I am here what to do next

whole knot
earnest phoenix
#

Bruh

#

Need the CLIENT ID

whole knot
#

Just try this for now

#

Maybe you do not even need a link

#

Then set the permission(s) and see what happens

earnest phoenix
#

Go to the bot thing?

whole knot
#

Yes, as you do not have slash commands

earnest phoenix
#

Ok

whole knot
#

Then set the permissions in the "Bot Permissions" tab that pops-up

earnest phoenix
#

Like this

whole knot
earnest phoenix
#

Yeah, what do next?X

whole knot
#

Save it and check out your bot

earnest phoenix
#

How to save it

whole knot
earnest phoenix
#

How to make people to invite my bot

whole knot
#

We do not give tips on advertising. Please take care of that yourself. You can also use our auctions

earnest phoenix
#

I don’t have the option to save it

whole knot
#

Then it was maybe saved automatically. Check if your bot has the button now, otherwise you need to dive in deeper yourself

#

A little research never hurts

chrome orbit
#

anyone good with mongodb (mongoose) that might be able to help with an issue im having?

light ingot
chrome orbit
#
async function guildRemove(client, con, id) {
    await guildSettings.findOneAndDelete({ guildId: `${id}` });
    return 0;
}

well according to the docs, this is correct, yet its not quite doing anything its suppose to be doing.

#

i'm just wondering if someone can verify its correct?

light ingot
#

yeah it does look correct tho

#

actually wait

#

you need to return a promise in that function to be able to work

chrome orbit
#

so what are your suggestions?

light ingot
#

for that you can make the promise return in the function

quartz kindle
#

that wont change anything

#

also why do you have client an con params if you dont use them?

light ingot
#

uh it would i guess

chrome orbit
#

i used to have it setup as MySQL, an am switching to MongoDB. Must've forgot to remove it.

light ingot
#

because i have a friend who's also a beginner at mongodb (even new than me) and he sometimes forgets to use await and so his action isn't performed

quartz kindle
#

then he has other issues because thats not really how js works

lyric mountain
light ingot
#

you could also use .then() but not sure if it'll work

lyric mountain
#

await just makes the code wait for a result

light ingot
#

yeah

chrome orbit
#

^

light ingot
#

but async functions require promises

#

simply using await doesn't do anything

quartz kindle
#

async functions are promises already

light ingot
#

it says "await has no effect on this type of expression"

quartz kindle
#

that means youre using await in the wrong places

light ingot
#

oh

chrome orbit
#

anyways, am i wrong by saying what i have is correct or is there something im missing?

quartz kindle
#

how do you call the guildRemove function?

chrome orbit
#

ive tried finding it first, then using .deleteMany(), but same result (nothing)

#

oh my, im so dumb smh

#

that would explain why its not working

#

forgot i commented out await client.utils.guildRemove(client, con, guild.id); when i was testing smh

light ingot
chrome orbit
#

okay, maybe im not as dumb as i thought i was because its still the same issue đŸ€Ł

civic scroll
#

the await deos nothing in that context

light ingot
#

yeah that's what I was saying

civic scroll
#

unless you have code that waits for the action's completion in consumer scope

light ingot
#

he needs a promise

civic scroll
#

no

light ingot
#

k I'm out

#

I'm simply too noob to help lmao

civic scroll
#

i can just do something like

function guildRemove(id) {
    guildSettings.findOneAndDelete({ guildId: id });
}

if i don't depend on completion of anything

#

also

#

id if it's from djs api

#

it's a string

#

no need to stringify it again

#

if the code doesn't work: it might either be incorrect key, wrong schema, or the key just didn't exist in the first place

chrome orbit
#

key exist in database, schema is correct. as far as the incorrect key, i could console.log it and see what its actually returning

#

my guess is its returning [object Object]

quartz kindle
#

if you removed the client and con parameters from one side but not the other side of the function, then yes

chrome orbit
#

see, key is correct

#

(in the database at least)

#

so its not returning anything Hmm

#

well nevermind. didnt change a single line of code and it fixed itself... đŸ€·â€â™‚ïž

lyric mountain
chrome orbit
#

very, but thats why im testing it in multiple guilds at a time. seems to be working stable

sharp geyser
#

You were likely fetching with an incorrect guild id tbh

carmine summit
#

Which is faster? map first or sort first?

chrome orbit
#

is it normal for guildAdd function to be ran on bot start?

#

(on bot start, my guildCreate event is firing)

sharp geyser
#

so you were likely feeding it wrong info

chrome orbit
#

As I said, I didn’t change any code and it fixed itself lol

sharp geyser
chrome orbit
#

Just spamming my console wile “error: duplicate guildId” as my bot creates the database for the servers when it joins it
 so the bot is trying to create the databases on bot start.

#

And with 100+ guilds, I don’t think I want it spamming each individual guild in the console lol

#

I suppose I could add an !exist variable

sharp geyser
#

As the bot identifies it does indeed run guildCreate event

supple oriole
#

Hello. I'm new to python and I don't really know how to fix this Error. It says that I am temporary blocked from discord's api for sending too many requests. I did read some documents and still don't understand. If possible, could anyone please fix it for me. thanks 😃

#
import cloudscraper, requests
import discord, time
import random, threading
import asyncio
from discord.ext import commands

bot = commands.Bot(command_prefix=".", intents=discord.Intents.all())
scraper = cloudscraper.create_scraper(browser={'custom': 'ScraperBot/1.0'})


@bot.command()
async def crash(ctx):
    games = scraper.get("https://rest-bf.blox.land/games/crash").json()
    if ctx.author.id != bot.user.id:
        await ctx.reply(embed=discord.Embed(description="Loading Bloxflip Crash API.",
                                            color=0x5ca3ff))
        ok = await ctx.channel.send(
            embed=discord.Embed(title="Checking Bloxflip API",
                                description="Checking Crash's API. Please bare with us.",
                                color=0x5ca3ff))

        def lol():
            r = scraper.get(
                "https://rest-bf.blox.land/games/crash").json()["history"]
            yield [
                r[0]["crashPoint"],
                [float(crashpoint["crashPoint"]) for crashpoint in r[-2:]]
            ]

        for game in lol():
            games = game[1]
            avg = sum(games) / len(games)
            chance = 1
            for game in games:
                chance = chance = 95 / game
                prediction = (1 / (1 - (chance)) + avg) / 2
                if float(prediction) > 2:
                    color = 0x81fe8f
                else:
                    color = 0xfe8181
                desc = f"""
        **Crashpoint:**
        *{prediction:.2f}x*
        **Chance of Reaching Crashpoint:**
              {chance:.2f}%
              
              Semi Accurate, will always be improved in the future. Chance = Chance of getting to the Crashpoint. There is always a chance of it going above the Crashpoint."""
                em = discord.Embed(description=desc, color=color)
                await ok.edit(embed=em)

bot.run('')
sharp geyser
#

All you can do is wait, and not spam discord's api anymore

supple oriole
#

oh, alright.

supple oriole
#

like randomly place the checkmarks around the board.

sharp geyser
#

no

supple oriole
dry imp
#

expected 💀

#

replit usually gives rhis error

supple oriole
#

hm

dry imp
#

since they use a shared ip

supple oriole
#

alright. it's fine ig.

dry imp
#

try kill 1 on shell

supple oriole
#

I did

dry imp
#

still error?

supple oriole
#

no

#

it runs now

#

ty!

hardy spire
#

hi

stuck fox
#

&help

rotund river
#

hello, i have a problem with mysql

#

if i execute


      const infoID = `SELECT \`ID\`, \`Reason\`, \`ID_Utente\` FROM \`shark_warn\` WHERE ID='${unwarnID}'`
      con.query(infoID, function(err, result){
        if (err) throw err;
        var warnInfoID = result[result.length - 1];
        client.warnInfoID = warnInfoID.Reason
        client.warnInfoIDut = warnInfoID.ID_Utente
        console.log(warnInfoID.Reason)
        console.log(warnInfoID)
      });```
#

it print RowDataPacket {
ID: 70,
Reason: 'Motivo non specificato.',
ID_Utente: 470991831329407000
}

#

the id is wrong

#

but in db is correct

pale vessel
#

What MySQL library are you using?

rotund river
#

this is the structure for ID_utente

pale vessel
#

Add supportBigNumbers: true and bigNumberStrings: true to your connection options

rotund river
pale vessel
#

Ya

rotund river
#

ok

pale vessel
#

It'll turn numbers from your database to strings since some numbers can go over the maximum safe integer in JS

timber fractal
#

I want to have my bot and website "communicate" with each other, now this would be easy from bot to website, with a simple api, but how could i easily communicate with my bot from my website? like for example, the website needs the bot to perform an action, how would it tell the bot to do so?

sage bobcat
#

One message removed from a suspended account.

green kestrel
supple oriole
#

By any chance does anyone know how to do something like this in python?

near stratus
#
  • Make a matrix with integer (uint8) values
  • Fill it randomly (Like 0 for nothing, 1 for mine, 2 for already scanned, 3 for question)
  • Then just run some if else Everytime someone votes
#
if target == 0:
  # nothing
elif target == 1:
  # you died
elif target == 2:
  # You already did this
#

something like this

rotund river
#

hello, anyone can help me with mysql npm?

#

i want to add all the result in embed organaized

#

this is the code i use for getting one (the first line)

        const infoID = `SELECT \`ID\`, \`Reason\`, \`Timestamp\`, \`Staffer\`, \`ID_Staffer\` FROM \`shark_warn\` WHERE ID_Utente='${target.id}' AND Staffer_unwarn IS NULL AND ID_Staffer_unwarn IS NULL`
        con.query(infoID, function (err, result) {
            if (err) throw err;
            var warnsInfoID = result[result.length - 1];
            client.warnsInfoID = warnsInfoID.ID
            client.warnsInfoRe = warnsInfoID.Reason
            client.warnsInfoTime= warnsInfoID.Timestamp
            client.warnsInfoStaff= warnsInfoID.Staffer
            client.warnsInfoIDStaff= warnsInfoID.ID_Staffer
            console.log(result)
            console.log(warnsInfoID)
            console.log(warnsInfoID.ID)
            console.log(warnsInfoID.Reason)
            console.log(warnsInfoID.Timestamp)
            console.log(warnsInfoID.Staffer)
            console.log(warnsInfoID.ID_Staffer)
        });```
and this is the result:
#
  RowDataPacket {
    ID: 1,
    Reason: 'Motivo non specificato.',
    Timestamp: 2022-08-27T13:12:29.000Z,
    Staffer: 'Manfry#8538',
    ID_Staffer: '470991831329406978'
  },
  RowDataPacket {
    ID: 3,
    Reason: 'Motivo non specificato.',
    Timestamp: 2022-08-27T13:34:10.000Z,
    Staffer: 'Manfry#8538',
    ID_Staffer: '470991831329406978'
  }
]
RowDataPacket {
  ID: 3,
  Reason: 'Motivo non specificato.',
  Timestamp: 2022-08-27T13:34:10.000Z,
  Staffer: 'Manfry#8538',
  ID_Staffer: '470991831329406978'
}
3
Motivo non specificato.
2022-08-27T13:34:10.000Z
Manfry#8538
470991831329406978```
#

now, how can i get all organized with a string?

#

or i use a count and after a for cicle

#

for defining all the lines

#

or idk

lament rock
#

result.map(
) where you can do whatever with the map

rotund river
civic scroll
civic scroll
#

for example

const number = [1, 2, 3];
console.log(number.map(v => v ** 2)); // [1, 4, 9]
console.log(number); // [1, 2, 3]
rotund river
civic scroll
surreal sage
#

Npm library for info boxes like this?

spark flint
rotund river
wheat mesa
supple oriole
#

basically like a slots machine if you would call it.

supple oriole
#

ye

#

tryna make smth like the image I sent

#

but I cant do it ngl

minor olive
#

If so:

import random
list = ["orange", "apple", "fruit", "pineapple", "other"]
randomAnswer = list[random.randint(0, len(list)-1)]
print(randomAnswer)
#

@supple oriole

supple oriole
#

ty

cursive musk
#

Hmm

#

does anyone know why Klasa is not working?

#
npm ERR! Could not resolve dependency:
npm ERR! peer discord.js@"github:discordjs/discord.js#master" from klasa@0.5.0
npm ERR! node_modules/klasa
npm ERR!   klasa@"*" from the root project
dense flame
#

maybe ask in their server (if there is)

sage bobcat
light ingot
#

kid amogus

lament rock
#

isn't klasa deprecated

rustic nova
#

yes it is

#

and so is the support for the version of discord.js you're probably using

bright thorn
#

what is instances for pm2 ?

lyric mountain
#

also why do u have 2 columns for the same data

#

and dont use var, like, never

frigid robin
#

Hey @lyric mountain I wanted to verify with u something before I start using this in prod cause I made lots of changes recently (using command prefix and also changed psycopg2 to asyncpg) and while debugging before I got a few times an error saying "FATAL: sorry, too many clients already.
I'm using a connection pool. The flow is as follows (removing irrelevant stuff):

db_connection.py

        if not tunnel_mode:
            pool = asyncpg.create_pool(
                database=database_name, user=database_username, password=database_password, host=database_host_address, port=database_port
            )
            return pool

Runner.py

async def main():
    async with db_connection.create_postgres_pool() as pool:
        bot.pool = pool
        await bot.start(TOKEN)

if __name__ == '__main__':
    asyncio.run(main())

then when there's an event this is how I use the pool:

async def get_rnchannelid_for_guild(bot, guildid):
    try:
        rn_channel_id = await bot.pool.fetch(sql_get_rnchannelid_for_guild, str(guildid))
        ...
#

Also found that my Postgres is limited to 20 connections right now, which idk if should be enough (thanks PythonAnywhere)

lyric mountain
#

let the pool handle how many connections are active at once

frigid robin
#

yes I just moved to using the pool now, I wanna use it in prod

#

was just wondering if I implemented it correctly, the docs were horrible

surreal sage
#

Run function, if it throws an error, use "null" as result

How to? (JS)

sudden geyser
#

try and catch

#

or make a function that does it for you

surreal sage
#

Ah yeah

#

function() {try{var=result}catch(){var=null}}

#

But in a ()=>{}

#

let queue = ()=>{ try { return (await client.player.createQueue(interaction.guild.id)) ?? null } catch(_) { return null } }

drifting cairn
#

try it and see s_duck_shrug

sudden geyser
#

Yes, but you could abstract it more.

function attempt(f, def = null, ...args) {
  try {
    return f(...args);
  } catch {
    return def;
  }
}

attempt(() => {
  throw new Error("wow");
}); // `null`
surreal sage
#

Still throws an error

#
    let queue = () => {
      try {
        return client.player.createQueue(interaction.guild.id) ?? null;
      } catch (_) {
        return null;
      }
    };
    queue = queue();```
sudden geyser
#

doesn't createQueue return a promise

surreal sage
#

It does not.

#

It throws an error instead of undefined*

drifting cairn
surreal sage
#

dk thought it'd help

drifting cairn
#

doesnt do anything if it doesnt return a promise

#

and why would createQueue throw an error?

surreal sage
#

well it doesn't change doe sit

#

Because there isn't a queue connection

drifting cairn
#

what package are you using?

sudden geyser
#

then maybe it's throwing elsewhere/later

surreal sage
#

discord-music-player

drifting cairn
#

then use the join function 1st?

surreal sage
#

I want to interaction.reply instead of crash

#

This is "skip song"

#

Not play

drifting cairn
#

then check if theres a queue connection prior to skipping the song or something

rich swift
#

Hi, I'm trying to request my server I switched my providers from repl.it to something else and my logging was working fine, but when I switched over and attempted to change the repl.it request the new one it's throwing me an HTTP 404 error.

lyric mountain
#

check if ur url is correct

rich swift
#

It is, I've double checked.

#

Is it http or https.

quartz kindle
#

if its a replit url, its https

rich swift
#

No, it's not replit.

#

I switched from it.

quartz kindle
#

if its an ip address, its http

rich swift
#

It is an ip. But it's throwing me a http 404 not found.

#

The bot is online.

quartz kindle
#

is the port correct?

rich swift
#

Yes.

quartz kindle
#

you're using a vps or a different type of host?

rich swift
#

Umm

quartz kindle
#

does it have a pterodactyl control panel?

#

or you access it using ssh?

ancient nova
#

in fact, it did

#

it never went past 1GB even though I allocated 1,5GB

#

I had to decrease the regex value to 512 and that fixed any memory leak I had

wheat mesa
#

You can’t take more than you have

#

đŸ€Ł

ancient nova
#

from what I read the allocation works by borrowing space from your physical ram to allow increased virtual ram

#

and when I borrowed over 4gb of my actual ram it tried allocating chunks of the gta map to a non existing space

#

it thought it had the space so yeah

ancient nova
spark flint
#

Invalid bitfield flag or number: MANAGE_CHANNEL.

#

🗿

#

Discord.js, trying to manage permission overwrites

uneven tartan
#

also, make sure to follow the guide where it mentions using a custom stream. ytdl-core is facing some issues right now

earnest phoenix
spark flint
#

yeah

#

its confusing

ancient nova
lyric mountain
#

It's not

#

Memory leak is when resources aren't freed after usage

#

So it's gets accumulated over time

#

Aka "leaking" your memory

ancient nova
#

yeah and chunks of the map stayed loaded when you had no actual ram left, that's what I was explaining

lyric mountain
#

No, they just aren't loaded at all

#

Increasing "memory" through regedit doesn't increase the actual usable memory

ancient nova
#

they were, I've seen it happen with my own eyes when trying to fix that issue in the first place

lyric mountain
#

No, what u probably saw was address overlap

ancient nova
lyric mountain
#

When the memory manager cycles back to the beginning of the memory because it can't find any more memory available, so it kinda corrupts whatever was there

ancient nova
#

my vram changed from 2gb to 1,5gb

#

and it doesn't lag or cut randomly anymore as I play

#

google "gta v map vram memory leak"

lyric mountain
#

Also, swap memory is a thing

ancient nova
#

what's that?

lyric mountain
#

Using part of the hd as memory

#

Obviously way slower than actual ram

ancient nova
#

well isn't that what alloc is anyway???

lyric mountain
#

Alloc is loading stuff into addresses

ancient nova
#

it takes space from ur physical actual ram u got on ur motherboard and uses it as virtual ram

#

that's what the people said

lyric mountain
#

Alloc is just short for allocation

ancient nova
#

I know

#

I'm saying that regex alloc for the segment size

lyric mountain
#

Also there's no "virtual ram"

ancient nova
#

I meant video ram

lyric mountain
#

Vram is exclusive to the gpu, normal ram can't be used

#

If u got 1gb vram u got 1gb vram

#

Nothing aside from buying a new card can change that

sudden geyser
#

except downloading more ram

ancient nova
#

I meant regedit yk what I was talking about 😭

lyric mountain
#

Who tf calls regedit regex?

ancient nova
#

but yeah i guess it does trick the game into thinking u got more vram

#

how come some games ran better then?

lyric mountain
#

Because u sacrificed data integrity

ancient nova
#

if it works it works ig

lyric mountain
#

The memory manager is smart enough to loop back once it reaches the last address if it must

#

It'll overwrite whatever is in those addresses tho

#

Meaning many corrupted assets and probably stuff like save data

ancient nova
#

people called the way gta v managed their resourced bad

#

and there was some issues with drivers detecting only chip memory which is 124 or 256 mb

#

so people used the dedicated reg to edit their displayed vram

#

to make gta v actually recognize their vram or something like that

lyric mountain
#

You're missing the entire problem bae

#

Gta only reads whatever values the OS shows

ancient nova
#

I think i'm good

lyric mountain
#

If the computer isn't detecting your actual memory, you DEFINITELY shouldn't simply edit those values

ancient nova
#

mah it did, Imean for others it didn't

#

I was just showing an example

lyric mountain
#

A bad example

#

Nobody except ultra knowledgeable people should ever open the regedit

#

That's the recipe for a big metal paperweight

sudden geyser
#

you're not linus torvalds

#

calm down

lyric mountain
#

Ik, that's why I don't fiddle with regedit

ancient nova
#

edited lots of things in regedit nothing ever happened to me because of it

#

well except one time but we don't talk about that

lyric mountain
#

Yet

ancient nova
sudden geyser
#

since when are pcs considered no good after 5 years

ancient nova
#

I changed a key in reg to change the color of my taskbar once 😂

#

make it transparent

#

it looks cool

ancient nova
wheat mesa
#

All fun and games until you change the wrong thing

rotund river
#

how can i create a field on a embed according to the number i give?

#

i stay create a system to visualize all your warn registrated in a mysql databases, how can i create the embed with the data mysql give me and the correct return?

#
  RowDataPacket {
    ID: 1,
    Reason: 'Motivo non specificato.',
    Timestamp: 2022-08-27T13:12:29.000Z,
    Staffer: 'Manfry#8538',
    ID_Staffer: '470991831329406978'
  },
  RowDataPacket {
    ID: 3,
    Reason: 'Motivo non specificato.',
    Timestamp: 2022-08-27T13:34:10.000Z,
    Staffer: 'Manfry#8538',
    ID_Staffer: '470991831329406978'
  }
]
RowDataPacket {
  ID: 3,
  Reason: 'Motivo non specificato.',
  Timestamp: 2022-08-27T13:34:10.000Z,
  Staffer: 'Manfry#8538',
  ID_Staffer: '470991831329406978'
}
3
Motivo non specificato.
2022-08-27T13:34:10.000Z
Manfry#8538
470991831329406978```
#

embed type this:
ID. Reason. Timestamp. Staffer. ID_Staffer
1 Motivo non specificato. 27/08/2022 13:12. Manfry#8538. 470991831329406978
3. Motivo non specificato. 27/08/2022 13:34. Manfry#8538. 470991831329406978

#

anyone know how to help me?

#

I don't know how to use a map

rigid maple
#

I want to create a gradient color code using the dominant colors in a picture using javascript (to be used in css) does anyone have an idea how to do it?

#

like this

pearl trail
feral aspen
#

@lyric mountain, I'd like to ask a question. When making a java project, when should I be making something like com.example.something.Something and when should I make like only a Main class and that's it.

rustic nova
#

domain.company.project.classpath

#

do de.aurel.discordbot.Main

severe field
#

s

pearl trail
#

yes

stark abyss
#

okay my discord bot works absolutely fine locally, but heroku throws error (node:4) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
now I have made sure my app id and bot token is correct. On heroku i did go to settings and added in config variables section but it still doesn't work.

stark abyss
#

locally i did heroku config --> consoled log correct bot token and app id

#

i also did heroku local --> runs absolutely fine no error

#

but on heroku it still throws the error

ancient nova
#

maybe try hardcoding the token??? pepeStraightFace

feral aspen
quartz kindle
lyric mountain
#

But never, never, put the Main class in the sources root

#

src/java/Main = nono
src/java/com/example/Main = yesyes

feral aspen
lyric mountain
#

Yes, don't do that

feral aspen
#

Correct.

#

What's java, though? Why a folder named java.

lyric mountain
#

While it will work, the jit can't optimize as much as when u have an actual package

lyric mountain
feral aspen
#

Ohh..

#

I do this: /src/main/java/com/hamoodihajjiri/something/Something.java.

lyric mountain
#

Because they need to bw able to know where they can find the sources

sudden geyser
#

I see that more often

lyric mountain
#

And there's the resources folder too

feral aspen
#

Indeed.

lyric mountain
#

That's because of unit tests

feral aspen
#

So, to conclude this...

lyric mountain
#

Always place Main on the package root, not on the sources root

feral aspen
#

Create packages inside src when creating classes?

lyric mountain
#

Not packages, package

#

In singular

#

Unless ur making a multi-module project

feral aspen
lyric mountain
#

Sources is src folder

#

Package is com/example

feral aspen
#

Fair, alright.

lyric mountain
#

Don't do that too, make a parent package

feral aspen
#

Like?

lyric mountain
#

src/com/example

feral aspen
#

Oh.

lyric mountain
#

Then put anything else inside it

feral aspen
#

src/com/example/entity or src/com/example/main or src/com/example/object, and such, correct?

lyric mountain
#

Yes

feral aspen
#

What about vanilla?

lyric mountain
#

Including vanilla

feral aspen
#

Cause supposedly I'm making a vanilla project.

feral aspen
#

I thought this rule applies to maven/gradle project, though.

#

Not really rule but best practice, I believe.

lyric mountain
#

The only thing that applies to them is the java and resources folders

#

Everything else is best practices

#

Also, usually you name your folders like:
model = for POJOs and normal, instantiable classes and templates
controller = database connectors and managers
view = screens and UX/UI classes

feral aspen
#

Looks like every time I start a project, I'll do something like this: /src/main/java/com/example/main/Main.java.

lyric mountain
#

Or if ur using gradle/maven, /src/java/com/example/Main.java

feral aspen
#

Fair enough.

#

Anyways, some projects or developments comes with an auto-generated main and test folder within the sources root.

#

src/main/java/...

lyric mountain
#

That's because unit testing

feral aspen
#

Or that, particularly.

#

Nevertheless, last question..

lyric mountain
#

main I believe would be the replacement of java folder for vanilla

feral aspen
#

Nono.

#

java would be inside main.

lyric mountain
#

Ah true, just checked

feral aspen
#

Along with java would be the resources folder.

#

Also, last question..

#

A package named by com.example, is the same as /com/example?

lyric mountain
#

Yes, the former is package notation, the latter is directory notation

#

Both are the same, but usually you use . instead of / when referring to classes and not normal folders

#

Also for imports

feral aspen
#

Usually, when I made new classes inside the java folder, I call the class com.example.Main.java.

#

It'd make a package named by com.example and a class named by Main.

lyric mountain
#

Yes

feral aspen
#

Sweet.

lyric mountain
#

That's part of why you always need a root package, so you can use imports

#

And libs that rely on reflection don't work at all without packages

#

Like spring

#

Or jpa

feral aspen
#

Don't know what those are.

lyric mountain
#

Spring is a huge framework that contains many stuff from database managing to REST to class managing

#

I use more for the REST interface (springboot)

earnest phoenix
lyric mountain
#

Jpa is THE database manager, sequelize was based on it

#

It's the official "java" way of managing databases

feral aspen
#

Oh, fair.

#

I appreciate it a lot. :)

earnest phoenix
#

how do i add a bot to my discord server

lyric mountain
#

The good thing about jpa is that it's database-agnostic, you can use any database (and multiple different database at the same time) without changing a single line of code

earnest phoenix
#

@feral aspen Thanks a lot

feral aspen
lyric mountain
#

Once you get past the "meh java is bad" stereotypes, you discover it's actually a great language

feral aspen
#

But in the end, I've noticed it's pretty decent, compared to Javascript.

#

Then I studied it for game development, too. And to challenge myself into making a calculator with NO HELP AT ALL. I mean, seriously.

lyric mountain
#

Like, it's way more strict than js, but it's also exponentially stronger, especially if u need to do multithreading

feral aspen
lyric mountain
#

And in the end, the strictness makes it easy to debug

#

Btw, I really recommend u to also try groovy

feral aspen
#

Groovy?

lyric mountain
#

Yes, it's a superset of java

feral aspen
#

Is it like TS for JS.

lyric mountain
#

Ye basically

#

But gor java it's the opposite

#

Ts adds types to js, groovy kinda removes them

#

It still allows them, but it's more dynamic

#

When u don't need a highly optimized project, groovy is great

feral aspen
#

Oh, wat. What's Kotlin, then?

#

I thought Kotlin was the TS.

lyric mountain
#

Kotlin is another jvm language entirely

#

If java was C++, kotlin would be Go

#

Brb

feral aspen
lyric mountain
#

Back

#

But well, all jvm languages can talk to themselves because they compile to the same language - bytecode

#

Sometimes you can even have both within the same project working like a charm

#

Groovy directly extends java, in such a manner that to convert a java project to groovy, all u need to do is rename from TheClass.java to TheClass.groovy

feral aspen
#

Ooooo.

lyric mountain
#

Ts requires an additional step that is refactoring the code to add typed parameters and variables, groovy doesn't

#

and example of "groovy way" (almost everything java has a "groovy way"):
java ```java
for (int i = 0; i < 100; i++) {
System.out.println("Step " + i);
}

groovy ```groovy
100.times { print "Step $it" }
lyric mountain
#
Map<String, Object> map = new HashMap<>(){{
  put("key", "value");
  put("otherKey", 123);
  put("abc", new Object());
}};
def map = [
  "key": "value",
  "otherKey": 123,
  "abc": new Object()
]
#
SomeClass abc = new SomeClass("a", 123, true, "blabla");
def abc = ["a", 123, true, "blabla"] as SomeClass
#

(also works to convert arrays into class objects)

sudden geyser
#

kotlin walks in

lyric mountain
feral aspen
#

I will.

#

I also need to understand those default imports.

lyric mountain
#

wdym?

feral aspen
#

No like how they work and such.

lyric mountain
#

what kind of imports u mean?

feral aspen
#

java.<something>.<something>.

lyric mountain
#

it's kinda like esm imports

#

but instead of import stuff from "package" u do import package.stuff

feral aspen
#

Well, in JS, it's not like I do const { Math } = require("javascript");

balmy yew
#

Hy

lyric mountain
#

there are 3 ways of using classes from other files in java:

  • import com.example.* = import everything from package com.example (not including subpackages)
  • import com.example.AClass = specifically import AClass
  • no import, simply use the fully named class (eg. com.example.AClass obj = new com.example.AClass())
#

with intellij u don't really need to bother abt this (same for most IDEs) since it auto-imports on-the-go

#

u can also enable auto-removal of unused imports (alt + enter -> Enable automatic optimization of imports (or smth))

feral aspen
#

Yup, that's why I used it and why you recommended me to use it, too.

feral aspen
#

ALT + ENTER, I'll need to remember that.

lyric mountain
#

alt enter is the shortcut for quick fixes

#

alt + insert is the shortcut for quick code generation (like getters and setters, constructor, overrides, etc)

#

alt + O for overrides
alt + I for implementations

feral aspen
#

👍 👍

lyric mountain
#

there's a plugin for IJ that shows u what shortcut u could've used instead of the mouse

#

dont remember the name

feral aspen
#

No worries about that. :)

feral aspen
#

If I'm inside /src/com/example, and I want to make packages...

lyric mountain
#

com/example is already a package

feral aspen
#

Well, what about multiple packages.

#

Example, package main and package methods, and package pictures, and etc.

#

What do I do?

lyric mountain
#

while u can, it's not recommended

feral aspen
#

Why not?

lyric mountain
#

because some libs wont work at all unless u configure them to search in other root packages

feral aspen
lyric mountain
#

u shouldn't treat packages as folders like that

feral aspen
#

Oh, what do I do then?

lyric mountain
#

u can put those 4 inside a common, root package

#

like com.hamood

feral aspen
#

Alright, so it'd be like this...

#

Then?

lyric mountain
#
com.example.
           ├ entity
           ├ main
           ├ object
           └ tile
feral aspen
#

Alright, so I add those packages inside the domain package.

lyric mountain
#

yes

sudden geyser
#

shouldn't it be com.example.project.[...]

lyric mountain
#

u don't usually put the project name in the root

#

only when packaging that u sign it with com.example.ProjectName

feral aspen
# lyric mountain yes

So, example, if I'm building a maven project, it'd be like this, supposedly: src/main/java/com/example/main/Main.java

lyric mountain
#

/main/Main.java -> Main.java

#

put the main class in the package root

feral aspen
#

Oh, and the rest in packages.

lyric mountain
#

yes

feral aspen
#

It's like index.js in src and rest in folders like commands and events, and whatever (in discord bot making)

lyric mountain
#

yes

feral aspen
#

Alright.

feral aspen
lyric mountain
#

when u make a jar file, u need to put details about it

feral aspen
#

Cause I also have this, src/main/java/com.example.sub/Woohoo.java.

lyric mountain
#

that's not a valid package name

feral aspen
#

Or somethin', Idk.

#

Is this a valid example.

lyric mountain
#

ah that's because intellij skip empty folters

#

so it shows only a long-named folder

feral aspen
#

So is .duck a package or what is this.

lyric mountain
#

the entire thing is

feral aspen
#

Ohh.

#

But when should Duck be inside com.hamoo and when should it be inside .duck.

lyric mountain
#

outside only if it's Main

#

like, the class that holds void main entry point

feral aspen
#

And I'm geniuenly confused as to why.

lyric mountain
#

show ur structure

feral aspen
#

Moment.

lyric mountain
#

u cant have a package that starts with java

feral aspen
#

Oh.

lyric mountain
#

like, for vanilla, simply use com.hamood

#

for maven/gradle, there'll already be a folder named java

feral aspen
#

And is java a folder or a package.

lyric mountain
#

a folder

quartz kindle
#

a fodder

feral aspen
lyric mountain
#

bcuz u cant make a folder inside sources root

feral aspen
#

Oh, what now.

civic scroll
feral aspen
#

Do I just make a maven project, then?

#

Or I can just not name it with java..

stark abyss
#

I mentioned it before but I did go to settings config variables and added it

lyric mountain
#

com.hamood goes inside the blue folder

#

don't worry abt other stuff

civic scroll
#

the best way imo is to use environment variables

#

or by any way, hide the token from outside

lyric mountain
#

I use a starter script

#

that sets the variables before starting

stark abyss
#

Config var is the environment variable

civic scroll
#

say if json config file, make sure nothing but the bot process access that

stark abyss
#

I am accessing my token through process.env.BOT_TOKEN

lyric mountain
#

and don't forget to gitignore it

stark abyss
#

I did

#

I don’t understand why this is happening now I had the bot hosted for like 1-2 years now I did change all of the code but I specifically didn’t mess with the settings

lyric mountain
#

is it repl?

stark abyss
#

What no

lyric mountain
#

what's the context again?

lyric mountain
#

yk heroku is ending free dynos right?

stark abyss
#

Yeah

solemn latch
lyric mountain
#

well, try printing what is being retrieved from the config

lyric mountain
stark abyss
#

It’s not like I am setting everything up right now, it’s just I had it all set up I updated the code to slash commands because discords like no more message content intent and ahhh

lyric mountain
#

try printing what's being retrieved

stark abyss
#

Okay I will

feral aspen
#

I know what each does, but I'm not sure which one to choose.

#

Cause in the end, if I do stable, then I need to make a new branch and work on main, and if it's main, then I need to make a new stable branch and leave it as the stable branch.

#

So.. what's better.

lyric mountain
#

master 👌

feral aspen
#

Why?

#

And is master same as main or stable.

lyric mountain
#

that was the standard name during the entire git story until they changed it because "politically correct"

#

other than that, it doesn't really matter what u name ur branches

feral aspen
lyric mountain
#

names doesn't matter

feral aspen
#

Yes, I know. But what does it mean, master, that's it's the development one or the stable one. 😂

lyric mountain
#

master is supposed to be the production branch

#

like, the official one

feral aspen
lyric mountain
#

production is production

#

the currently running one

#

in-dev is in-dev, never confuse with production

#

for development branch it's usually called nightly

feral aspen
#

Fair enough.

quartz kindle
#

wut

#

no idea what that is

quartz kindle
#

dafuq are you trying to do?

earnest phoenix
#

Just reply with like a embed for example and add buttons with the ButtonBuilder

#

Wait

#

modal.getTextInputValue("custom-id") if your using a components Handler and I think you can use collectors instead then

knotty quartz
#

I have a blacklist script with execute should send a different message however it ignores the message and script and moves straight onto the command.

E.g: /avatar

Supposed to say: You are blacklisted.

What it does: Sends avatar

Code:

Error fixed! Thanks to tim!

quartz kindle
#

thats a very bad idea

#

you should never create event listeners inside commands

#

you should only have one client.on('interactionCreate' in your bot

#

either in your main file or in your event loader

knotty quartz
#

Thank you so much!

#

It works, that was the thing failing the override.

quartz kindle
#

👍

wheat mesa
#

204 is accepted though, for most APIs you’d get a valid object back along with a 204

solemn latch
#

"valid response" could mean anything

sudden geyser
#

Why is a 204 returning a body

wheat mesa
#

Then just check if you got an object in the body (I’m assuming it’s returning 204 either way)

#

Oh I’m stupid, I was thinking of 200

#

Just check the status code

sudden geyser
#

there's also this option for config

wheat mesa
#

You could do that but just make sure you’re catching the rejection

#

what

#

You’re overcomplicating it

#

Just check the status code

knotty quartz
#

How can i check to see if channel acccess is there to prevent downtime?

wheat mesa
#

204 is “No Content”

#

res.status or res.code or res.statusCode or something, look at the docs

knotty quartz
#

DiscordAPIError[50001]: Missing Access

DiscordAPIError[40060]: Interaction has already been acknowledged.

Uncaught Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
Process exited with code 1

#

When used in a channel without the bot accessing it ^

#

How can I fix it?

drifting cairn
knotty quartz
drifting cairn
knotty quartz
#

It shuts down because the bot has 0 access to the channel.

#

Can I send my code?

#

To see if i miss typed something

drifting cairn
#

uh

#

sure

#

ig

wheat mesa
#

yes

knotty quartz
#
const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('purge')
        .setDescription('Purge up to 99 messages.')
        .addIntegerOption(option => option.setName('amount').setDescription('Number of messages to purge.')),
    async execute(interaction) {
        //Blacklisted Script
        //Blacklisted End Script
        if (interaction.member.permissions.has(PermissionsBitField.Flags.ManageRoles)) {
        const amount = interaction.options.getInteger('amount');
        if (amount < 1 || amount > 99) {
            return interaction.reply({ content: 'You need to input a number between 1 and 99.', ephemeral: true });
        }
        await interaction.channel.bulkDelete(amount, true).catch(error => {
            console.error(error);
            interaction.reply({ content: 'There was an error trying to purge messages in this channel!', ephemeral: true });
        });

        return interaction.reply({ content: `Successfully purged \`${amount}\` messages.`, ephemeral: false });
    }
        else {
            await interaction.reply({content: 'You did not meet our requirements. `MANAGE_MESSAGES` is needed.',ephemeral: true})
        }``` @drifting cairn
#

I was testing to see if the error was because the bot didn't have access to using that channel (which it shut down too - but I got all 3 of those messages)

drifting cairn
#

inside of your .catch on the bulkDelete function

knotty quartz
#

oh.

drifting cairn
#

yep

knotty quartz
#

Do I just use followUp then? or? (Sorry abit new to purge and console.log)

drifting cairn
#

just dont continue if the bulkDelete function throws an error

knotty quartz
#

Ok. Thank you!

drifting cairn
boreal iron
#

Yes can only reply once

#

Then need to send a follow up message to your initial response

knotty quartz
#

Works just sends a message saying it purged because there is no follow up.

lament rock
#

You can send a deferUpdate without worrying about it later if you don't want to send any message

#

otherwise, you need to edit the original interaction response or followup

knotty quartz
#

ok

boreal iron
#

403 post channel messages

#

You don’t have the permission to send a message in that channel

wheat mesa
#

(make a permission handler, your life will instantly become 10 million times easier)

#

I should start doing pull requests to github projects, maybe I'll gain a little bit more confidence in my programming skillset

#

if you want scalability, js makes writing handlers easy, so definitely go for the handlers route if that's what you need

#

but if it's a small project then do whatever

#

Fair

#

I'm just looking for any excuse to procrastinate on this essay

lyric mountain
#

just get the embed from the message

earnest phoenix
#

The data of the message isn't attached to the interaction, and since the embeds are a part of the message, you can't get it that way

lyric mountain
#

interaction doesn't have embeds

#

message has

#

sigh

earnest phoenix
#

Huh? What exactly are you trying to do?

lyric mountain
#

cant u simply serialize the fields into the custom id?

earnest phoenix
#

The embeds have the fields property so you can access that embed's fields, and then access the specific field you want with indexes

lyric mountain
#

but anyway, if ur the one who created the embed, simply iterate over the fields

#

since u already know the sequence beforehand

earnest phoenix
#

And finally access the value property of the field for it's value

spark flint
#

just do ```js

let embed = new MessageEmbed(<embed>)
.setTitle("Application Accepted")

#

that gets the current EXISTING embed, and edits the title, then just send that new embed

earnest phoenix
#

That should work if you want to get the value of that embed's first field

wheat mesa
#

"I love you assembly <3"

#

I wholeheartedly agree