#development

1 messages · Page 752 of 1

fluid basin
#

wdym

#

content-type: image/png
dump content into res.send

#

iirc

delicate zephyr
#

nope

#

I dont wanna have to save the image as a file

#

I shouldnt fricken have to

lusty dew
#

Google is your best friend if you can’t figure something out

delicate zephyr
#

You say that

#

ive been googling for the last 20 minutes

loud salmon
#

thats a rip

delicate zephyr
#

I wouldnt have asked if I hadn't googled

#

Got it

#

17th page of google

#

but I got it

loud salmon
#

also dying pls read the channel etiquette pinned, telling people to go to google doesn't really help D:

lusty dew
#

Yes but it should be a resource people need to learn to use

delicate zephyr
#
  1. If you know something, and someone asks a question about that thing, don't shit on them for asking. Either help them or stay quiet. If you don't have anything nice or helpful to say, keep quiet.
vagrant stream
#

How to get the ID of the first channel on the server? How to send an invitation to the same channel to the console?

#

Please mention

delicate zephyr
#

@vagrant stream What language?

vagrant stream
#

JavaScript

modest maple
#

why are you generating invites to be sent to console

lusty dew
#

I was not shitting on them what the fuck

delicate zephyr
#

msg.guild.channels.first().id @vagrant stream

#

Dying I highlighted what you should have friend

vagrant stream
#

Thanks

modest maple
#

it is against TOS to log invites

#

and make a backdoor with it

#

just

#

FYI

loud salmon
#

@vagrant stream do not generate invites without permission. It is not allowed and can get you banned from here and discord itself

#

@delicate zephyr spoonfeed

lusty dew
#

I wasn’t shitting on you though. I was giving you a suggestion as if you rely on us too much you won’t learn anything

vagrant stream
#

Okay, so I know the ID of the desired channel, how do I get the invitation URL to it?

opaque eagle
#

Show your code @delicate zephyr

#

for the express

delicate zephyr
#

@opaque eagle i got it

opaque eagle
#

oh ok

modest maple
#

@vagrant stream why do u want to make the invite>

lusty dew
#

But whatever, it was a mistake coming back here smh

loud salmon
#

D:

opaque eagle
#

you're not saving the image, right... just create a png stream or a buffer

delicate zephyr
#

@opaque eagle Sinister

#

I said I got it

opaque eagle
#

oh ok

vagrant stream
#

@modest maple Interesting, must

opaque eagle
#

just wanted to make sure

loud salmon
#

um, dying, he already said he used google excessively. He was asking here because according to him he was on the 16th page of google

modest maple
#

@vagrant stream what?

lusty dew
#

I did not know this information else I wouldn’t have suggested googling

loud salmon
#

@vagrant stream do not generate invites without permission. It is not allowed and can get you banned from here and discord itself

lusty dew
#

😂

delicate zephyr
#

just as an fyi

modest maple
#

I did not know this information else I wouldn’t have suggested googling
then dont say "google it"

vagrant stream
#

Oh....

#

@modest maple I want to be on the servers where my bot is, to watch all the errors

loud salmon
#

thats not allowed avenger

modest maple
#

that will get you and your bot banned from here and Discord in general

lusty dew
#

So you would rather me just to give them the code they need

#

Ight

slender thistle
#

No one said "go spoonfeed"

lusty dew
#

I’m done on this topic

#

I’m going to general

loud salmon
#

uh, no one said that? He was simply asking a genuine question and you just told him to google despite not knowing the topic?

delicate zephyr
#

Like even though I figured it out what sinister said is a good example of how to help

#

you're not saving the image, right... just create a png stream or a buffer

lusty dew
#

I just said I’m done with the topic why continue it

vagrant stream
#

I know, but this my bot is not popular, and my friends only use it, what difference does it make for what?

modest maple
#

easy its called breaking TOS

#

and making a backdoor

loud salmon
#

it breaks discord tos

modest maple
#

two big No Nos

slender thistle
#

Be it for your friends or not, creating invites through your bot without the server members' consent is against Discord ToS,

#

Keep your curiosity limited

vagrant stream
#

ToS?

delicate zephyr
#

i mean just enjoy ur bot not being given any permission at all when joining a server

modest maple
#

Terms Of Service

delicate zephyr
slender thistle
#

Or straight up kicked smug

vagrant stream
#

Okay, I won’t do that, you warned me. But still how to do it?

loud salmon
#

no

#

read the documentation

#

if you want to do that

modest maple
#

we're not gonna teach you how to potentially break TOS

#

after learning your intention

lusty dew
#

Lol

vagrant stream
#

😒

modest maple
lusty dew
#

I mean it’s not hard

#

Just read the docs

modest maple
#

bruh

#

lets not repeat this

loud salmon
#

i already told him smh 😠

vagrant stream
#

How to convert ID to channel name?

lusty dew
#

I didn’t see

#

Fetch the channel using the ID

#

Then get the name from the data you get back

vagrant stream
#

Or how to send to the channel knowing its ID?

lusty dew
#

Get the channel with its ID and send to it?

loud salmon
#

if you keep asking questions that can be easily solved by reading the documentation you will be punished

vagrant stream
#

Ask you faster

slender thistle
#

I would doubt that

vagrant stream
#

@lusty dew yes

loud salmon
#

uh

slender thistle
#

Searching the docs will entirely depend on you while asking someone will depend whether they know the answer and have the time/are willing to answer the question

lusty dew
#

I was telling you how to do it xd

#

Get the channel with its ID and send to the channel

vagrant stream
#

msg.guild.channels.first().id.send("Hello")

#

?

lusty dew
#

Uhm

#

No

loud salmon
#

last chance avenger, please, just read your language documentation and search for how to send a message to a channel

vagrant stream
#

😒

#

Ok

loud salmon
#

thank you.

vagrant stream
#
chan = msg.guild.channels.first().id
client.channels.get(chan).send("Message")

Thanks =)

slender thistle
#

Uhhhhhh

loud salmon
#

shiv pls

marble juniper
#

you could just do

slender thistle
#

No I mean they could straight up access the first element of guild.channels

#

instead of re-getting it k3llyShrug

marble juniper
#
msg.guild.channels.first().send("message")
#

ez

loud salmon
#

yes that could also be possible

#

but shhhhhh

lusty dew
#

Xd

marble juniper
#

sry I meant

lusty dew
#

Message failed auto correct screwed it up

loud salmon
#

gg link

lusty dew
#

I meant to say boyo

#

XD

vagrant stream
#

Lol

#

Big Thanks ==))

marble juniper
#
//fixed ver kek im dumb
msg.guild.channels[0].send("yeetus deletus")
earnest phoenix
#

K

quartz kindle
#

channels is a collection, not an array

lusty dew
#

Lmao

quartz kindle
#

i dont think you can use numbered indexes on it

lusty dew
#

Tim shhh

marble juniper
#

ugh

quartz kindle
#

you can do this tho xd ```js
let channels = new Proxy(message.guild.channels,{
get: function(obj,prop) {
return [...obj.values()][prop]
}
});
channels[0].send("lul");

sudden geyser
#

more work!

lusty dew
#

XD

marble juniper
#

or dis

#
 let defaultChannel = "";
  message.guild.channels.forEach((channel) => {
    if (channel.type == "text" && defaultChannel == "") {
      if (channel.permissionsFor(message.guild.me).has("SEND_MESSAGES")) {
        defaultChannel = channel;
      }
    }
  })
defaultChannel.send("ok")
#

if you just want to get the first channel the bot can send messages in

#

from the server

sudden geyser
#

even shorter:

message.guild.channels.find((channel) => channel.type === "text" && channel.permissionsFor(message.guild.me).has(FLAGS.SEND_MESSAGES));```
surreal sage
#

how to do custom emojis with bots?

marble juniper
#

find one

#

or make one

surreal sage
#

something with <e\🆔>

modest maple
surreal sage
#

gonna try

modest maple
#

use \ to get the full thing

#

\<custom emoji>

surreal sage
#

id?

marble juniper
#
var emoji = client.emojis.find(e => e.id == 'id').toString()

if you don't want to use < >

surreal sage
#

ok

west raptor
#

yes it is

#

javascript can't handle big ints like ids

lusty dew
#

Lol

surreal wagon
#

But with me it's working

west raptor
#

it literally can't

sudden geyser
#

the last two digits of a number becomes 00 for me with ids, so it can't.

surreal wagon
#

Okay

lusty dew
#

Show code I’m curious now

surreal wagon
#

Hmm

west raptor
#
~ 
❯ nix-shell -p nodejs
these paths will be fetched (9.20 MiB download, 45.63 MiB unpacked):
  /nix/store/2rbbn30ii3xi5aa9rdlgsw5xfk634wfg-nodejs-10.17.0
copying path '/nix/store/2rbbn30ii3xi5aa9rdlgsw5xfk634wfg-nodejs-10.17.0' from 'https://cache.nixos.org'...

~ via impure 
❯ node
> 257521982021566464
257521982021566460
> 
#

the id changes

lusty dew
#

👀

surreal wagon
lusty dew
#

The ID changes exactly

#

So it doesn’t work

#

If the ID changes it’s not a valid ID anymore

#

@west raptor also what’s nix-shell?

#

Is it a custom shell or smth

west raptor
#

Kinda, it's basically an isolated environment

lusty dew
#

Ah okay

west raptor
lusty dew
#

Okay

#

Now for my question

#

When using Klasa (discord.js framework) how would I use the KlasaReady event

#

I know I gotta use the event class but idk how I’d go about doing that specific event

west raptor
#

I'm guessing KlasaReady is basically just the ready event fired when the bot is ready?

#

taking a look, it does seem that way

#

so make a standard event how you usually would and for the event name it'd be klasaReady

lusty dew
#

Ohhh

#

I thought I had to include some random stuff oof

#

Okay thanks dream I missed that entirely

quartz kindle
#

js supports big ints, but it is kinda impractical to use them

restive furnace
#

I've forgot how i could call first object in a object?

#

object[0] is giving me undefined/null.

quartz kindle
#

objects are not ordered, they dont have a concept of first or last

#

you have to convert them or a part of them to an array by using Object.keys() / Object.values() / Object.entries()

restive furnace
#

Okay, ill try that. Thanks.

lusty dew
#

What would be the best way to make different kinds of ships for a sim bot

west raptor
#

ships?

lusty dew
#

Like say 1 ship has a health of 100xp and can mine 200 ore every 20m or so

west raptor
#

Oh

#

A class

lusty dew
#

Would I need a database entry for these ships?

#

Probably to track what ship a user has

west raptor
#

if you want to store them yes

lusty dew
#

How would I store em

#

?

west raptor
#

Database

lusty dew
#

I know

#

But would I use an ID system or what? What’d be the best way of doing such a thing

west raptor
#

well, can the user customize the ship?

lusty dew
#

Yes

#

They will be able to upgrade attack boost, defense boost and mining speed

west raptor
#

Alright then so you could say have a class with the properties and when ever a new ship is created create the class and store it

earnest phoenix
#

i usually use twitter's snowflake system to generate ids

#

it is also what discord uses

lusty dew
#

Well the user themselves can’t make a ship

#

Ima have already made ships that the users can buy/upgrade too

west raptor
#

it's basically the same concept, no?

lusty dew
#

Oh wait I see what you’re saying now ahaha

#

Sorry

quartz kindle
#

if each ship is unique and all of them must be stored, then unique ids/snowflakes, else you can just store an entry for the user, containing stuff like ship type, component levels, xp and such

west raptor
#

^

quartz kindle
#

do you need to access ships without users?

#

like searching for highest level ship, biggest ship, etc

lusty dew
#

Well

earnest phoenix
lusty dew
#

Yes kinda

quartz kindle
#

what kind of database are you gonna use?

lusty dew
#

Ima have a "shop" that people can buy higher level ships

earnest phoenix
#

ohw shit

lusty dew
#

So I need to be able to track what the highest level ship is from the current ship they have

quartz kindle
#

is each person limited to one ship or can they have many?

lusty dew
#

Default is 1

#

But they can buy a perk with in game currency to be able to run more ships

west raptor
#

@earnest phoenix what why are you storing true/false as strings

lusty dew
#

And I’m using sequelize + Sqlite3

earnest phoenix
#

@west raptor idk

west raptor
#

you're just making life harder on yourself

quartz kindle
#

ok, so one way to do it is to have a dedicated table for ships

#

each ship will have an owner id, and all other properties

lusty dew
#

So like

#

Let me make an example table real quick

earnest phoenix
#

@west raptor well i could store them as non Strings but thats not the problem rn

west raptor
#

your if statments aren't formatted correctly it looks like

#

idk

quartz kindle
#

from what i can see, your embed is empty because none of those conditions passed

#

ie, none of the database entries is null

lusty dew
#

Discord on my pc is stuck in a loop of installing the same update

#

@quartz kindle that’s the model I’m thinking you mean

quartz kindle
#

if you make owner id unique, then each person can only have one ship

lusty dew
#

Oh true

quartz kindle
#

instead you can make an auto incrementing id and have that as your primary key

lusty dew
#

Wdym

quartz kindle
#

just make owner id an index

earnest phoenix
#

@fallen plinth Blizzard

west raptor
#

what

lusty dew
#

Mmm how

#

I don’t understand sorry

quartz kindle
#

id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},

lusty dew
#

Okay

quartz kindle
#

and add an index

lusty dew
#

And how would I use that

quartz kindle
#

{
indexes:[
{
unique: false,
fields:['ownerId']
}
]
}

earnest phoenix
#

@earnest phoenix

west raptor
#

@earnest phoenix stop??

earnest phoenix
#

ok

#

sorry

lusty dew
#

Wait what

#

Would that be inside the owner_id column

#

Or outside

quartz kindle
#

define("ships", {columns}, {indexes});

lusty dew
#

Like that

#

?

#

Oh wait

#

I have to restart my pc hold up

#
module.exports.Ships = seq.define('ships', {
    owner_id: {
        type: Sequelize.INTEGER,
        autoIncrement: true,
        primaryKey: true,
    },
    attck_boost: {
        type: Sequelize.SMALLINT,
        defaultValue: 1,
        allowNull: false
    },
    def_boost: {
        type: Sequelize.SMALLINT,
        defaultValue: 1,
        allowNull: false
    },
    health: {
        type: Sequelize.SMALLINT,
        defaultValue: 100,
        allowNull: false
    }
},
    {
        indexes: [
            {
                unique: false,
                fields: ['owner_id']
            }
        ]
    })
#

like this tim?

earnest phoenix
#

@quartz kindle null is when it does not exits

restive furnace
#

true : yes ? no

#

notnull || "Not found"

quartz kindle
#

@lusty dew yeah that should work

#

but owner_id should not be the primary key, nor auto increment

#

primaryKey and autoIncrement should be another field

lusty dew
#

You said it should

#

Did you not?

quartz kindle
#

an id field

#

not an ownerid

#

it will be the id of the ship itself

lusty dew
#

Oh okay

quartz kindle
#

@earnest phoenix yes, but does it exist?

earnest phoenix
#

no

lusty dew
#

Now I gotta figure out the class eek

earnest phoenix
#

if the bot joins a guild it automaticly does not exists

#

no wait nvm

restive furnace
#

you need to wait few seconds, cuz onGuildAdd (or wut evr it is) will be fired before even the guild is ready sometimes

quartz kindle
#

wut

lusty dew
#

Hm

#

Don't think that is how it works

#

Tim, what would be the best approach for the class?

#

I have never really used classes so eek

earnest phoenix
west raptor
#

what

opaque eagle
#

What's the difference between mongoose's findOneAndUpdate() and updateOne()

earnest phoenix
#

running the robot but the website does not write that online

lusty dew
#

Because your bot has not been tested and verified yet

#

It will if it get's approved

earnest phoenix
#

I understand and thank you for your prompt reply

west raptor
#

@opaque eagle findOneAndUpdate returns a document

lusty dew
#
module.exports = class ShipBuilder {
    constructor(health, power, ore_cap, def_boost, attk_boost, owner_id){
        this.health = health;
        this.power = power;
        this.oreCap = ore_cap;
        this.defBoost = def_boost;
        this.attkBoost = attk_boost;
        this.ownerID = owner_id
    }
}

isn't this how I would setup my class?

west raptor
#

updateOne does not

quartz kindle
#

@lusty dew you dont actually need to use classes, you can use anything else that makes you more comfortable

lusty dew
#

Well

quartz kindle
#

but if you wanna dive into classes, its worth the while

lusty dew
#

I want to use classes tbh

#

The framework I am using is class based (Klasa)

quartz kindle
#

have you ever used prototypes?

lusty dew
#

so it would be nice to learn how to use em

#

Probably just don't know what they are

quartz kindle
#

classes, prototypes, instances, inheritance, etc... they are all connected, its like a whole world by itself

#

classes are basically a nicer way to create prototypes

#

in javascript EVERYTHING runs on prototypes

#

when you create an array, you're using a prototype

lusty dew
#

Ooo

quartz kindle
#

an object, a string, a number

lusty dew
#

I didn't know that

quartz kindle
#

everything uses prototypes

#

so basically, you when you have a piece of data, like "test" or 123

#

you have a data type, and methods attached to that data type

#

"test" is a string, and it has methods such as .length, etc

#

those are part of the prototype, or the object class

#

they are not actually part of the data

#

just attached to it

lusty dew
#

Yea

#

Makes sense

#

so basically in a class when you are doing

#
module.exports = class ShipBuilder {
    constructor(health, power, ore_cap, def_boost, attk_boost, owner_id){
        this.health = health;
        this.power = power;
        this.oreCap = ore_cap;
        this.defBoost = def_boost;
        this.attkBoost = attk_boost;
        this.ownerID = owner_id
    }
  get() {
    //blah
  }
  build() {
    //build the ship
  }
}
#

Would those be considered methods?

quartz kindle
#

yes, get and build are methods

#

you can modify and extend prototypes and classes, like this

#

classes are the same, just with a neater syntax

broken jay
#

Which is better for developing bots: PY or JS?

quartz kindle
#

both are average

lusty dew
#

Preference

#

Use whatevever you are comfortable with

#

Okay so my question is

#

In the class how would I make the different types of ships?

quartz kindle
#

the best way would be to create a base class and then extend it with specific ship classes

#

for example

west raptor
#

@broken jay It really depends honestly

quartz kindle
#
class BaseShip {
  constructor(data) {
    // build your base ship
  }
}

class specialShip extends BaseShip {
  constructor(data) {
    super(data)
    // build your specific ship
  }
}```
west raptor
#

Both have their pros and cons

quartz kindle
#

in the base ship, you should have all the properties and methods that all ships have

#

and then in each specific ship, you have that ships specific properties and methods

lusty dew
#

Hm\

#

So like

quartz kindle
#

and when you create a ship instance: let myShip = new specialShip(input)

west raptor
#

wouldn't specialShip be bad naming

quartz kindle
#

myShip creates a specialShip which in turn creates a BaseShip and joins everything together

broken jay
#

Is there any article where is both pros and cons for developing discord bot?

west raptor
#

No, not really

quartz kindle
#

the only pros and cons is: which language are you more familiar with and prefer using, and which runtime you prefer running in your computer or vps

lusty dew
#

Wait a sec

#

how does super work again?

#

doesn't it get things from the other class?

quartz kindle
#

super gets things from the parent class

lusty dew
#

Ah mk

#

So like

quartz kindle
#

so when you create an extended class, you need to activate the parent as well

lusty dew
#

So essentially

broken jay
#

But performance? Which is faster?

lusty dew
#

I don't do anything with super

#

or the constructor?

quartz kindle
#

both are more or less equal in performance

lusty dew
#

Like do I do

west raptor
#

*Typically though javascript is a little faster if you wanna get technical

#

but then it again

#

it comes down to how you optimize it

lusty dew
#

I am confused about this class thing xd

broken jay
#

ok

lusty dew
#

Tim would I make a build method in the BaseShip class to build the default ship?

quartz kindle
#

only if you need async code to build it

#

because constructors cant be async

lusty dew
#

Hm okay

#

I am trying to figure out how the actual building of the ship would happen

quartz kindle
#

unless you wanna use "unbuilt" ships for anything

lusty dew
#

Hm

#

That actually gave me an idea

#

I could have the option to allow them to scrap the ship for parts and sell them to get some money to go towards a new ship

quartz kindle
#

yeah you could give it a destroy() method for example

lusty dew
#

Yea

#

I still can't think of how the build method would work though

quartz kindle
#

what does building mean for you? how do you imagine it should work?

#

not code-wise

lusty dew
#

Well

quartz kindle
#

user experience wise

lusty dew
#

Hm

#

Let me put this in a different perspective

#

You know those games where you build say a farm and it takes x time to finish the build

#

and it takes resources to build said farm

#

I was thinking of something kinda like that

#

You have to collect x amount of materials to be able to build a new ship

quartz kindle
#

then you do need an unbuild status

#

just add a status property to the ship

#

and some kind of progress

lusty dew
#

Wdym status?

quartz kindle
#

a ship that is not yet built is still a ship

#

one way to do it is to have a status property

#

so you can check ship.status

#

another way is to have a dedicated "unbuilt ship" class

lusty dew
#

Eek

#

Okay

#

So when I am doing the build method

#

do I just do something like

#

Wait

#

when making the build method

#

do I just give it all the health, def_boost, attk_boost, etc values and save them to the database?

#

or is there something specific I have to do

quartz kindle
#

a class instance itself cannot be saved in a database, so you need to extract and rebuild your classes

#

so you need to give all the values to a constructor when you create a class

#

so that when you create an instance, you can supply existing data to it

lusty dew
#

Uhhh

#

Okay

quartz kindle
#

lul

lusty dew
#

Tim

#

Do you mean like this

#
module.exports = class ShipBuilder {
    constructor(health, power, ore_cap, def_boost, attk_boost, owner_id){
        this.health = health;
        this.power = power;
        this.oreCap = ore_cap;
        this.defBoost = def_boost;
        this.attkBoost = attk_boost;
        this.ownerID = owner_id
    }
  build(){
    this.health = 100;
    this.power = 1;
    this.oreCap = 200;
    this.defBoost = 1;
    this.attkBoost = 1;
    this.ownerID = someID
  }
}
#

?

quartz kindle
#

something like that yes, but an unbuilt ship is still a ship

#

so go ahead and js constructor(...,built) { this.built = built; } build() { if(this.built) return; }

lusty dew
#

so

#
module.exports = class ShipBuilder {
    constructor(health, power, ore_cap, def_boost, attk_boost, owner_id, built){
        this.health = health;
        this.power = power;
        this.oreCap = ore_cap;
        this.defBoost = def_boost;
        this.attkBoost = attk_boost;
        this.ownerID = owner_id;
        this.built = built
    }
  build(){
    if(this.built) return;
    this.health = 100;
    this.power = 1;
    this.oreCap = 200;
    this.defBoost = 1;
    this.attkBoost = 1;
    this.ownerID = someID
  }
}
#

and I am assuming the default of build should be false

#

or would it be true

quartz kindle
#

you dont need the ownerid in the built method

#

yeah the default would be false

lusty dew
#

Okay

quartz kindle
#

then inside the build method, you should check if the owner has enough resources to begin building

lusty dew
#

Wait why won't I need ownerID in build method

quartz kindle
#

because this ship already has an owner id

lusty dew
#

Oh?

#

Oh yea

#

It is the default ship

#

every get's it

#

gets*

quartz kindle
#

everything you put in the constructor is part of the class, and everything can be accessed from all its methods

lusty dew
#

Ah mk

quartz kindle
#

so the build method will build a ship with default values

#

what about the ship type?

#

do all ship types have the same default values?

lusty dew
#

No

#

Each ship type has different values

#

health, def, attk, etc will be different

#

Also I just realized something

#

I am going to be using ore that they mine as the resources

#

I have yet to make the ore class

quartz kindle
#

welcome to inheritance hell

#

lmao

lusty dew
#

Lmao

#

Yea

#

okay

quartz kindle
#

but still, learning classes is worth it, and coding oop does feel good af

#

you will probable end with something like a user class, which has an array of ship classes the user owns

#

and you can assign classes as properties of other classes and create circular dependencies

#

like djs does

#

for example, ```js
class Ship {
constructor(owner) {
this.owner = owner
}
}

class User {
constructor() {
this.ships = [];
}
buyShip(type) {
let ship = new Ship(this);
this.ships.push(ship);
}
}

lusty dew
#

Wow

#

What if there is more then one ship

quartz kindle
#

so you can do user.ships[0].owner.ships[0].owner.ships[0].adInfinitum

lusty dew
#

how would you handle that

#

Wait what

quartz kindle
#

user.buyShip() will create a ship and add it to the list of ships the user class has

#

user.ships is an array

#

you can make it an object or Map if you want

lusty dew
#

so user.ships[0] first ship in the array then you use .owner to see who owns the ship

#

why do you keep doing ships[0] after that

quartz kindle
#

to demonstrate the circular dependency

lusty dew
#

Ah okay

quartz kindle
#

we build a Ship class by supplying user's this, so ship.owner is a reference to the entire user class

#

no need to do stuff like users.find(user => user.id === this.ownerID)

#

if you want to find the owner object from within a ship instance

#

just a nice and tidy way to connect things

#

discord.js does this as well, such as message.guild

#

or message.channel

lusty dew
#


module.exports = () => {
    class Coal {
        constructor(price, type){
            this.price = price;
            this.type = type;
        }
        create(){
            this.price = 10;
            this.type = "Cheap"
        }
    }

    class Diamond extends Coal {
        constructor(data){
            super(data)
        }
        create() {
            this.price = 200;
            this.type = "Expensive"
        }
    }
}
#

So something like this?

#

I am working on the Ore (resources)

quartz kindle
#

the problem is

#

classes are supposed to be like a physical object you have in your hands and manage

#

resources are things you collect and spend

#

its kind of a different thing

lusty dew
#

Hm

#

So how would I do the resources

quartz kindle
#

you are not going to have 1 coal lying around and then do things with it are you?

#

like paint it pink or put wings on it

lusty dew
#

😂

#

No

quartz kindle
#

your classes are the user and the ships

#

resources can simply be a property that is part of the user

#

to keep track of how much the user has

lusty dew
#

Hm

#

How would I make it so it isn't resources in total but like

#

say for the next ship they need 2000 coal and 2000 iron

quartz kindle
#

so like the more ships they have the more expensive it gets?

#

regardless of ship type

lusty dew
#

Yes

quartz kindle
#
class User {
  constructor() {
    this.ships = []
    this.iron = 0
    this.coal = 0
  }
  buyShip() {
    let cost = this.ships.length * 1000 + 1000;
    if(this.iron > cost && this.coal > cost) {
      let ship = new Ship(...);
      this.ships.push(ship)
    }
  }
}```
#

in this case, i made cost a simple formula based on how many ships the person has

#

each ship increases the cost by 1000

lusty dew
#

Hm

#

Is there an easier way to do such a thing

#

Like the formula is perfect

#

but defining each ore like

#

this.coal
this.iron
this.diamond
etc

#

seems a bit of a tedious thing

#

as I plan on having 20-30 ores

quartz kindle
#

well, you can put them in a resources object

#
this.resources = {
  iron:0,
  coal:0,
  etc
}```
lusty dew
#

Okay thanks

#

that way I can just do

#

this.resources.coal and such right?

quartz kindle
#

yup

lusty dew
#

Btw

#

can I split the classes up into different files?

amber fractal
#

You can extend classes

lusty dew
#

Yes I know

quartz kindle
#

yeah

lusty dew
#

but would it be better to split them up?

#

Make it cleaner instead of like 10 classes in one file

quartz kindle
#

probably

lusty dew
#

Okay

amber fractal
#

Oh i didn't know that's what you meant lol

lusty dew
#

Wait

#

User wouldn't extend ShipBuilder would it?

#

User is an independant class right

quartz kindle
#

should be yes

#

extending classes should be done when you have a base type of something, that has methods that all classes should share

#

for example, if you have baseClass.mymethod() and you extend it, then mymethod() will also be available in the extended class by default

lusty dew
#

Hmmm okay

#

Also

#

My big question is

#

How will I tell which ship they are trying to buy?

#

Cause they don't have to buy the next one avaliable

quartz kindle
#

there are many ways to do this

#

there is something called static properties and static methods

#

a static property is a property attached to the class, but not to its instance

#

for example

#
class test {
  constructor() {
  }
  ok() {
  }
  static ok() {
  }
}
#

the static method is not available in an instance, meaning you can access it by test.ok but not by a = new test(); a.ok

#

so basically, you can use static properties and add metadata to a class, information about the class, methods that do not target instances

#

a class becomes an instance when you use new

lusty dew
#

Okay

#

That kinda makes sense

#

but how is this useful in telling what ship they are trying to buy

#

and what resources it takes to buy said ship

quartz kindle
#
class Ship2 {
  static requirements() {
    return {iron: 10, coal: 10}
  }
}
let reqs = Ship2.requirements();
if(iron > reqs.iron && coal > reqs.coal) {
  let ship = new Ship2();
}
lusty dew
#

Hmmm okay

#

and as for your cost formula

#

I am assuming I can modify that?

quartz kindle
#

sure

#

another useful thing to know about classes, is to make use of getters and setters

#

they help make your code neater as well, basically if you would make Ship2.requirements() a getter, you would be able to use it like Ship2.requirements.iron instead of Ship2.requirements().iron

lusty dew
#

Hm

#

How would I make it a getter

quartz kindle
#

get requirements() {}

#

or in the above case static get requirements() {}

#

similarly, you can use set myMethod() {} if you want to do ship.myMethod = somevalue instead of ship.myMethod(somevalue)

lusty dew
#

Ahhhh mk

#

So let me try something

quartz kindle
#

the real advantage in using getters tho, is called lazy loading

#

you can use getters to generate data only when you access it

#

for example get time() { return new Date() } will always return the current time

#

but this.time = new Date(); will return the time when you created the instance

#

and both are used as Ship.time

lusty dew
#

Ahhh okay

#

Okay so in my ships.js file (holds all the ship related classes)

#

I have this

#
    class RustBucket extends ShipBuilder {
        constructor(data){
            super(data)
        }
        static get requirements() {
            return {coal: 3000, iron: 4000}
        }
    }
#

in my users.js (holds alll the user related classes)

#

Will I need to destruct the RustBucket class to get the requirements?

#

Like

#
const { RustBucket } = require('./ships')

module.exports = () => {
    class User {
        constructor(){
            this.ships = [];
            this.resources = {
                iron:0,
                coal:0,
                diamond:0,
                lapis:0,
                emerald:0,
                dragonDust:0,
                darkCrystal:0,
                uranium:0
            }
        }
        buyShip(){
            let cost = RustBucket.requirements.iron * 1000 && RustBucket.requirements.coal * 1000
            //blah blah
        }
    }
}
#

But that doesn't seem to make sense actually

#

cause then that would be specific to one ship

quartz kindle
#

you need to export the classes

#

module.exports = { RustBucket, OtherShip, etc }

#

then you can require them like that, or just require all of them

#

const ships = require("./ships")

#

then you can specify the ship in the buyShip method

#

buyShip(type)

#

then you can let cost = ships[type].requirements

#

and then js for(ore in cost) { if(this.resources[ore] < cost[ore]) return "not enough " + ore; }

#

and add the formula somewhere in there

lusty dew
#

Hm

#

Let me just model what you said real quick

#

to see if I get it

quartz kindle
#

you dont need to export the User class inside a function

#

unless you want to call it from a function but then you need to return it

#
module.exports = class {...}
User = require(...)
user = new User(...)

or

module.exports = (...) => { return class {...} }
User = require(...)
user = User(...);```
lusty dew
#

ore is red for some reason

#

Idk if it is the linter being weird

#

or if it is something else

#

When I hover over it, the thing says "Unresolved variable or type ore"

#

I think it is the linter acting up

#

Eek

quartz kindle
#

probably being weird, cost should be an object

#

you can use other types of loops as well

lusty dew
#
        buyShip(type){
            let cost = ship[type].requirements
            for(ore in cost){
                if(this.resources[ore] < cost[ore]) return `Not enough ${ore}`
            }
        }
#

So like this then

quartz kindle
#

no, requirements is the requirements object of the ship

#

you cant multiply an object by 1000

lusty dew
#

Ohhh

#

True

quartz kindle
#

inside the loop, ore is each ore in those requirements

#

ie: iron, coal, etc

lusty dew
#

Okay

#

so I would do the formula there?

quartz kindle
#

yeah

lusty dew
#

and then I would use the formula in the if statement right?

opaque eagle
#

Can someone help me with mongodb... i keep getting this error: CastError: Cast to ObjectId failed for value "656271376638017556" at path "_id" for model "Guild"

#

I've always used Postgres

#

Mongodb is so new to me lol

#

anyways if someone can tell me why that happens it would help

lusty dew
#

is cost[ore] the ore itself like

#

iron, coal and such

quartz kindle
#

cost is the requirements

#

ore is the ore itself

#

cost[ore] is the requirement for that specific ore

lusty dew
#

Okay

#

So I am assuming to make the formula I would do something like ore * 1000

#

or whatever

quartz kindle
#

yeah, but double check your formula

#

if iron cost is 1000, cost[ore] * 1000 = 1000000

wooden lance
#

anyone know of a huge list of profanity I can stick in an array?

quartz kindle
#

and you want to make it based on how many ships the user has

opaque eagle
#

["Ollie"]

earnest phoenix
#

don't waste time on making word filters

#

there'll always be a way to bypass them

#

and you'll get more false positives than true positives

lusty dew
#

Hm

#

so I would just do

wooden lance
#

true

opaque eagle
#

i tried to make an array filter once

lusty dew
#

let formula = this.ships.length * ore + 1000

#

?

opaque eagle
#

it detected class in a codeblock as ass

wooden lance
#

Yeah, it's hell

earnest phoenix
#

theoretically speaking there would be ~1111998^1990 ways to bypass your filter

#

which is a huge number

wooden lance
#

yes

#

seems different from others

lusty dew
#

Roblox has the most sophisticated swear filter ever

wooden lance
#

yes it does

amber fractal
#

It's the worst one too

wooden lance
#

it catches everything...and more

lusty dew
#

It might be worse

#

but you gotta admit it

#

pretty impresive

amber fractal
#

It isnt even theirs

lusty dew
#

Still

wooden lance
#

i wouldnt be surprised if it is using ai

lusty dew
#

It is impressive

#

Whos filter is it though?

amber fractal
earnest phoenix
#

every filter depends on how restrictive the chat box is

wooden lance
#

ooooo

lusty dew
#

SuperCell uses it

#

@quartz kindle Would I simply do
let formula = this.ships.length * ore + 1000 as you did in your previous example for the formula

quartz kindle
#

something like that yeah

lusty dew
#

Okay

#

and I am assuming I would then use formula in the if statement

quartz kindle
#

figure it out :3

lusty dew
#

Yea I am trying

#

xd

#

So if cost is the requirements of that ship

#

and cost[ore] is the requirement for that specific ore

shy turret
#
function configSet(name, response) {
  try {
    config[name] = [response];
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(err) {
    if (err) throw err;
    });
    output = 1
    return output;
  } catch(err) {
    output = 0
    return output;
  }
}

function and

#
                  try {
                    eval(fs.readFileSync('moves//fighteval//' + move + ".txt").toString())
                  } catch(err) {
                    simpleEmbed(message, "Use a Move", 'An error has occured.\n**ERROR**: `Something went wrong when trying to compile "moves//fighteval//' + move + '.txt"`')
                    console.log(err)
                    return
                  }
                  configSet("fighthp_" + message.author.id.toString(), userhp);
                  configSet("fighthp_" + opponent.toString(), opponenthp);

code

#

dont ask me why im not using require

earnest phoenix
#

stop using json files as a database

lusty dew
#

@quartz kindle Would it be something like:

for(ore in cost){
  let formula = this.ships.length * ore + 1000;
  if(this.resources[ore] < cost[ore] / formula) return `Not enough ${ore}`
}
#

Wait no

#

oof

wooden lance
#

Anyone know how I could install node-gyp rebuild on ubuntu? I can't install npm modules.

npm ERR! errno 1
npm ERR! ref@1.3.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ref@1.3.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-12-22T19_49_31_125Z-debug.log
lusty dew
#

That would be bad

oak imp
#

"Stop using json files as a database"

This. All of this.

lusty dew
#

cause if iron is 2000 and they have one ship that would be 2000 / 2000 which is 1

#

eek

shy turret
#

@oak imp then use what as a database?

restive furnace
#

@wooden lance u need to install build-tools

earnest phoenix
#

a database

restive furnace
#

@shy turret sql

earnest phoenix
#

because json files are not a database

shy turret
#

dont have it lol

wooden lance
#

thank you

earnest phoenix
#

sql is a language

restive furnace
#

sql database i meant

shy turret
#

it's better than using text files as a database which i used to do

quartz kindle
#

my bot still uses json lmao, and its at 2k guilds

earnest phoenix
#

it's better than using text files as a database which i used to do
it really isn't

#

it's equivalent

#

it's still sync IO operations

shy turret
#

not really

oak imp
#

I mean if you need something simple and lightweight, sqlite is a decent option @shy turret

shy turret
#

how do i get sql

earnest phoenix
#

sql is a language

restive furnace
#

and u can use orm, and then its ez as json

earnest phoenix
#

for the second time

#

there are databases that implement sql

#

sqlite is one of them

lusty dew
#

Sequalize is a good orm

earnest phoenix
#

it's local so it's perfect for small bots

restive furnace
#

TypeORM or Sequelize on js 👌

wooden lance
#

@restive furnace just to clarify, am I installing it with npm, or something else?

restive furnace
#

apt

wooden lance
#

okay

restive furnace
#

sudo apt install build-tools should work

quartz kindle
#

apt if you're on linux

restive furnace
#

he said he is on ubuntu

quartz kindle
#

👍

lusty dew
#

Tim I can't figure it out

#

:c

restive furnace
#

Anyone know how I could install node-gyp rebuild on ubuntu? I can't install npm modules.
he said

lusty dew
#

I feel like I am doing something wrong

wooden lance
#
Building dependency tree
Reading state information... Done
E: Unable to locate package build-tools
quartz kindle
#

your Tim free trial has expired

shy turret
#

don't use json has a database isn't helping...

#

i dont want to rewrite the whole bot again

restive furnace
#

@wooden lance try google cuz there was an trick to fix that

wooden lance
#

ok

restive furnace
#

"how to install build tools on ubuntu xx.xx?"

quartz kindle
#

isnt it build-essential?

#

built-tools is for windows

oak imp
#

@shy turret like I said, take a look at using sqlite

restive furnace
#

wait...

earnest phoenix
#

i dont want to rewrite the whole bot again
migrating to an actual database =/= whole ass rewrite

restive furnace
earnest phoenix
#

if you don't want to, then don't complain for having problems with something that's been said to not be done

restive furnace
wooden lance
#

@restive furnace build-tools or build-essentials?

#

aha yes

restive furnace
#

go there

wooden lance
#

i found that too

#

and i was confused

#

over what to install

restive furnace
#

i forgot the real bame

#

name

#

sry

#

cuz didnt use ubuntu while

wooden lance
#

lel and now i have to wait for apt to install half a gb of stuff

restive furnace
#

centos xd

#

i've many times installed ubuntu desktop on ssh lol

#

and its like 5 gb

wooden lance
#

oof

quartz kindle
#

if you're on a vps, half a gb of stuff will be done in couple minutes

wooden lance
#

u would think

restive furnace
#

ye and my internet is pretty fast so it download gb/2-3mins

#

xd

#

its one of fastest in my country

wooden lance
#

very slow when ur server is in germany

restive furnace
#

it is slow if ur vps on germany and u like somewhere like america or asutralia

#

australia

quartz kindle
#

location shouldnt matter, whats your servers internet speed? 10mb?

wooden lance
#

i believe the speed is like, 100mb/s

quartz kindle
#

so theorically is should be done in a minute

wooden lance
#

yes

restive furnace
#

if ur uplaod 1mb then it wont do anything if ur download is 100mb

#

/s

quartz kindle
#

100mb/s can download 750mb of data per minute

wooden lance
restive furnace
#

100mb/s download = normal, 30-40mb/s upload = normal in finland

quartz kindle
#

usually when installing stuff with apt, its not the internet that makes it slow, is the actually installing process, disk write and cpu

restive furnace
#

and ss it

earnest phoenix
#

100mb/s 😳

wooden lance
#

it's a vps, i have no clue how i would do that

earnest phoenix
#

are you sure it's not 100mbps

wooden lance
#

im going to sound like an idiot here, but what's the difference?

unique nimbus
#

From what it shows its 100mbps

earnest phoenix
#

megabytes vs megabits

unique nimbus
#

Megabits most likely

restive furnace
#

mb/s = mbps ?

earnest phoenix
#

no

wooden lance
#

im confused

earnest phoenix
#

the difference is in casing but i always write in lowercase

oak imp
#

Mb != MB

wooden lance
#

wot

restive furnace
#

mb per or / s

west raptor
#

what

earnest phoenix
#

8Mbps = 1MB/s

restive furnace
#

okhe

west raptor
#

@oak imp it's the same thing

earnest phoenix
#

because 8 bits is 1 byte

restive furnace
#

my downloading from steam is usually at 10mb/s

topaz fjord
#

1 byte is 8bits

oak imp
#

Megabits is not the same as megabytes, no

earnest phoenix
#

100mb/s would be 800mbps internet which is almost a gigabit connection which is rare

west raptor
#

you just said Mb != MB lol

earnest phoenix
#

because Mb is not MB

#

Mb is megabits

#

MB is megabytes

restive furnace
#

its not actually rare again in finland many of internet providers provide 1gb internet

topaz fjord
#

MiB

oak imp
#

Yep, Mb is shorthand for megabits, whereas MB is megabytes

wooden lance
#

who on earth came up with this system

west raptor
#

what that's dumb as fuck

topaz fjord
#

it's like that everywhere Thonk

wooden lance
#

im still getting this error

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ref@1.3.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ref@1.3.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-12-22T20_08_00_983Z-debug.log
``` aaaaaaaaaaaaaaaaaaaa
oak imp
#

Force rebuild from source maybe?

#

Unless thats what youre already doing..

west raptor
#

why does capitalization have to make that much of a difference

earnest phoenix
#

a lot of people confuse Mb with MB because a lot are tech illiterate and spread false information around

#

install better SQLite 3 for start

#

how else would you abbreviate them, dream

wooden lance
#

@oak imp i have no clue what ur saying

earnest phoenix
#

it follows SI system rules

west raptor
#

valid

#

why do people say like

#

100mb then

earnest phoenix
#

they confuse it probably

oak imp
#

Because not many people outside tech fields know the difference

earnest phoenix
#

fun fact

#

windows is also confusing bits with bytes

west raptor
#

lmao

topaz fjord
#

windows is trash

oak imp
#

Truth lolz

wooden lance
#

windows be a potato

topaz fjord
#

it's all about macos or linux mmLol

oak imp
#

Windows is meant to be easy, not technologically accurate lmao

west raptor
#

Because not many people outside tech fields know the difference
@oak imp tbf i only learned that today

#

it's not really taught

topaz fjord
#

ur slow dream

west raptor
#

I know

earnest phoenix
#

if you take IT it's one of the first lessons you have i think

slender thistle
#

We haven't been taught that neither in school nor in college

modest maple
slender thistle
#

and I'm going for programming Think

modest maple
#

just learnt it passivley

quartz kindle
#

nobody has time to differentiate them, we just use context. when talking about internet speeds, Bits is the defacto standard, regardless of which abbreviation you use, we all know what you're talking about

#

same with file sizes, but with bytes

oak imp
#

- loses even more faith in the education system -

Wait... perchance are you both from the states?

#

@west raptor and @slender thistle I mean

wooden lance
#

node-gyp rebuild is still being annoying

west raptor
#

I am

#

shiv is not

slender thistle
#

I am far from the freedomland

west raptor
#

the opposite

oak imp
#

Russia?

slender thistle
oak imp
#

Ah yes, apologies

#

@wooden lance look into rebuilding from source.

#

It works a little different

#

Might help ya

west raptor
#

first they need to give the full error lol

quartz kindle
#

which module are you trying to install btw?

wooden lance
#

@oak imp what is the command

oak imp
#

Anyways, this developer kitteh is off for a shower and then chores. Good luck peeps lolz!

quartz kindle
#

node-gyp is just a requirement, you dont need to explicitly install it

wooden lance
#

i am an idiot

west raptor
#

I've found node-gyp issues are often the problem of not having windows build tools

#

but im not

#

sure if you;re using windows

wooden lance
#

nope, using ubuntu

west raptor
#

what's the full error?

#

I can type

#

shush

wooden lance
#

o god this is long

quartz kindle
#

not as long as a C program full of warnings because of outdated coding style

modest maple
#

xD

#

pycharm is like that

#

has a go at you for not having a blank line at the end of your code

west raptor
#

ah I get those all the time when compiling programs

#

they're not too bad

#

running gentoo you get used to them eventually

wooden lance
#

im just going to send the debug log because there is no way i am going to be able to copy all of this

west raptor
#

is it a bunch of compile time warnings and errors

thin gyro
#

What does bots library mean

#

When I upload my bot

west raptor
#

the bot's main library interacting with the Discord API

quartz kindle
#

the library you use to code your bot

#

you did code your bot... right?

lusty dew
#
buyShip(type){
            let cost = ship[type].requirements
            for(ore in cost){
                let formula = this.ships.length * ore + 1000;
                if(this.resources[ore] < cost[ore] + formula) return `Not enough ${ore}`
            }
            let ship = new ship[type];
            this.ships.push(ship)
        }

I think I figured it out tim

wooden lance
lusty dew
#

No one is going to downlaod that

wooden lance
#

aaaaaaaaaa pastebin time

west raptor
#

it's a log file dude

lusty dew
#

At least I wouldn't

amber fractal
#

it's a .log file...

earnest phoenix
#

number one rule of the internet

lusty dew
#

I still don't download files off the internet

quartz kindle
#

i did

earnest phoenix
#

don't trust files

amber fractal
#

I'll download it for you

lusty dew
#

It doesn't matter what kind of file it is

#

it can be injected with malicious content either way

west raptor
#

are you executing it? No

amber fractal
#

a log

west raptor
lusty dew
topaz fjord
#

one question

quartz kindle
#

165 warn enoent ENOENT: no such file or directory, open '/root/DiscordBotApp/package.json'

#

.>

lusty dew
#

These guys don't know how viruses work obviously

topaz fjord
#

why don't you have package.json

wooden lance
#

@lusty dew dude, it's a log file. not an executable.

lusty dew
#

@quartz kindle

buyShip(type){
            let cost = ship[type].requirements
            for(ore in cost){
                let formula = this.ships.length * ore + 1000;
                if(this.resources[ore] < cost[ore] + formula) return `Not enough ${ore}`
            }
            let ship = new ship[type];
            this.ships.push(ship)
        }

I think I got it

wooden lance
#

@topaz fjord because it refuses to make one

topaz fjord
#

wdym

#

"it refuses"

lusty dew
#

Also it can be any kind of file, a virus can be launched if the file is opened

west raptor
#

npm init

topaz fjord
#

^

lusty dew
#

doesn't have to be an executable

wooden lance
#

o there u go

quartz kindle
#

@lusty dew sorry but These guys don't know how viruses work obviously right back at you lol

lusty dew
#

🤷

topaz fjord
#

fuck the virus

west raptor
#

you cant put a fucking virus in a damn log file lol

topaz fjord
#

if they want my data they can have it

wooden lance
#

@lusty dew okay, how would the code run?

#

where would u put the code

topaz fjord
#

also macos virus protection gang

lusty dew
#

Lmaoo

#

Either way ima just focus on my shit you guys do you

quartz kindle
#

@lusty dew also, your code is trying to multiply ore by 1000, which is the same as doing "iron" * 1000

amber fractal
#

It's just a log. If you have the time to put a virus in a log file to execute on open, you have too much time.

west raptor
#

this is npm generated also

topaz fjord
#

npm is a virus mmLol

#

yarn is better

wooden lance
#

lol it worked

west raptor
#

valid point

lusty dew
#

@quartz kindle Okay, so I am assuming I would have to get the value the same way I did before cost[ore]? You said it is the specific ore so shouldn't that be like 2000 * 1000 if iron is set to 2000\

quartz kindle
#

yes

lusty dew
#

Okay makes sense

#

is there anything else you see wrong that I need to fix?

quartz kindle
#

cost[ore] + formula will most likely be wrong

lusty dew
#

Why so?

quartz kindle
#

if person has 1 ship, and the ship you're trying to buy costs 2000 iron

#

1 * 2000 + 1000 = 3000
cost[ore] + formula = 5000

lusty dew
#

wait what

#

how is it 1 * 1000 + 1000

#

I though it'd be 1 * 2000 + 1000

quartz kindle
#

woops

#

fixed

lusty dew
#

yea

#

so that means the cost for the next ship would be 4000

#

that is assuming they want the next ship level

quartz kindle
#

well, its fine, but its a different formula alltogether

grave mist
#

Should I ask here about bot development only? I got question related to html

quartz kindle
#

you can ask all development questions

lusty dew
#

It is development in general

grave mist
#

That's what the topic of the channel said that's why asked

#

So I'm making a website

#

And I want to make 1 section cover the whole page

lusty dew
#

What would be a better formual to use?

grave mist
#

Like when I go to the page, I will see one section with some texts and when I scroll, I should see another section with some texts so 1 section = 1 screenful or whatever you call it

quartz kindle
#

your decision. the original formula is supposed to increase costs by 1000 for each ship. the way you did it increases cost by 1000 plus the base ship cost

lusty dew
#

Hm

#

But I basically did the same as before

#

Oh wait

#

I see

quartz kindle
#

@grave mist so you want it to scroll automatically?

lusty dew
#

so doing cost[ore] + formula is includingthe base ship cost as well?

quartz kindle
#

or still have manual scrolling

grave mist
#

Manual scrolling

quartz kindle
#

then all you need to do is set your section to height: 100vh

#

@lusty dew yes

grave mist
#

What does vh mean

quartz kindle
#

view height

lusty dew
#

So what should I do differently?

#

just

#

if(this.resources[ore] < formula)?

quartz kindle
#

yes

lusty dew
#

Ah okay

#

Well I think the buyShip method is done

#

Thanks tim

grave mist
#

And btw, I used ```css
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
text-align: center;

lusty dew
#

Now I need to figure out the check for the resources

#

which shouldn't be hard

quartz kindle
#

absolute position removes the content from the document flow

earnest phoenix
#

you also can't have all styling be universal

#

have media queries

quartz kindle
#

to center an element is better to use css display: block; margin: 0 auto;

grave mist
#

Yea, but I mean the center of screen

quartz kindle
#

vertical center too?

grave mist
#

Yea