#development

1 messages · Page 54 of 1

harsh nova
#

mutating passed parameters can lead to unknown behaviour which is fun to see in action but not fun to debug

rustic nova
#

I don't wanna experience that nightmare during debugging

harsh nova
#

c++ is a nightmare in and of itself ngl

rustic nova
#

it's better to be able to view the flow instead of suddenly having a function called and a pretty critical value changed

#

And I don't think neither of these improve any code performance

harsh nova
#

Was a while ago I wrote with c++ but I did write a script to read inputs from a ps4 controller a while back

rustic nova
#

glad I suffer on Java instead of c++

eternal osprey
rustic nova
#

probably better if you wanna be able to understand your code later on

earnest phoenix
#

Using references instead of ordinary assignments can optimize the code performance if the compiler isn't able to pick them up for inlining and stuff

#

You should only use references if you're doing a lot of such reassignments

eternal osprey
#
 char a = 'a';
    a = static_cast<int>(a)
    cout<<a;```why would this return just plain ``a`` instead of it's int value 97?
#

would there be any way to convert that char a to a int, and pass it to the same a variable?

quartz kindle
#

you need another var with a different type

eternal osprey
#

owhh i see

#

#include <iostream>
#include <fstream>          // for file I/O
#include <cassert>  

using namespace std;
enum Action {Encrypt, Decrypt};
char rotate_char (char a, int r, Action action)
{
    char b;
    cout << a - 0;
    

if(action == Encrypt){
 if(a >= 0 && a < 32){
     b = a;
 }else{
     b = (a - 32 + (r % (128 - 32)) % (128 - 32) + 32);
 }
}
    return b;
}
int main()
{
   cout << rotate_char('a', 32 ,Encrypt) <<endl;

    return 0;
}
```i've done this, but now it returns me some strange ass shit:
#

I mean all characters work for really small values of r

#

but not for 32 etc

quartz kindle
eternal osprey
#

if a < 32, the outcome will just be a

#

else if a >= 32 and <128 it will perform that formula

raw nest
#

Is there a way in a JS function to get the file where the function was called? Without an extra param?

lyric mountain
raw nest
lyric mountain
#

well u could try throwing an exception and catching it at the same time, then getting the stacktrace and finding the line before the current function

deft rock
#

how long does a global command take to register?

earnest phoenix
#

Depends the bot

#

For me it's never more than a minute

#

On my testing bot it's seconds/instant

earnest phoenix
#

It used to take an hour for them to be registered and cached

#

But now it's instant

deft rock
#

humm wonder why mine wont do it then

earnest phoenix
#

Probably something wrong, or you have done it too many times today PepeHmm

deft rock
#

No, did it once

#

its a new bot

#
const fs = require("node:fs");
const path = require("node:path");
const { Routes, REST } = require("discord.js");
const { clientId } = require("./config.json");
const dotenv = require("dotenv");
dotenv.config();

const commands = [];
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs
  .readdirSync(commandsPath)
  .filter((file) => file.endsWith(".js"));

for (const file of commandFiles) {
  const filePath = path.join(commandsPath, file);
  const command = require(filePath);
  commands.push(command.data.toJSON());
}

const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);

rest
  .put(Routes.applicationCommands(clientId), { body: commands })
  .then((data) => console.log(`Successfully registered ${data.length} application commands.`))
  .catch(console.error);
#

I get no errors, it says it was successfully registered. But when I go do my command nothing appears as it wasnt registered

#

Got it too work

#

Helps if the bot was online 😂

thorny field
#

I want people to be able to contact me if they find any bugs or glitches on my bot, what is the best simple way to do that

lyric mountain
#

do note tho, only a fraction of users ever bother to report bugs

thorny field
#

Modals? What is that

lyric mountain
thorny field
#

Oh is that supported in the python version?

lyric mountain
#

check the docs

thorny field
boreal iron
#

Still client caching issues seem to require to reload the client quite often I noticed (before being available)

earnest phoenix
#

At leas that has always worked for me

eternal osprey
#
/  Pre-condition:
assert (a >= 0 && a < 128 && r >= 0);
/* Post-condition:
Result value b > 0 or b == 0, and b < 128, and result value r > 0 or r == 0.
*/
if(action == Encrypt){
 a = ((a >= 32 && a < 128) ?  (a - 32 + (r % (128 - 32))) % (128 - 32) + 32 : a);
}else if(action == Decrypt){
a = ((a >= 32 && a < 128) ?  (a - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : a);
}```why is this returning me warnings: ``'comparison is always true due to limited range of data type'``
earnest phoenix
eternal osprey
#

a is a char and r is an integer

deep fern
#

bro

#

now every 2hours or so my bot will get rate limited

lyric mountain
#

tf is that ur doing

eternal osprey
#

i am trying to encrypt chars based on the r .

deep fern
#

can anyone help

lyric mountain
#

no

eternal osprey
#

Imagine i have char 'a', which has a value of 97, and chosen r = 1, the new value would be 98.

deep fern
#

my bot is getting rate limited in every 2hours

deep fern
lyric mountain
eternal osprey
#

It works, i ran some google tests. However, now i am facing the issue that the encryption is slightly off due to the fact that above statements are always true

lyric mountain
#

and for ratelimit, what exactly do u want help with? simply don't spam the api

deep fern
lyric mountain
deep fern
deep fern
#

i have just written my code

#

and just run it

#

and hosted it with uptimerobot

#

thats it

lyric mountain
#

well, I can't help if you dont give anything to work with

#

at least show the error

deep fern
#

429 hit on /route

#

whatever

#

like i can fix it

#

i just wanna know the reason why

#

and why it happens so often

#

and how can i fix that

lyric mountain
#

that's not the error

eternal osprey
lyric mountain
#

I want the full stacktrace

deep fern
lyric mountain
#

no, the error u got in the console

deep fern
#

i dont get error

lyric mountain
deep fern
#

i just need help with how can i reduce rate limit

lyric mountain
deep fern
#

429

#

hit on /route

#

and the bot is off

lyric mountain
#

THAT'S THE ERROR

#

just show that

deep fern
#

i fixed it dude

lyric mountain
#

sigh

deep fern
#

i am saying tho

#

that

lyric mountain
#

you don't get the point

deep fern
#

how can i reduce how often i get rate limited

lyric mountain
#

I don't want u to write the error, I want the error itself

#

a print of it, per se

eternal osprey
deep fern
lyric mountain
#

I don't want u to write it

#

I want the original, untouched thing

deep fern
#

yeah

#

thats the rogiginal

#

original*

lyric mountain
#

that's just the message of the error, but the useful part is in the rest of the error

#

aka the stacktrace

earnest phoenix
#

You are most likely using Replit which uses shared IPs for lots of projects. Since lots of people share the same IPs the rate limits come way faster.

lyric mountain
#

all loggers should include the full stacktrace

earnest phoenix
#

Solution? Of course: don't use Replit kryptonWriting

deep fern
earnest phoenix
#

You cannot prevent yourself from getting rate limited.

deep fern
#

cuz

#

i used to get rate limited in like 1day or so

earnest phoenix
#

If you don't change 'hosting' provider, you will always get rate limited.

deep fern
#

not this often like only 2hour

earnest phoenix
#

Either self host on some raspberry pi or pay for a proper VPS for as less as $2/month

lyric mountain
#

console.log(e) will only print the exception message, but exclude everything else

earnest phoenix
#

Keeping on using replit will make you getting ratelimited, that's a fact

earnest phoenix
#

You may also eventually get rate limited by Discord - and be unable to even get your bot online

lyric mountain
#

shared ip, yeah

earnest phoenix
# eternal osprey a is a char and r is an integer

The warning occurs because the range of the data type of char is 0-255 by default but this is compiler-dependent, you should explicitly declare if you want the char to be signed (range of -127 to 127) or unsigned (range of 0 to 255)

Since it's unsigned for you and you're checking if the char will be greater than or equal to 0, it'll always be true

eternal osprey
#

how would i sign it?

#

char*?

lyric mountain
#

that's a pointer

earnest phoenix
#

signed char

lyric mountain
#

what is the original question asking for?

#

like, why can't u let the char under/overflow?

eternal osprey
eternal osprey
#
char rotate_char (char a, int r, Action action)
{
//  Pre-condition:
assert (a >= 0 && a < 128 &&  r >= 0);
/* Post-condition:
Result value b > 0 or b == 0, and b < 128, and result value r > 0 or r == 0.
*/
if(action == Encrypt){
 a = ((a >= 32 && a < 128) ?  (a - 32 + (r % (128 - 32))) % (128 - 32) + 32 : a);
}else if(action == Decrypt){
a = ((a >= 32 && a < 128) ?  (a - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : a);
}
    return a;
 
}```
lyric mountain
#

ye I saw the spaghetti

#

but like, simply add a + r

#

when it reaches 256 it'll overflow to 0

eternal osprey
#

we can't ass we eventually create it based off random r's

lyric mountain
#

...yes?

eternal osprey
#

We eventually have a randomizer that will add values to certain characters so they get 'encrypted'.

#

However, i must do it like this

#

my teacher says so

lyric mountain
#

but how is that an issue with a + r?

#

u could pass anything as r

#

it'll still work regardless

eternal osprey
#

don't ask me, we just got these formulas and some background info to work with.

#

it must be done like this

#

but yeah, for some reason the output is slightly different then it should be

#

and i think it's due to that encoding

lyric mountain
#

ok, then lemme humanize that code

if (chr >= 32 && chr < 128) {
  char radix = 128 - 32;
  char offset = r % radix;

  if (action == Encrypt) {
    chr -= 32 + offset;
  } else if(action == Decrypt) {
    chr -= 32 - offset + radix;
  }

  chr %= radix + 32;
}
#

considering it's checking for < 128 I imagine it's indeed a signed char

eternal osprey
#

i see

#

the assert i made is giving issues tho

#
[----------] 4 tests from OTPTest
[ RUN      ] OTPTest.use_OTP_1
Assertion failed!```
#

``main.cpp, Line 39

Expression: a >= 0 && a < 128 && r >= 0``

#

i will log a rq to see what's going on

#

but @lyric mountain isn't it strange that we are checking if a character is smaller then < 128?

#

I mean it's a character...

#

shouldn't we convert it to int first?

lyric mountain
#

characters are numbers

#

it's equivalent to short in some langs

eternal osprey
#

hmm then this issue is really strange

deep fern
#

i got a new hosting

#

lets go

earnest phoenix
earnest phoenix
#

I meant the name

deep fern
#

its a pterodactyl hosting

#

i dont even know the name

earnest phoenix
deep fern
#

still free

eternal osprey
#

i am following all steps i must

earnest phoenix
#

hey, does anyone know how i can possibly make a new array in a json file without overwriting already existing data?

lyric mountain
#

then simply find which line has the same name as the current file and get the next

raw nest
#

ah like that ye true. I'll find a way^^thanks:)

lament rock
lyric mountain
lament rock
#

oh that's stupid

lyric mountain
#

the stacktrace is collected at runtime, that's why you need to throw it

#

indeed a stupid trick, but does the work

lament rock
#

JS is a little different and the stack is collected as the code runs and if the code reaches too large of a depth (recursive), an error saying that the max stack size has been reached. You can also configure the max stack size

lyric mountain
#

it's the same concept

lament rock
#

Well no, the thing with js is you can construct a new Error and not throw it and still get the stack

lyric mountain
#

ah true

eternal osprey
#

after 10 fucking hours i finally finished my assignment

#

The issue was so damn easy

#

nvm iot's still broken

#

where's that ? coming from?

#

even if it's a whitespace it should be coded normally?

#
while(!infile.eof()){
initialise_pseudo_random(initial_value);
initial_value = next_pseudo_random_number();
char individual = infile.get();
cout << individual <<endl;
cout << "end" <<endl;
char init = rotate_char(individual, initial_value, action);
outfile << init;

}
outfile.close ();
infile.close ();```what i am using
lyric mountain
eternal osprey
#

what???

#

this is what the end of the file looks like

lyric mountain
#

when u manipulate characters directly you'll eventually enter in the special characters domain

eternal osprey
#

you have a normal processed space, and then you have 2 whitespaces which counts as 1 character

eternal osprey
#

this is theirs

lyric mountain
#

you either opened or saved the file with a different encoding

#

also that last char is probably EOF char encoded with ur algo

neon leaf
#

can I somehow make these chakaraui toasts start lower? I know that containerstyle exists but I dont know if I can do that with it

eternal osprey
#

yeah i thought so as well

lyric mountain
#

what did u use to write the text?

#

also yes, note how there's a 15th line

eternal osprey
#

Yeah these are the encoded chars and they are not encoded with it

#

how would i remove this?

lyric mountain
#

simply don't save the file with it

eternal osprey
lyric mountain
#

what did u use to create the file?

#

notepad, sublime, vscode, what?

eternal osprey
#

ifstream

lyric mountain
#

I didn't mean the output file

#

I mean the input

eternal osprey
#

the 15th line was done by my teachers, on purpose i think.

lyric mountain
#

then just delete that line

eternal osprey
#

It should stay intact. However, if the EOF() function was the cause of this is there no other way to do this?

lyric mountain
#

not function, character

#

and no, there's no other way

#

the algorithmn is doing exactly what u want, the issue is in the input text

eternal osprey
#

oowhh that's an easty fix then

#

i could check if my current char i am looping on (called init) is equal to the EOF character?

#

and if it is, simply return.

lyric mountain
#

kinda

eternal osprey
#

yup it works, thank you!

#

Never knew, there's a EOF property in c++!

surreal sage
#

I saw something once and I want to get back to it

#

It was a .then with an object inside the function

#

.then(({something}) =>

#

Which gets specific keys/entries from the returned object

#

But how.

lyric mountain
# surreal sage But how.

consider you have the object

{
  "name": "Abc",
  "age": 21
}

doing .then(({name}) => Console.log(name)) would print the name, which is the same as doing .then(obj => Console.log(obj.name))

#

it's just a shortcut

#

it's not an object inside the function, it's the deconstructor

#

it's like when u do import {a, b} from "./file"

surreal sage
#

Understood

#

Thanks for lmk

fickle arch
#

so I tried make my new bot get total server it's in with this (old code from previous bot)

 client.on("ready", () => {
   let total = client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)
 
   console.log(`${client.user.username} is now online!`)
   let activities = [ `${client.guilds.cache.size} servers`, `${total} users!` ], i = 0;
   setInterval(() => client.user.setActivity(`${config.prefix}help | ${activities[i++ % activities.length]}`, { type: "WATCHING" }),5000)
 })```
but it's only shown amount of member in 1 server + watching 1 server 
*first picture is the old project and the second one is the new one (the second one is in 3 server*
lyric mountain
#

that's getting the total members, not servers

fickle arch
#

invited it to new server and it now shown 2 server and not 3 (for some reason) but the total members is updated

#

yeh it only shown the 2 server the bot in and not the original server, ig it's not a big deal

lyric mountain
#

cache is never guaranteed to have the actual number of guilds

#

same applies to any other cache

quartz kindle
#

you have to define them inside the interval so they are recalculated

#
const a = client.users.cache.size; // define the value once
setInterval(() => {
  console.log(a) // will always be the same value because it was defined only once
})
``` ```js
setInterval(() => {
  const a = client.users.cache.size; // will get the updated value on every interval
  console.log(a) // value will always be up to date because its redefined on every interval
})
earnest phoenix
#

PS: setInterval kryptonHype

quartz kindle
#

set int eval

#
set int eval("Krypton")
earnest phoenix
quartz kindle
#

/compress Krypton

deft rock
#

Sounds stupid I know. But if I made a bot to fight suicide would that be against discord TOS or anything?

lyric mountain
#

it'd be obnoxious af

deft rock
#

Why?

lyric mountain
#

you can't fight suicide by deleting any mentions of it

#

if anything you'll only remember the person about bad times

deft rock
#

Who said that's what the bot would do :/

lyric mountain
#

or in the very least, make the users hate the bot

deft rock
#

I never said the bot would delete the messages

#

Idk where u got that from

lyric mountain
#

ok, then what would it do?

#

send hotline number?

deft rock
#

Basically in summary the bot will do that and (if I'm able to get it) will send help. It's gonna be a challenge but I'll get it.

lyric mountain
#

yeah nobody will be helped by that

quartz kindle
#

wasnt there a story in the usa where a person called a suicide hotline, they sent the cops, and the cops shot the person?

earnest phoenix
lyric mountain
#

I do know that having some constantly remembering you that you're depressed only makes things worse

earnest phoenix
deft rock
lyric mountain
#

oh boy, I do

#

a long time ago, about 4 years iirc I had some hard times due to parental abuse

#

I can say for sure, the worst thing to happen is having someone trying to "help" you by saying "no dont do that" or "your life matters"

#

it doesn't help, in fact, it only made me feel worse since, when you reach that point, you don't give a fuck to hypocritical words from people that never bothered to help you when you needed

#

you want to help? treat the root cause, not depression itself

#

and a bot cant do that

earnest phoenix
#

I have lil problem. I tried to get user.id in discord py using discord.User but it says that user has no tuple. When i printed only user i got something like this. How to get id from this?

rustic nova
#

these are arguments you can access using their keys, such as the name by user.name or check if it is a bot by user.bot

#

what you're viewing is the string-based object that was converted from the user object to a readable string

#

mostly used for debugging, though refer to discordpy's docs on what certain objects could have for parameters

earnest phoenix
#

i tried using user.id but it says it has no tuple

#

or maybe how i could covert this somehow

rustic nova
#

it should be provided correctly, granted that you've obtained it through discordpy

#

post your lines causing said error

earnest phoenix
rustic nova
#

code please

earnest phoenix
#

The whole command?

lyric mountain
#

yes

rustic nova
#

most importantly from where you're defining user to where you're going to use it

earnest phoenix
#
@bot.command(pass_context=True, no_pm=True)
async def closeticket(ctx, * user_author: discord.User):

    channel = bot.get_channel(1026486467071057940)
    author = ctx.author

    db = sqlite3.connect("main.db")
    cursor = db.cursor()

    if not user_author:
        cursor.execute(f"SELECT user_id FROM tickets WHERE user_id={author.id}")
        user = cursor.fetchone()
        if not user:
            return await ctx.send("Nie masz żadnego otwartego zgłoszenia!")
        else:
            cursor.execute(f"DELETE FROM tickets WHERE user_id = {author.id}")
            await author.send("Zgłoszenie zostało zamknięte, a reszta danych usunięte.")
            embed = discord.Embed(description=f"ID: {author.id}")
            embed.set_author(name=f"{author.name} ZAMKNĄŁ SWOJE ZGŁOSZENIE", icon_url=author.avatar_url)
            await channel.send(embed=embed)
    else:
        print(user_author.id)
        cursor.execute(f"SELECT user_id FROM tickets WHERE user_id={user_author.id}")
        user = cursor.fetchone()
        if not user:
            return await ctx.send("Wybrany użytkownik nie ma otwartego zgłoszenia!")
        else:
            cursor.execute(f"DELETE FROM tickets WHERE user_id = {user_author.id}")
            await user_author.send("Zgłoszenie zostało zamknięte, a reszta danych usunięte.")
            embed = discord.Embed(description=f"ID: {user_author.id}")
            embed.set_author(name=f"{user_author.name} ZAMKNĄŁ SWOJE ZGŁOSZENIE", icon_url=user_author.avatar_url)
            await channel.send(embed=embed)

    db.commit()
    cursor.close()
    db.close()
rustic nova
#

so as far as I'm seeing, the user provided is through the user that used the command right?

earnest phoenix
#

yeah

rustic nova
#

what's the difference between author and user_author btw

#

one if the message author, the other one the ticket or

earnest phoenix
#

author = User that used a command
user_author = Given id when calling a command e.g. !closeticket <id>

rustic nova
#

ohhh

earnest phoenix
#

yeah...

#

I'm slowly breaking down over this

rustic nova
#

so discordpy automatically converts it to a user?

earnest phoenix
#

yeah

rustic nova
#

sounds dangerous ngl

earnest phoenix
#

Yeah XD

#

Kinda

#

But it works somehow

rustic nova
#

wanna like, try to fetch a user yourself? would be my guess

earnest phoenix
#

But still idk why i can't use this id

#

I'll try this

rustic nova
#

even though it should theoretically work

#

you could also ensure its the correct type by using type(user_author) and echoing that back

#

because a tuple is not the same thing as a discord.User and would explain your error

#

since you cant obtain values within a tuple through string based indexes/attributes, only by number indexes

sharp geyser
#

@rustic nova smell

rustic nova
#

no u

sharp geyser
#

Ima make you drink a Caramel Macchiato

rustic nova
#

ew

sharp geyser
#

Ima turn you into a starbucks girl

#

@rustic nova I got a lot of books from my library

#

Programming ones

rustic nova
sharp geyser
#

I got 2 on python, one for basics the other for ML in python, one C# book and one about Assembly Languages and hardware

rustic nova
#

need a python one istg

sharp geyser
#

Its an older book

#

but its still hella useful for basics

earnest phoenix
#

Good stick to it I will do it differently. Anyway the question I have is an important one. If I don't have Message Intents then what can't the bot do?

rustic nova
#

read message contents it was not pinged in

sharp geyser
#

Get message content

#

thats literally all the Message Content Intent does

#

it just denies the ability to read the content of messages it wasnt mentioned in

rustic nova
#

you will still get the events

#

just not the content

sharp geyser
#

just the content will be undefined

earnest phoenix
#

So if I'm doing technical support in private messages bot, then I would need Message Intent?

sharp geyser
#

I think dms still get it

#

I dont remember

rustic nova
earnest phoenix
sharp geyser
#

If its in DMs no

rustic nova
sharp geyser
#

You're free to keep it disabled

#

Anything in a guild though if you wanna read message content outside of messages the bot is pinged in then yes

earnest phoenix
rustic nova
#

well as the message content intent says

sharp geyser
#

You need the GUILDS intent for receiving the messageCreate event in servers

rustic nova
#

commands will not work if you're talking about - for example

#

unless you're doing something like @Aurel closeticket

sharp geyser
#

without the GUILDS intent messageCreate wont fire in guilds

earnest phoenix
#

oh okay

rustic nova
#

Any fields affected by the message content intent are noted in the relevant documentation. For example, the content, embeds, attachments, and components fields in message objects all contain message content and therefore require the intent.
...
Apps without the intent will receive empty values in fields that contain user-inputted content with a few exceptions:

Content in messages that an app sends
Content in DMs with the app
Content in which the app is mentioned
earnest phoenix
#

Big thanks

boreal iron
#

The intent GUILD does not include messages

sharp geyser
#

That’s a intent?

#

Damn proves what I know

#

Hey Fake wanna do half of my custom Halloween bot /s

boreal iron
#

Man… pigs will learn to fly before I ever touch TS or python

#

Also im always busy unfortunately

#

Can’t even get my own shit done

quartz kindle
#

lmao

sharp geyser
#

Tim hey buddy

#

Should I even bother with caching (gotta love autocorrect) messages for a rpg bot?

#

All I plan on doing as of right now is just listening for messages but I don't necessarily need those messages after

wheat mesa
#

If you have no use for them afterwards, no reason to cache them

#

Though I thoroughly believe you’ll probably need to cache them at some point for an rpg bot

nocturne dagger
#

Hey there, I cannot figure out how to fetch a message for the live of me on the newest discord.js

I am doing


const msg: GiveawayMsgType = await client.channels.cache.get(giveawayDetails.channel).messages.fetch(giveaway.id)

#

.channel is the channel id

.id is the msg ID

#

I am sure its a small change I am missing but I can't find it in the docs at all.

wheat mesa
#

What’s the error?

#

(Or is it just not working?)

sharp geyser
#

Should I just store the messages on the channel class then waffle?

wheat mesa
#

Idk

#

I should get back to my physics homework

nocturne dagger
#

I changed it to

(await client.guilds.cache
          .get("889928598927073412")
          ?.channels.cache.get("889928599552028714")) as TextChannel
      )?.messages.fetch("1027730505434681355");
#

but its undefined

wheat mesa
#

Those channels/guilds probably aren’t cached

nocturne dagger
#

the message is being fetched on start up

#

or, it was created while the bot is running

wheat mesa
#

Log the values of those guilds and channels

#

One of them is probably undefined and therefore ending the chain early

nocturne dagger
#

but what is weird is that up to guild it just logs the guild id

#

and then obviously the channel would be undefined if its just a guild ID

rustic nova
#

then the guild isnt cached

#

is what I'm guessing

boreal iron
#

All this weird chaining…

#

Why do you even access the guild cache then access the channel cache?

#

you can access the cached channels directly as property of your client

nocturne dagger
#

I tried that as well

#

as client.channels.cache(id)

#

did not work either

sharp geyser
#

Its almost as if you can't use .fetch

#

😮

boreal iron
#

Use fetch to get the channel once it’s not cached

sharp geyser
#

Relying on things being cached is a surefire way to failure

#

Now then time to figure out how I wanna handle event listening

boreal iron
#

Unless you’re 100% sure it’s cached

#

Because you did so earlier for example

sharp geyser
#

I am now realizing how lazy I am and dont wanna write a caching system that will work for anything

nocturne dagger
sharp geyser
#

What in the fuck

boreal iron
#

What’s the reason of fetching the guilds for example when they already being provided with the ready event

#

I mean fetch will access the cache anyways before doing a request but this doesn’t make it less confusing

#

Not to mention that your action may result in a major rate limitation you will suffer from later on for example when trying to fetch another channel/message etc. like you did in your code example

nocturne dagger
#

Ok, put it simply, I just need to get a msg so i can edit it

wheat mesa
#

Fetch the message via its id

nocturne dagger
#

but something changed from v13 to now

wheat mesa
#

client.messages.fetch

#

That simple

nocturne dagger
#

Tried that and it broke, maybe I'm being stupid ill try again

wheat mesa
#

Await it

#

It’s a promise

nocturne dagger
#
const msg: any = await client.messages.fetch(giveaway.id);
wheat mesa
#

Oh yeah I forgot messages isn’t a thing on djs

nocturne dagger
#

Messages does not exist as a type on client either

#

Yea thats the issue haha

wheat mesa
#

You’ll need to fetch the channel and then fetch the message from there

nocturne dagger
#

After about 20
// @ts-ignore

#

it worked!

boreal iron
#

Ask yourself why you use ts in the first place

sharp geyser
#

messages arent attached to the client only channels iirc

quartz kindle
#

if youre doing that right after creating the client, the channel is not gonna be cached yet

#

you would need to do it in the ready event

boreal iron
#

Has anybody ever found out how mobile browsers utilize the feature to switch between a desktop/mobile version of the site?

solemn latch
boreal iron
#

It does not fake it’s screen resolution

boreal iron
#

Detecting the screen size or user agent and redirect the client has nothing to do with that

#

Browsers like safari or Firefox on mobile offer the functionality to show the desktop version of a site or mobile version (you can switch back and forth)

solemn latch
#

The browser doesnt control that does it?
the site does, All it(the browser) does as far as I can tell it detects the viewport scale.

boreal iron
#

There aren’t much sites supporting this functionality but I yet couldn’t figure out what exactly happens in the background

#

No the viewport doesn’t change as well as the screen size

#

Nothing is faked by the browser

#

To emulate a desktop client

#

There must be something else I don’t think of

solemn latch
#

Well, css only checks viewport size/scale right?

#

for media queries

#

Your backend wont know that though

#

Ie a brower will process the css as if its viewport is 1920x1080 but the viewport might only be 900x300 or something.

#

(which would be called viewport scaling iirc)

#

But I'm not a web developer and could be 1000% wrong

boreal iron
#

I’m not sure if that is handled via css
I somehow guess it’s a specific browser feature you have to build and use

solemn latch
#

My site does not account for it and it does it fine

#

Just using media queries for the responsive layout

boreal iron
#

Yes, me too

#

Which results in using that browser feature actually does nothing

#

But it’s sometimes a good thing or necessarily to get to view the desktop version

solemn latch
#

🤔 are you saying the desktop switch doesn't work for your site or it does?

boreal iron
#

It does not lol

#

The browser does not fake or emulate a different screen size and does not report a different viewport

#

IT DOES SOMETHING but idk what

solemn latch
#

ah, it works for me just using media queries.

Which leads back to my original question, is your mobile version using a seperate mobile site(ie, m.site.com)? or using media queries for a responsive layout between desktop and mobile.

boreal iron
#

I’m just using media queries

#

Anything relies on the reported screen size of the client

solemn latch
#

Is your media queries set to the standard size for between mobile and desktop?

#

I cant remember what that is, but there is a standard media query size

boreal iron
#

Wut

#

The default layout is of course the mobile view and various media queries catch screen sizes larger than XX

solemn latch
#

1280px wide is the standard resolution to start displaying a desktop version.

If the desktop flag sets the width to 1280px wide, and your media queries show the mobile version at that width it wont do anything.

boreal iron
#

It’s actually 1200 if I’m not wrong

#

And no the client doesn’t report a different screen size when using that switch

solemn latch
#

It might be, 1280 is what mine is set to

#

the client wouldnt would it?

boreal iron
#

You can find That out yourself

#

Just open the site and use the switch and debug the parameters your client provides

boreal iron
#

But that’s also not the case

#

Which means the browser does not emulate a different screen size

solemn latch
#

I'm not sure what else it would be then

boreal iron
#

Makes us already two

#

Who don’t know that dirty secret

solemn latch
#

🤔 So, just playing around with my css files.

@media only screen and (max-width: 980px) { allowed the desktop setting to work.
@media only screen and (max-width: 979px) { did not allow it to work.

#

(using chrome)

#

Other browsers might use other levels

boreal iron
#

playing around with a max width is a horrifying solution

#

You should always use min widths

#

Scaling it towards a desktop size showing the mobile version by default

solemn latch
#

My site requires a desktop

#

You can't create webhooks on mobile

boreal iron
solemn latch
#

That's a discord limitation not mine

proven lava
#

Long time top.gg user, first time joiner...

In discussion with my DAO team, we envisioned collecting the "shared servers" of Discord members to sort of 'word cloud'-esque map of server populations. I am wondering if Top.gg has anything like this already in the works, or if someone here might have a point of contact for a commission or collaboration?

#

For example, if you put in the uid of all members of a channel on Discord, it could create a map with all their servers (or at least all those shared by 2+ members) that shows the relative population crossover

sharp geyser
sharp geyser
#

@earnest phoenix Love how discord blocks it

#

Gotta open in the browser

earnest phoenix
#

Oh well mmLol

earnest phoenix
#

Will someone give an example of some command that requires Message Content Intent to work? Besides Automod

sharp geyser
#

Any command that takes response back

boreal iron
#

Actually not anymore since modals exist as direct way to response

sharp geyser
#

Hey fake

#

Fuck off

#

:)

boreal iron
#

Even if they’re lacking a lot of field types

sharp geyser
#

Do modals work on mobile yet

boreal iron
#

They work on mobile since they got introduced

sharp geyser
#

Wait discord actually added something on launch with mobile support

#

no fucking way

#

Discord never supports the cool shit on mobile

boreal iron
#

Just android users were fucked using the old client iirc but who gives a fuck about them freerealestate

sharp geyser
#

still waiting for the codeblocks to be syntax highlighted

#

and mfs got modals

boreal iron
sharp geyser
boreal iron
#

That would be nice tbh

#

ETA 2032

earnest phoenix
#
print("uwu")
console.log("uwu");
#

Yeah

sharp geyser
#

Not all

earnest phoenix
#

Is mongodb a good database for bots in more than 1000 guilds

#

Or are there other better databases in terms of performance

earnest phoenix
deft rock
#

Good morning,
I have 2 things to ask

  1. Does anyone have a document that I can setup/host my own lavahost (music)

  2. [error] Unhandled exception : 'user is not allowed to do action [find] on [test.guilds]' Does anyone know what went wrong?

earnest phoenix
deft rock
#

Im not sure. I was told to use this lavahost thingy for music for my bot

earnest phoenix
deft rock
#

thank you. Anyidea for my 2nd question?

earnest phoenix
#

What is that error thrown from?

deft rock
#

Ill grab the full error brb

#

Seems to be from MongoDB?

earnest phoenix
neon leaf
#

Does anyone know how to remove the short white screen when switching pages in a react site?

pearl mantle
#

.

surreal sage
#

This isn't specifically about development but just shooting my shot

#

My VPS' connection just fails

#

It doesn't shutdown

#

It just can't send any requests

#

Or receive

#

This happens about once a day for 5-10 mins

#

I saw using uptimerobot it happened twice within 30 minutes

#

1 minute downtime and 4 minutes

deft rock
earnest phoenix
boreal iron
surreal sage
#

All connections r dead

boreal iron
#

Ok… so network specific issues

#

Just for the statistics, what’s your provider if I’m allowed to ask?

urban cape
#

Anyone here with a good knowledge on express js?

boreal iron
#

Just ask your question

urban cape
#

I am typing it, 20000 character code

boreal iron
#

lol

urban cape
#

I make a file ready with a websocket
and then I request data to /movies/xx
but then it gives me an error empty response

urban cape
#

I see in the console that I have a request, but in the browser or with curl it doesnt send anything

earnest phoenix
#

can you dm me templates of multiporpse discord bots

lyric mountain
radiant kraken
#

you can use any top.gg bot as a template

lyric mountain
quartz kindle
urban cape
#

Sure, but that doesnt explain the error, locally via http it does work, via https not.

solemn latch
#

local https?

urban cape
#

Not tried, I am working on that

boreal iron
urban cape
#

I have certbot

#

I cant make it work via https

solemn latch
#

Why not use a reverse proxy like nginx?

urban cape
#

I thought having cloudflare was enough

quartz kindle
#

you have cloudflare flexible ssl?

#

or strict?

urban cape
#

strict

#

Everyother webpage works but just not the movie one

quartz kindle
#

but it works if you bypass cloudflare?

urban cape
#

Yes

quartz kindle
#

you said it worked locally, like using localhost?

urban cape
#

bypassing cloudflare does work over http

quartz kindle
#

hmm

#

what if you turn off cloudflare and access your website normally?

urban cape
#

I can try that

#

I just changed the DNS settings, now its time to wait

urban cape
#

So it just does not work over https

#

but why

lyric mountain
#

perhaps ur ssl is configured wrongly

#

also, you should use cloudflare origin certificate instead

urban cape
# lyric mountain perhaps ur ssl is configured wrongly

That should not be the case.
First I had that my code would read a file smaller than 2gb and it worked.
A couple of days ago I worked out how to get a buffer from a 3gb file and it is not working anymore.
That cant be a ssl issue
I couldn't find evidence that the extra 1gb is a problem.

lyric mountain
#

wait, 1gb?

#

what is ur api for?

urban cape
#

I have a hard disk full of movie. I want to read the movies for personal use. (It is not illegal).
So my api sends out sometimes 3gb out of movie data.

lyric mountain
#

are u sending it as a stream?

urban cape
#
return res.end(moviebuffer, "binary")

I dont think so

lyric mountain
#

well, that could be the issue

#

if ur api takes too long to return an answer, the connection may close prematurely

#

aka "pipe broken"

solemn latch
#

Also, cloudflare has file limitations

urban cape
lyric mountain
#

fo anything bigger than 1gb you should consider using a stream instead

urban cape
#

Ok, i can try

lyric mountain
#

what kind of value are u returning?

quartz kindle
#

you should never use buffers for large files

#

always use streams

#

unless the chunking code you're using only returns small buffers

lyric mountain
#

I also imagine 2 simultaneous requests would crash the api due to OOM

urban cape
#

Yeay, it is personal use with password. So nobody can use it except me 🙂

lyric mountain
#

still

urban cape
#

It worked for 1.8gb files so I didnt complain. Then when the files get larger fs.readFileSync thought it was to large. ugh
Then I could not make it work anymore

quartz kindle
#

again, use streams

#

never use buffers for large files

urban cape
#

Ok, I am working on it. I come back when I cant get it to work.

quartz kindle
#

this will read only the specific chunk from disk and stream it directly to the response, so it doesnt need to store anything in memory

umbral lake
#
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('ok')
app.post('/vote', webhook.listener(vote => {
    db.add(`votes.${vote.user}`, 1)
    let value = JSON.stringify({
        embeds: [
            {
                title: "Un nouveau vote est arrivé !",
                description: `<@${vote.user}> vient de voter Synapse sur Top.gg !`,
                color: "255"
            }
        ]
    })
    fetch("webhook lol", {
        method: 'POST',
        headers: {
            'Content-type': 'application/json',
        },
        body: value
    }).catch(e => console.log('Erreur : ' + e))
}))
app.listen(3000)
``` I'm on replit but idk if works or no and idk if I use the good port :/
urban cape
#

thx

#

thx

quartz kindle
#

use process.env.PORT instead of 3000

umbral lake
quartz kindle
#

replit uses dynamic ports

lament rock
#

that env var is the port replit exposes

quartz kindle
#

the correct port is saved in the env variable

umbral lake
lament rock
#

yup

umbral lake
#

oh ok ok, I will test, thx

lament rock
#

its a built in env var

quartz kindle
#

the env port is done automatically, its not a custom env

#

its built in by replit

umbral lake
#

Okayy

urban cape
umbral lake
urban cape
#

I mean, 3gb in ram isnt that bad

#

when starting to write the code on a normal pc I had 80gb in ram

lyric mountain
#

80?

quartz kindle
urban cape
quartz kindle
#

lmao wtf

urban cape
#

not the smartest plan

lyric mountain
#

...don't u mean 8gb?

quartz kindle
#

how much ram do you jave?

urban cape
#

no 80

urban cape
lyric mountain
#

80 ain't achievable no matter how I look at it

quartz kindle
#

lmao

lyric mountain
#

128??

quartz kindle
#

i mean

urban cape
#

Little overkill pc

quartz kindle
#

thats just 4x 32gb sticks

urban cape
#

Yes

quartz kindle
#

pretty common these days

#

if you can afford :^)

urban cape
#

And after I added another batch of movies, I had 330gb

lyric mountain
#

that's like, not something u can call "normal pc"

urban cape
lyric mountain
#

only for first world countries ig lul

#

around here 32gb is already considered a lot

quartz kindle
#

i have a laptop with 8gb xd

urban cape
quartz kindle
#

my vps has 2gb

#

:^)

lyric mountain
#

and to think mere 20 years ago we were reaching impressive 16gb hdds

quartz kindle
#

i had a quantum fireball 3.2gb

urban cape
#

I have another small question.
I have now a video element on html and when I want to skip to a certain part it loades the whole movie.
Anyway to avoid that
(I do it on html, because with some flags enable in browser you can select your audio track and because dvd had multiple audio tracks, i wanted that to.)

quartz kindle
#

the progress bar should be linked to the chunking

#

so when you click on it, the correct chunk should be calculated and requested

#

i never really did that myself so i dont know the specifics

urban cape
#

I just skipepd from 00:00 to 1:11:43 and it wont go after getting 600mb

#

almost fully loaded

#

lmao

#

I hate html

quartz kindle
#

are you using a player library or are you coding your own html player?

urban cape
#

just my own html

quartz kindle
#

maybe this will help

urban cape
#

I was on the exact same site

#

lol

quartz kindle
#

but from what om reading, you might have to use advanced stuff

#

the html5 player doesnt give you much control

#

most players use stuff like mpeg dash and hls

radiant kraken
lyric mountain
#

when code is so magic that it starts emitting an aura

wheat mesa
radiant kraken
radiant kraken
cinder patio
#

imagine using unsafe in rust

#

code as u8 as char

#

Chars can't be larger than a u8 anyways so you're just making it harder to read the code

#

Assuming Self::Character is char ofc

clever bobcat
#

hi

#

how to get bot dev role

wheat mesa
#

By getting a verified bot on top.gg

clever bobcat
#

...

#

how to make my bot popular

wheat mesa
scarlet kiln
jovial nimbus
#

Is there an alternative to this tempfile.site

#

or no

spark flint
jovial nimbus
spark flint
#

very

#

thats how to get a URL instead of emailing it

jovial nimbus
spark flint
#

oh

#

wait

#

you want an API one

#

not sure then sorry

jovial nimbus
lyric mountain
#

u can also simply make ur own api, shouldn't be too hard

jovial nimbus
lyric mountain
#

well, most will be paid (for obvious reasons)

jovial nimbus
#

Explain more

lyric mountain
#

you see, apis that allow file upload inherently need high storage space, and to be able to sustain a high amount of users they either
A - have paid plans
B - have very low per-user allowed capacity
C - have very low file lifetime

#

else someone could just upload a ton of junk to purposely fill their storage capacity

#

and yes, there are people who would do that just to see the world burn

jovial nimbus
#

true I know that, and I assure you you're right

lyric mountain
#

happened to you?

jovial nimbus
pine nova
rustic nova
#

probably cnaming your domain to theirs

surreal sage
#

I got a nice array here

#

But I want it to filter entries that are 5 minutes old or less

#

Using the epoch timestamp "creation"

#

Tell me how

#

.filter(f => f.created + 60 * 5 > Date.now() / 1000) is what I got now 🥶

boreal iron
#

The object key is called creation not created

#

At least that’s what I can see in your screenshot

#

filter((item) => Date.now() - item.creation * 1000 < 300000)

#

Same like yours but multiplying instead a division to prevent floats

sharp geyser
#

@dry imp wtf is this for/else shit in python

sharp geyser
#

its so useless

boreal iron
#

It’s python, that’s what’s wrong

dry imp
#

shut up fake ur opinion dont matter 🙄

dry imp
deft rock
#

Reminds me of myself

sharp geyser
#

Guido van Rossum said that if he had to make Python again, he would have never put for/else and while/else into the language. Why would a potentially useful feature that saves extra variables be seen as such a mistake? Find out in this video, where we see how for/else while/else work, where they came from, and why you should probably avoid them ...

▶ Play video
rustic nova
#

never used it

#

lol

#

theres no use fr

dry imp
#

i didnt even know lol

sharp geyser
#

I just learned about it and figured out how useless it is

dry imp
#

i thought the else was in the loop

sharp geyser
#

basically the way it works is if the for loop ends naturally then the else runs

sharp geyser
#

so if you break it yourself it wont run

ocean jay
#

Hello I've been stuck on this error and tried a lot of methods but still dunno KEKW

lyric mountain
#

What's even the point of it then?

dry imp
#

yea i know but its damn useless

sharp geyser
#

Well haku

lyric mountain
#

Lmao this is more useless than do...while

sharp geyser
#

it was modeled after how loops would work if you used labels and if statements instead

pale vessel
#

do...while is useful if you want to run the code at least once before checking the conditions

lyric mountain
#

Well, u can always just Initialize the variable as 1 less

#

But it at least has a niche use

sharp geyser
#
def basic_syntax_while():
  x = 0
  # START_LABEL
  if x < 3:
    # break means GOTO END_LABEL
    x += 1
    # GOTO START_LABEL
  else:
    print("DONE")
  # END_LABEL

This is the example the guy used to illustrate how it was envisioned to work

dry imp
#

misty, why did u learn this

sharp geyser
#

I was bored

#

else in the case of for/else should be named to nobreak because it only gets run if there is no break keyword in the loop

#

:p

lyric mountain
#

Nobreak 🔋

sharp geyser
#

lol

#

Pretty sure some kid is being mowed down rn I hear a chainsaw and kids screaming

#

Halloween month is fun!

boreal iron
dry imp
#

ill work in ur mine

#

what are we mining

boreal iron
#

sulphuric acid with your bare hands smirk

radiant kraken
#

chars are u32 codepoints

sharp geyser
#

@rustic nova lets play roblox

rustic nova
#

@mild crescent no ads please

#

thanks

rustic nova
sharp geyser
#

yw

sharp geyser
rustic nova
#

btw not me being in pain rn

#

also 5 am much

#

just a part of the pain im going through

sharp geyser
#

You could be doing that better im sure

rustic nova
#

ik

#

lol

sharp geyser
#

idk python yet so I cant say

wheat mesa
#

I’m an avid python hater

#

No shame

dry imp
#

shameless

rustic nova
#

smelly @sharp geyser joining vc

earnest phoenix
#

</play input::ID>

#

It's not working plz help

#

Coz of 2 collon it's not working any other way to add collon to my input

#

Why do you put 2 :, just use one and place the name before and ID after that

#

</play input:0> - </play input:0>

radiant kraken
#

also use __slots__, it minimizes the object's size in memory

olive arrow
dry imp
#

or use format() trollbutbetter

radiant kraken
#

unless you're making it backwards-compatible to Python < 3.6, there is no reason not to use f-strings

crystal wigeon
#

Hey is there a way i can set a custom property on "MessageButton"?

#

i added the types but when i click on a button i dont see my custom properties

boreal iron
#

As long as your structure is cached/in memory you can attach/add whatever you like to it

#

As well as overwriting/deleting properties etc

#

What actually is a “message button” for you?

#

You’re speaking about message components -> buttons?

ancient nova
#

hello

boreal iron
eternal osprey
#

hey guys

#

is there an equal method in c++ for the array.includes method?

boreal iron
#

93.158.92.13 - - [08/Oct/2022:08:23:16] "GET /humans.txt HTTP/1.1" 302 219 "-" GET /humans.txt
lmao
that's how I search the web for humans, too - never found one yet

radiant kraken
graceful cobalt
#

guys does anyone knows any good discord bot hosting which is free or very cheap(under 5$) with which i caqn deploy code from github

dry imp
#

what specs

eternal osprey
#
char arr[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '!', ',', '.', '-'};
 bool matches_found = false;
 bool stop_counter = false;
  char individual;
  while(!stop_counter){
     r++;
    if(!input.eof()){
     
      matches_found = false;
     individual = input.get();
    a = ((individual >= 32 && individual < 128) ? (individual - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : individual);
        for(int i = 0; i < 56; i++){
      cout <<a;
    if(a == arr[i]){
     //code
    }else{
      //code
    }
     }
   
    }```I need to implement a code that would basically check if each character in the file that gets decrypted to variable a, is in the array. If that's the case, it will stop. Else it will keep on moving on and incrementing the r. However right now it doesn't work as i don't know what code to add to the last if statements.
graceful cobalt
# dry imp what specs

any specs over 1gb ram and a good cpu ( my bot has 100 commands and is in 170 servers)

dry imp
#

plox.host

#

pebblehost is also good if u want multiple bots on same service

quartz kindle
#

i heard good things about that advin thing

dry imp
#

yea no under 5 tho

quartz kindle
#

but id still recommend hetzner even though its more expensive

#

doesnt advin have like 2gb for 2 bucks?

spark flint
#

yes

#

hetzner is good as well

dry imp
#

nah

spark flint
#

apart from their invoices

dry imp
#

the plans dissapear on my end

spark flint
#

o

quartz kindle
#

go to micro kvm vps

#

its still there

dry imp
#

go buy it

#

it doesnt exists on the store

quartz kindle
#

hmm

dry imp
#

i bought it before i know there is that plan on the amsterdam kvm standart vps group

#

not there anymore tho

eternal osprey
quartz kindle
#

youre right, its not there

cinder patio
eternal osprey
#

i am mainly trying to read a file and get all the characters. Then i want to check if each one of those characters is in the array.

#

because imagine i do: c++ if(a == arr[i]){ bool_var = true; }else{ bool_var = false } it might work for 1 character, but the file contains like 20 characters or so

earnest phoenix
cinder patio
#

those are your conditions right

eternal osprey
#

those are my conditions indeed

#

the only problem atm, is that if the first is equal it will stop the whole loop, However there are lots of other characters in the file that didn't loop yet.

cinder patio
#

well what do you mean by "stop"

#

stop what?

eternal osprey
#

should i give you some background info?

cinder patio
#

Tell me what do you want to stop

eternal osprey
#
{}:}|"}|463262"}```imagine i have this file. I will need to create a function that will find the number r where all these characters are normal characters (that are in the array). This is an assignment about encrypting/decrypting using OTP and i already got the function to calculate the decrypted character.
eternal osprey
#

else i want to increment the r

#

not sure if you get me

#

please ping me if anyone knows the answer.

radiant kraken
earnest phoenix
radiant kraken
wheat mesa
#

is he searching through an array for an element?

#

Just do a linear search, or binary if you know the array is sorted

eternal osprey
earnest phoenix
#

Then count the amount of characters that have been found in the array, and stop when it's the expected amount of characters

eternal osprey
#
char arr[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '!', ',', '.', '-'};
 bool matches_found = false;
 bool stop_counter = false;
  char individual;
  while(!stop_counter){
     r++;
    if(!input.eof()){
     
      matches_found = false;
     individual = input.get();
    a = ((individual >= 32 && individual < 128) ? (individual - 32 - (r % (128 - 32)) + (128 - 32)) % (128 - 32) + 32 : individual);
        for(int i = 0; i < 56; i++){
      cout <<a;
    if(a == arr[i]){
     //code
    }else{
      //code
    }
     }
   
    }```so what this code does is that it decrypts a file. The file with the chars are already given, but i now need to find the r of the above formula that they used for encrypting
earnest phoenix
#

Also you may want to use a formatter like clang-format, it might also be supported by the editor you use already

eternal osprey
#
//above the code when it reloops as not all characters are equal it will set the counter to 0.
  if(a == arr[i]){
    counter++;
if(counter == 30731){
   cout << "done";
   stop_counter = true;
}```Only issue with this is that it keeps on looping. Even with only 2 characters it keeps loopin forever. Even if the 30731 is set to 2 in this case
radiant kraken
#

voltrex, stop promoting llvm programs

eternal osprey
earnest phoenix
radiant kraken
#

it's like "Oh you're trying to learn JavaScript? then you should use our popular Node.js runtime, where you don't have to use a browser to use JavaScript"

earnest phoenix
#

Oh just because I mention a popular project/program that they could use I'm somehow trying to self-promote or something? I'm just helping

pine nova
#

💀

earnest phoenix
#

I know that I'm a member of the LLVM Developer Group but that doesn't mean I can't mention it's projects/libraries when applicable

earnest phoenix
#

Their formatting is off-putting, so it's harder to read to help out

cinder patio
#

could be discord fucking up the formatting

#

it does it to me

radiant kraken
#

it's normal since they are quite new to c++

earnest phoenix
#

In this case I'm sure it's not because of Discord

cursive musk
#
.setDescription(
            `__**Top.gg**__\n${
              checkDBLVote
                ? `\`In ${ms(user.lastVoted - Date.now() + DBL_INTERVAL, {
                    long: true,
                  })}\``
                : "[`Available Now!`](https://top.gg/bot/1000496153462329496/vote)"
            }\n\n__**Rewards:**__\n`
          )
#

Not sure why it isn't updating with the time after I vote.

rustic nova
#

this is barely readable, could you format it correctly so it is more understandable

cursive musk
#
   await message.channel.sendCustom({
      embeds: [
        new MessageEmbed()
          .setDescription(
            `__**Top.gg**__\n${
              checkDBLVote
                ? `\`In ${ms(user.lastVoted - Date.now() + DBL_INTERVAL, {
                    long: true,
                  })}\``
                : "[`Available Now!`](https://top.gg/bot/1000496153462329496/vote)"
            }\n\n__**Rewards:**__\n`
          )
          .setAuthor(
            message.author.tag,
            message.author.displayAvatarURL({ dynamic: true })
          )
          .setColor(message.guild.me.displayHexColor)
          .setFooter({ text: "https://universebot.xyz" })
          .setTimestamp(),
      ],
    });
wheat mesa
#

lol

rustic nova
#

still can't really tell what it is supposed to do, sorry

radiant kraken
#

it sends an embed

earnest phoenix
#

...

civic scroll
earnest phoenix
#

And assuming user.lastVoted is a timestamp, it'll always be lower than Date.now() and since you're subtracting them, you're working with negative numbers here or if that's what you intended on doing

wheat mesa
#

man I wanna rewrite some of the components in my ECS to not be as messy

#

perhaps I should have a lot of systems that do specific tasks instead of one big system that does a lot of tasks

wild mist
#

im trying to refresh a discord oauth token, but this is returning unknown grant type for me. anything wrong?

cursive musk
flat copper
#

how can i set middleware on a single path like:
like it calls it whenever /api is called
/api/1
/api/2
/api/3

in express

earnest phoenix
wild mist
#

if im posting to incorrect url the response should be different

earnest phoenix
#

Actually the incorrect oauth2 endpoints would give kinda the same response because of the grant type, are you making the POST request to /oauth2/token?

wild mist
#

using @discordjs/rest and discord-api-types

earnest phoenix
#

Weird, then I don't see why that error would be given as the response, it feels like it's an issue from @discordjs/rest

wild mist
#

well, it is fine when im requesting first token

#

just no for refreshing it

#

i dont see it a package problem

eternal osprey
earnest phoenix
wild mist
#

they ignored me, asked like 3 times no response

eternal osprey
cursive musk
earnest phoenix
feral aspen
#

Learning more about Java. :)

wheat mesa
#

remove the semicolons after each set of {}

#

you don't need them

feral aspen
wheat mesa
#

huh?

#

Why not just do RandomPassword.random(10)

#

No need for a constructor for a class that only contains static methods

rustic nova
#

Yeah isnt really necessary to initialize a new object for that

feral aspen
#

Hm.. really?

rustic nova
#

better to just make it a static method

feral aspen
#

It's shorter though?

wheat mesa
#

It's worse for performance

feral aspen
#

Or it's not best practice?

wheat mesa
#

And it's a bad practice

#

You should only ever use new for objects that need to be instantiated because they keep track of some sort of data

#

This method doesn't need any object specific data

feral aspen
#

Sweet.

#

Lastly, when should I be using static and when should I instantiate a new object? Eyes

#

All I know for now is that static just makes my life easier, but I haven't understood the correct difference.

earnest phoenix
#

You should declare them as static if you want to use them without instantiating a new instance of the class

Otherwise don't mark them as static, as it'll then become a prototype property/method

#

Other than that it doesn't really matter, because the performance difference is basically almost the same, just the semantic usage is different

surreal sage
#

You've got an array with strings, see the strings as an authentication or proxy list

I want to iterate over that array, each time it should run a function (promise) and wait for it to resolve or reject before continuing with the next item

#

I know the javascript is full of crap

#

And isn't async

#

So how would I?

earnest phoenix
#

For that you need to be inside an async function, because that's how asynchronous operations work, not just limited to JavaScript

surreal sage
#

So if I would for loop the array, it would indeed wait til it has been completed correct?

#

await func(item)

earnest phoenix
#

Yes it would wait until the promise of the called function is resolved before going to the next iteration

surreal sage
#

What if the function returned another promise?

#

As in resolved another promise*

wheat mesa
#

In small scenarios like that yeah it's fine, but definitely not good practice

surreal sage
#

The process wouldn't be kept alive for a long time

earnest phoenix
surreal sage
#

Not a production thing

wheat mesa
#

Ah

#

I see

surreal sage
#

It's just: Complete those tasks and kill your self (process.exit 😅)

earnest phoenix
surreal sage
#

It'll just keep resolving the promises until there is no promise to resolve?

earnest phoenix
#

Yes

surreal sage
#

Pretty much what I want 😄

earnest phoenix
#

Every language has it's own weird history in some ways

surreal sage
earnest phoenix
#

The forEach() method does not wait until the promises are resolved, it keeps going to the next iterations regardless

sharp geyser
#

No

surreal sage
#

That's pretty !awesome

sharp geyser
#

@rustic nova

#

stop playin terraria without me

lyric mountain
wooden ember
#

found a way to fix the cpu persentage on my bot info command< used to have two numbers cuz the cpu is a dual core

#

i fixed it by installing a single core cpu

#

lol