#development

1 messages · Page 1510 of 1

white drum
#

does anyone understand html and embeds and discord?

mellow kelp
#

yeah, what's your question

white drum
#

so video previews from my website do not load onto discord

#

example:

#

did my internet just die

#

nvm

mellow kelp
#

o

white drum
#

thats an example

#

the video doesnt show within discord

#

where another website

mellow kelp
#

yeah

#

because it's an actual video

white drum
mellow kelp
#

o

white drum
#

that does

#

that shows

#

and its exactly the same but different website

#

and different video

mellow kelp
#

not really sure

white drum
#

and i am getting a request

#

"GET /assets/Videos/mercedes-aa-class.mp4 HTTP/1.1" 200 13763150 "-" "Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)"

slow kettle
#

How do i get the Bot Dev role?

white drum
#

by not speaking in this channel about it

#

and submitting a bot and getting it approved

slow kettle
#

Okay i just wanted to ask

slow kettle
slim heart
#

u have to actually send a form-data body

crimson vapor
#

body: (new FormData()).append('file1', fs.readFileSync('./aFile.ext'))?

#

@slim heart eeeeeeeee

slim heart
#

file

crimson vapor
#

fuck I must be doing something wrong

mellow kelp
#

@crimson vapor The append() method doesn't return the formData itself

#

its just void

crimson vapor
#

well I fixed that

#

still doing something wrong tho

mellow kelp
#

o

#

rip

crimson vapor
#

@mellow kelp do you think you could help me with this?

mellow kelp
#

hm

#

what were you trying to do again?

crimson vapor
#

send a file

mellow kelp
#

local file am i right?

crimson vapor
#

yea

#

or buffer

#

icba to care

#

I want it to just work

mellow kelp
#

hmm

#

node.js or browser

crimson vapor
#

node.js using node-fetch

#

so basically browser

mellow kelp
#

oh then you need the form-data package

crimson vapor
#

I have

#

dw

mellow kelp
#

o

#

hm

crimson vapor
#
  1. idk how to send json in formdata
#
  1. idk how to send a file
mellow kelp
#
  1. some discord routes support both json and formdata
#
  1. me neither KEKW
crimson vapor
#

fuck

mellow kelp
#

well i mean

#

if appending a buffer doesn't work honestly i dont know what might

crimson vapor
#

lol

trim saddle
#

discord supports both

#

but only form-data if you intend to send files

crimson vapor
#
const FormData = require("form-data");
const fetch = require('node-fetch')
const fs = require('fs');

const formData = new FormData();
formData.append('file', fs.readFileSync('README.md'), 'README.md')

fetch('https://discordapp.com/api/v8/channels/731324778345922631/messages', {
  method: 'POST',
  headers: {
    Authorization: 'Bot TOKEN',
    "Content-Type": "multipart/form-data",
  },
  body: formData
}).then(e => e.json()).then(e => console.log(e))```
#
{ message: 'Cannot send an empty message', code: 50006 }```
#

@slim heart what did I do wrong?

slim heart
#

u might need to convert it to a data uri instead of a buffer

crimson vapor
#

the formData?

#

if so, how?

#

or the file

#

idfk

slim heart
#

idk i'm getting lost too

crimson vapor
#

oh

slim heart
#

you should ask in discord devs

trim saddle
#

@crimson vapor you wanna borrow my data uri thing?

crimson vapor
trim saddle
#

well yeah but it's a whole class thing

crimson vapor
#

you can send files?

trim saddle
#

no i can make data uris tho

crimson vapor
#

o

#

ima ask in discord devs

quartz kindle
#

iirc formdata requires special headers

trim saddle
#

content-type: "multipart/form-data"

quartz kindle
#

thats not enough

#

headers: form.getHeaders()

trim saddle
#

wha.

crimson vapor
#

yes but no

#

still didn't work

slim heart
#

in the docs u also need like the Content-Disposition header for the file name

trim saddle
#

berry

#

go apply for discord

#

and simplify image uploading

mellow kelp
#

yes

slim heart
#

this is as simple as it gets pensiveaf

#

i've just never done it

trim saddle
#

if you're editing data like a user profile

#

or a guild

slim heart
#

it sends the data as form data

trim saddle
#

all you have to do is provide a data uri

crimson vapor
#

wait it didn't work

#

tim

quartz kindle
#

the form-data package has an example for axios, just change it to use node fetch

quartz kindle
#
axios.post( 'https://example.com/path/to/api',
            form.getBuffer(),
            form.getHeaders()
          )
#

hmm weird, they have an example for node-fetch that doesnt use headers at all

crimson vapor
#

asked on discord devs

#

made me verify my phone tho sad

mellow kelp
#

lmao

slim heart
#

might do it automatically in node fetch

crimson vapor
#

perhaps

quartz kindle
#

formdata headers are weird af

crimson vapor
#

discord requires multipart/form-data

quartz kindle
#

yes, but thats not enough

#

this is how a form-data content-type looks like

slim heart
#

that's extra info i think

#

is there a content-disposition header?

quartz kindle
#

here's another example using node's http.request ```js
var form = new FormData();
form.append('image2.png', fs.readFileSync('./public/image2.png'));

res.set('Content-Type', 'multipart/form-data; boundary=' + form.getBoundary());
crimson vapor
#

FUCK YES

#

TY TIM

#
const FormData = require("form-data");
const fetch = require('node-fetch')
const fs = require('fs');

const formData = new FormData();
formData.append('file', fs.readFileSync('README.md', 'utf8'), 'README.md')
console.log(formData.getHeaders());
fetch('https://discordapp.com/api/v8/channels/731324778345922631/messages', {
  method: 'POST',
  headers: {
    ...formData.getHeaders(),
    Authorization: 'Bot NjkyMDI5MzIwNzc1ODYwMjQ1.Xnokhw.KEKW',
  },
  body: formData
}).then(e => e.json()).then(e => console.log(e))```
#

WORKED

trim saddle
#

ha

crimson vapor
#

TY @quartz kindle

trim saddle
#

imagine

#

it actually works

#

ha

quartz kindle
#

if only the token worked too

#

kekw

slim heart
#

gamer

#

should pr the form-data readme and add that @quartz kindle

crimson vapor
#

lmao

quartz kindle
#

i mean, its already in their examples

crimson vapor
#

ty tim

#

so much

quartz kindle
#

btw, isnt google drive supposed to auto delete items from trash after 30 days?

crimson vapor
#

iirc

quartz kindle
#

my google drive was full of old ass trash

crimson vapor
#

or maybe once your drive fills up

quartz kindle
#

from a year ago

crimson vapor
#

like 100%

#

bc thats smart tbh

#

delete shit only when needed

quartz kindle
#

ye but like

#

my drive was 15gb used out of 15gb

#

i had to empty trash + reload + empty trash + reload a bunch of times

#

because shit's bugged af

#

now the trash is finally empty

#

and got 10gb free space back

#

@_@

crimson vapor
#

LOL

#

what do you use drive for?

quartz kindle
#

github backup

#

sort of

crimson vapor
#

lmao what

quartz kindle
#

all my projects are inside the drive sync folder

#

so everything i do gets auto synced to drive

crimson vapor
#

oh

#

makes sense

trim saddle
#

ah yes

crimson vapor
#

what about node_module?

quartz kindle
#

the only shitty thing is that google drive sync cant filter out stuff

trim saddle
#

UnhandledPromiseRejectionWarning: TypeError: source.on is not a function thank you so much formdata

quartz kindle
#

so node_modules is included

quartz kindle
#

another formdata challenger?

#

xD

crimson vapor
#

iirc this one is caused by shitty error handling

#

@slim heart how can I update the headers using your rest api lib?

trim saddle
#

perfect

#

no errors in console

crimson vapor
#

good

#

did it work?

trim saddle
#

but no file sent

crimson vapor
#

fuck

trim saddle
#
const form = new fd()
form.append("payload_json", JSON.stringify(body))
form.append("file", file.baseString, file.filename)
res.body(form, "form")
res.header({
"User-Agent": "DiscordBot (https://discord.gg/coolinvite, v1)",
"Authorization": `Bot ${this.token}`,
// @ts-ignore
...form.getHeaders()
})

centra is fun

crimson vapor
#

did it work for you?

trim saddle
#

nope

crimson vapor
#

rip

valid temple
#
client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)

using this code to count total guilds, in a command i'm using the same thing but with message. at the beginning. The text coommand has the right count but the bot status is stuck on an old number. Anyone know why that'd be happening?

crimson vapor
#

are you updating the status? if you are show the code

trim saddle
#

@quartz kindle be my debugger

valid temple
# crimson vapor are you updating the status? if you are show the code

yes

client.on('ready', async () => {
    const activityList = [
        `${client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)} cuties!`,
        `${client.guilds.cache.size} servers!`,
        'niko help',
        'niko | n! | にこ'
    ]
    setInterval(() => {
        const activityRandomizer = Math.floor(Math.random() * (activityList.length - 1) + 1);
        client.user.setActivity(activityList[activityRandomizer], { type: 'WATCHING' });
    }, 100000)

});
#

wait...

#

i gave wrong code... smh

crimson vapor
#

no

#

thats status code

valid temple
#

yes

#
client.guilds.cache.size
trim saddle
#

i think i give up

valid temple
#

thats what im using for guilds

crimson vapor
#

is activityList static?

valid temple
#

i believe so

#

it updated earlier from 13 to 10 but now it wont update from 10 to 30

crimson vapor
#

if it static it will only change on restart

#
      const req = await fetch(this.#shard.client.options.api + `/channels/${this.id}/messages`, {
        method: 'POST',
        headers: {
          ...message.getHeaders(),
          Authorization: `Bot ${this.#shard.client.token}`,
        },
        body: message
      }).then(e => e.json())
      if (req.code) throw new Error(req.message)``` @trim saddle this worked for me
#

message being FormData

valid temple
#

well it changed earlier and i didn't restart... idk

trim saddle
#

i use centra for my stuff

crimson vapor
#

whats centra?

trim saddle
#

a different requesting lib

crimson vapor
#

oh

#

should be similar tho

#

no?

#

idk I use berry's code for everything

trim saddle
#

i think so...

crimson vapor
#

console log the response

#
      } catch (err) {
        throw err;
      }``` I want to throw the error
crystal wigeon
#

hey guys

#

anyone know about node resque?

crimson vapor
#

it worked

crystal wigeon
#

how do i return a callback func? like im passing a func to node resque jobs but then i want a callback from this function

crimson vapor
#

@quartz kindle

#

oh he is offline

crystal wigeon
#

@umbral zealot

umbral zealot
#

"returning a callback function" is... returning a variable that contains a function

#

that's it

#

return (a) => {blah};

analog imp
#

anyone familiar with events and missing permissions on ready? thought i had this accounted for, one sec for code:

crystal wigeon
#

i know

#

so its like

#

im passing a func to my node resque jobs

#

inside there

#

im passing a func that has callback

umbral zealot
#

I'd like to clarify, I have no idea how node-resque works, I've never used it, and I've never installed redis, so my assistance is very limited 😂

crystal wigeon
#

note that not all funcs have call back

#

awit

#

well i tried it

umbral zealot
#

I can only speak in generalities of javascript

crystal wigeon
#

and its good

#

i know js lol

#

i mean the basic call func

#

jsut trying to get it from node resque

#

since idk the syntax

umbral zealot
#

Right so what do you have now and what do you need to do?

crystal wigeon
#

there

analog imp
#
try {
        exports.invReady = client => {
        client.guilds.cache.forEach(e =>{
            if(e.me.hasPermission('SEND_MESSAGES')===false) {
                return;
            }
        })
        wait(1000);
        client.guilds.cache.forEach(g => {
            (doing stuff)
        });     
        console.log('Loaded all invites in all guilds')
    }
} catch (error) {
console.log('error')
}
crystal wigeon
#

what i have now is workers that'll pick a function that returns void

#

if i have a func that returns callback

umbral zealot
#

CAn you show the code

crystal wigeon
#

idk how to do it syntactically

#
      [jobName]: {
        Plugins: [Plugins.JobLock],
        PluginOptions: {
          JobLock: { reEnqueue: true },
        },
        perform: () => {
          jobsToComplete--;
        //   this.tryShutdown();
          if (typeof jobFunc === "function") {
            return jobFunc(funcParams);
          }
          return false;
        },
      },
    }```
#

this is the job

analog imp
#

and the error i keep getting on ready:

(node:23432) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at RequestHandler.execute (c:\Users\PC4\Desktop\v2-new\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (c:\Users\PC4\Desktop\v2-new\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
crystal wigeon
#

that takes the func

#

this func returns a callback

umbral zealot
#

Actually it doesn't

crystal wigeon
#

how do i access that

umbral zealot
#

I mean, this returns the results of jobFunc(funcParams) so unless jobFunc returns a function, it's not "Returning a callback"

#

just to be clear: a callback is literally just a function we call by another name because it's cutesy.

crystal wigeon
#

yes

#

so the result of this jobFunc is a call back

umbral zealot
#

Ok so, like, how do you call perform(), then?

crystal wigeon
#

it automatically does that when i init the workers

#

and push to queue

umbral zealot
#

then you can't access the return value, I'm pretty sure

analog imp
#

i am using both try-catch for catching the error, and forEach looping each guild to check permissions. still comes up with the error on start. no commands used, just on ready. know where the error is just would like to catch it, but seems to be doing it at permission checks

crystal wigeon
#

yeah thats what i was thinking

umbral zealot
trim saddle
#

@crimson vapor tried logging the raw response

umbral zealot
#
        client.guilds.cache.forEach(e =>{
            if(e.me.hasPermission('SEND_MESSAGES')===false) {
                return;
            }
        })

This just... loop and does nothing. It's pointless.

crystal wigeon
#

lol

crimson vapor
analog imp
#

alright so that aside, not even this is doing anything

try {
        exports.invReady = client => {
something something
    }
} catch (error) {
console.log('error')
}```
umbral zealot
#

you can't set an exports from within other code either

#

it has to be top-level

slim heart
#

tho i think it might not work

#

ngl

crimson vapor
#

I don't think it does

slim heart
#

1s

trim saddle
#

got the proper json response

analog imp
#

still exports. that's odd imo

crimson vapor
#

pog

slim heart
#

ok

#

do that

trim saddle
crimson vapor
#

berry

#

does it add the headers?

umbral zealot
#

Why would you even export a function from within a try/catch that doesn't even make any sense

crimson vapor
#

or just replace them?

slim heart
#

and do
{ headers: {...}, body: formData, parser: (_) => _) }

umbral zealot
#

I dunno it looks like button mashing to me

slim heart
#

its cuz the parser is all messed

crimson vapor
#

parser: (_) => _)?

#

that would error no

slim heart
#

no

analog imp
#

because i'm trying to catch missing permission "SEND_MESSAGES" from the getgo

slim heart
#

so if options.parser is there itll just run it and return itself

umbral zealot
#

you should do that catch inside the function itself

umbral zealot
#

Anyways, what you need is filter() not forEach

#

like I said the foreach is 100% pointless as is

analog imp
#

.filter() for each guild?

umbral zealot
#

no

analog imp
#

hmm

umbral zealot
#

client.guilds.cache.filter

trim saddle
#

@slim heart can you like join a live share before my brain

umbral zealot
#

so you want to filter on guilds where you have permissions to speak, right?

slim heart
#

sure

#

o

#

u mean like code share

#

cant rn im like nap time but u can ask questions ig

trim saddle
#

naptime?

analog imp
#

this is on the ready event, when the bot loads in, i'm not looking to filter guilds, because it needs to load each guilds' invites

#

whenever it restarts

trim saddle
#

it's 11 at night

umbral zealot
#

So what are you trying to do

trim saddle
#

and you're a grown man

analog imp
#

trying to catch missing permission "SEND_MESSAGES" from the getgo

slim heart
#

nap time

umbral zealot
#

"catch"

#

for what reason

#

what are you trying to do

#

what's the end game? I have literally no clue what you're trying to do

crimson vapor
#

400 bad request

#

the fuck

#

how

slim heart
#

show?

analog imp
#

if my bot is in 100 guilds and each guild denies send messages, it won't stop polluting the logs

umbral zealot
crimson vapor
#
      const req = await this.#shard.client.api().channels[this.id].messages.post({
        body: message,
        headers: {
          ...message.getHeaders(),
          Authorization: 'Bot NjkyMDI5MzIwNzc1ODYwMjQ1.KEKW',
        },
        parser: (_) => (_)
      });
      if (req.code !== undefined) throw new Error(req.message)
      return new (require('./Message'))(req, this.#shard);```
umbral zealot
#

no comprende amigo

#

Where is it failing

#

what problem are you trying to fix

#

Because this is clearly an X/Y problem. We need the why

trim saddle
#

nap time

#

i guess i'll catch you in the morning

wheat valve
#

What do you have to include in a say command for it to be allowed on top.gg? Sorry if this is the wrong chat

analog imp
#

fails at this:

  async push(request) {
    await this.queue.wait();
    try {
      return await this.execute(request);
    } finally {
      this.queue.shift();
    }
  }

RequestHandler.push (c:\Users\PC4\Desktop\v2-new\node_modules\discord.js\src\rest\RequestHandler.js:39:14

umbral zealot
slim heart
#

the exact same code works with node-fetch @crimson vapor ?

trim saddle
#

say commands are a bad idea

umbral zealot
crimson vapor
umbral zealot
#

what problem in your code are you trying to fix

trim saddle
#

mainly because people can use it to slander your bots image

slim heart
#

dont ctrl+z

#

pensiv

#

it leaves the program running

analog imp
#
try {
        exports.invReady = client => {
something something
    }
} catch (error) {
console.log('error')
}
umbral zealot
#

Ok and what does that do

crimson vapor
#
      let req;
      try {
        req = await fetch(this.#shard.client.options.api + `/channels/${this.id}/messages`, {
          method: 'POST',
          headers: {
            ...message.getHeaders(),
            Authorization: `Bot NjkyMDI5MzIwNzc1ODYwMjQ1.MMLOL`,
          },
          body: message
        }).then(e => e.json())
      } catch (err) {
        throw err;
      }```
umbral zealot
#

AGain, what is your end goal here, what are you trying to write

bleak spire
#

guys how can i make my bot 24/7 online?

umbral zealot
#

is it an invite tracker? a ping/pong command? scratch-your-ass-with-a-robot integration?

#

what the fuck are you doing

slim heart
#

does that work million

analog imp
#

fetches guild invites, if a guild is missing send messages it should return and not proceed for that guild. tracks invites on ready

crimson vapor
#

yes

#

I can test again

bleak spire
#

guys?

umbral zealot
heavy anchor
crimson vapor
#

yep it does berry

analog imp
#
try {
        exports.invReady = client => {
        client.guilds.cache.forEach(e =>{
            if(e.me.hasPermission('SEND_MESSAGES')===false) {
                return;
            }
        })
        wait(1000);
        client.guilds.cache.forEach(g => {
            g.fetchInvites().then(async guildInvites => {
                invites[g.id] = guildInvites;
            });
        });     
        console.log('Loaded all invites in all guilds')
    }
} catch (error) {
console.log('something')
}
umbral zealot
#

Ok god

#

so again

#
        client.guilds.cache.forEach(e =>{
            if(e.me.hasPermission('SEND_MESSAGES')===false) {
                return;
            }
        })

This does absolutely fuck-all

#

nothing

#

nada

#

it's pointless code

#

Why does it exist

#

what is its intended purpose

analog imp
#

holy shit

#

i just realized

#

where i fucked up

slim heart
#

idk

#

i cant comprehend this rn

analog imp
crimson vapor
#

damn

#

rip

umbral zealot
#

You did? Good, because I still have no goddamn clue what you're trying to do 😂

#

Because this... this makes sense. ```js
client.guilds.cache.forEach(g => {
g.fetchInvites().then(async guildInvites => {
invites[g.id] = guildInvites;
});
});

I know what this is. Looks like the AIG invite tracker code, somewhat.
#

But a shit version of it tbh

crimson vapor
#

invites[] undefined

umbral zealot
#

Cuz... I mean... it literally is ```js
// Initialize the invite cache
const invites = {};

// A pretty useful method to create a delay without blocking the whole script.
const wait = require('util').promisify(setTimeout);

client.on('ready', async () => {
// "ready" isn't really ready. We need to wait a spell.
await wait(1000);

// Load all invites for all guilds and save them to the cache.
client.guilds.cache.forEach(g => {
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
});

Straight-up from this <https://anidiots.guide/coding-guides/tracking-used-invites>
crimson vapor
#

not really

#

its shittier

umbral zealot
#

But your added loop is just... nothing

analog imp
#

lmao, yeah it is

#

and i realized

#

it's just

#

pointless to have

umbral zealot
#

you just realised after I said it like 3 times, so... thanks for catching up to 20 minutes ago in the conversation, I guess?

analog imp
#

ye ye, thanks for bearing with me. i would leave a tip for you if i could

umbral zealot
#

Actually I'll give you a tip: when you want help it's a great idea to actually read the responses people are giving you, like, using your brain.

#

If you don't comprehend the answer, or you need more info, ask instead of ignoring it

#

3 times.

analog imp
#

yeah i get it. brain is cheese, i'm dumb, moments of insanity

#

thanks

umbral zealot
#

Sounds like you're very tired

#

And tired programmers are dumbass programmers.

slim heart
#

cap

#

i do my best work 2 minutes away from sleeping

crimson vapor
#

I don't

analog imp
#

ngl yeah quite, been busy with work, probably shouldn't be working on this alsjdalksdj

crimson vapor
#

but I can explain berry

#

I sleep whenever I get a really hard problem I can't solve

#

and I wake up when I solve it

#

stonks

umbral zealot
slim heart
#

all of my bots were continually coded over multiple moments before i fell asleep

umbral zealot
#

Full 8 hours of sleep, doctor's order.

crimson vapor
#

how much sleep do you get lmao

#

for that much progress

#

kekw

slim heart
#

i go to sleep at 4am and wake up at 6am on work days and 8am on stinky days

crimson vapor
#

is school stinky?

slim heart
#

no weekends n shit

crimson vapor
#

oh

slim heart
#

well

crimson vapor
#

I sleep till 12 on weekends

slim heart
#

same

crimson vapor
#

but I sleep at 4-5

#

depending on when I get yelled at

slim heart
#

but stinky days are days of school when theyre online

crimson vapor
#

true

solemn leaf
#

I slept all day

#

I couldnt think straight

#

But its 10 pm.amd I cant sleep

analog imp
#

wow i am a dumbass. fixed it in the real code, now it's working perfectly; no more polluting logs. thanks to you all who watched me go through a moment of insanity and bared with me

earnest phoenix
#

i cant seem to understand the command to put insert in order for it to welcome members when they join, anyway someone couple help me?

bleak spire
#

guys can i make a glitch project 24/7 online?

cerulean ingot
#

bruh i found a way to host a bot

#

you can make 3gb servers

#

to host them

#

holy shit this is amazing

bleak spire
#

HOW

cerulean ingot
#

dm me

#

so i can help you

bleak spire
#

OK

cerulean ingot
#

this shits amazing

#

how is this real

#

17ms ping..

agile lance
#
    let value = 250
    if(!args[0]==code) return message.reply('Hmm.. The code entered is invalid.')
    if(args[0]==code) {
      let codeRedeem = db.fetch(`CODE2_${message.author.id}`)
      if(codeRedeem ==null) {
        db.add(`Cash_${message.author.id}`, value)
       await message.channel.send(`Success! You have redeemed the code: ${code} and received ${value} coins!`)
     return db.add(`CODE2_${message.author.id}`, 1);
  }
} else {
  message.reply('Code already redeemed.')
}```

But for whatever reason, It responds to any message as long as it starts with the prefix. Ideas? (it gives no errors)

d.js v12
lusty quest
#

did you use a Command Handler or is it a single file Bot?

agile lance
#

Command handler

lusty quest
#

so this one command fires regardless of the command being valid or not

agile lance
#

Yeah

#

as long as it starts with c!

lusty quest
#

sounds like an issue with your command handler

agile lance
#

Never seen this happen before

lusty quest
#

or your command

sacred aurora
#

and whats the response?

lusty quest
#

probably the error

agile lance
sacred aurora
#

oh

lusty quest
#

wait so it skips your entire logic?

agile lance
#

Basically

sacred aurora
#

i think

!args[0]==code

that is wrong

lusty quest
#

yea there is stuff wrong with your entire command

sacred aurora
#

i never write it like that

lusty quest
#

he gets the first item from the array

sacred aurora
#

try

args[0]!=code

instead

agile lance
#

Okay

lusty quest
#

but this wont fix the issue that the command fires on every string that starts with the prefix

agile lance
#

Now it automatically redeemed the code without any code being inputed

sacred aurora
#

:v really

lusty quest
#

there is something broken in your logic somewhere either the Command handler or the command

agile lance
#

command handler is fine

#

It works for my balance command

lusty quest
#

other commands work fine?

agile lance
#

Yep

#

Just this one is messed up somewhere

lusty quest
#

then its probably this one command

sacred aurora
#

does the code only "release"?

agile lance
#

thats the only code yeah

lusty quest
#

i guess its a placeholder for Dev

sacred aurora
#

why not make the command named "code"
and then make an array that contain all the code to be redeem

#

so the script check if args[0] included in the code array then it redeem it

#

something like _code [the code]

#

fuk or am i misunderstood the problem

#

hmm

lusty quest
#

i think this is something for later

#

currently the command fires without being called

#

eg every string that starts with the prefix triggers this command

sacred aurora
#

oh

sacred aurora
#

the _ is the prefix

#

instead of ${prefix}[code]

agile lance
#

Oh i figured it out

sacred aurora
#

umm is there an event that called when the bot leave a server?

sacred aurora
agile lance
#

i never exported the ‘name’ module so it never knew the command name

sacred aurora
#

hmmmmm

crimson vapor
#

guildDelete iirc

agile lance
#

guildMemberLeave

sacred aurora
#

oh kay

pale vessel
crimson vapor
#

nope

agile lance
#

guildDelete is when the bot leaves a guild

sacred aurora
#

:v its the member that leave then

#

yeah thats what i wanted

agile lance
#

guildMemberAdd and guildMemberDelete are for members i believe

#

dont trust me i that >.>

lusty quest
sacred aurora
#

whoa thanks

#
client.on('guildCreate', async (guild) => {
  console.log("Leaved a server named " + guild.name);
  return Config.deleteOne({guildId: guild.id});  
});

that should work right

pale vessel
#

it's guildDelete

sacred aurora
#

oh sorry :V

#

just that?

pale vessel
#

Yes

sacred aurora
#

is there any other problem

bleak spire
#

can someone help me pls?

sacred aurora
#

ah aight

pale vessel
#

"create" doesn't mean the bot left a server lmao

sacred aurora
#

yeah i know XD

bleak spire
#

@pale vessel how can i make my glitch porject bot 24/7 pls

pale vessel
#

I don't know

#

Glitch premium maybe

lusty quest
#

you cant

pale vessel
#

you can't use ping services, they're against tos

lusty quest
#

exept with buying prem

#

but then i would get a proper VPS instead they are cheaper and less limited

bleak spire
#

can i download the project and make in visual studio code?

lusty quest
#

you have your bot on Github right?

bleak spire
#

no

lusty quest
#

doesnt glitch need the project to have a github repo?

#

never used it tbh

bleak spire
#

how can i make it to github

lusty quest
#

idk never used glitch

#

i would have to google it anyways

bleak spire
#

ok

rocky hearth
#
const moves = currentSquare.isFreezed ? this.freezedMove : this.vectorMove;

Is this a valid js? This statement is written in a method of the same class.

crimson vapor
#

should be

rocky hearth
#

But when I do moves().
It says this is undefined

#

I tried doing

const move = (currentSquare.isFreezed ? this.freezedMove : this.vectorMove).bind(this);

And then it worked fine!

bleak spire
#

@lusty quest i uploaded to github

lusty quest
#

then just clone the repo to your pc and edit the bot with VSC

#

maybe install Github desktop to manage it from your PC

tribal siren
#

did you define this

lusty quest
#

would also make sure to make the Code private if you dont want others to use it

bleak spire
lusty quest
#

well there is everything you need

bleak spire
#

how can i now open this with vsc

tribal siren
#

go to vsc...?

lusty quest
#

did you got vsc installed?

rocky hearth
tribal siren
#

do you have it

bleak spire
#

@lusty quest yup

tribal siren
#

then go to it

lusty quest
#

rightclick in the folder and then use open in vsc (works for me)

bleak spire
lusty quest
#

well so you dont installed this integration

#

then do it the other way

#

open VSC and then open the project inside vsc

crimson vapor
#

or click on the folder and press open with visual studio code

tribal siren
#

so now my problem uuh

lusty quest
#

if you see the screenshot above he doesnt installed the extension for it

crimson vapor
#

oh

#

kekw

tribal siren
#

how to make a bot find the first channel in the guild?

bleak spire
#

ok work its work

rocky hearth
#

or simply drag and drop the folder in vsc

bleak spire
#

but i need now to make it 2477

lusty quest
#

get a VPS

bleak spire
#

24/7

lusty quest
#

if you dont know where check the pins in this channel

tribal siren
#

get a VPS

bleak spire
#

i cant found

tribal siren
#

then try better

lusty quest
tepid osprey
#

I need a simple welcome messages but it won't show

#

And my welcome is like if someone joins a server where bot is it also says that

lusty quest
#

listen to the MemberAdd event

cerulean ingot
#

best cheap vps hosting?

#

looking for >= 1gb ram

#

= $4 a month

analog imp
lusty quest
#

but iirc Vultr offers a 1GB VPS for 3$/Month

dusky sundial
#

I pay $6/month for 1GB of RAM on Vultr, but with a high freq CPU as well

cerulean ingot
#

should i get the 512 gb $2.50 a month plan or a raspberry pi 3 b+

lusty quest
#

how far did you plan to Grow your Bot?

dusky sundial
#

VPS is usually a better option than self hosting imo

cerulean ingot
#

hmm

lusty quest
#

VPS got its ups and downs,
Good:
Usually 99% of the time 24/7
no Hardware Maintaince required
Bad:
You are fucked if the hoster decides to Shutdown (yes this is a thing)
You have to Maintain the Software Side

Rapsberry Pi:
Good:
100% Access to the Hardware
No Fear of loosing access to it for some reason (like the Hoster shuts down)
Bad:
Passive Cost of Electicity
You Have to manage the Software and Hardware yourself (Good if you are good in linux/ Server Stuff)
Usually they boot of an SD Card, you have to add a 2nd storage or the SD card will degrade fast.
Affected by local poweroutages

cerulean ingot
#

thank you lol

lusty quest
#

there are ways to overcome the SD card limitations (there is now the ability to boot of an External Drive)

dusky sundial
#

I used to host mine on a Raspberry Pi 3b+ and it worked fine with around 1k guilds. But as it grew I decided it was probably better to swap to a vps. I'm pretty sure Discord even said in their verification message that when the bot grows bigger a hosting service is usually better.

lusty quest
#

depends on the context, i could run my Bot of my NAS easy, until i reach around 3-4 Shards i guess

#

but i prefer the Reliability of an proper host and plan to switch to K8 anyways soon

dusky sundial
#

Yeah, I just happened to have a raspberry lying around. I probably wouldn't buy one just for bot hosting tho

analog imp
#

brain has a point--my bots do well, and honestly the electricity isn't too bad, they aren't big though, only thing with that is becoming familiar with raspbian. i will say, if your isp is unreliable or have network updates, it will boot your bot offline. i have suffered this a few times, due to updates on my network. my honest recommendation is if you plan on going 2k guilds or more, don't go with a pi

#

damn my typing is really slow tonight

lusty quest
#

i have an Raspberry also running, but there i have some stuff for my network running on (Pihole and UI Controller)

dusky sundial
#

I'm gonna try the new Windows 10 thingie for Raspberry Pi just to see how it works lol

lusty quest
#

windows is Trash, if EA would not Ban Linux Users i would run now Probably Manjaro or popOS

analog imp
#

do you have an older pi brain? my pi 2 b is still running strong, even after some stress testing hehe. still used for small projects :)

lusty quest
#

B3+

analog imp
#

ahhh

lusty quest
#

i have even a Server lying around lol.

#

could throw in a few HDDs and run something on it, but the issue is it got an AMD Turion N40l Processor

silver lintel
#

how can i create a special cooldown with djs? like im using a normal discord.js command handler with example command like

module.exports = {
  name: 'test',
  aliases: [],
  cooldown: 2,
  description: 'test cmd',
  type: 'hidden',
  execute: (message, args) => {
    //...
  }
}
``` but how do i like change the cooldown depending on whether there are args or not
lusty quest
#

i where also thinking about to get a Turing Pi board. this thing is interestening, you can plug 6 Compute Modules in and form a K8 Cluster with them

lusty quest
#

but it will be probably annoying

#

since you have to somehow let your command handler known that there are arguments

analog imp
#

hmmmm

#

true

#

could use humanize-duration if you don't want to modify the handler, but would probably get messy

#

did that a few times prior to redoing my handler

earnest phoenix
#

Oh right, any problem else?

shrewd creek
#

guys i put my bot status as the no of servers in which my bot is in but it shows 0 always

analog imp
#

i don't recommend going that route btw if you are going for lengthy cooldown times, just remembered. if your bot restarts at all it will remove the "cooldown" for everyone in the map

lusty quest
lusty quest
shrewd creek
lusty quest
#

py?

shrewd creek
#

yea

lusty quest
#

idk then

analog imp
#

even better lol

#

redis is good

#

if it's a few seconds though i'll just map it

bronze sapphire
#

litteraly what i do lmfao

#

typescript owo

earnest phoenix
#

say "owo" again and i'll put your head into a WC

bronze sapphire
#

uWu

#

😉

earnest phoenix
#

say "uwu" again and i'll put your head into a WC

bronze sapphire
#

pop

earnest phoenix
#

That's better than "uwu" or "owo"

bronze sapphire
#

w

bronze sapphire
earnest phoenix
analog imp
lusty quest
#

the Turing Pi is fine price wise, you pay 180€ for the Board and then 60€ for each module

#

if you go with the conventional stack you either get some cable salad while running 2 cables to each RPI or use the POE board and get a more expensive POE switch

earnest phoenix
analog imp
#

POE switch is the likely method i'd go

#

not a fan of cable salad

lusty quest
#

this here is probably the wrong place to look for this stuff

#

yea but in the end the Turing Pi board will be cheaper

#

since you have to get the POE Board for each RPI

analog imp
#

yep yep, just checked it out. been a while since i've looked at their products

lusty quest
#

exept you have already a few RPI lying around

analog imp
#

looks like they're limiting compute modules and out of stock for the turing pi

#

and ofc, there's a turing pi 2

#

not a bad price actually for it

lusty quest
#

py is one of the easyest to learn

earnest phoenix
#

Ya, this is probably the wrong place cause all people that talks here are making or already has a bot.

lusty quest
#

if you know py easy

earnest phoenix
lusty quest
#

py is ok but not the most efficent language

#

compared to js as example py is super slow

analog imp
#

imo if you wanna go with least efficient c# is the way to go

earnest phoenix
#

The most efficent language for making bots is js with the library discord.js

lusty quest
#

Rust is way more Efficent

analog imp
earnest phoenix
#

Programming always includes maths

#

Learn basic maths to make basic code

#

Probably not here

analog imp
#

not here, and not sure where you could hire someone

slim void
#

I have a bot.. but I'm having nothing but problems.

#

And I'm not enjoying coding rn

#

I enjoy the creation. But not making it.

earnest phoenix
#

Ik someone that accept contracts to make bots but he speaks spanish

analog imp
earnest phoenix
#

Teaching a machine how to do something

#

Creating beatiful systems

#

What the hell is musk

#

Oh

#

Nvm

#

Also, you don't need money to start creating your own bot

analog imp
#

not really sure what to tell you tbh, learning programming doesn't cost money

#

neither does implementing your ideas into it

earnest phoenix
#

My bot doesn't generate money and i don't want to generate money with my bot
Also, i didn't spend money on my bot.

#

Suggest ideas to someone to implement in an existent bot

analog imp
#

^^^

earnest phoenix
#

So all you want is credits

#

Uh

#

You are wrong.

analog imp
#

not really, i don't think contributing to a hobby/field/whatever that benefits everyone, whether you are credited or not is a waste of life

#

then all i can recommend is learning programming

#

if you want to create something that's yours

earnest phoenix
#

Bro

analog imp
#

bruh

earnest phoenix
#

Imagine this:
"I got a big idea that will innovate everybody and someone else that i hired makes real my idea" your credits arn't too important cause you didn't make real that idea.

analog imp
#

@slim void

slim void
#

Don't ping me pls, I'm busy.

analog imp
#

i recommend learning programming as a start to your endeavors. as simple as that, but i don't think you're in the right spot for hiring people, and calling programmers on the low end isn't nice. wish you luck!

slim void
#

Yeah I have my own bot.

#

Custom suggestions, logs, huge database, just don't wanna go farther lol.

lusty quest
analog imp
#

really? is the performance better in c#? interesting

#

time to do some research

lusty quest
#

yea? C# is pretty efficent

analog imp
#

hmmm, in regards to multi threading definitely

lusty quest
#

a compiled Language is usually always more efficent than non compiled

analog imp
#

if i had to put discord.js vs discord.net for bot development, i'd still go for js personally

lusty quest
#

if you want more efficent langauage look into Rust

analog imp
#

i'm a bit familiar, honestly i've been pretty curious about mercury though

#

in regards to machine learning even

#

got any thoughts on mercury?

cinder patio
#

never heard of it

lusty quest
#

never looked into it

#

but ive heard of it a while ago

analog imp
lusty quest
#

looks fine, but i think i stick with Learning Rust

analog imp
#

i've heard lots of good things with rust tbh

#

kinda like

lusty quest
#

its fast AF

analog imp
#

python collects garbage, rust collects 0

lusty quest
#

since it compiles to machine code, since its memory save you dont need to collect garbage

cinder patio
#

but Rust is also very restrictive and that's why i don't really like it.

analog imp
#

hmmmm

lusty quest
#

i just started learning it yesterday, im about 1/4 throu the docs, also thanks to knowing other programing languages its relatively easy to pickup

cinder patio
#

Did you get through lifetimes?

lusty quest
#

next chapter for me is Ownership

#

lifetimes is later i guess

cinder patio
#

cause that's when I just gave up

lusty quest
#

im already further with Rust than GO

analog imp
#

ayyy

#

google's very own go

lusty quest
#

well failed to Install a Enviroment for go. so i gave up

cinder patio
#

I prefer C++ over Rust and Go, but that's just me

lusty quest
#

Go is nice bcs of fast Compiling, but Rust on the other hand compiles to well optimized fast code

cinder patio
#

you can also make your own language if you aren't happy with any of the existing ones lol

#

It's actually pretty easy to create your own programming language, but it's really hard to make it good

bleak spire
#

finally its done

honest perch
#

@lusty quest how tf did you fail to install go

lusty quest
#

idk had issues getting the enviroment working

slender thistle
#
        for webhook in self._webhooks:
            if webhook == "dbl":
                func = self.dbl_vote_handler
            else:  # dsl
                func = self.dsl_vote_handler
            self.__app.router.add_post(self._webhooks[webhook]["path"], func)
``` there's definitely a better way to go about this but I'm really not sure what it is ![KEKW](https://cdn.discordapp.com/emojis/727825308404940800.webp?size=128 "KEKW")
worldly nebula
wheat jewel
#

for some reason

#

mongoose is rounding userids

#

does anyone know why

#

for me it rounded 248692731163967498 to 248692731163967500

lusty quest
#

did you store them as an Int?

wheat jewel
#

@lusty quest yes

lusty quest
#

dont do this

wheat jewel
#

how should i store

#

@lusty quest

cinder patio
#

store them as a string

lusty quest
#

store them as a String. most Discord libs should be able to parse the ID from a string

wheat jewel
#

okay thanks

#

when you do message.author.id it is a int right?

lusty quest
#

iirc its also a string

#

bcs it exceeds 32bit int iirc

true ravine
#

Storing any ids as an integer is a nightmare because you get all kinds of weirdness, so in my experience most use strings

wheat jewel
#

okay, thanks

true ravine
#

Yw

dawn yacht
#

Hello Im making warning system but I need to know what permissions should I make it require in order to warn someone?

lusty quest
#

there are 2 ways i guess. use Admin or manage Guild Permission or request that they set Roles that are allowed to do so

dawn yacht
#

In rules I shouldnt make it require Admin

lusty quest
#

not the Bot, the User

dawn yacht
#

Yes I mean for user

#

Like kick

lusty quest
#

the rules state for Bot

dawn yacht
#

You cant kick without kick permissions

#

I want to know what permissions should user need to warn

true ravine
#

There is no warning system built into discord - if you were to make your own it doesn't require any permissions from discord

dawn yacht
#

So regular people warn admins???

slender thistle
#

I used KICK_MEMBERS and BAN_MEMBERS for my warn commands

dawn yacht
#

Idk /:

true ravine
#

If you want to limit who can warn who, you need to do that in your code. Discord doesn't have a warnings system so none of it's permissions are relevant

#

And yes if you want the user to receive a kick or ban at a certain amount of warnings you will need kick and ban members permissions from discord, but the actual warnings do not

dawn yacht
#

I will just make it manage channels :v

#

It is okay?

slender thistle
#

Not the best option, but...

true ravine
#

On the github integration thingy for vscode, how do I commit some changes with one message and others with a different message?

lusty quest
#

i think you can select what files to commit

true ravine
#

I tried selecting them and then pressing commit but it just did all of them KEKW

lusty quest
#

hmm then use Github Desktop and do it there. works for me

true ravine
#

I'd rather be able to do everything from one program tbh

modest acorn
#

i just use sublime merge and text

#

works for me

true ravine
#

Oh wait I found out how

#

You stage them and then commit

#

Then it works

lusty quest
#

can you push them also to Origin with VSC?

true ravine
#

Idk I only push to one branch and then merge when I'm happy with it

#

I assume so though

lusty quest
#

probably over a cmd then.

stuck scaffold
#

What is the reason

#
Mongoose.connect("mongodb://localhost:port/db", {
    useUnifiedTopology: true,
    useNewUrlParser: true,
    useFindAndModify: false
});
true ravine
#

Your code looks fine to me, perhaps your mongodb server has some issues

stuck scaffold
#

hmm

#

how can i solve the issue

true ravine
#

I'm not sure as I used mongodb atlas where it is hosted and managed for me

zenith terrace
#

For warn

stuck scaffold
#

local mongodb

low spindle
#
  let activities = [
      `Utilize ${config.prefix}help para obter ajuda`,
      `${client.guilds.cache.size} servidores!`,
      `${client.channels.cache.size} canais!`,
      `${client.users.cache.size} usuários!`
    ],
    i = 0;
  setInterval( () => client.user.setActivity(`${activities[i++ % activities.length]}`, {
        type: "WATCHING"
      }), 1000 * 60); 
  client.user
      .setStatus("online")
      .catch(console.error);
console.log("Estou Online!")
});```
true ravine
low spindle
#

Code for status

rose warren
earnest phoenix
#

Why is this doing that..

#

Why is this doing that..

rose warren
earnest phoenix
#

Alr

#

@rose warren

rose warren
#

Try const deletecount = parseInt(args[0]) instead

earnest phoenix
#

Alr, but won’t it be like this

rose warren
#

Also, catch the errors.

message.channel.bulkDelete(deleteCount + 1).catch(error => message.reply(`Couldn't delete messages because of: ${error}`)); 
earnest phoenix
#

const deletecount = parseInt(args[0]);

#

Like that right?

rose warren
#

Yes. That's what I said 👀

earnest phoenix
#

You were missing a ; 😉

#

Or is it not in this code?

rose warren
#

You should do +1 on deletecount so it includes the command

earnest phoenix
#

Alr

rose warren
#

And you don't need the ; in node. Doesn't make any difference here.

earnest phoenix
#

Oh alr

#

message.channel.bulkDelete(deleteCount + 1).catch(error => message.reply(Couldn't delete messages because of: ${error}));

#

Which line should this be in? Sorry I forgot

rose warren
#

Replace the current line that does the bulkdelete with that

#

16

#

🙄

earnest phoenix
#

Alrighty

rose warren
earnest phoenix
#

Let’s try!

#

Lol

#

Uh the bot isn’t even responding anymore...

rose warren
#

Check console

earnest phoenix
rose warren
#

Oh you just need to add tick quotes

#
message.channel.bulkDelete(deleteCount + 1).catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
earnest phoenix
#

I was also thinking that

rose warren
#

My bad. Sorry. I'm on my phone.

earnest phoenix
#

All good

rose warren
#

No

zenith terrace
#

you did ' instead of ` lol

rose warren
#

Like I showed you

#

The last one is in the wrong place

zenith terrace
#

and that

rose warren
#

Please learn js syntax. There are lots of good free resources online

#

Copy/pasting tutorial code will only get you so far

zenith terrace
#

and not that far

earnest phoenix
#

@zenith terrace I tried " first didn’t work neither...

zenith terrace
#

you need to do ` .-.

earnest phoenix
#

Oh

#

Lol

rose warren
true ravine
#

At least you have the docs open

#

That's a very good start

#

#readthedocs

earnest phoenix
#

Lol

#

@rose warren ive also done that

zenith terrace
#

well did it work?

earnest phoenix
#

Nope...

rancid cairn
#

use python

earnest phoenix
#

Wait lemme try again last time

#

@zenith terrace yea not working

zenith terrace
#

no one cares about "use python" opinions, so let them code whichever language

earnest phoenix
#

Lol

zenith terrace
rancid cairn
earnest phoenix
#

Not really showing any errors

true ravine
#

If you get any errors they might contain a line number where something went wrong, if not use console.logs and see where they stop logging

earnest phoenix
#

Just on the response it’s saying there’s a bug..

true ravine
#

What about on repl?

earnest phoenix
#

Hm just says successfully loaded

true ravine
#

In that case try console logs

earnest phoenix
#

Lemme reload again

true ravine
#

Put them at various stages and see which actually log

earnest phoenix
#

Yes, now it logged it

rancid cairn
#

good job

true ravine
#

It's saying about line 107, have a look there

#

Try looking for parts of the error referencing your code, and then see what it's on about

earnest phoenix
#

Hm let’s see but I don’t think there are 107 lines

true ravine
#

It says it's in index.js

earnest phoenix
#

Ohh

true ravine
#

Top line in your ss

#

That might just be your command handler tho

earnest phoenix
true ravine
#

Ah it is

earnest phoenix
#

Не то, чтобы не рады

#

Lol

#

What’s the error?

sacred aurora
earnest phoenix
#

Yep

rancid cairn
earnest phoenix
sacred aurora
#

bruh

earnest phoenix
#

@true ravine so what ya see?

true ravine
#

Yeah scroll up a bit in your logs from where you took that screenshot

earnest phoenix
#

Me screen isn’t that big but ok

#

Lol

sacred aurora
#

now thats the problem

earnest phoenix
#

Delete count is not defined wtf

#

It is tho.. isn’t it?

sacred aurora
#

u define it with lower case c

zenith terrace
sacred aurora
#

'deletecount'

earnest phoenix
#

WTH IT CHANGES IT SELF I SWEAR IT DOES THIS ALL THE TIME BAD BOY REPL.IT >:C

sacred aurora
#

bruh

true ravine
#

If you can work out what the repl gods want then maybe you could write your variables names in that way so they don't change them

earnest phoenix
#

True

true ravine
#

Also most IDEs show if a variable is not used or defined by changing the colour a bit - does repl do that?

earnest phoenix
#

Uh why does it do this before it didn’t, it said there was an error before weird..

true ravine
#

The deleting it's own message thing?

earnest phoenix
#

No, like

#

I say

#

+purge 0

#

Then it says successfully deleted message

true ravine
#

Oh I see

sacred aurora
#

change the code again then

true ravine
#

I mean true

sacred aurora
#

if(deleteCount <= 0) return blasdsadald

earnest phoenix
#

LOL

true ravine
#

Look for the code where you tell it to delete messages, and see if something looks wrong

earnest phoenix
#

I’ll see what I can do

true ravine
#

In theory shouldn't it throw an error if you try to delete 0 messages?

#

Or will it just do nothing

#

Idk

sacred aurora
#

it'll just do nothing i guess

#

since there no error

earnest phoenix
#

Yea it dosent

true ravine
#

Perhaps you are adding 1 to your count then

sacred aurora
#

oh right

#

i think i saw deleteCount + 1 in your code

earnest phoenix
#

I hate this idiotic cool down like every time I remove it, it shows 504 error

true ravine
earnest phoenix
#

What the fuck is that WHAT THE FUCK IS THAT

true ravine
#

That's good

earnest phoenix
#

But why does it say

#

Purged messages...

true ravine
#

Purging messages is an async thing so unless you wait for it to finish it will say it was successful no matter what happens

#

For now though, just add an if statement to make sure deleteCount is greater than or equal to 1, and you'll be cookin

earnest phoenix
#

Ye you’re right

opal plank
#

here's a question, is it bad to do await Promise.catch() ?

try/catch is usually the syntax i follow , even for single lines, but i was recently thinking if its a bad idea to do await .catch()

Anybody knows?

true ravine
#

Is there any particular reason you want to do it that way?

opal plank
#

declarations, mostly

#
let thing;
try {
thing = await something
} catch(e) {console.log(e)};

///////

let thing = await something.catch(e => console.log(e));
#

the usual format i follow is the top one, im used to not chaining .then() or .ctahc() with await, though recently i've been pondering about that

#

apart from the obviously shorter code, im not sure if there are any implications when using await with a catch

true ravine
#

From my limited understanding, the promise.catch syntax and try{await promise}catch{oh no} syntax are two different methods of doing the same thing and don't really have any reason to mix if that makes any sense

earnest phoenix
#

Sa

opal plank
#

thats the thing with mixing that im a bit curious about, clearly , most docs i visited state either one or another, and most of the times favouring try/catch other than .catch/.then, though im part i assume most of this is to accomodate and push towards using async code

#

there are plenty of stuff like this out there

#

where the phrasing suggests using .then/.catch is not recommended

true ravine
#

Ngl this seems like a question for Tim, he'll have a big brain answer

opal plank
true ravine
#

Yeah like you say I've never seen them mixed

opal plank
#

im aware both works, but im unaware of why they shouldnt, or more precisely, why they arent recommended

#

@quartz kindle timmy turner

#

feud or evie might be able to answer those too

true ravine
#

True

willow mirage
#
[ [ 11, 2, 4 ], [ 4, 5, 6 ], [ 10, 8, -12 ] ]
#

how i can make this to one array ?

opal plank
#

destroy them

lusty quest
#

concat the arrays

#

or did i think on the wrong thing?

opal plank
#

[...arr] should work

willow mirage
#
arr1.concat(arr2);
arr1.concat(arr3);
#

?

opal plank
#

not quite

#

concat returns an array

willow mirage
#

ye?

opal plank
#

concat doesnt manipulate the original array

willow mirage
opal plank
#

thats the descontruction operator

willow mirage
#

but it is still in array

#
[ 11, 2, 4 ] [ 4, 5, 6 ] [ 10, 8, -12 ]
slender thistle
#

declare new arr
for i from 0 to arr length
for j from 0 to arr[i] length
do new arr push(arr[i][j])

willow mirage
#

bruh

#

nah nah

opal plank
#

this

willow mirage
#

damm

opal plank
#

i wonder if i can make it shorter