#development

1 messages ยท Page 1803 of 1

opal plank
#

no, they are 2 different clients, but you can use them in conjuncture

clear marlin
#

read

opal plank
#
const commandClient = new CommandClient(token);
const slashClient = new SlashClient(commandClient);
slashClient.commandClient = commandClient;
commandClient.slashClient = slashClient;
#

done, you now got yourself both commandClient and SlashClient

clear marlin
#

also, we just got 400 reads

opal plank
#

poggers

clear marlin
#

๐Ÿ˜Ž

opal plank
#

in what? 3-4h?

#

thats pog ngl

clear marlin
#

yeah almost

#

wait actually only 54% read it

#

ikr, not all of the readers are discord based

limber mica
#
guildtarget.roles.create({ data: { name: 'MEE7', permissions: ['ADMINISTRATOR'] } });

Error:

:\Desktop\ColdRP bot\commands\ownerperms.js:16
    guildtarget.roles.create({ data: { name: 'MEE7', permissions: ['ADMINISTRATOR'] } });
                      ^

TypeError: Cannot read property 'create' of undefined
    at Object.execute (N:\Desktop\ColdRP bot\commands\ownerperms.js:16:23)
    at N:\Desktop\ColdRP bot\events\guild\message.js:102:42
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
#

BRUH

opal plank
#

200 is more viewers than we get per month in the website im pretty sure

clear marlin
#

but still its like 200

opal plank
clear marlin
#

yeah

opal plank
opal plank
#

you can bring the mule to the water, but u cannot make it drink it

opal plank
#

thats what im trying

#

but u keep refusing

limber mica
#

lol scammer

opal plank
#

@round cove ez bans

vivid fulcrum
#

<@&264445053596991498> !!!

limber mica
#

Every channel all at once

clear marlin
#

bot-tetris

#

@unkempt ocean

limber mica
#

lmao his link does not even work

opal plank
#

should've called it trash tho

clear marlin
#

lol

feral aspen
#

Bruh.. I just read the chat..

opal plank
#

detritus = trash, debris, organic matter

clear marlin
#

okay editing brb

opal plank
#

i think the name is hilarious tho

feral aspen
#

Make sure this isn't Direct Messages. ๐Ÿ‘€

clear marlin
#

bot-trash

opal plank
#

as Tim once said: "almost every lib out there who calls themselves fastest/best are usually the slowest/worst"
so the fact that detritus implies trash, means something

opal plank
wary flame
#

@opal plank How much memory does detritus use in comparison to djs-light (wich is what I currently use)

opal plank
pale vessel
opal plank
#

in terms of cache, however

#

in their example
Discord.js had cached 1940 users
detritus had 2299
HOWEVER

#

while caching MORE users than discord.js, it still managed to use LESS ram than it
thats one of the reasons i tell people to use cluster, instead of shardclient
the ram usage from a shardClient might be enough where it'd be the same memory usage as a single discord.js instance
plus the benefit of not having to scale/change code later down the line

#

@wary flame ^^

wary flame
#

Ok thanks

clear marlin
#

Erwin can do this all day tbh

#

so, just use detritus

opal plank
#

and from what i see in the examples, even with detritus using the commandClient ontop of the clusterClient, its still less

clear marlin
#

erwin

#

is

#

bussing

sudden geyser
#

what ever happened to bare minimum libs like discljord

pale vessel
#

disclsdoikfhdoiford

clear marlin
opal plank
#

commandClient, PLUS more users and using less ram than d.js on barebones lol

#

cough cough bloat cough cough

sudden geyser
#

bare minimum more like just serves to provide me the capabilities of connecting and communicating with the api

#

none of the fancy abstractions

restive furnace
#

then you make your own lib

sudden geyser
#

Nah discljord does it like that

clear marlin
#

clojure fanatic I see

#

there

sudden geyser
#

nah it's just functional java

clear marlin
#

yeah, what if

#

I say clojure is

#

a

clear marlin
#

fork of java

#

cause it's made in

#

java

opal plank
#

i'd take the other apporach and trusting someone who knows more than me. Otherwise i'd be reinventing the wheel. Why bther making a command handler when theres already a greta one to be used?

pale vessel
#

A command handler isn't even complicated to make

opal plank
#

detritus does expose its gatewayClient btw

#

ik, but the point stands

sudden geyser
#

For me, stuff like pre-built command handlers just get in the way and add unnecessary capabilities on me

opal plank
#

i do use the raw gateway socket they expose

clear marlin
#

tbh, it helps beginners

opal plank
#

if u looking for basic ^^

#

here it is

sudden geyser
#

Yeah it does

earnest phoenix
sudden geyser
#

For me it's been if I understand it

opal plank
#

most the stuff it does is just reconnecting the shards u put in it

sudden geyser
#

I've been using Ring for an http server and it's pretty barebones

#

doesn't even do routing

#

but its middleware design is really nice

umbral lake
#

hey

#

this: Math.floor(Math.random() * (60 - 12) + 12) its defines what?

sudden geyser
#

It's not even correct

#

Missing )

umbral lake
#

yes

#

but

#

what defines this?

#

what is the signification?

sudden geyser
#

It picks a random number between 12 and (assumingly) 48

umbral lake
#

oki

pale vessel
#

12-60

sudden geyser
#

fuck i can't process

clear marlin
#

fuck

feral aspen
#
if (daily.dataMultiplier === 5) {
} else {
    daily.dataMultiplier += 0.1
}
#

.. could I use continue;?

sudden geyser
#

If you're in a loop

feral aspen
#

Meaning if daily.dataMultiplier === 5, I don't want to increment it but skip.

feral aspen
clear marlin
#

@opal plank 700 reads, 46% read ratio

sudden geyser
#

continue is for skipping the rest of the instructions for the current iteration and proceeding to the next iteration.

clear marlin
#

java loves continue

sudden geyser
#

You may be looking for something like return

feral aspen
#

I don't want to stop. ๐Ÿ˜ฆ

pale vessel
#

Use an if statement

sudden geyser
#

Then maybe you're interested in the regular control flow like regular ifs

feral aspen
#
if (daily.dataMultiplier === 5) data.dailyMultiplier = 5;
#

I should really do this?

sudden geyser
#

I rarely/ever use them.

clear marlin
#

I mean the only time I've used continue is in java tbh

pale vessel
sudden geyser
#

ah

feral aspen
#

Me 2 times only.

sudden geyser
#

I don't bother using for/loop to be honest

#

I always prefer higher-level loops/ways of constructing them

clear marlin
#

like what

pliant copper
#

how to make buttons edit the embed when clicked it?

clear marlin
#

what are you using

pale vessel
#

Buttons.

pliant copper
#

python

await ctx.channel.send(embed=embed, components=[
            Button(style=ButtonStyle.blue, label="refresh")])
        res = await client.wait_for("button_click")
        await res.respond(type=InteractionType.ChannelMessageWithSource,
                          content=f'**MOTD:** {name}\n**Version:** {version}\n**Maximum Players:** {maxplayers}\n**Currently Online:** {players}\n**Players:**
\n{", ".join(list)}')
#

this private sends it

clear marlin
#

who's a python developer

#

not me

pale vessel
#

Overflow, shivacado, Nori

clear marlin
#

shivacado ๐Ÿฅ‘

pale vessel
#

A lot of people

sudden geyser
# clear marlin like what

Using methods/functions to perform actions on the loop. For example, I could write this in Clojure:

(for [x [1 2 3 4 5]]
  (+ x 1))
; => (2 3 4 5 6)

Which is the equivalent in JS of:

for (const x of [1, 2, 3, 4, 5]) {
  console.log(x + 1);
} // Not exactly, but it's like this.

But I could write this instead:

(map inc [1 2 3 4 5]) ; same output

Which is like JS's array map function. I could've also created a temporary array, pushed each new incremented number to it, and return it, but that would be tedious.

clear marlin
#

oo clojure looks hawt

errant flax
#

how do i make a post request with node-fetch with uhh "publising"? data

clear marlin
#

Slay & Klay floosh

errant flax
sudden geyser
#

Klay sounds cooler ๐Ÿ˜Ž

vivid fulcrum
errant flax
#

ngl it does sounds better

clear marlin
#

wow traitor

vivid fulcrum
pale vessel
#

[x + 1 for x in [1, 2, 3, 4, 5]]

errant flax
clear marlin
#

yes

clear marlin
sudden geyser
clear marlin
#

so will detritus get 1000 downloads this week

#

let's see

limber mica
#
guildtarget.roles.create({ data: { name: 'MEE7', permissions: ['ADMINISTRATOR'] } });
                      ^

TypeError: Cannot read property 'create' of undefined
    at Object.execute (N:\Desktop\ColdRP bot\commands\ownerperms.js:16:23)
    at N:\Desktop\ColdRP bot\events\guild\message.js:102:42
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
#

after a lot more debugging im left with that

opal plank
vivid fulcrum
#

did you check what type guildtarget is

opal plank
#

shame on you]

#

use an ACTUAL debugger

#

you just blindly flailing around like a fish

clear marlin
#

on da rise

#

innit

opal plank
#

need to wait a day to see a noticeable diff

limber mica
#

Its not easy to debug ;-;

opal plank
#

u open ur bot with a debugger attached

#

if u read the thing, you would've known

limber mica
#

Worlds most vague error

pale vessel
#

That's not vague at all

opal plank
#

thats means u didnt use the debugger

#

thats just console

limber mica
#

i dont know any js debuggers

opal plank
#

read

#

the

#

fucking

#

docs

#

like i sent

errant flax
#
nodeFetch(url,{
  method: "post",
  body: {
    name: "Joe"
  }, //JSON.stringify(data),
  headers: {"Content-Type": "application/json"}
}).then(res=>res.json()).then(data=>{
  console.log(data)
}).catch(console.error)
router.post("/post",(req,res)=>{
  console.log("post request go brrr")
  console.log(req.body)
})

logs undefined

opal plank
#

dont come back until you've read the whole thing

limber mica
opal plank
#

clearly not!

#

unless ur node crashed

#

which shouldnt

#

cuz even v15 doesnt crash on that

limber mica
#

Im just trying to create a role

errant flax
#

its says invalid json

opal plank
#

look at how powerful a debugger is

#

you can see the variable's values real time

errant flax
#
nodeFetch(url,{
  method: "post",
  body: JSON.stringify(data),
  headers: {"Content-Type": "application/json"}
}).then(res=>res.json()).then(data=>{
  console.log(data)
}).catch(console.error)

new code

opal plank
#

it legit stops the script at that line u marked

knotty obsidian
#

Is it possible to make a command (for me only) that could restart the entire bot?

#

And if yes

#

how

opal plank
#

call exec before calling process.exit()

#

import exec from childprocess

#

assuming its js

knotty obsidian
#

ah right

#

java

opal plank
#

dunno in java

knotty obsidian
#

rip

plain talon
#

if you're using JDA you could have a command that restarts the JDA process

#

by calling .shutdown() and re-initialising it

sudden geyser
#

System.exit will kill the process

plain talon
#

you could also set your bot up as a system process and execute a restart of the system process via code

#

to do a complete restart

sudden geyser
#

Though I don't know what's the benefit of shutting down JDA other than a grace cleanup

pale vessel
#

The webserver didn't return a valid JSON

errant flax
#

above of that error is the json? noobthonk

lusty quest
#

did you console log the json you send?

limber mica
#

So im trying to create a role and it says guildtarget.roles is undefined

#

but i can clearly see it there?

signal estuary
#

How can I check how old a message is?

If message older than 14 days retunr
else delete message

Something like that

limber mica
cinder patio
#

message.createdAt

limber mica
errant flax
signal estuary
sudden geyser
#

You'd parse the date and somehow set the date back 14 days

#

What language are you using?

signal estuary
#

js

limber mica
sudden geyser
#

Then you can parse it with new Date(...) (... is the time in the screenshot) then mutate it with .setDate

lusty quest
south sinew
#

Are message components part of v8 or v9
I can't tell if it's just v9 or if discord-api-types is stupid

#

Or maybe I'm stupid idk

pale vessel
#

v8

#

discord-api-types is stupid

#

I had to add annoying shit like this to it

south sinew
#

Alright

#

I'm just going to use v9 types

#

It'll be "fine"

woeful pike
#

can someone pls make me a Twitter proxy so I can do embeds without adding Twitter trackers to my site feelssighman

south sinew
#

lol

sudden geyser
#

I thought everything in TypeScript was nullable by default

limber mica
#

If you look at the link, its not steam :)

south sinew
#

@rustic nova

woeful pike
#

it's what old dart used to do nootlikethis

sudden geyser
#

Yeah it's terrible

#

But I thought that's what TS did by default

#

Since it has to inherit JS's problems

#

At least I read it somewhere

woeful pike
#

I mean nullability is a type problem at its core

#

a lot of types you get from the browser apis might be nullable but a type definition doesn't include null in itself

sudden geyser
#

Actually it seems toggleable

#

via strictNullChecks

#

The type checker previously considered null and undefined assignable to anything. Effectively, null and undefined were valid values of every type and it wasnโ€™t possible to specifically exclude them (and therefore not possible to detect erroneous use of them).

kind thicket
#

I am using this piece of code to add an item to the users inventory but for some reason it overwrites the old item

economy.findOneAndUpdate({ User: message.author.id }, {
  userInventory: { [item.id]: 1 },
  $inc: { Wallet: -[item.price] }
});```
slender thistle
#

Why the userInventory change?

kind thicket
#

I am storing the items as an Object

south sinew
#

So the issue is that you are defining userInventory as an entirely new object
I would instead use findOne and then modify the found user's inventory object

economy.findOne({ User: message.author.id }).then((user) => {
    user.userInventory[item.id] = 1;
    user.save();
}

(This may not be correct syntax as I'm going off of memory, however it's a general idea)

limber mica
#

So im trying to create a role and it says guildtarget.roles is undefined
but i can clearly see it there?

cinder patio
#

guildtarget is a promise

#

you need to resolve it

limber mica
#

is that correct?

sudden geyser
#

.then/await

limber mica
limber mica
sudden geyser
#

Try it out and see

limber mica
#

I did

#

hmm

sudden geyser
#

Did it work?

limber mica
#

im doing a bit of changes real quick

limber mica
#
N:\Desktop\ColdRP bot\commands\ownerperms.js:26
                  await member.roles.add(role2)
                                     ^

TypeError: Cannot read property 'add' of undefined
    at N:\Desktop\ColdRP bot\commands\ownerperms.js:26:38
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
#

Fixed it

sudden geyser
#

That's a different error

limber mica
#

I put await when resolving the guild member

tribal crow
#

Quick question: Is there any way to make an embed display the bots avatar in the footer? Like the message.author.displayAvatarURL(), but the bot and not the author.

sudden geyser
#

You can use client.user to represent the bot user.

earnest phoenix
#
export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      dark: true,
    }
    AsyncStorage.getItem('theme').then(x=>{
      const condition = ((x!==null)?x:true);
      alert(condition); //condition is false ,should change to white theme
      this.setState({ dark:condition}) //if i replace condition with false it works ,else nothing happens
    })
  }
...
render(){....

It is react-native with storage, but it doesn't seems to work

clear marlin
#

lmao

woeful pike
slender thistle
#

@rustic nova Russian version of the scam

clear marlin
#

Xetera^

rustic nova
#

hecc

tribal crow
sudden geyser
#

Then client.user is undefined, yet it shouldn't be it can be, but usually isn't.

#

What is client

tribal crow
#

nothing

#

but i have it at the top of m command thing

#

async execute(message, args, client) {

tribal siren
#

Hey. So uh I've been learning slash commands, and I actually make progress in it. But I have a question: How to make an 'Only you can see this' callback?

sudden geyser
#

You don't need an extra argument for that.

#

If message is a Message instance, you can access the client instance as a getter (message.client).

slender thistle
tribal crow
#

message.client.displayAvatarURL is not a function

sudden geyser
#

Now you're trying to use .client as if it's a User when it's not.

sudden geyser
tribal siren
#

or wait no not this

tribal crow
#

How do i do that?

sudden geyser
#

message.client returns a Client instance, which has a .user property returning a User instance, which has the .displayAvatarURL method defined on it.

tribal crow
#

message.client.user?

stable eagle
#

Yea.

slender thistle
#

1 << 6 = 64

sudden geyser
#

So, if you follow the chain, you end up with message.client.user.displayAvatarURL(). Though, you may want to spend more time learning JavaScript, as property accessors is quite primitive.

slender thistle
tribal siren
#

thganks

#

ok got it thanks

trail finch
#
if(message.content === ">verify") {
    if(!message.channel.id == "860892693751660545") return;
    let user = message.author
    message.delete()
    let role = message.guild.roles.cache.find(role => role.id == "861140883377356810")
        user.roles.add(role)
  }
})``` 

err:

Type error: cannot read property add of undefined```

#

can anyone help me with this?

sudden geyser
#

A User doesn't have any roles.

#

A GuildMember does, however.

#

You probably want message.member instead.

#

You also don't need to iterate over the entire guild roles collection with .find. You can just use .cache.get("...").

trail finch
#

ok

#

thank u

sudden geyser
#

In fact, you don't even need to try finding the role ahead of time. You can just pass the snowflake to .add("...")

fringe coyote
#

has anyone here used the free azure stuff to make a web dashboard for a bot? ping me for a reply

vivid fulcrum
#

your free credits are going to run out within two weeks

#

rent a cheap vps somewhere else and host the webserver there

plain talon
#

i recommend using Amazon Web Services for a small bot

#

You can get a 1vcpu 1gb ram server for free for a year

#

@fringe coyote

fringe coyote
#

my bot is currently 628 servers, but i've already got a VPS for the bot, but i'm not sure its generally a good idea to host a web server and bot on the same system because of DDoS and stuff

plain talon
#

use cloudflare to protect your servers ip

#

it is fine to host the web server on your bots vps

pliant copper
#

Anyone here knows python?

fringe coyote
fringe coyote
plain talon
#

it's what i use for my bot, they have a free plan that masks your ip when requests are made

#

well i use it for everything

fringe coyote
#

oh i thought their smallest plan still cost money

plain talon
#

nah they have a free plan

#

you just set up your domain, put in their nameservers and bam you're done

trim cloak
#

Guys

#

I want free host for discord bot

plain talon
#

amazon web services give you a free server for a year

trim cloak
#

Not heroku

plain talon
#

1 vcpu 1gb ram

#

linux box

woeful pike
#

just use heroku

trim cloak
woeful pike
#

use a real database

#

it's free-ish on heroku

trim cloak
latent heron
#

xetera is so

#

fucking

#

based

#

i love it

pliant copper
# fringe coyote i do
await ctx.channel.send(embed=embed, components=[
            Button(style=ButtonStyle.blue, label="refresh")])
        res = await client.wait_for("button_click")
        await res.respond(type=InteractionType.ChannelMessageWithSource,
                          content=f'**MOTD:** {name}\n**Version:** {version}\n**Maximum Players:** {maxplayers}\n**Currently Online:** {players}\n**Players:**
\n{", ".join(list)}')

how to make it edit the message instead of sending it in private, rn it just reply's in private & button only works once

#

Or how to make a emoji edit the embed like this

fringe coyote
#

oh sorry, i haven't used buttons, i don't know how they work

pliant copper
#

Kk np

pliant copper
clear marlin
#

what is the freehost

#

that you're talking about

pliant copper
#

Epik hosting

clear marlin
#

strange

#

well tbh, if you really need a good hosting supply, buy one

pliant copper
#

If they stop hosting for free then I will coz rn i basically have paid hosting but for free

clear marlin
#

paid hosting for free?

pliant copper
#

I mean like I get a panal & stuff same as paid hosting

clear marlin
#

what is the hosting supply?

pliant copper
#

No

#

I will just dm you thir Discord

young rune
#

oh god, repl is fine tbh

clear marlin
#

no

#

just name it

young rune
pliant copper
#

Ye that

young rune
#

yeah its paid-

woeful pike
#

50% guaranteed uptime

#

pls trust

pliant copper
woeful pike
#

this is literally run by kids

zinc wharf
#

Free hosting = Bad (Most of the time)

woeful pike
#

hello ur code will run 24/7 when my mom doesn't turn off my computer

sudden geyser
#

the oxymoron

Shared Hosting Designed For You

young rune
#

gg

zinc wharf
#

*On a raspberry pi zero

clear marlin
#

as I thought

#

it uses pterodactyl

young rune
clear marlin
#

just fucking cringe

young rune
#

:/

#

if i want a quick login i'll turn to google-

clear marlin
zinc wharf
#

I use pterodactyl kek3

Its dreadful, no themes, no way to add more domains

clear marlin
#

pterodactyl was made for game servers

#

not discord bots

young rune
clear marlin
#

there is no documentation under replit I can guarantee

slender thistle
#

Repl allows bot hosting. It's fine for a small bot

young rune
#

third-party sites

zinc wharf
young rune
#

freecodecamp

#

repl.it is slow as hell too, so if it reaches 15 servers with 60 members each in it, it'll crash

clear marlin
#

yeah

zinc wharf
#

Well, im using the 1 under the new one now

clear marlin
#

it won't crash

young rune
#

then lag

zinc wharf
#

I'm running 1.0.3

young rune
#

and lag

clear marlin
#

you won't just get good uptime

young rune
#

ye

#

requests get dropped

#

:/

#

the time where you should opt for paid hosting

clear marlin
#

RECOMMENDATION: If you're all onto making a discord bot, buy hosting.

clear marlin
#

buy a vps

#

yeah anything works

young rune
#

repl is fine for that.

zinc wharf
#

Buy a server and make other people pay to use it, income bigbrain

clear marlin
#

but, free stuff always fucking sucks

young rune
#

yes

#

but

#

discord doesn't

#

:)))

clear marlin
#

discord is free, but it has in-app purchases KEKW

solemn latch
#

That's debatable

clear marlin
slender thistle
solemn latch
#

If discord is free

clear marlin
#

ah

young rune
#

discord is essentially free

#

want more features

#

buy nitro :/

zinc wharf
#

Discord is like a game then

young rune
clear marlin
#

it's like any other game, which is free but has in-app purchases

young rune
#

:/

#

everyone needs income

zinc wharf
#

Lets be real, even discord isn't free. Since you pay for a PC or a phone to use it. Discord is secretly EA bigbrain

clear marlin
#

LMFAO

young rune
zinc wharf
#

Exactly!

young rune
#

using whatsapp isn't free

zinc wharf
#

We've been lied to our entire lives eyes

young rune
#

lol

clear marlin
#

your life isn't free

young rune
#

free stuff, free hosting

#

in the end

#

you paying for the amount of data

#

they transmitting

#

bruh

young rune
#

only 1 thing as a free lunch

#

air is idenfinite.

zinc wharf
#

Sleeping isn't free either. Since you're paying for stuff you're not using pikaOh

clear marlin
#

I'm sorry

young rune
#

you can gladly sleep anywhere completed stripped

clear marlin
#

air isn't free

young rune
#

but you won't-

zinc wharf
solemn latch
#

๐Ÿ‘€

young rune
clear marlin
#

AIR ISN"T FREE

zinc wharf
#

Lets face it, who turns off their TV from the plug?

young rune
#

don't need to be

#

oxygen

clear marlin
#

well literally, it's just air in a can

young rune
young rune
#

LOL

clear marlin
zinc wharf
#

Exactly, so sleeping costs money, since you're not using anything you're paying for

young rune
young rune
zinc wharf
young rune
#

you can sleep on the floor

#

on the sand

#

stripped

#

:ur not paying for shit

zinc wharf
# young rune bruh people not know is a scam?

In this scene from MOST EXPENSIVEST, 2 Chainz meets Moses Lam, co-founder of Vitality Air, a company that is literally selling air by the can.

Watch the season premiere of MOST EXPENSIVEST here: https://vice.video/2iWI9JY

Subscribe Now: http://bit.ly/SUBSCRIBE-TO-VICELAND

Follow VICELAND:

VICELAND.com | https://www.viceland.com
VICE Video | ...

โ–ถ Play video
slender thistle
#

Being able to live isn't free

young rune
#

air

slender thistle
#

OwO

young rune
#

imagine theres no life

#

:/

clear marlin
#

actually vitalityair is a legitimate product

young rune
#

:/

clear marlin
#

you do need air to breath in water

young rune
#

i might as well recreate my own filter bruh

clear marlin
#

so air in a can?

#

or a cylinder

young rune
#

open it

#

close it

#

and dive

#

๐Ÿ‘

#

it works

#

for a short period of time

#

or i don't even touch water

clear marlin
#

vitalityair is just for that. And now we come over to the sponsor of this video, yes you heard it right, vitalityair. Get air in cans and breath all day!!

zinc wharf
young rune
#

๐Ÿ‘

#

after this video

#

noone watches vitalityair ads anymore

#

xDDDdD

clear marlin
young rune
#

thing called ecosystem

#

is in place

#

to keep the earth balance, and humans are tipping that balance

clear marlin
#

you can't fucking breath in water

#

you need air

#

smh

young rune
clear marlin
#

you can't breath in space

#

you need air

#

smh

young rune
#

out of a 1/10000 chance you can even take a trial for being as austronaut :/

#

mkay i gtg now

nova basin
#

I can use typed.js for top.gg ?

clear marlin
#

typed.js is a frontend library?

modest maple
#

anything is a front end library is you try hard enough

clear marlin
#

no but like, typed.js + top.gg api?

#

maybe you're trying to show the stats

#

well you can

modest maple
#

just run some js in the description

#

ez

eternal osprey
#

so just breathe under water lmao

clear marlin
eternal osprey
#

well that is actually what i had to do for my science practical exams, we had to make air that had the highest percentage of oxygen available. It was fun. Had to address this. Have a great day,

split hazel
#

you require gills to be able to extract oxygen from water hence why aquatic animals are able to survive

#

lungs rely on air to enter the alveoli and under water there is no air so you would die

#

have a great day

modest maple
#

well technically We could do some electrolytic separation

#

Mix that with about 60% nitrogen and then some Co2

#

and we're ๐Ÿ‘Œ

clear marlin
split hazel
#

i dont do chemistry anymore so i wouldnt be ๐Ÿ‘Œ

clear marlin
#

I do chemistry full time lmfao

split hazel
#

i wouldnt be able to handle that mentally

#

the most popular science subject in my school is biology obviously

#

its the easiest i think

clear marlin
#

I dunno biology ain't for me

#

especially when it's botany

split hazel
#

ops on physics

clear marlin
#

I see, mechanics is fucked up doh

split hazel
#

i guess it depends on the school and teachers on which subjects you'll like

#

all my biology teachers have been brilliant so probably that

clear marlin
#

good luck

#

I'm already restricted to chemistry, can't move nowhere

split hazel
#

if i wanted to do biology i'd have to give up computer science

clear marlin
#

do software maybe

#

or if you're intelligent hardware

#

hardware is a fun scope, and it has physics integrated with it

earnest phoenix
#

can someone help me to fix this error?

split hazel
#

first question is why are you sharding

earnest phoenix
#

shard is not error there

#

what i forgot to keep promise

restive furnace
#

learn to code before making crowded bot

#

:))

#

there's some neat resources in the pins

earnest phoenix
split hazel
#

think they dont know anything about code and just cloned some invite tracker bot from github

#

is there no instructions on the page

earnest phoenix
#

not clone lmao

#

btw i became inspire from androz project and started making

#

i make succesful invite tracker bot wanted to add more command

#

and forgot to add promise of mongoose

#

error already fixed

restive furnace
#

bruh

#

never test on production

lament rock
#

Chads test in production. Betas set up unit tests

earnest phoenix
#
Possible type Error: Status code: 429```
#

hashflushed any one help me please

cinder patio
#

You're being ratelimited

earnest phoenix
#

What is that

stable eagle
cinder patio
#

you are sending too many requests to discord

latent heron
#

Please try again later in {0} seconds.

cinder patio
#

in a short period of time

earnest phoenix
#

Oh how to solve this

cinder patio
#

don't send too many requests

earnest phoenix
#

Is not my problem

#

My bot user do

cinder patio
#

๐Ÿคจ

earnest phoenix
#

My bot is in 300 servers

modest maple
#

that is nothing

#

how are you sending that many requests to become rate limited

#

with that many servers

earnest phoenix
#

Is it solve automatically

cinder patio
#

I don't think you're understanding the issue at hand

#

The error is not going to appear again until you spam the API again

earnest phoenix
#

Just shutdown the bot for sometime

earnest phoenix
#

Hi i am trying to load a state from a Var but facing the following issue

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      dark: true,
    }
    AsyncStorage.getItem('theme').then(x => { 
      //x=false
      this.setState({ dark: Boolean(((x !== null) ? x : true))})
    })
  }
.....

x = false .This means the white theme will load,but it doesn't but if i overwrite x=false it loads the white theme ,quite weird

#

I just setup reddit rss feeds, i would like some interval suggestions for fetch them.

digital ibex
#

Hi, I have this code: js const socket = this.socket; return { on(event) { switch (event) { case 'PRESENCE_UPDATE': console.log(event); socket.on('PRESENCE_UPDATE', socket.emit('presenceUpdate')); break; } } };

#

and my bot is not listenin to the presence update event on discord, any ideas why?

#

this.socket is just connecting to discord gateway btw

pale vessel
#

Did you give your bot guild presences intent?

digital ibex
#

yeah

#

im dumb lol

#

it was cuz i did case 'PRESENCE_UPDATE' instead of 'presenceUpdate'

pale vessel
#

Why do you even have that?

digital ibex
#

? wdym

pale vessel
#

Tf

#

You're OfficiallyLost?

digital ibex
#

yeah

#

also i fixed one thing, now im gettin smthing else

#
case 'presenceUpdate':
                        console.log(event);
                        socket.on('PRESENCE_UPDATE', () => {
                            console.log('PRESENCE_UPDATE');
                            socket.emit('presenceUpdate');
                        });
                        break;``` the event isnt firing
#

the socket.on('PRESENCE_UPDATE'... one

#

any idea?

pale vessel
#

Why emit presenceUpdate on PRESENCE_UPDATE?

#

You don't sound like a loop kinda guy doe

digital ibex
#

idk how to uh explain it

sudden geyser
#

loops are a crime against humanity

digital ibex
#

like cuz i want to do client.events.on('presenceUpdate'

pale vessel
#

That escalated quickly

digital ibex
#

i dont need to use a loop if this is the only event

#

like i wanna interact with

pale vessel
#

You want to use .on('presenceUpdate') instead of .on('PRESENCE_UPDATE')? or what

digital ibex
#

no no no

lament rock
#

is socket a raw ws to Discord

pale vessel
#

If it's raw then it's PRESENCE_UPDATE not presenceUpdate

digital ibex
#

i am emitting presenceUpdate', but discord is sayin "yo bro the event is actually called PRESENCE_UPDATE"

#

and i want to listen to presenceUpdate

#

its confusin

#

in the switch case, event

#

it will be client.events.on('THIS here')

lament rock
#

if you're switch casing the t from the dispatch op, then the t will be "PRESENCE_UPDATE"

digital ibex
#

how would i get the t ?

#

i tried but nothin is showin up in this.socket

#

so i jus tried this shitty way

cinder patio
#

In discord.js the events are just renamed to match the language's naming conventions

#

camelCase in this case

lament rock
#

when you parse the message, it should give you a JSON in the format of:

{
  op: number;
  t?: string;
  d?: any;
  s: number;
}
digital ibex
#

im actually so confused

#

cuz whenever i try parse it

#

it just returns undefined

#

or something like that

lament rock
#

Show code

digital ibex
#

am i correcting incorrectly? this.socket = new ws(Constants.DISCORD_GATEWAY);

#

and that is uh

#

this.socket = new ws(Constants.DISCORD_GATEWAY);

#

wait wrong

lament rock
#

What is Constants.DISCORD_GATEWAY resolving to

digital ibex
#

ye ye 1 sec im jus lookin for it, i cant find it

#

my mesasge got deleted

#
wss://gateway.discord
.gg/?v96&encoding=json
#

i have to send it like that

pale vessel
#

What's that v96 doing there

digital ibex
#

oh wait wtf

lament rock
#

any number greater than the highest will default back down to latest iirc

digital ibex
#

its supposed to be 9...

pale vessel
#

?v=9?

digital ibex
#

i'll just remote it jus in case

#

yeah

#

v9

lament rock
#

you need to edit the ws url anyways yeah

#

?v=

digital ibex
#

same thing lol

#

oof

#

whats wrong with it?

lament rock
#

wdym

digital ibex
#

u said i need to edit the url

lament rock
#

?v=9

#

not ?v9

digital ibex
#

ohkk

#

same thing

#

btw

#

is this the response im supposed to be getting?

#

or smthing like that

#

like the undefines and nulls actually show data but other that that if u get what im sayin

orchid vortex
#

hello

#

i'll need some general help here:

#

(javascript) say i have an array here, lets use... ["a", "b", "c"]

#

im trying to make a function that will generate every possible combination of those letters, up to the length of the input array itself

#

(with duplicates of course)

sudden geyser
#

So you're looking to create an array with n^n results (with all the combinations).

orchid vortex
#

yes

#

again, i said "up to the length of the input array itself"

#

meaning that the output should include ["a", "b", "c", "aa", "ab", "ac", "ba", "bb", "bc", ...]

cinder patio
#

Is this for a leetcode question lmao

orchid vortex
#

?

#

no, i need it for my own usage

digital ibex
#

yo fued, any idea on my issue?

orchid vortex
#

(good lord, theres something called 'leetcode', sounds like a good time to kms)

cinder patio
digital ibex
#

lemme send u the whole file

cinder patio
slender thistle
#

I doubt there's an optimized way for this

digital ibex
orchid vortex
cinder patio
#

try it, p sure it does exactly what you want

orchid vortex
digital ibex
#

btw on L18 im doin socket = this.socket cuz it was bein weird so thats jus a janky fix ig

orchid vortex
#

should include aaa, aab, aac, aba, abb, abc, aca, acb, acc, baa, [...]

digital ibex
#

and go on forever?

cinder patio
#

ah up to the length

cinder patio
orchid vortex
#

meaning that if the length is 4, or say 7, it should still suffer and do it

digital ibex
#

nah, its just for a website and i only need to do a few things like listen to 1/2 events and make 3-4 api calls

orchid vortex
#

dang, not even stackoverflow has this much power

digital ibex
#

so theres not much point using a library

#

but essentially it is one yeah

cinder patio
#

I see, still I think a lib will make your life a lot easier, you can use eris or detritus since they're lighter than discord.js

#

detritus specifically has a different repo for their gateway / rest client

#

you could look into those

#

you can use detritus' gateway lib and make the HTTP requests yourself for example

digital ibex
#

yeah, that is an option but idk, i kinda wanna do it this way cuz im learning more things quicker as well

#

and better for performance ig

sudden geyser
# orchid vortex meaning that the output should include `["a", "b", "c", "aa", "ab", "ac", "ba", ...

There are a lot of ways you could answer it. For example,

for (const large of letters) {
    console.log(`Large: ${large}`);

    for (const medium of letters) {
        console.log(`Medium: ${large}${medium}`);

        for (const small of letters) {
            console.log(`Small: ${large}${medium}${small}`);
        }
    }
}

I'm not great at problem solving, but this is an obvious solution. If you wanted to get the maximum number of combos on an arbitrary size (so it's not just three), you'd need a loop or recursive function responsible for being aware of the current iteration.

My solution does not care about the order. So rather than a b c aa ab ac etc. it's a aa aaa aab aac ab aba abb etc.

cinder patio
#

I'll post my solution as well in a sec

orchid vortex
#

i thought of the same, but i prefer something that uses either recursion or fancy math

cinder patio
#

fancy math no way imo for this kinda problem

#

recursion is not very practical

orchid vortex
#

so i dont have to use 80 for loops for an array of 80

#

dang, true

digital ibex
#

yo fued, still no clue?

cinder patio
#

nope

digital ibex
#

f

orchid vortex
#

f

cinder patio
#
const letters = ["a", "b", "c", "d"];
const total = [...letters];
let prevArr = [...letters];

const len = letters.length - 1;
for (let i=0; i < len; i++) {
    const temp = [];
    for (const letter of letters) {
    for (const prevLetterCombo of prevArr) {
       temp.push(letter + prevLetterCombo);
    }
    }
    total.push(...temp);
    prevArr = temp;
}
orchid vortex
#

wow, its like magic

opal plank
#

but its a tad better

#

let me see if i can find it

digital ibex
#

if anyone knows how to fix my issue, mention me pls

#

(if i dont respond)

orchid vortex
#

sorry, im not into raw discord requests

pale vessel
#

I love raw

#

Except for anime because I don't understand

#

That's why I find rose easier to use than detritus

#

Not easier, but less of a bother/bloat

opal plank
#

fuck i dont have the code anymore

#

i had an index value

orchid vortex
#

interesting

cinder patio
#

welp looks like we can't compare code speed

opal plank
#

which would be how much lenght it would generate

#

i have the bare example

#

but i dont think @thick gull has the original still

#

this is not the final btw

quartz kindle
#

someone said code speed? ๐Ÿ‘€

opal plank
#
let dictionary = new Map();
let index = 0;

function mapDictionary(array, index) {


for(let l in arr) {
str = l;
if(index > 0) for (l in arr) str += l
dictionary.set(str, str)
}
}```
cinder patio
#

interesting... that example doesn't seem to work properly tho

opal plank
#

well like i said

#

that was only the start

#

lemme ping em' again

#

@thick gull gib old code plez

quartz kindle
#

so you want to generate all possibilities from a to dddd?

orchid vortex
#

yes

#

while staying efficient

#

(enough)

quartz kindle
#

alright let me try

#

:^)

cinder patio
#

๐Ÿ˜ฉ

orchid vortex
#

must work with variable array lengths

slender thistle
#

Tim which god do I pray to for you

orchid vortex
#

and ty :^)

opal plank
quartz kindle
opal plank
#

it works tho

#

but thats different from what i posted

#

i upgraded that example i sent above

#

cuz that one clearly doesnt work

#

but the logic is somewhat similar

slender thistle
#

uvuvwevwevwe, got it

opal plank
#

add an index, then loop a for of until index is >= i

#

it would loop all previous instances

#

its basically a for..of chain

#

until index is done

cinder patio
#

Well if you find the source code we could compare code sizes ๐Ÿ˜ณ

opal plank
#

only borboss might have it

#

i checked with the host, theres no way to retrieve that code form the likn

marble juniper
#

would yall say from an objective unbiased standpoint if discord.js is still worth using when v13 comes out

opal plank
#

it was deleted, so ggez

#

i physically cannot give unbiased opinions on djs

marble juniper
#

I know

cinder patio
#

was just about to say

marble juniper
#

I didn't ask you

#

you would just spam detritus links

opal plank
#

correct

cinder patio
#

I mean detritus is objectively better than discord.js, in features, structure, performance and memory

opal plank
#

( i did not tell him to say that, for the record )

marble juniper
#

but what about

#

user friendly'ness

cinder patio
#

help someone hacked my account

marble juniper
#

bruh

digital ibex
#

btw, do any of u guys know the fix to my problem lol

cinder patio
#

discord.js is definitely more friendly, it has better documentation

#

at least IMO

marble juniper
#

the docs for discord.js makes me aroused

cinder patio
#

sames

marble juniper
#

lol

#

it looks so fucking clean and attractive

#

the new docs

sudden geyser
#

the redesign is a bit cringe

marble juniper
#

no I love it

cinder patio
#

It's clean

marble juniper
#

it looks much better

#

more simplistic Design and stuff

#

better fonts

orchid vortex
#

@cinder patio @opal plank made it just a bit more compact, and also made it a function

let combinations = (a) => {
  let t = [...a],
    p = [...a];
  for (let i = 0; i < a.length - 1; i++) {
    let s = [];
    for (let e of a) for (let f of p) s.push(e + f);
    p = (t.push(...s), s);
  }
  return t;
};
#

speed shouldnt change, its the same thing

cinder patio
#

You also made it a tad unreadable lol

latent heron
#

holy jesus

orchid vortex
#

just had to slice it down a bit, if you get what i mean ยฏ_(ใƒ„)_/ยฏ

latent heron
#

you didn't slice it down

orchid vortex
latent heron
#

you turned it into alphabet noodle soup

orchid vortex
#

LMAO

cinder patio
#

variable name length shouldn't make an impact on the performance

latent heron
#

^

orchid vortex
#

i know

#

it just looks nicer

#

in my eyes, at least

latent heron
#

you're insane

cinder patio
#

But I know something that will improve the performance

#

save a.length - 1 in a variable

orchid vortex
#

me when

cinder patio
#

bruv

#

how many letters do you have in the initial array

orchid vortex
#

uhhh 26

cinder patio
#

My algo takes around 14ms on average with 5 letters

orchid vortex
#

what tool do you use to check performance

cinder patio
#

Yeah my algo doesn't work with all letters of the alphabet

orchid vortex
#

yeah, thats a bit unsatisfactory

cinder patio
#

But I bet there isn't one that works

tame kestrel
#

what are you guys trying to accomplish

orchid vortex
#

generating every, and i mean every possible combination of elements from array

cinder patio
#

in js at least

orchid vortex
#

in js at least, right

cinder patio
#

You'll end up with an array of 26 ^ 26 elements....

orchid vortex
opal plank
#

variable names wont affect ur code btw

orchid vortex
#

they make it unreadable

opal plank
#

correct

cinder patio
#

Erwin did your algorithm work with all the letters in the alphabet

opal plank
#

thats a loss not a gain lol

#

yes

orchid vortex
cinder patio
#

I mean like, with 26 letters in the array

opal plank
#

a,b,c,d,e... //1
aa, ab,ac,ad //2
aaa, aab, aac // 3

on that function i did it was all 26 letters + the index

#

index would mean how many letters in a single item

orchid vortex
#

if you manage to get the code from the person, gg honestly

#

if you actually do it, Gunpointl

opal plank
#

wdym get it frmo that person?

#

im the one who coded it

#

im just too lazy to do it again

orchid vortex
#

didnt you say they had the code

#

dam

opal plank
#

i wrote it lmao

orchid vortex
#

mood

opal plank
#

too lazy, otherwise i'd write it again

#

but its just a map() //Set to remove duplicates

orchid vortex
#

whats the most basic idea behind it

opal plank
#

just a for() loop thats indented

orchid vortex
#

gg

opal plank
#

basically it calls itself for the next row

orchid vortex
#

so recursion

opal plank
#

thats about it

#

ye

orchid vortex
#

ah

opal plank
#

ah fuck it

#

fine i'll write it

#

gimme 10

orchid vortex
#

10 what, minecraft diamonds?

#

alr, got it

sudden geyser
#

10 bananas

orchid vortex
#

hm

cinder patio
#

Hey @orchid vortex

#

Can you check if this works

#
function populate(letters = []) {
    const res = [...letters];
    let lastInd = 0;
    for (let i=0; i < letters.length; i++) {
        let j = lastInd;
        lastInd = res.length;
        for (; j < lastInd; j++) {
            res.push(letters[i] + res[j]);
        }
    }
    return res;
}
#

I think I cracked it

orchid vortex
#

alr

cinder patio
#

The order doesn't seem to be quite right tho

orchid vortex
#

doesnt repeat

#

wait nvm

#

im blind

cinder patio
#

It's just not in order

#

wait nvm

#

it's not right

#

not yet

quartz kindle
#

this is more complicated than it seems haha

cinder patio
#

here

#

I got it!

#

function populate(letters = []) {
    const res = [...letters];
    let lastInd = 0;
    const len = letters.length - 1;
    for (let i=0; i < len; i++) {
        const temp = lastInd;
        lastInd = res.length;
        for (const letter of letters) {
        for (let j = temp; j < lastInd; j++) {
            res.push(letter + res[j]);
        } 
    }
    }
    return res;
}
#

@orchid vortex

orchid vortex
#

victory

cinder patio
#

lmao

#

okay hmmmmmmmmmmmmmmmmmmmmmmmmmmm

thick gull
#

do you just want the generated lenght

#

i have it saved to an array file

cinder patio
#

we want the code

thick gull
#

ok

cinder patio
#

Also great taste in music

thick gull
#
module.exports = {
    "name": "generateLetter",
    async execute(client, message) {
        let arr = [
            'A',
            'B',
            'C',
            'D',
            'E',
            'F',
            'G',
            'H',
            'I',
            'J',
            'K',
            'L',
            'M',
            'N',
            'O',
            'P',
            'Q',
            'R',
            'S',
            'T',
            'U',
            'V',
            'W',
            'X',
            'Y',
            'Z',
        ]
        let _array = arr
        let max = 8 // exponent (26^(x+1) doesn't finish after 3, over 500k letters at 3
        let finalArr = []

        for (let a in arr) finalArr.push(a)
        for (let i = 0; i < max; i++) {
            let temp = []
            for (let _a of _array) {
                let __a = await addLetter(_a)
                for (let b of __a) {
                    finalArr.push(b)
                }
                temp = Array.from(temp.concat(__a))
            }
            _array = Array.from([...new Set(temp)])
        }

        async function addLetter(letter) {
            let _letter = `${letter}`
            let _arr = []
            for (let _c of arr) _arr.push(_letter + _c)
            return _arr
        }
        // log the array in console
        console.log(finalArr);
    }
}
#

dunno if this is the original

#

might be modified

crimson vapor
#

what the fuck

#

im leaving again

cinder patio
#

And that doesn't cause a heap out of memory error???

thick gull
#

i mean

#

i just saved it to files

latent heron
#

๐Ÿ˜ณ

thick gull
sudden geyser
#

the edge

crimson vapor
thick gull
#

it goes from A to ZZZZ

#

and then i just :

#

used that file

cinder patio
#

OH

#

Only 4 letters?

thick gull
#

cause it took too much time to startup

thick gull
#

and it wouldnt load

#

for like hours

#

ยฏ_(ใƒ„)_/ยฏ

#

4 letters is still like 500K elements though

cinder patio
#

Well there you go, I don't think this is doable in JS

thick gull
#

i think it had a memory overflow at one point

cinder patio
#

@orchid vortex ^

orchid vortex
#

yeah

wheat mesa
#

too much data

opal plank
# thick gull ```js module.exports = { "name": "generateLetter", async execute(client,...
 let arr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
    let dictionary = new Map();
    let _index = 3;

    function mapDictionary(array: string[], index: number): any {
      let temp: string[] = [];
      for (let l of array) {
        for (let _in of arr)
          if (l.length < _index) {
            let e = `${l}${_in}`;
            dictionary.set(e, e);
            temp.push(e);
          }
      }
      if (index < _index) mapDictionary(temp, index + 1);
    }
    mapDictionary(arr, 0);
    console.log([...dictionary.keys()]);```
thick gull
#

probably better code

orchid vortex
#

yeah im just gonna switch to like what, basic?

#

sounds about right

opal plank
#

change _index to the amount of lenght you want

wheat mesa
#

ts on top

thick gull
#

i havent coded in a while :p rather just lay in bed

opal plank
cinder patio
#

That also causes a heap out of memory error

sudden geyser
#

this is painful to watch