#development

1 messages · Page 170 of 1

crystal wigeon
#

Hey anyone know any good orm or query builder for golang to connect with Postgres ?

radiant kraken
#

why do you count them

bitter granite
radiant kraken
bitter granite
#

Just like to note last month activety compare to like the next month

#

So I know if I am lazy or not

#

There is more thou then that

radiant kraken
#

oh alright

heavy mantle
#

How do we show the number of servers like this?

radiant kraken
heavy mantle
pale vessel
#

yup

neon leaf
#

mh yes

earnest phoenix
#

@real rose hmm

rustic nova
#

cool that you can validate it

#

still not the right place to ask

#

-needdev

gilded plankBOT
#

You seem to be asking for something you don't have experience for or something that hasn't been done yet, but really need for your bot/server.
You can hire developers from Fiverr or Freelancer to code the things you need for your bot/server.

bitter heart
#

I wonder what this error is, it appears when trying to use the button?

earnest phoenix
bitter heart
#

"discord.js": "^14.0.2",

earnest phoenix
#

Update to the latest stable version, that's a bug

bitter heart
#

error line 😦

earnest phoenix
earnest phoenix
bitter heart
#

interaction.guild.users.cache.get("ID") example

earnest phoenix
#

You get the member from the guild using the interaction.guild.members.cache.get() method (use interaction.guild.members.fetch() preferably as not every member is cached), and use the https://old.discordjs.dev/#/docs/discord.js/14.13.0/class/GuildMember?scrollTo=setNickname method

earnest phoenix
# bitter heart

<GuildMemberManager>.fetch() returns a promise, resolve it

earnest phoenix
# bitter heart let member = ?
freeCodeCamp.org

JavaScript has the ability to carry out asynchronous (or async) instructions. These instructions run in the background until they have finished processing. Asynchronous instructions do not stop the JavaScript engine from actively accepting and processing more instructions. This is why JavaScript is non-blocking in nature. There are a few

deft wolf
#

You can only use await in async functions, so keep that in mind

bitter heart
#

Whatever I write where there is a question mark, the problem will be solved.

wheat mesa
#

(Please don’t use .then() without a good reason)

bitter heart
#

let member = await ?

wheat mesa
#

no

bitter heart
#

i dont understand

deft wolf
#

That's why you need to understand

wheat mesa
#

You are currently doing let member = interaction.guild.members.fetch(id)

#

However that function makes a request that is not completed immediately, and therefore to get the actual intended data, you need to await that function call

earnest phoenix
#

If we write out the solution for you, you won't understand why that fixes your issue, it's quite fundamental to understand how promises work in JavaScript

bitter heart
#

okay thanks

earnest phoenix
bitter heart
#

ok I understand the problem

#

thank you for your help

bitter heart
#

So, how to set it to enter only numbers in modal?

#

@earnest phoenix

deft wolf
#

As far as I know, the modal only has text field options

#

But you can probably check it with the code whether the user entered a number or not and reject his modal if the field does not have a number

proven lantern
#

is there a way to disable typing status in a channel?

pale vessel
#

maybe with some css tricks

crystal wigeon
#

anyone know golang?

sharp geyser
crystal wigeon
#

im learning the language

sharp geyser
#

okay but what lang do you want to use an orm in

#

golang?

crystal wigeon
#

yeah

sharp geyser
#

one sec

crystal wigeon
#

golang, idk they have query builders

#

but i saw sqlc was a good option

sharp geyser
crystal wigeon
#

ty

sharp geyser
#

this is what I used to use

crystal wigeon
#

gotcha

sharp geyser
#

when I used go

crystal wigeon
#

anyway i have another issue

sharp geyser
#

whats that

crystal wigeon
#

with interfaces, im trying to extend the responsewriter by adding a custom method to it, basically this

#

import (
    "encoding/json"
    "net/http"
)

type HttpResponseWriter interface {
    http.ResponseWriter
    success(data interface{}, status int)
    error(message string, status int)
    forbidden()
    unauthorized()
    notFound()
}

type HttpResponseWriterImpl struct {
    http.ResponseWriter
}

func (rw HttpResponseWriterImpl) success(data interface{}, status int) {
    rw.Header().Set("Content-Type", "application/json")
    rw.WriteHeader(status)
    response := map[string]interface{}{
        "success": true,
        "data":    data,
    }
    json.NewEncoder(rw).Encode(response)
}

func (rw HttpResponseWriterImpl) error(message string, status int) {
    rw.Header().Set("Content-Type", "application/json")
    rw.WriteHeader(status)
    response := map[string]interface{}{
        "error":   true,
        "message": message,
    }
    json.NewEncoder(rw).Encode(response)
}

func (rw HttpResponseWriterImpl) forbidden() {
    rw.error("Forbidden", http.StatusForbidden)
}

func (rw HttpResponseWriterImpl) unauthorized() {
    rw.error("Unauthorized", http.StatusUnauthorized)
}

func (rw HttpResponseWriterImpl) notFound() {
    rw.error("Not Found", http.StatusNotFound)
}

func RegisterResponses(next http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        rw := &HttpResponseWriterImpl{w}
        next.ServeHTTP(rw, r)
    })
}

This is my interface


import (
    "cloudview/app/src/api/middleware"
    "net/http"

    "github.com/gorilla/mux"
)

func RegisterRoutes() *mux.Router {
    router := mux.NewRouter()
    subrouter := router.PathPrefix("/v1").Subrouter()
    subrouter.Use(middleware.RegisterResponses)
    subrouter.HandleFunc("", func(w middleware.HttpResponseWriter, r *http.Request) {
       w.success() // not working throws error
// i want to access w.success("message")
    }).Methods("GET")
    homeRouter(subrouter)
    return subrouter
}

And this the middleware. how can i fix the issue or how do i go about it

#

but im not able to access it in the handlefunc

#

i tried using rw.success in the middleware directly and itseems to work

#

but outside i get type errors

sharp geyser
#

What errors do you encounter (I may or may not be able to help as I haven't used go in years)

crystal wigeon
#

its basically saying i cant use my custom interface type in the handleFunc

#

mux router btw

sharp geyser
#

Hm

#

yknow how you have *http.Request try using an astrisk in front of your HttpResponseWriter, iirc you can't just directly pass it like you are now as w middleware.HttpResponseWriter

crystal wigeon
#

i also tried *middleware.HttpResponseWriter

#

still doesnt work

sharp geyser
#

hm

crystal wigeon
#

same error

sharp geyser
#

yea sorry, I haven't used go in a while so I am not as knowledgable at it anymore

#

I've looked at it a few times and even looked at some docs but I don't see what is going wrong here

crystal wigeon
#

the problem is there seems like there's no way to modify the interface

#

some said i need to create my own interface but thats what i did here

#

the other solution is to create that interface for every single route, but then whats the point of middleware

sharp geyser
#

you definitely should be able to do it

crystal wigeon
#

the other solution is to write it very ugly like its own standalone function and call success with data without using interface but i dont wanna do that

#

it looks like i have to modify the Write method

#

but its restricted usage

#

might work if i use http.Handle instead of http.handleFuncworth the shot

#

ig not, cause that gets ugly as well

bitter heart
#

Now I have an automod id and I want to delete automod using this id, how do I do it?

#

I tried this but it didn't work

quartz kindle
#

.delete(id)

neon leaf
deft wolf
#

Holy shit

rustic nova
#

nice

neon leaf
#

(72 cents disappeared because fees)

rustic nova
#

time to get something better to process payments than paypal taking half

#

somewhat half*

neon leaf
#

I think it was 40 cents + 2.5%

#

ah its 35 cents + 5%

#

not the worst

neon leaf
#

currently I just retry the ci until it works lmao

earnest phoenix
# neon leaf how do I fix this in my ci

Package pangocairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangocairo.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pangocairo', required by 'virtual:world', not found

neon leaf
#

I mean it worked for like 3 months before without issue

#

havent changed dependencies in like 1 month

#

I mean it still works but its a lottery

earnest phoenix
neon leaf
#

thanks

crystal wigeon
#

Anyone know any payment service that offers like a wallet system which you can load money into and then make payments ? And if they have sdk or apis

#

Like an integration

spark flint
#

stripe i think

crystal wigeon
#

Hmm, anything else?

#

I don’t mean something like services that accept Apple Pay etc

#

I mean like a proper wallet management like how vultr has a way to load some $$ into wallet first

#

From which they charge the amount

wheat mesa
#

Does plaid have something like this?

earnest phoenix
#

I have a problem, probably a small one, with my bot on top.gg, I can't see the main photo

slim void
#

How many places u gonna ask?

#

Helped in support.

old sonnet
#
const hello = ["w",  "o", "r",  "l", "d"]
const world = ["h",  "e", "l", "l", "o"]

console.log(`${world[1]}${world[2]}${world[3]}${world[4]}${world[5]} ${hello[1]}${hello[2]}${hello[3]}${hello[4]}${hello[5]}`)
#

I might just be the best js developer

pale vessel
#

it's average

neon leaf
#
console.log((['c', 'h', 'e']).slice(1).join('').concat('llo', ' '.repeat(1), 'world'))
rustic nova
#

Real ones put hexadecimal into an array, convert it to a char in an array, then append each char into an array again, then print it out

#

My name is Profesyonel, so is my programming

digital swan
#

anyone familiar with google search console? pages from my sitemap arent being indexed unless i manually request indexing through the url inspection thing

neon leaf
deft wolf
#

Good job

neon leaf
#

writing sql queries is fun

#

(until its not)

lyric mountain
#

you dont need the external select btw

neon leaf
#

wdym

lyric mountain
# neon leaf wdym

you can simply return the row number without external select like ```sql
SELECT row_number() OVER (ORDER BY xp DESC) AS row_number
FROM serverUsers
WHERE serverId = ${ctx.metadata.serverId}
AND userId = ${id}

neon leaf
#

o

#

well

#

it seems to always return 1

lyric mountain
#

ah, fair point, I actually forgot it'll exclude all other values

neon leaf
rustic nova
#

probably wrong but idc

quartz kindle
#
page.catch(x => throw x).catch(x => throw x).catch(x => throw x).catch(x => throw x)
proven lantern
#

throw early catch late

radiant kraken
frigid wave
#

H

deft wolf
#

I

neon leaf
radiant kraken
#

i see sir

tulip ledge
#

Alright, so when you click a button it edits the message and you get a select menu. Once you select an item in the menu a modal appears. But for some reason when you first click the button you can't select anything in the menu for like the first 3-5 seconds and it sais "the interaction failed". Also if you don't select anything after 3-5 seconds it also sais "the interaction failed". But after you can select anything and the modal will pop up. Anyone knows why this could be?

deft wolf
#

Maybe it's an interaction with the button itself?

#

It seems to me that if you don't use .deferUpdate() on the button you will get "interaction failed" even if you send the embed

tulip ledge
zinc phoenix
#

Give código

tulip ledge
#

since I'm showing a modal

#

so if I deferUpdate it'll give me an already acknowledged error

zinc phoenix
#

No ingleses

#

Sou do Brasil

digital swan
tulip ledge
#

I just fixed it

digital swan
#

So if you’re doing any longish requests it would affect it

tulip ledge
#

one button would instantly open the modal and another one would first ask you to select an item from the menu

#

so for the ones that shows a menu I deferred it

#

thanks!

pale vessel
#

zang, dbm got hands

deft wolf
#

DBM - discord bot maker

civic scroll
#

what is this magic language

civic scroll
#

yeah i can't do this

#

it looks like nightmare

lyric mountain
#

dont think we can help with that here

#

you'll need to ask in bdfd server

radiant kraken
#

imagine having to code and host all of that in your phone

deft wolf
#

Coding on the phone is terrible

civic scroll
#

i did

#

but not this level of nightmare

#

even assembly seems more tolerable than this

violet galleon
#

Replit

civic scroll
#

at this point just use javascript on god

civic scroll
earnest phoenix
radiant kraken
sand meteor
#

Hey why the css is not working in bot description?

deft wolf
#

It should work normally

sand meteor
pale vessel
#

you have to explicitly set your own style otherwise it'll use top.gg's own css

#

use an iframe if you're lazy

sand meteor
#

Ohk

#

Wait

summer torrent
#

they are migrating discord from webpack to rspack

pale vessel
#

for that speed

ionic vector
#

What is a Acceptable way to use the a DM command?

Only for mods or admin or remove fully?

radiant burrow
#

my vote thing runs before my shard manager does anything. all it does is send the vote to a function to find the user in the database and increase their vote streak and stuff like that. I've had some issues now that there's multiple shards, that because I moved where the vote listener is (used to be in the login function) due to sharding the function doesn't seem to be able to access the database. where am I supposed to put the vote listener?

i can provide code as needed im just not really sure what IS needed ._.

radiant burrow
digital swan
#

Well you only want the vote listener to receive it once

radiant burrow
#

right, that only runs once

digital swan
#

The entry point (where your manager is) is only running once but the actual bot code is running for however many shards or clusters there is

radiant burrow
#

yeah

#

that's why i moved it into the code with the manger. but having it before the manager spawns or creates shards isn't working

digital swan
#

What happens

radiant burrow
#

the vote goes through but it can't connect to the database

digital swan
#

Any error?

radiant burrow
#

MongooseError: Operation document.findOne() buffering timed out after 10000ms

digital swan
#

Is there a way to set a limit of connections on your database?

#

I’m not familiar with mongo

radiant burrow
#

that error generally means it didn't connect I think

#

not that there's too many connections, but it can't find the connection at all

digital swan
#

I was thinking that it’s waiting for a connection to open and one didn’t within 10 seconds

#

So if you’ve got the connections limit set at something low it might not be able to connect

radiant burrow
#

hmm I guess it might be that. ill look more into what the error means. I didn't see it as trying to make a new connection and not having space

#

but I have to go to breakfast so I'll try later

radiant burrow
#

I'll try doing the vote listener after the shards connect, thx

surreal sage
#

How can I add stuff to next/head in _document.jsx?

#

I want to add meta tags and have them be on all pages

slim void
#
import Document, { Html, Head, Main, NextScript } from 'next/document';

class MyDocument extends Document {
  render() {
    return (
      <Html>
        <Head>
          {/* Add your meta tags here */}
          <meta name="description" content="Your page description" />
          {/* Add other meta tags as needed */}
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}

export default MyDocument;

It would be something like that

surreal sage
#

oh so it is like that

#

ok ty

slim void
#

Np

surreal sage
#

is it possible to extract a single file from a file that is a zip file but doesn't have the headers

#

the 'zip' is 100gb+ so no extracting it entirely

#

i needa get Data/Localization/english/global.ini from it

#

preferably in node

#

cmd/ps acceptable

wheat mesa
#

I’m not entirely sure how zip algorithms work, but you’re definitely going to need to stream the data

surreal sage
#

or is a step to it

#

node-stream-zip js errors

quartz kindle
#

so it needs to read the last chunks first to figure out where the files are

#

but there should be a lib that does that

#

what error does node stream zip throw?

untold crow
radiant burrow
#
// Edit the name localizations of this command
command.setLocalizedNames({
  'en-GB': 'test',
  'pt-BR': 'teste',
})
  .then(console.log)
  .catch(console.error)
#

this is how the djs guide shows it

#

i think ru is not the correct tag

untold crow
#

Is it capitalized?

radiant burrow
#

it's exactly like that

#

i copied it

untold crow
#

I'm using slashcommandbuilder

radiant burrow
#

ohh gotcha

#

yeah then it looks right, then I assume one of the values in the ru name is a character it doesn't like? which would be silly because why would it not accept russian (?) characters in a localization field

untold crow
#

If that's the case then there really is no workaround unless I use a romanized version of it

quartz kindle
#

seems like DJS's fault

#

open an issue about it

frosty gale
#

is discord.js still cursed

#

i havent used it in years

#

ijust know they wrapped a shit ton of shit around builders that make the code annoying if anything

#

but it might be easier for beginners so 🤷‍♂️

radiant kraken
untold crow
untold crow
earnest phoenix
#

Guys I’ve just come back from coding and I have forgotten everything, I need to know why my bot is not working without it showing errors

#

It is showing but I don’t get it

deft wolf
#

Depends on what you mean by "doesn't work"

earnest phoenix
#

The codes running but something seems wrong with the hosting website

deft wolf
#

You provided invalid token

earnest phoenix
#

I don’t think so, I just changed it

real rose
#

it says "invalid token"

#

you provided an invalid token

earnest phoenix
#

I just changed it again

#

Same answer

real rose
#

you need to change it in your code too

earnest phoenix
#

The codes running but the bot doesn’t seem to be

#

I did bro

real rose
#

because you provided an invalid token

earnest phoenix
#

I just changed again brother

real rose
#

well your client.login has an invalid token in your code

earnest phoenix
#

It may be the hosting website I’m not sure

real rose
#

so maybe its formatted wrong

#

or spaces or something

earnest phoenix
#

Let’s check

earnest phoenix
deft wolf
#

Also remember that the token must be a string so client.login("token") and not client.login(token)

real rose
#

mind showing your code? Blur out your token of course

earnest phoenix
#

For sure

#

Sorry for the confusion guys I just started again

#

It’s been 2 years

real rose
#

dont worry KEKW I always code on and off

earnest phoenix
real rose
#

And your client.login?

earnest phoenix
#

I can’t seem to find a client login let me try

real rose
earnest phoenix
#

There

real rose
#

oh

earnest phoenix
#

I made it in a secure way

real rose
#

process.env.token is for environment files

#

You have a JSON string which looks like a config.json file

#

whats the name of this file?

earnest phoenix
#

Index.js

real rose
#

no the one with your token and default_prefix in it

earnest phoenix
#

config.json

real rose
#

Yeah so process.env would be for env files. Either you can change that to client.login(config.token) or move your token to another file called .env and have

token=TOKEN_HERE
earnest phoenix
#

Alright I’ll change thanks let’s see

real rose
#

thumbsUpCat Should work then 😄

earnest phoenix
#

Same response

real rose
#

What did you change

earnest phoenix
#

I removed the env

real rose
#

and changed it to?

earnest phoenix
#

Config.token

real rose
#

and did you define config earlier yea?

earnest phoenix
#

Sorry I don’t get what you mean

real rose
#

did you define config

#

like

#

const config = require("./config.json");

earnest phoenix
#

Hm

real rose
#

obvi the ./ is different depending on where your config is located

earnest phoenix
#

What about I use the old code but what do I have to change with the config.json file

#

Because my code is a bit old and messed up

real rose
#

i can't magically see your code so i dont know how to fix it

earnest phoenix
#

I mean before you

#

Yeah so process.env would be for env files. Either you can change that to client.login(config.token) or move your token to another file called .env and have

token=TOKEN_HERE
#

That sounds good?

#

Can’t I just change the old files name to .env

real rose
#

no

earnest phoenix
#

Alright let me try that

earnest phoenix
#

They’re empty

bitter heart
#
   moment.locale("tr")
   let member = newMember;
   console.log(newMember)
   let formattedDate = moment().format('DD/MM/YYYY HH:mm');
   await db2.set(newMember.userId+formattedDate, `${member.activities.type} ${member.activities.name} ${member.activities.details} ${member.activities.state}`)
   console.log(`${newMember.userId} Adlı Kişiden Şunlar Kaydedildi: ${member.activities.type} ${member.activities.name} ${member.activities.details} ${member.activities.state}`)
  });

1118823722267181119 Adlı Kişiden Şunlar Kaydedildi: undefined undefined undefined undefined

How do I fix it?

real rose
#

${member.activities.type} ${member.activities.name} ${member.activities.details} ${member.activities.state} are all undefined

#

I believe activies is a list of activites so you need to index which one you want

#

[0] [1] [2] etc

#

member.activities[0].type

bitter heart
#

If I want it to write all of them, should I put 0?

deft wolf
#

No, 0 mean first

#

If you want to list all of them you need to use some sort of loop

#

forEach or for let

earnest phoenix
bitter heart
bitter heart
earnest phoenix
#

Alright

deft wolf
earnest phoenix
#

Nope no change

deft wolf
#

You are using it somewhere

earnest phoenix
#

It’s was ```process.env.token

#

Before

#

Then it showed me this error

deft wolf
#

It's still the same error

#

Nothing has changed at all

earnest phoenix
#

I’m confused

#

What do I have to change

#

I have a file called config.json

#

Why is it not working

sage bobcat
#

One message removed from a suspended account.

deft wolf
#

Can't you just console.log it?

#

And see what it is

earnest phoenix
#

My bad I just came back to coding

deft wolf
#

console.log(config.token)

earnest phoenix
#

In the index file?

deft wolf
#

Yes

earnest phoenix
#

Behind the token?

#

I mean behind the other code

deft wolf
#

Yes, just put it and run the code

earnest phoenix
#

Still the same error

deft wolf
#

What do you have in your console?

earnest phoenix
#

It was process.env.token before

#

Let me check

deft wolf
#

It should print out your token

earnest phoenix
#

I get this then

real rose
#

tbf

#

i tried to help bro

#

and i got nowhere

earnest phoenix
#

Sorry bro it’s hard I’ve forgotten everything

real rose
#

i did dm you to help further

#

but you dun want it

deft wolf
#

I asked you to check if config.token gonna print your token in console

real rose
real rose
#

because you're not defining it correctly

bitter heart
#
  if(!oldPresence){
    if (oldPresence.user.id !== client.user.id) {
      const oldStatus = oldPresence.status;
      const newStatus = newPresence.status;

      if (oldStatus !== newStatus) {
        switch (newStatus) {
          case 'online':
            console.log(`${newPresence.user.tag} artık Çevrimiçi.`);
            await db.set(oldPresence.user.id+"+"+moment().format('DD/MM/YYYY HH:mm'), "Çevrimiçi")
            break;
          case 'idle':
            console.log(`${newPresence.user.tag} artık Boşta.`);
            await db.set(oldPresence.user.id+"+"+moment().format('DD/MM/YYYY HH:mm'), "Çevrimiçi")
            break;
          case 'dnd':
            console.log(`${newPresence.user.tag} artık Rahatsız Etmeyin.`);
            await db.set(oldPresence.user.id+"+"+moment().format('DD/MM/YYYY HH:mm'), "Çevrimiçi")
            break;
          case 'offline':
            console.log(`${newPresence.user.tag} artık Çevrimdışı.`);
            await db.set(oldPresence.user.id+"+"+moment().format('DD/MM/YYYY HH:mm'), "Çevrimdışı")
            break;
        }
      }
    }
  }
});```

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

TypeError: Cannot read properties of null (reading 'user')
    at Client.<anonymous> (C:\Users\Emir\Desktop\Unity\bot.js:30:21)
    at Client.emit (node:events:529:35)
    at PresenceUpdateAction.handle (C:\Users\Emir\Desktop\Unity\node_modules\discord.js\src\client\actions\PresenceUpdate.js:37:19)        
    at module.exports [as PRESENCE_UPDATE] (C:\Users\Emir\Desktop\Unity\node_modules\discord.js\src\client\websocket\handlers\PRESENCE_UPDATE.js:4:33)
    at WebSocketManager.handlePacket (C:\Users\Emir\Desktop\Unity\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31) 
    at WebSocketManager.<anonymous> (C:\Users\Emir\Desktop\Unity\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)  
    at WebSocketManager.emit (C:\Users\Emir\Desktop\Unity\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
    at WebSocketShard.<anonymous> (C:\Users\Emir\Desktop\Unity\node_modules\@discordjs\ws\dist\index.js:1173:51)
    at WebSocketShard.emit (C:\Users\Emir\Desktop\Unity\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
    at WebSocketShard.onMessage (C:\Users\Emir\Desktop\Unity\node_modules\@discordjs\ws\dist\index.js:988:14)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:398:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v18.18.0```
#

can you help me

real rose
#

TypeError: Cannot read properties of null (reading 'user')

#

oldPresence is null

deft wolf
#

I don't know why you need a user.tag when 99% of people don't have a tag anymore KEKW

bitter heart
real rose
#

yeah

#

if oldPresence is null

#

it runs the code

#

I think you want if(oldPresence)

#

without the !

grim aspen
earnest phoenix
#

My discord bot is not responding and is showing no errors

#

It’s online

deft wolf
#

Then the two most popular reasons: lack of intent or you need to change client.on("message") to client.on("messageCreate")

deft wolf
#

In that case, it's the intent fault i guess

earnest phoenix
#

What’s that

deft wolf
#

What version of discord.js is it?

earnest phoenix
#

Let me check

#

Hm how do I check

civic scroll
#

package.json located at your bot's project root directory

earnest phoenix
#

Alright thanks I code on mobile so it’s a bit hard to see

#

Version 1.0.0

civic scroll
#

check inside dependencies field

earnest phoenix
#

12.5.1

deft wolf
#

This version still works at all?

real rose
#

update your discord.js and read the new tutorials

#
discord.js

discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.

earnest phoenix
#

How do I update it

real rose
#

npm i discord.js@latest

earnest phoenix
#

I’m an old fellow 👴

real rose
#

removed

#

Upgrading from v12 to v13

deft wolf
#

And then from v13 to v14 angeryBOYE

real rose
#

oh i forgot were 14 now

#

💀

#

13 to 14 KEKW

earnest phoenix
#

Uh

#

Where do I add the line npm install discord.js

real rose
#

your cli?

civic scroll
# bitter heart ```client.on('presenceUpdate', async (oldPresence, newPresence) => { if(!oldPr...

some optimisations


client.on('presenceUpdate', (oldPresence, newPresence) => {
  if (oldPresence)
    return;
  if (oldPresence.user.id === client.user.id)
    return; 

  const newStatus = newPresence.status;

  if (oldPresence.status === newStatus)
    return;

  let responses = {
    online: 'Çevrimiçi',
    idle: 'Boşta',
    dnd: 'Rahatsız Etmeyin',
    offline: 'Çevrimdışı'
  }
  
  console.log(`${newPresence.user.tag} artık ${responses[newStatus]}.`);
  const key = `${oldPresence.user.id}+${moment().format('DD/MM/YYYY HH:mm')}`;
  db.set(key, newStatus === 'offline' ? "Çevrimdışı" : "Çevrimiçi");
});
earnest phoenix
real rose
#

command line interface

#

where you type commands

#

to run your bot

earnest phoenix
#

Oh alright so I make a command file and it to there

civic scroll
#

something like command prompt

earnest phoenix
#

Sorry it’s confusing on mobile

real rose
#

no

#

command prompt yeah

civic scroll
#

ever heard of it

real rose
#

where do you type your node index.js

earnest phoenix
#

Let me check

#

In core

real rose
#

This is why people should do some learning with basic js before trying to code a bot wewe

real rose
earnest phoenix
#

I told you I just came back from coding brother

#

Your right I should’ve done some research tho

real rose
#

Should look into the details before jumping right into the deep end topggWink
It would be a better use of your time to start from scratch, pull up the d.js 14 docs and a youtube tutorial and go from there

#

There is no point in trying to fix an old bot when none of your memory is refreshed

#

❤️‍🔥

earnest phoenix
real rose
#

Anson the Developer on yt

earnest phoenix
#

Alright thanks

real rose
#

he usually quite good

deft wolf
civic scroll
# bitter heart ```client.on('presenceUpdate', async (oldPresence, newPresence) => { if(!oldPr...
client.on(
  'presenceUpdate', 
  (oldPresence, { status: newStatus, user: { tag, id } }) => {
    if (
      oldPresence
      || oldPresence.user.id === client.user.id
      || oldPresence.status === newStatus
    )
      return;

    let responses = {
      online: 'Çevrimiçi',
      idle: 'Boşta',
      dnd: 'Rahatsız Etmeyin',
      offline: 'Çevrimdışı'
    };
    
    console.log(`${tag} artık ${responses[newStatus]}.`)
    let key = `${id}+${moment().format('DD/MM/YYYY HH:mm')}`
    db.set(key, newStatus === 'offline' ? "Çevrimdışı" : "Çevrimiçi")
  }
);

an even more optimised version of this

civic scroll
earnest phoenix
civic scroll
#

i don't watch videos

#

i read websites

earnest phoenix
#

Is there a website you’ll recommend

civic scroll
#

sorry i was slow at typing

earnest phoenix
#

It’s all good thanks

#

I’ll check em

untold crow
#

I went right into coding the most complicated thing in the world right off the bat

#

Armed with nothing more than documentation and lots and lots of youtube tutorials

real rose
#

i dont remember talking to you at all

#

however, i digress.

real rose
#

and chatgpt

untold crow
real rose
#

PES2_SmugSmirk good answer

untold crow
# real rose and chatgpt

chatgpt is surprisingly bad at giving any useful code seeing as how it's several versions out of date with pretty much everything

real rose
#

for people who dont know how to use it

untold crow
#

Okay then

wheat mesa
#

It’s not terrible for “examples” of a poorly documented library or framework

earnest phoenix
#

Why is it giving me this

surreal sage
#

I'm sending a message through a webhook

#

With an embed and a plain text file (formdata)

#

And the file is going before the embed

#

Is it possible to switch it up so the embed's first?

#

payload_json is up first

earnest phoenix
#

How to I update my node.js on replit?

#

It seems like it’s impossible

slim void
#

Replit is trash. Best of luck

surreal sage
#

average inbox when working on ci

radiant kraken
#

i rarely check emails lol

#

especially github ones

surreal sage
#

i think i messed up

inner gorge
#

thats fine

magic sonnet
#

What did I do wrong 🥲

surreal sage
#

revert from win 11 to win 10

pale vessel
#

win11 is good dawg

surreal sage
#

good to slow ur pc

pale vessel
#

shitpc

surreal sage
#

great pc

#

win10 better for optimizing

#

win11 more background shits

magic sonnet
#

I have 4 year old laptop it can't get any slower than it is already 🥲

surreal sage
#

always good with old laptops

undone rose
#

Win 11 gang

arctic arch
#

¯_(ツ)_/¯

earnest phoenix
#

I code on movile

neon leaf
#

just get a pc from facebook marketplace

#

ez

pale vessel
#

yeah you'll most likely find some good gaming laptops sold by boomers that don't know their actual value

neon leaf
#

or weird parents that are selling their kids gaming pc for misbehaving for 50% the price

#

just tell em, uh that component looks faulty, gonna have to cut 200€ off that or sum

#

99% chance it works

earnest phoenix
#

my server doesnt show up when I try to add it to top.gg

#

anyone knows a fix?

deft wolf
#

Wrong channel to ask but try to click "refresh servers" and then logout and login again

#

Should work

neon leaf
earnest phoenix
sage bobcat
#

One message removed from a suspended account.

rustic nova
#

Speedrun of ending up in the retirement home

lunar palm
#

lmfao

mortal python
#

Do you guys know when using the ShardManager, if no specific amount of guilds is specified, does it automatically spawn new shards as the bot continues to grow in new servers? (Without having to restart the bot).

harsh nova
mortal python
#

Yes, the discord one. Thank you!

wheat mesa
#

And back then it was considered an “entry level” gaming laptop

#

Aka less than 800 bucks

mortal python
limpid rain
#

hello

charred nest
undone rose
#

Are we allowed to ask non bot development related coding questions here

charred nest
#

as long as its development related its good, doesnt have to necessarily be bot

deft wolf
#

I've seen topics about websites, games and animations here

charred nest
#

bot is just most popular topic since topgg is a place to list your bot poggythumbsup

#

but any development convo is welcome here iirc

deft wolf
#

And the famous Steam API from which one guy wanted to download information about every game on Steam

charred nest
mortal python
charred nest
#

no problemo !

untold crow
#

Using the message partial doesn't require the message content intent correct?

#

Discord.js v14 by the way

quartz kindle
#

not required afaik

untold crow
#

Thank god

#

I would rather beat myself with a bat than enable the message content intent

undone rose
#

So, I have a question about compiling electron applications. I created these two programs using electron. Got them working exactly how I wanted them by running the electron . command in my src directory. The apps are both frameless and can be fullscreened when I double click on them. One of them is just a blank black form that I use to make my OLED display go completely black when I press a button, and the other one is a transparent video player that is supposed to only show the video and nothing else.

The issue I'm running into, as seen in the video below, is that the compiled version of the electron app has a title bar above the video for some reason. It's still a frameless application, and that title bar doesn't show up when I'm running the app via electron ., so I'm very confused about what exactly is going on here. Another thing you see in the video is that I can double click on the app to fullscreen it, but that functionality doesn't work in the compiled versions of the apps either. Anybody know why this might be happening and what I can do to fix it?

earnest phoenix
bitter heart
#

please help

deft wolf
#

Just read error

#

Apparently there is a limit of 25 fields in embed

bitter heart
#

How do I fix it?

bitter heart
deft wolf
#

Not if you want to make more than 25 fields. Set some limit or split it into two or more embeds

#

I don't know what this command is for, but choose the method that better suits what you expect from the bot

#

Or do pagination using buttons

#

There are several ways to solve this problem

earnest phoenix
#

Guys how do I make my node.js v16 on replit

eternal osprey
#

Hey, i added a little faq to my website.
I know it;s a lot of text but i mean, it's a faq so i think its alright. However, do you guys think that the different questions (denoted by a bolder header) should be toned down a bit by size? And any other tips on the design?

earnest phoenix
#

Like 11 and then 13

eternal osprey
#

wait sorry what?

#

I don't understand what you mean ;0

earnest phoenix
eternal osprey
#

wouldn't that make it 24

#

but yeah i get what you mean

#

i just wanted a clear difference between the different headers

#

got it toned down to this

earnest phoenix
#

Looks nice

#

And it’s still stayed 12

strong python
sharp saddle
earnest phoenix
earnest phoenix
untold crow
strong python
sharp saddle
#

find ```json
"scripts": {
"test": "..."
}

sharp saddle
#

also, the repls are already updated to the latest version of node iirc

earnest phoenix
#

I don’t know why mine isn’t

earnest phoenix
earnest phoenix
#

Why is my node.js updated tf

#

Not

sharp saddle
#

well

sharp saddle
earnest phoenix
sharp saddle
#

in shell?

sharp saddle
earnest phoenix
#

Alright

earnest phoenix
#

This is the whole error

sharp saddle
#

scroll up

peak drum
#

"MODULE_NOT_FOUND” sounds like you don’t have everything installed yet

earnest phoenix
peak drum
#

Sure it is, but you’re missing a package.

earnest phoenix
peak drum
#

There it is

earnest phoenix
#

What is it

peak drum
#

Run npm install express

earnest phoenix
#

Alright

#

In .replit ?

peak drum
#

You’re missing the package called express

earnest phoenix
#

Or terminal

peak drum
#

Terminal

earnest phoenix
#

Alright let’s see

#

Now it’s giving this

earnest phoenix
peak drum
#

You’re missing a file

#

If you don’t know what any of it means I suggest you take a JavaScript course

earnest phoenix
peak drum
#

The error says otherwise

earnest phoenix
#

That’s weird I have all the files that I had before the error

#

:/

peak drum
#

It cannot find index.js in the folder strangeNormalUnits-1

earnest phoenix
peak drum
#

Well now it can’t find it anymore

earnest phoenix
deft wolf
#

Once again, what is name of the index file right now?

peak drum
#

Goodluck trying to solve it xD KEKWDisco

lyric mountain
radiant kraken
peak drum
earnest phoenix
#

Isn’t there another coding app I can use for coding

#

Mobile

deft wolf
#

App or platform because replit is a platform where you can also host the bot, so it is not just an app but also hosting

#

So writing the code is one thing, hosting it is another

earnest phoenix
deft wolf
#

I have no idea, I've never used replit

sharp saddle
# earnest phoenix

change "start": "index.js" to "start": "node index.js" in package.json

surreal sage
sharp saddle
surreal sage
#

is there a way for me to choose what github sees as the readme file in a sub-folder?

#

root README.md and I have another folder with a lot of README(xxx).txts and my own README.md

#

how can I make sure it will choose my readme file?

rustic nova
#

it can only read that one readme.md on the main folder

#

having readmes in different folders will display these readmes when navigating that folder

real rose
earnest phoenix
real rose
surreal sage
#

hi ok so

#

im trying to regex \d+\.\d+ and not \d+\.\d+\.\d+

#

(enforcing x.xx.x)

#

I am struggling

#

basically x.xx cannot have another dot after

surreal sage
#

only the last should match

earnest phoenix
surreal sage
#

try 3.21.0

#

match \d+\.\d+, there may not be any dots infront or behind in a global search

earnest phoenix
surreal sage
#

that indeed works thank u

#

(autoregex ai thingie made the exact same thing as you when you sent it)

earnest phoenix
undone rose
surreal sage
#

const makes it so that you cant change the type on it right?

#

as js const object = {}; object.foo = "bar"; object.foo; // "bar" this works

#

same for arrays

#

but not numbers

surreal sage
#

no quotes, nothing surrounding

#

no real type

civic scroll
#

you can still change its shape via delete and other object manipulation shnenanigans

civic scroll
# surreal sage but not numbers

direct property assignments for any other primitives would not work because method / property accessing is instanciated with a temporary instance of the primitive class while doing so (in this case, Number class)
(doing so on null or undefined would raise a TypeError runtime error instead)
however, mutating the very class that was used to create said temporary instances would work

#

in this example, all other numbers would have a property called unreal with a value of true

civic scroll
civic scroll
civic scroll
civic scroll
pastel jewel
#

👀

surreal sage
#

@earnest phoenix your replacement is here TrollHD

earnest phoenix
radiant kraken
earnest phoenix
surreal sage
#

python is the best programming language

#

(if you don't want to do anything useful)

lament rock
#

idk. I'd rather python for AI than any other language

#

Or anything math heavy

earnest phoenix
# lament rock Or anything math heavy

I mean, most of the AI and math libraries that are available for Python aren't even written in Python, they're written in C/C++ that have Python bindings, if you really want the most optimal one and the best performance then you know which one to choose mmLol

stiff dust
#

Hi I need help!
I want to drop Candy if 50 messages sent in last 5 minutes but as you can see in my code its little different and I don't know what should I do
this is my current code

const hallowstreatCooldown = new Set();
let hallowstreatCounter = 50;

module.exports = async (client, message) => {

    if (message.channelId === '1168435757397053440') {

        if (!hallowstreatCooldown.has(message.author.id)) {

            hallowstreatCooldown.add(message.author.id);

            setTimeout(() => {
                hallowstreatCooldown.delete(message.author.id);
            }, 10 * 1000);

            if (!hallowstreatCounter) {

                hallowstreatCounter = 50

                setTimeout(() => {
                    hallowstreatCounter = 0;
                }, 5 * 60 * 1000);

            };

            if (--hallowstreatCounter === 0) {

                // Drop Candy

            };

        };

    };

};

for example if we need only 2 more messages to drop and the timer reach 0 it will reset everything -_-

earnest phoenix
#

Reads to me like it works as intended

sharp geyser
#

No drop candy

#

kthxbai

stiff dust
rustic nova
#

drop table candy

neon leaf
#

Someone rename drop to nuke

#

NUKE TABLE users;

radiant kraken
eternal osprey
#
const {
  SlashCommandBuilder,
  EmbedBuilder,
  PermissionFlagsBits,
  ActionRowBuilder,
  ButtonBuilder,
  ButtonStyle,
} = require("discord.js");```
Instead change the require of index.js in /Users/apple/Desktop/s/responder/commands/adopt/adopt.js to a dynamic import() which is available in all CommonJS modules.
#

why tf is it saying this?

#

file is called adopt.js, i didn't do shit differently than usual

eternal osprey
#

i already discovered what the problem was ffs. I used an import only package

neon leaf
earnest phoenix
neon leaf
#

idek

frosty gale
#

bro thought breaking it open would help let the wifi out more

spark flint
#

let the wifi escape

green kestrel
#

lol i love breaking AI

magic sonnet
#

Word

#

@neon leaf fix your AI sir

neon leaf
#

no

#

tell openai to fix workers

spark flint
#

cloudflare workers down

magic sonnet
#

😵

neon tusk
neon leaf
#

its heart was broken

#

quite literally

rustic nova
#

its always "how does workers work" but never "how is workers"

sharp geyser
rustic nova
#

yes

neon leaf
#

I slipped in lines

#

and suddenly commit names were switched

magic sonnet
#

Ok buddy

tight oak
#

hey I have a little question if somebody can help me im a beginner on this, I want to do reward for vote Ive done a lot of step the only problem right now I had is this :
(im on python)

#

Its when I do a test vote

wheat mesa
#

Show some code related to your endpoint

lyric mountain
#

just as a tip, put those errors at DEBUG level, not WARN

#

else your console will be filled with invalid requests from the bots on the net

tight oak
bitter heart
#

For example, I have a voice channel id called 1234 and I want to kick everyone in this channel from voice, how can I do it with Nodejs?

earnest phoenix
earnest phoenix
#

The <Collection>.array() method was removed, call <Collection>.values() for the values of the collection and iterate through it using a for loop

bitter heart
deft wolf
#

Why do you add .user after members

bitter heart
deft wolf
#

Are you sure channel is in cache? Also just console.log(members) to find out what it really is

pale vessel
#

values() returns an iterator, use a for loop instead of forEach()

bitter heart
pale vessel
pale vessel
#

i don't think users have a voice property

#

check the docs

bitter heart
#

What should I fix now?

pale vessel
#

theres no need to use player.user since player is a guild member

tight oak
earnest phoenix
# bitter heart
  1. Use an ordinary for loop, not a for await loop
  2. player here is a guild member, no need for user
tight oak
earnest phoenix
magic sonnet
#

How to become bot?

deft wolf
#

Click on any suspicious link on discord or scan the qr code

#

Within a few days, your account will turn into a bot sending invitations to nsfw servers or a nitro scam

#

And if you mean selfbot, you won't get that answer here, Discord's ToS applies on this channel

rustic nova
#

Got what they asked for

#

Love it

fossil flume
#

how can i check if a user is voted to my bot or not?
python topggpy

radiant burrow
#

could I in theory have 75 people invite my support server's helper bot, get it verified, and then have it leave the servers (or do nothing in any server that's not the support one I guess)?

i just kinda want it verified lol

deft wolf
#

Discord has something that if a bot is added to too many servers at the same time, they will not verify it and you will get a time block for a certain period of time when it comes to verification

#

I don't remember what it's called exactly

radiant burrow
#

inorganic growth

#

but like it can be slow. it just has to be 75

deft wolf
#

Exactly, although I have no idea if it's possible to set the bot to private, for example

#

After verification

radiant burrow
#

but does having it be in those 75 servers just to get verified and then leaving them violate any verification terms? will the bot or i get banned/ in trouble?

radiant burrow
deft wolf
#

Probably not, it is possible for people to add a bot and then kick it

radiant burrow
#

no I do already do that

#

it works

deft wolf
#

I don't think Discord cares about checking it

radiant burrow
#

kk! Ill try it when i know i can find 75 people to add it haha. just people in the support server who wanna help

deft wolf
#

Just remember that if your bot uses the message content intent, you will have difficulty verifying it

radiant burrow
#

hmm though i guess when it's verified ill have to apply for the privilege intents derpypuddle

inner loom
#

hi

#

someone can help me

magic sonnet
#

How to become a bot?

quartz kindle
surreal sage
radiant kraken
#
iARTIFICAL INTELLIGENCE
  return 1;
} else {
  return 0;
}ARTIFICIAL INTELLIGENCE
magic sonnet
#

Hello, how may I assist you today?

sharp geyser
rustic nova
#

I'm sorry to hear you're struggling with depressions, but due to my content policy, I am unable to help you and you should rather consult a professional for help

neon leaf
#

e

earnest phoenix
#

guys i m having difficulty in voting

neon leaf
errant flax
#

why does it not line break

earnest phoenix
rocky dagger
#

How can i change the permissions here using code?

wheat mesa
#

#support and also try not to ping every staff member, usually you don’t need to ping anyone

earnest phoenix
surreal sage
#

regex problemos 🔥

#

i need to remove the spaces out of a capturing group for subsitution

#

e.g Test 1 > Test1

sinful nova
#

Ñ

#

Ñ

#

Ü

deft wolf
#

Are you ok?

sinful nova
#

Ñ

#

You can say Ñ

deft wolf
#

No, i can't

sinful nova
#

And ü

#

?

sinful nova
#

Ñ

surreal sage
#

ñ

sinful nova
#

Spanish or english

surreal sage
#

US doesn't

#

🎉

sinful nova
#

Ü

#

Ñüá

#

Hello?

#

'
Ñüá

#

Bots

#

L ol§

quartz kindle
#

on mobile you can say all of that easy

#

just hold the character and a list of variations appears lul

surreal sage
#

gboard on top.

radiant kraken
surreal sage
#

when i think of google

#

i think of voltrex

#

when i think of shitty code

#

i also think of voltrex

#

🥰

#

/j

#

anyways

#

more regex help needed

#

I have a capturing group and I want to negative lookbehind that capturing group

#

Basically the same thing cannot be infront

surreal sage
#

the usual (?<!\1)(blehhh) doesnt work

earnest phoenix
eternal osprey
#

hey guys

#

i have a data mining project coming up soon

#

does anyone know a good project to do that involves classificaation using a decision tree?

#

of course you have disease classification etc but idk i rather would love to do something creative but i am not a creative person lmao

magic sonnet
#

Is it okay if I open a virus on my PC? I was told if I throw it in the river after I do this, then retrieve it it should have no virus on it.

radiant burrow
#

hey i know im pinging u like a billion years late but this is the only info i found after searching online/ a few discord servers.

so i run a funciton with the vote event, to give the user coins. So it needs to access the database. But it doesn't seem to be able to use the schemas and everything from other filepaths.

I even tried defining the three functions/ things it needs outside of the function and then passing them in, but with no luck. do you happen to know how to use external filepath functions inside a function ran

app.post("/dblwebhook", webhook.listener(async (vote) => {
  try{
    await manager.broadcastEval(userVote, { context: 
      { vote: vote } });
  } catch (err) {
    console.log(err);
  }
}));

and the imported userVote function is:

const { EmbedBuilder } = require('discord.js');
const globals = require("../General functions/globals.js");

const UserProfile = require('../models/UserProfile');
const chestDrop = require('../General functions/chestDrop.js');
const updateBalance = require('../User functions/updateBalance');

async function userVote(vote) {
    console.log("trying vote");
    const clientsUser = client.users.fetch(vote.user);
    if(!clientsUser){ return; } // check if the users on this shard

    console.log("found user", clientsUser.username);

    const user = await UserProfile.findOne({ userID: vote.user });
    if(!user){ return; };
    console.log("user profile was found");
.
.
.
continued

it doesn't seem to like me using other functions, and I get errors about using them. Unfortunately I don't have the exact error but it was about being unable to find the location of the imported functions. I can dig through the logs if it helps

Do you happen to know how to use other external functions and things inside the vote event function call when using sharding?

#

my issue is so niche that i can't find any answers anywhere online but im hoping someone here knows how to do this with the vote event derpypuddle

radiant burrow
quartz kindle
#

but the voteFunction is passed to broadcasteval and executed by the shards

#

but when it gets there, its inside the shards ecosystem, not in the managers

#

and the imported files are in the manager, not in the shards

#

you have to put the requires inside the userVote function

#

all of them

#

and also, the require paths are relative to the location where the function will be executed

#

which is somewhere inside the DJS code most likely

#

so you have to replace those relative paths with absolute paths

#

or resolve them beforehand

radiant burrow
#

ahah thats what I suspected, I tried passsing it all into uservote but I did't do it as described. Ill do that. thank you!

surreal sage
#

What databases are up to the following requirements?:

  1. Large collection with over a million of items
  2. ↑ Fast searching and filtering
  3. Some sort of support in Node.js
  4. Preferably a graphical display for debugging
wheat mesa
#

Pretty much any mainstream database is built with performance in mind

#

Can’t go wrong with postgres

#

I’ve heard good things about MariaDB but I can’t speak to the validity of that myself as I haven’t used it

neon leaf
#

In my experience with PG I'm able to search an IP in a list of 4million subnets in 3ms

neon leaf
#

Why

compact pier
#

Do I really need a refreshable access token for a mobile device? Or just a token that never expires, only if user logout

lyric mountain
#

depends on your safety standards

#

all oauth2s will expire after some time, as that's standardized

#

but if ur making your own authorization flow then it's up to you to define this

compact pier
#

is it a good idea to create a token with device ip in it? so check, if the connection not from that ip address, will require a token refresh?

rustic nova
#

it ends up being annoying for people that have dynamic addresses

#

and share a single ip

digital swan
#

also annoying if you connect from mobile data and then have to log in

compact pier
#

ahhh

halcyon kite
#
  return "[Name: " + info[0] + " " + info[1] + 
  ", Email: " + info[2] + 
  ", Subject: " + info[3] +
  ", Teacher: " + info[4] + 
  ", Day: " + info[5] + 
  ", Start Time: " + info[6] + 
  ", End Time: " + info[7] + "]";

This is more of a javascript question but whenever I call this
in a console.log() the return doesn't return anything yet if I put a console.log before the return it actually logs so I know its not anything before the return.

#

yeah I have no idea

#

does async mess with it?

deft wolf
#

Can't you just define it before return?

#

And return variable

halcyon kite
#

i tried that

#
  var text = "[Name: " + info[0] + " " + info[1] + 
  ", Email: " + info[2] + 
  ", Subject: " + info[3] +
  ", Teacher: " + info[4] + 
  ", Day: " + info[5] + 
  ", Start Time: " + info[6] + 
  ", End Time: " + info[7] + "]"
  return text;
deft wolf
#

Also what do you want to do because it looks like an array but also it is string and look like object

halcyon kite
#

ok so im trying to grab info from a row in google sheets and then return it, i honestly dont know why I made the array but i kinda did,

#

its supposed to return a text form

#

i just thought it looked nicer than rows[rowIndex].get('<whatever goes here>')

#

for every place where info is

lyric mountain
#

show the rest of the code please

#

the console.log part I mean

#

also, js has interpolated strings, you don't need to append like that

halcyon kite
#

yeah

#

alr

#

ill send

#
const api = require('./Student.js');
//Ignore this, part of another test
const dotenv = require('dotenv');
dotenv.config();
console.log(api.getStudentAt(0, 1));
lyric mountain
#

and getStudentAt too

halcyon kite
#

k

#
async function getStudentAt(sheetIndex, rowIndex) {
  const dotenv = require('dotenv');   
  dotenv.config();
  const { GoogleSpreadsheet } = require('google-spreadsheet');
  const { JWT } = require('google-auth-library');
      
  const serviceAccountAuth = new JWT({
    // env var values here are copied from service account credentials generated by google
    // see "Authentication" section in docs for more info
    email: process.env.CLIENT_EMAIL,
    key: process.env.SHEETS_PRIVATE_KEY,
    scopes: [
      'https://www.googleapis.com/auth/spreadsheets',
    ],
  });

  const doc = new GoogleSpreadsheet(process.env.SHEETS_ID, serviceAccountAuth);
  await doc.loadInfo(); // loads document properties and worksheets
  
  var sheet = doc.sheetsByIndex[sheetIndex]

  const rows = await sheet.getRows();
  const info = [
    rows[rowIndex].get('Student_First_Name'),
    rows[rowIndex].get('Student_Last_Name'),
    rows[rowIndex].get('Email'),
    rows[rowIndex].get('Subject'),
    rows[rowIndex].get('Teacher'),
    rows[rowIndex].get('Day'),
    rows[rowIndex].get('Start_Time'),
    rows[rowIndex].get('End_Time')
  ];
  return "[Name: " + info[0] + " " + info[1] + 
  ", Email: " + info[2] + 
  ", Subject: " + info[3] +
  ", Teacher: " + info[4] + 
  ", Day: " + info[5] + 
  ", Start Time: " + info[6] + 
  ", End Time: " + info[7] + "]";
#

wait

#

it kinda big

lyric mountain
#

use hatebin or smth

halcyon kite
#

haste? alr

pale vessel
#

also it looks like it's an async function, should probably await while calling it

lyric mountain
#

no, hate

halcyon kite
#

alr

halcyon kite
lyric mountain
halcyon kite
#

oh

#

lmao

lyric mountain
#

it's like the former hastebin, but better

#

never liked what they did to haste after it was sold to toptal

halcyon kite
#

there i think

lyric mountain
#

it's missing closing bracket

halcyon kite
#

oh yeah lmao

#

there

lyric mountain
#

well, a possible cause is that it's async

#

so you're required to do console.log(await api.getStudentAt(0, 1));

#

it sucks tho that it'll also require that scope to become async

halcyon kite
#

alr

lyric mountain
#

given async is contagious

#

alternatively u can do api.getStudentAt(0, 1).then(console.log)

pale vessel
#

if u dont care then api.getStudentAt(0, 1).then(console.log)

halcyon kite
#

honestly its just a testing file

#

so i dont rlly

#

im rn developing this for a bot

#

imma have to look more into async and stuff

lyric mountain
#

you could also make a model for student info, to reduce on those array accesses

halcyon kite
#

oh true

lyric mountain
#

but yeah, async is annoying to deal with

#

never liked that approach to parallel computing

halcyon kite
#

yeah

#

Imma come up with a nicer model later

#

probally using \n

lyric mountain
#

oh, not what I mean

halcyon kite
#

o

#

u mean like a toString?

lyric mountain
#
class Student {
  let name, email, subject, teacher, day, startTime, endTime;

  constructor(rows) {
    name = rows.get("Student_First_Name") + " " + rows.get("Student_Last_Name");
    email = rows.get("Email");
    subject = rows.get("Subject");
    teacher = rows.get("Teacher");
    day = rows.get("Day");
    startTime = rows.get("Start_Time");
    endTime = rows.get("End_Time");
  }

  toString() {
    return `[Name: ${name}, Email: ${email}, Subject: ${subject}, Teacher: ${teacher}, Day: ${day}, Start Time: ${startTime}, End Time: ${endTime}]`;
  }
}
#

this

halcyon kite
#

hm

#

alr

#

thx

#

ill defo look into it

neon leaf
#

I think I finally support all reasonable ip formats

quartz kindle
#

if length = 2, its first and last, if length = 3, its first, second and last

neon leaf
quartz kindle
#

whats the logic behind it?

neon leaf
#

behind my code or generally?

quartz kindle
#

in general, like why does ipv4 work like that

neon leaf
#

idfk

quartz kindle
#

lmao

neon leaf
#

ok well my 1 should be 0.0.0.1 technically