#development

1 messages · Page 76 of 1

earnest phoenix
#

and you got punished

#

"I didnt dm him out of the blue, we had been talking before." Meaning, I didnt message him from the server.

#

they were in my past dms

#

It went over my head

#

I deleted the invite immediately anyways

solemn latch
#

👀 I don't see this on record anywhere.

#

It sounds like this may have been mishandled.
But it seems it didn't happen from the account you're on. Do you mind dming me the user ID this happened with so I can look into it.

earnest phoenix
#

we need to learn java or javscript for discord ?

#

Oh

earnest phoenix
compact pier
#

but javascript support more things (i guess)

#
earnest phoenix
lyric mountain
lament rock
#

nah djs has full coverage

#

I also saw fake in my room after I told him he had a skill issue

#

On an unrelated note, I'm trying to dive into procedural generation in C#, but the runtime I'm using is super limiting in what it can do so I find myself struggling.

#

The runtime compiles the C# into asm for the runtime which mostly comprises of EXTERN calls which are expensive to make and can destroy cpu performance

#

the vm has no math interpreter, so all math is EXTERNed

lament rock
sudden geyser
#

don't fight me kid

boreal iron
#

Also just because I'm driving 24/7 doesn't mean I'm always driving

earnest phoenix
#

Hey, this is my ready.js file.
My bot don't show the activity status. Plz help!!

module.exports = {

    name: 'ready',

    once: true,

    async execute(client) {

        console.log(`✅ Bot is online.`);

        client.user.setPresence({ activities: [{ name: `Yo boi`, type: `PLAYING` }], status: 'dnd' });

    },

};```
#

My d.js version- 14.7.0

lyric mountain
slender wagon
#

hello so i am using typescript nextjs
and for some reason when i try to link an css element to html i get an issue

={styles.btn-hover}

whenever there is a - it throws an error

boreal iron
#

It makes much more sense to export your events in modules, too to organize your structure

#

Instead of putting your stuff into 5000 lines of your index

boreal iron
boreal iron
earnest phoenix
boreal iron
#

Oww my brain

quartz kindle
#

to use names with dashes you have to use the bracket syntax

#

styles["btn-hover"]

slender wagon
#

ohh right

#

thanks :)

quartz kindle
lyric mountain
boreal iron
sharp geyser
#

Figured it out

boreal iron
#

It's called consistency

#

Either you follow your own structure consistently or just code inconsistent crap

sharp geyser
#

Right so fake youre a pretty smart guy right?

boreal iron
#

sometimes

sharp geyser
#

I have a question

boreal iron
#

Pay first, please

sharp geyser
#

More of a logical one on how I should tackle this issue I am having

#

If your information is good enough I will give 2 doll hairs

#

Now then

#

I have a class, this class will end up having a decorator that specifies that its a "controller" aka a router. This controller takes in a path so /users -> example.com/users
Now the methods of the class will have decorators as well specified how it should handle the execution e.g a post request to /:id -> POST example.com/users/:id

How should I handle attaching this metadata to the class so I can use it later on.

#

I know for classes Ican just do smth like class.constructor.path = pathTheyGave

#

but as for methods of the class I have 0 clue on what I can use to attach to the class method

#

Oh bet

#

I can just do the same

#

nvm problem solved thank you come again

#

@quartz kindle

        const classMethods = Object.getOwnPropertyNames(Object.getPrototypeOf(this))
            .filter(n => n !== 'constructor')
            .map((key) => this[key])

How does this look mmLol

boreal iron
#

Why do need to get the classes' methods like that?

boreal iron
sharp geyser
#

but this is all I could come up with

boreal iron
#

But still why is that needed?

sharp geyser
#

Cause the class is a controller that has a router attached to it, and the methods are the router handlers

#
const {Router} = require('express')


function controller(path){
    return function(target) {
        target.constructor.prototype.path = path
        target.constructor.prototype.router = Router()
    }
}

function post(path){
    return function(target) {
        
    }
}

@controller('/api')
class OlogyRouter {

    constructor() {
        const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(this))
            .filter(n => n !== 'constructor')
            .map((key) => this[key])
        console.log(methods[0])
    }

    @post('/hello')
    hello(req, res) {
        res.send('Hello')
    }

}

module.exports = { OlogyRouter }

This is essentially what i am doing rn

#

OlogyRouter is a controller with the path /api the hello method is a post router that will corrospond to ``/api/hello`

#

Right now I am trying to figure out how to register the router with the post decorator but realizing I can't use any class properties from the decorator for some reason

sage bobcat
#

One message removed from a suspended account.

sharp geyser
boreal iron
#

Weirdos

sharp geyser
#

@boreal iron Here you go

#

Now go find one

lament rock
sharp geyser
#
// Include the necessary headers and namespace declarations
#include <iostream>
#include <cstdio>

using namespace std;

// Define a kernel function to compute the square of a number
int square(int x) {
  return x * x;
}

int main() {
  // Read a number from the user
  int n;
  cout << "Enter a number: ";
  cin >> n;

  // Compute the square of the number
  int result = square(n);

  // Print the result
  cout << "The square of " << n << " is " << result << endl;

  return 0;
}
#

provided by ChatGPT

wheat mesa
#

me when you should inline int square(int x)

sharp geyser
#

lol

sharp geyser
wheat mesa
#

totally not using it to generate a websocket implementation for a chatting app backend

sharp geyser
#

I literally asked it how to do it in rust

#

it crashed in the middle

#

got rate limited

boreal iron
sharp geyser
#

Then be lonely forever

boreal iron
#

Yes

bronze heath
#

How to create image

rocky hearth
#

What is the best alternative to fakerjs?

plain coral
#

Does anyone know developer for PHP page? but since i need that guild discord i can see.

earnest phoenix
#

Why this is not working in v14?

const { Util } = require('discord.js');```
earnest phoenix
surreal sage
#

If you look at the attached video you can see a horizontal progress tracker
The progress on this tracker would be the amount scrolled in percentage (halfway thru the page: 50%)
How do I do the math so the tracker is on max width when the page is fully scrolled?

    await waitForElm("#progress-tracker");

    function update() {
        const scrolled = window.scrollY;
        const max = document.documentElement.clientWidth;
        document.getElementById("progress-tracker").style.width = `${scrolled}px`;
    }
    update();

    window.onscroll = update;```
#
document.getElementById("progress-tracker").style.width = `${(scrolled / max) * 100}%`;```
possibly?
#

that should do it yeah

#

actually no

#

(max scroll)

#
function update() {
        const scrollAmount = $(window).scrollTop();
        const documentHeight = $(document).height();
        const windowHeight = $(window).height();
        const scrollPercent = (scrollAmount / (documentHeight - windowHeight)) * 100;
        document.getElementById("progress-tracker").style.width = `${scrollPercent}%`;
    }```
did it, all good now
tall lance
#

is youtube music allow on discord again?

lyric mountain
#

it's the other way around

#

youtube itself doesn't allow their content to be played through non-official players

earnest phoenix
tall lance
earnest phoenix
#

Ya

tall lance
earnest phoenix
tall lance
south fractal
#

Built a music bot using the napster api. Cant see why or how it would go against their terms of use. Haven’t gotten a response from them via email yet but its been working well from the past month. Are there any other known bots which use napster?

lyric mountain
#

youtube itself doesn't allow external players

#

ah wait, napster is a streaming service

#

This Terms of Use Agreement (“Agreement”) is a legally binding and valid agreement between you (“you” and “your”) Napster Music Inc. and either Napster Luxembourg S.à r.l. (if you live in Europe), Napster do Brasil Licenciamento de Música Ltda. (if you live in Brazil), Napster K.K. (if you live in Japan), or Rhapsody International Inc. […]

#

but since they do have an official api for intergrating their streaming service in third-parties, I think they do allow it

lyric mountain
south fractal
#

oh yea the tos, i am aware, are there any known bots who use (or claim to use) the api tho?

lyric mountain
#

doesn't matter

#

there were many big bots that used youtube, doesn't make it more "legal" in any way

#

rely only on the official documentation, if it says "you are allowed" then that's enough approval for usage

south fractal
#

fair

#

doesn’t answer my question but..that works

lyric mountain
#

the answer to your question is the ToS itself

#

read it, see what it says "you cant" and what it says "you can"

south fractal
radiant kraken
#

i must be drunk or something what the hell is happening

#

@earnest phoenix

earnest phoenix
#

its in an array

maybe thats why?

#

try logging y.raw

radiant kraken
#

oh wait one of the objects doesnt have a raw attribute

#

stupid me

radiant kraken
#

@earnest phoenix please fix the ansi color encodings in Node.js stack traces

#

they dont work in windows

earnest phoenix
#

Not all terminals support ANSI color code highlighting

radiant kraken
earnest phoenix
radiant kraken
#

im sure it does

#

i dont use the windows terminal cuz its slow

earnest phoenix
#

Nobody really uses the CMD anymore, only either PowerShell or Windows Terminal

radiant kraken
#

console.log works, but not Node.js' internal exception stack trace for some reason

#

lots of people still use CMD

#

PowerShell is slow as fuck

earnest phoenix
#

Neither of those are slow whatsoever unless you're using an ancient computer

radiant kraken
#

i am just using a low-end laptop

#

still, this bug has been going for years now

earnest phoenix
#

i use cmd all the time

radiant kraken
#

so true

#

cmd do be fast tho

vestal tundra
#

How i can fix interaction.reply is not a function error?

neon leaf
#

@lyric mountain are you sure I should just hash passwords? shouldnt I salt them aswell?

vestal tundra
#

the code

solemn latch
vestal tundra
#

its same with interaction.reply

#

this still does not work

lyric mountain
#

hashes are already irreversible

#

you literally cannot find out what the original content was except for brute force, and that'd take more time than Earth has left

solemn latch
lament rock
#

There are server farms dedicated to this that can crack less strong hashing algorithms.

#

some new amd cpus came out with 96 cpu cores and they are stronk

boreal iron
#

oh god

solemn latch
vestal tundra
#

Its in line 17

boreal iron
#

No... he means where you gonna call it

vestal tundra
#

um line 17

boreal iron
#

you gonna call interactionRun(...) somewhere within your interactionCreate event

#

(or event handler/command handler)

#

If the error says interaction.reply() isn't a function it means the passed parameter interaction probably isn't an interaction (instance)

#

actually a ChatInputCommandInteraction it seems like

boreal iron
#

So either show us where you call interactionRun(...) or log the parameter interaction yourself to see what it is

#

yeah gimme a sec

boreal iron
#

right after async interactionRun(client, interaction) { put console.log(interaction);

#

And show the result to me

#

or show this to me

#
  // Slash Commands
  if (interaction.isChatInputCommand()) {
    await commandHandler.handleSlashCommand(interaction);
  }
vestal tundra
#

wait

#

{
settings: {
data: {
name: 'NoobBot',
region: 'en-US',
owner: '782224893780557854',
joinedAt: 2022-09-20T18:49:08.780Z,
bots: 0
},
stats: { xp: [Object] },
ticket: { limit: 10, categories: [] },
automod: { strikes: 10, action: 'TIMEOUT', wh_channels: [] },
invite: { ranks: [] },
max_warn: { action: 'KICK', limit: 5 },
welcome: { card: true },
suggestions: { staff_roles: [] },
_id: '1018432526798303274',
prefix: '!',
counters: [],
__v: 0
}
}

boreal iron
#

Well yeah, that's not an interaction instance

#

looks more like a database result

vestal tundra
boreal iron
#

Yes, once again interaction is not an instance of an interaction

#

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

#

The parameter interaction is not an instance of an interaction

#

whatever you copy and pasting together isn't doing the job like u think

#

the parameters don't magically become what you name 'em after

#

sadly

surreal sage
#

How would I access the footer as the script in this situation?

quartz kindle
#

scripts have access to the entire document from anywhere

surreal sage
#

Yeah but access the parent element?

quartz kindle
#

theres no such thing

surreal sage
#

Ight

quartz kindle
#

js sees the entire document through the document variable

#

no matter where the script tag is

surreal sage
#

ight

slender wagon
#

so i can use anything made of react on next.js

#
#

useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
slender wagon
#

any idea why the buttons aren't showing in 1 line

#
.button {
  position: relative;
  display: inline-block;
  padding: 15px 30px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-decoration: none;
  font-size: 20px;
  overflow: hidden;
  transition: 0.2s;
  margin: 10px;
}
lofty cipher
#

How can i get a 5% from a number?

boreal iron
#

number * 0,05

lofty cipher
#

Thanks

#

Danke

lyric mountain
#

put a background color in the parent div to see its size

slender wagon
#
.main {
  min-height: 100vh;
  padding: 4rem 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

found the parent div since i was using an already made template (simple) the display: flex i was using ruined it

#

i removed the flex but i can't seem to center the buttons

#

maybe cuz they are both using the same class

#
<a href="" className={`${styles.button} ${styles.one}`} target="_blank">Leo</a>
        <a href="" className={`${styles.button} ${styles.three}`} target="_blank">Fire</a>
#

the class one and three only changes the colors

dry siren
#

you could have done flex-direction: row; no?

slender wagon
#

i want them in one line

#

not like this

#

oh

#

the main div includes more than this

#

would placing another div over this fix it?

dry siren
#

well "row" should put the children in one line

slender wagon
#

yes yes

#

i just tried it

dry siren
#

hmm

slender wagon
#

worked now

#

i made a seperate div

#

just for the buttons

earnest phoenix
#

What's the best way to enforce a downtime page? I've got the code for the downtime page. But if the user disables the site javascript, they can go to any part of the site and bypass the window.location.href = "downtimepage.html"; page. This is all for a website btw

spark flint
#

Getting error: no member named 'AccessorSignature' in namespace 'v8' when installing node-canvas on Mac M1. Google hasn't provided much help. How can I fix?

boreal iron
#

If you include the same (down status) page in your backend no matter which site the user tries to access in the frontend then this is save

#

Also navigating through your sites by using their file names as part of the url is... well nothing you do nowadays

#

U usually use query parameters to get the current site as well as using them in your anchor elements (links)

#

RewriteRule(s) are also a nice way to deal with this

#

For example a folder like structure redirecting to the source

#

...org/home/news/latest -> ...org?site=home/news#latest

#

Depending on the amount of "folders" you could also add more query parameters or whatever

#

I actually prefer this way nowadays

#

It's also good to hide your engine

#

...org/home/news -> ...org/something.php?site=home/news

#

Or .ejs or whatever it is called

#

or .apsx

earnest phoenix
#

Alr ty

boreal iron
#

Which hasn't much to do with the initial question anymore

#

But yeah

earnest phoenix
#

Still helps lmao

#

thanks

boreal iron
#

But once again make sure to include your down time file no matter what the location (url) the user browses

#

In the backend

#

To ensure there's no possibility of a bypass

earnest phoenix
#

Alr

boreal iron
#

Somebody who understands its beauty

sharp geyser
#

It seems boring asf to use

#

I also dont know much about it even though I hate on it to annoy you

boreal iron
#

Wdym it seems boring?

#

Which language is "surprising" and idk the opposite of this?

sharp geyser
#

C++

#

you bang your head against the wall every time you use it

sharp geyser
#

tell me how to use php so I can use it and see if I would ever use it again

boreal iron
#

Only if you gonna pay me

sharp geyser
#

Okay then ima not use php

boreal iron
#

lol

#

Go to php.net and read the like 50000 sites long introduction

#

This will help to get in touch with it

sharp geyser
boreal iron
#

lmao

#

Yea

sharp geyser
#

Nice

boreal iron
#

There are so many abstract projects nowadays

#

I don't even know half of it

sharp geyser
#

fuck it ima learn ruby

boreal iron
#

With the base extensions you can do like already anything you need

sharp geyser
#

Can I order dominos pizza ?

boreal iron
#

Yes

#

But you don't want to

#

I heard it sucks

radiant kraken
#

can someone optimize this algorithm i wrote yesteday ```js
// array is le array of numbers
function detectSequences(array) {
let curr = null;
let prev = NaN;
const sequences = [];

for (const elem of array) {
if (elem === (prev + 1)) {
if (!sequences.some(x => x.code === curr)) {
curr = prev;
sequences.push({
code: curr,
plus: 0
})
}

  for (let i = 0; i < sequences.length; i++) {
    if (sequences[i].code === curr) {
      sequences[i].plus++;
      break;
    }
  }
} else {
  curr = null;
}

prev = elem;

}

return {
sequences,
rest: array.filter(x => sequences.every(y => x < y.code || x > (y.code + y.plus)))
};
}

sharp geyser
#

@wheat mesa your area of expertise

radiant kraken
#

it's a function that takes inputs in the form of things like [1,3,4,6,8,9,10] and return { sequences: [{ code: 3, plus: 1 }, { code: 8, plus: 2 }], rest: [1, 6] }

sharp geyser
#

@earnest phoenix @quartz kindle your area of expertise trollface

sharp geyser
#

fail

radiant kraken
#

ill just ask someone else

earnest phoenix
#

thank you for understanding

sharp geyser
#

my brain too smol

radiant kraken
radiant kraken
#

but i'm sure the code along with my description is clear enough for some people to understand

earnest phoenix
#

tf even is a sequence

sharp geyser
#

sequence is a pattern of some sort iirc

radiant kraken
#

thanks for the explanation

sharp geyser
#
from flask import Flask

app = Flask(__name__)

@app.route('/', methods=["POST"])
def stinky():
    return 'Null, Stinks'
radiant kraken
#

no

dry imp
#

disgusting

plain coral
#

no need "py" but only is cpanel and active bot run python "py"

#

but no have run python

#

and only is "php"

radiant kraken
#

js

earnest phoenix
plain coral
#

@earnest phoenix sorry ping you experience "php" or think only js?

radiant kraken
#

can you optimize that

earnest phoenix
sharp geyser
#

I don’t think fake wants to deal with him anymore

earnest phoenix
#

Almost everything FakE says is sarcasm as they said it themselves, so not too fond to deal with them that much

radiant kraken
earnest phoenix
earnest phoenix
rocky hearth
#

if I set tsconfig target to esnext, would it wont be able to support older browsers?

novel snow
#

Hello there, I am running into an odd issue, this is unexpected behaviour when calculating a formula, the expected outcome is not the outcome I am recieving, using a handheld calculator, and wolfram alpha and google calculator, all of which show the same expected result, except when implemented in Node JS.

Does anyone have any idea what might be wrong? Thanks in advance.

      //1/1+10(^(Rb-Ra)/400)
      //1/1+10(^(1500-1500)/400)
      console.log(1 / Math.pow(10, (1500 - 1500) / 400));
      //expected outcome is 0.5
      //outcome is 1
earnest phoenix
rocky hearth
#

1500 - 1500 is 0

#

0 / 400 is 0

earnest phoenix
#

Even newer browsers may not support it because it's for the next unstable JavaScript standards

novel snow
#

I know, the fact remains that if you calculate the same formula anywhere else you get 0.5

radiant kraken
#

what about my algorithm thingy

#

just tell me what needs to be optimized

earnest phoenix
#

volt ur aboutta get cancelled

radiant kraken
#

triggered 99% of the programming community

rocky hearth
#

js is religion

sharp geyser
#

I only use js out of necessity now

#

Other than that I use c++, now I’m starting to use python as well

sterile brook
#

js is '0' != []

sharp geyser
#

It’s true

sterile brook
#

But [] == 0

sharp geyser
#

Ofc

sterile brook
#

And '0' == 0

sharp geyser
#

Because it’s empty which is false

earnest phoenix
#

arrays are objects

sterile brook
earnest phoenix
#

null is object

#

everything is an object

sharp geyser
#

I didn’t even know I was replying tf

earnest phoenix
#

💀

sterile brook
#

Brackets powaaa

sharp geyser
sterile brook
sharp geyser
#

Idk why you’d ever want to but not a lot of people know you can cause they never pay attention to basic js

earnest phoenix
#

voltrex prob hates me for making json to js and vice versa

sharp geyser
#

Have you seen how I register express routes?

earnest phoenix
#
{
  "console": {
    "log": "('hello world')",
  }
}
#

this is how itd work

sharp geyser
#

That’s not bad

earnest phoenix
#

yes but

#

its flawed

#

and very shid

sharp geyser
#

All it is just looping over it and using properties

#

though I imagine doing classes would be a bit hard

earnest phoenix
#

im worried about volt

#

hes gonna explain that 0 == [] lore

#

and im pretty sure its gonna be longer than the distance of moon to earth

sterile brook
earnest phoenix
# radiant kraken <@456226577798135808>
function extractSequences(arr) {
  const sequences = [], rest = [];

  for (let i = 0, curr = null, ref = null; i < arr.length; i++) {
    const n = arr[i], next = arr[i + 1];

    if (curr !== null) {
      if (next === curr + 1) {
        curr++;
        sequences[ref].diff++;
        continue;
      }

      curr = null;
      ref = null;
      continue;
    }

    if (next === n + 1) {
      curr = next;
      sequences.push({ num: n, diff: 1 });
      ref = sequences.length - 1;
      continue;
    }

    rest.push(n);
  }

  return { sequences, rest };
}

Benchmarked, 600 milliseconds for 999k iterations, tested between multiple algorithms and this is the fastest one for exactly what you want

#

fucking damn

#

thought you were writing lore but nope

#

I avoided keeping an actual reference because that stops a certain pass we have in V8

earnest phoenix
# earnest phoenix hes gonna explain that 0 == [] lore

The simple explanation is the type casting and coercion of all primitive types and objects, the non-strict equality operators try to coerce both of the left-hand side and right-hand side values to each other's exact type, going by that example, the empty array (right-hand side) being coerced to an integer due to the type mismatch compared to the 0 integer (left-hand side), array-to-integer coercion returns it's length

#

knew it

#

There are many many different coercions depending on the type

earnest phoenix
#

I cancel you

earnest phoenix
earnest phoenix
earnest phoenix
plain coral
#

Error problem solution:

#
async def whois(ctx, *, user: discord.Member = None):```
#

"ValueError: 'Whois' must be all lower-case"

radiant kraken
#

how is it not clear enough

earnest phoenix
#

null

#

never question people not being able to read

spark flint
#

lol

rocky hearth
#

@earnest phoenix Why oopsGlobal is a global variable?

function fun1() {
  oopsGlobal = 5;
}
#

yes it works without that

#

yes, how?

earnest phoenix
#

volt getting too many bitches :trollface:

earnest phoenix
quartz kindle
# rocky hearth yes, how?

when you dont use var/let/const, you are implicitly telling js that you are editing an existing variable, so js starts looking for it and it goes up the scopes until it reaches the global scope, and when it still doesnt find it, it then assumes you want to create it and creates it there for you

rocky hearth
#

hmmm. But it shouldnt happen.

#

is this similar to how we can initialise a non existing key to an object?

quartz kindle
#

not exactly

#

js implicitly creating a global variable when it doesnt find an existing variable, is a remnant of the old js design that aimed to be as dynamic as possible, but today there are things like strict mode for example that fixes those possibly unwanted behaviors

#

if you run a script in strict mode, the global variable thing will not work

rocky hearth
#

oohk

quartz kindle
#

but objects are different, they are designed to be like dictionaries where keys can be created, deleted and initialized at any point with any value

rocky hearth
#

I thought oopsGlobal = 5, is same as window.oopsGlobal = 5

quartz kindle
#

that is more engine dependent than actual js design

#

window only exists in browsers, so its up to the browser engine to put it there or not

#

on node.js there is global

#

but global variables are not always automatically put there

#

its better to explicitly put it there using global.myvar = 5 if you want it there

#

in node, the global object can be accessed from all files, without having to use require/import

rocky hearth
#

ok cool, thanks

rocky hearth
#

I want to make a website to view pdf files.
Basically it will accept a url as a query param.
Then then display it properly.

How can I get started with this?

#

does anybody know of any react package for this?

quartz kindle
#

technically browsers already support pdf, so you could load the pdf in an iframe or something

lyric mountain
#

that's the equivalent of left-handed wrench

next storm
spark flint
next storm
earnest phoenix
#

Did you even read the first part at all?

spark flint
quartz kindle
#

lmao

quartz kindle
#

if you want to keep using v17, then you need to have built tools installed on your system, which include python and visual studio tools, in order to build the sqlite binary yourself

next storm
#

I guess i've completely lost my mind topgg_codebase

quartz kindle
#

18.12.1 is the latest LTS

next storm
#

I'm going up with 16.16.0

quartz kindle
#

16.19.0 is the latest v16 LTS

next storm
#

okay

lyric mountain
#

just go with v18

#

no reason to use older LTS

next storm
#

2 days ago it was working fine

#

but idk what happened today :/

boreal iron
#

Well then debug your code to see what's causing the error

next storm
#

yeah doing that only, but i dont think so that there's any error in my code, as the same code is hosted on my VPS, with node version of v17.9.0, but when I'm doing it on VSC, it's not loading the cmds

lyric mountain
#

u cant compare two environments with different versions

#

v18 is the latest lts, so it means you can go farther than v16 without needing to update so soon

boreal iron
#

Well if you already know which part of the code isn't working as intended then debugging goes way quicker

next storm
#

finally got it fixed
idk why my command loader wasn't working, so I've to make a new one using fs

boreal iron
#

I don't ask

eternal osprey
#

is this correct?

#

Because OLAP is analysis and OLTP is about transactions

#

In all these three we are not performing a transaction (insert, update) but analysis (reading)

quartz kindle
#

id go for the second option

#

the first and third are actual db queries, the second one is not

#

there nothing actually happening in the second one, its just a verbal administrative request

neon leaf
#

does anyone know if its possible to verify a uptime kuma webhook request? I can seeme to find an option to add like Authorization

neon leaf
#

oh, its last week so not released yet, ig i gotta wait then

sharp geyser
#

if its an npm package

#

you could just pull from the github

neon leaf
#

its a docker image (atleast thats how im usin it)

sharp geyser
#

npm install githublinkwherefeatureisavailable

#

oh

#

ic

earnest phoenix
#

Was merged into master branch, you can just build from source

sharp geyser
#

yea

neon leaf
#

is there any way to know how long a service has been offline with the webhook? is it heartbeat.duration?

sharp geyser
#

well a heartbeat is typically something that gets sent over periodically

neon leaf
#

in this case its the monitors status

sharp geyser
#

and heartbeat.duration is either the last it sent a heartbeat or the time it takes to send a heartbeat on an interval

neon leaf
#

and it isnt periodically

sharp geyser
#

then that doesn't make sense, a heartbeat is sent over to keep a connection alive

#

but ig this isn't websockets so idk

lyric mountain
eternal osprey
# quartz kindle id go for the second option

I see. I indeed changed it already. I now tend to see OLTP as small databases, that are not complex (so one single sql query would suffice). OATP more like big databases, that are complex and need multiple queries

#

Thnaks for the help !!

lofty cipher
#

Is this 5-8% from User money?

const random = Math.floor(perAdd(usereconomy.money, usereconomy.money / utils.randomNum(50, 80)))
earnest phoenix
#

Also, try it and see then debug and fix

sharp geyser
#

can you even divide like that to get a percentage

neon leaf
#

does anyone know if there is a way to send a custom webhook in gitea?

earnest phoenix
neon leaf
#

I cant find any option to send to custom url

#

oh, is it the gitea option?

earnest phoenix
#

Gitea supports webhooks for repository events. This can be configured in the settings page /:username/:reponame/settings/hooks by a repository admin.

neon leaf
lyric mountain
lyric mountain
#

or just value * (0...1)

#

where 1 is 100%

boreal iron
#

I wonder what schools are teaching nowadays

lyric mountain
#

nobody ever pays attention to calculus

boreal iron
#

Yeah I feel like that's right

lyric mountain
#

fyi, that's also called "rule of three", u can use it for linear interpolation and some other stuff like inversely proportional growth

earnest phoenix
#

It's the only rule you need to remember from math class

#

Hey! Plz help me!.
It's my server info and server icon code. The problem is that when I run these commands on a server with no icon, the bot crashes.
The catch err at the end won't work. Plz help!

Code- https://sourceb.in/DY52p5xAgY

lyric mountain
#

also congratulations, that's one of the worst formatting I ever saw

boreal iron
#

Comes close to Mr Bae ones

#

Wtf is that catch block

lyric mountain
boreal iron
#

When sending a follow up message failed then you send another follow up message

#

Without awaiting it anymore or catching if it fails

#

You should about that again

lyric mountain
#

so if it errors anywhere else in the code, it'll still crash

earnest phoenix
# lyric mountain show error

Ep

Received: 'null'

2 ExpectedConstraintError > s.string.url Invalid URL

Expected: expected to match an URL

Received: | 'null'

at UnionValidator.handle (/home/runner/ Test-bot/node_modules/@sapphire/shapeshift/ dist/index.js:1088:23)

at UnionValidator.parse (/home/runner/T

est-bot/node_modules/@sapphire/shapeshift/d

ist/index.js:201:88) at EmbedBuilder.setImage (/home/runner/

Test-bot/node_modules/@discordjs/builders/d ist/index.js:252:23)

at Object.execute (/home/runner/Test-bo t/Commands/Test/suuuu.js:22:14)

at Object.execute (/home/runner/Test-bo t/Events/interactionCreate.js:17:27)

at Client.<anonymous> (/home/runner/Tes t-bot/Handlers/event_handler.js:14:58)

at Client.emit (node:events:527:28)

at Client.emit (node:domain: 475:12) at InteractionCreateAction.handle (/hom

e/runner/Test-bot/node_modules/discord.js/s rc/client/actions/InteractionCreate.js:97:1 2)|```
earnest phoenix
lyric mountain
#

doesn't matter

#

it doesn't work now, that's the only important thing

#

so, check if the guild has an icon before setting a thumbnail

earnest phoenix
#

Can u plz help me so that the bot replies that the server has no icon.

lyric mountain
#

simply check if the url is null

earnest phoenix
lyric mountain
#

what's inside this, check before calling setImage

#

here too

#

and here

earnest phoenix
boreal iron
lyric mountain
boreal iron
#

Just check if the method returns something or null

#

method() ?? "no icon"

lyric mountain
#
let stuff = null
if (stuff) {
  // stuff isn't null/undefined/falsey
}
#

also may I warn you, this will never show the real values

earnest phoenix
#

Will this work?

const icon = interaction.guild.iconURL({ dynamic: true,  size: 1024 });

if (icon == null ) return interaction.followUp({ content: "The server has no icon!" });```
lyric mountain
#

errr...kinda

boreal iron
#

if(!icon) is good enough

#

Could also be undefined

#

(maybe)

#

Who knows the consistency of djs

earnest phoenix
lyric mountain
earnest phoenix
lyric mountain
#

there's ur answer

earnest phoenix
#

Testing rn

#

So how the f*ck I can show the real value?

Look the truth is- I am new in discord.js and I created stuff reading the docs.

boreal iron
#

You would need to fetch all this as it's not guaranteed to be cached (at any time)

lyric mountain
#

yep

#

and fetching all is a TERRIBLE thing

boreal iron
#

Which is just api spam imo

lyric mountain
#

first because api spam, second because memory issues

earnest phoenix
#

What about the icon problem?

lyric mountain
#

u already solved it didn't u?

earnest phoenix
boreal iron
#

If no icon is present you can not use it

#

That's how it is

lyric mountain
boreal iron
lyric mountain
#

just a bro tip, halt bot development for a while and study programming in general

#

like, I know making bots is cool and stuff, but there's no glory in being stuck staring at code you don't know what it does

solemn latch
#

a small understanding of programming makes bot development way more fun and interesting imo.

lyric mountain
#

copying code online does work but only up to a certain point, after that it starts snowballing hard

#

if you don't know how to properly glue code together u end up with a frankesntein that works only 5% of the time

ancient nova
#

hello bois

#

haven't been here in a while

lyric mountain
#

ohno

solemn latch
ancient nova
#

my main pc broke again this time the cpu failed

solemn latch
#

👀 what are you doing to your pc for it to keep failing

ancient nova
#

all i got is a old ahh laptop can't rly do much on it 🥲

ancient nova
#

i had the i3 for about 4 years , i'm gonna upgrade it soon for an i7 or an i9

#

wait why does every video i save on my phone on discord gets corrupted

boreal iron
ancient nova
boreal iron
#

Not to say that this strongly depends on the rest of the specs

slender wagon
#

Unless it was overheating all the time

ancient nova
#

all i have to upgrade now is my cpu and hopefully my pc will be alive again

ancient nova
#

it was overclocked

#

to the max

#

from like 2.6ghz to 3.6ghz

boreal iron
#

Once you upgrade the cpu you also wanna upgrade the ram

slender wagon
#

I wouldnt overclock a laptop that can barely breath

boreal iron
#

Oh a laptop

ancient nova
#

nope it was a pc that broke

slender wagon
slender wagon
ancient nova
#

the laptop i'm using now is because my pc is broken

boreal iron
#

So a pc then everything I said was fine

ancient nova
#

again

slender wagon
#

Ah

earnest phoenix
#

I honestly don't get why people overclock CPUs, like you don't even get much more out of it, barely a little bit more clock speed but that's it

ancient nova
#

should be fine

earnest phoenix
#

Overclocking is very bad for any kind of hardware

ancient nova
#

baking any kind of stuff on unity went by wayyy faster

#

sometimes a matter of hours

slender wagon
#

Oh Unity

#

That explains alot

boreal iron
ancient nova
#

its a pretty good engine

boreal iron
#

Nobody cares about if it's bad or not

earnest phoenix
#

Unless it dies out or damages something

boreal iron
#

Bullshit

slender wagon
boreal iron
#

Must be a bad sample then

earnest phoenix
#

It's the reason most people don't overclock, most of them also have no idea how to overclock either even then

boreal iron
#

Also im not increasing the core voltage

ancient nova
boreal iron
#

I'm just trying to push the hz to a stable condition without increasing the voltage

ancient nova
#

but mind it was already 3ish years old

#

and it lasted another 2.5 years

boreal iron
#

Which won't damage the cpu at all

ancient nova
#

with the overclocking

#

i changed the paste maybe twice or thrice the entire time i had that cpu

boreal iron
#

Even on 5.4GHz

earnest phoenix
boreal iron
#

You must be doing something wrong

boreal iron
ancient nova
boreal iron
#

I mean you can slightly increase it without getting too creepy

ancient nova
#

called "booster mode" or something similar

#

does anyone know what i'm talking about?

boreal iron
#

Things are pretty easy, if you don't know exactly what you're doing then don't do it

#

But yeah usually a cpu upgrade includes a ram upgrade which also requires a chip set update

#

If you wanna have something better and newer

#

Which means quite a lot of money

solemn latch
#

Thankfully last gen is still a good choice, but even that will be a full system upgrade.

boreal iron
#

Pff I would still buy a 9900k if the ram limits wouldn't be as sick

#

Nowadays you also wanna have ddr5

quartz kindle
#

always go for the cheapest possible current gen iteration

boreal iron
#

Shut up poor guy

quartz kindle
#

:^)

boreal iron
quartz kindle
#

seriously tho, top tier stuff is not worth it, entry and medium stuff is always more cost effective

#

top tier stuff is overpriced for very little performance advantage

#

plus it falls off very fast, and upgrades are very expensive too

boreal iron
#

Intel Xeon Platinum Gold is overpriced? Wtf 10k for a processor is cheap

boreal iron
#

If you wanna play games in 4K on high you will need a high end cpu, ram kit and gpu

#

But such a setup is not required for your guys weird anime booba bling bling games

#

Yeah who tf wants efficiency cores

#

We want performance!

#

No matter it takes 600W

quartz kindle
#

lmao

boreal iron
#

Also I dunno where's that price from but it's not 777

#

It should be around 400-500

#

iirc

quartz kindle
#

this one's single core is almost 2x faster than the 9900k

boreal iron
#

Tf hexacore

solemn latch
#

Much more common in the past 4-5 years

boreal iron
#

Trash

solemn latch
#

especially midrange

#

that 5.3 turbo speed though 👀

boreal iron
#

Let's be real what Intel pushes out of their architecture is brutal
AMD can only survive by choosing a much more modern technology

#

To reach like the same performance

solemn latch
#

👀 isnt that a good thing?

#

using more modern tech

#

Thats how they keep undercutting intel

#

on pricing

boreal iron
#

Imagine if Intel would switch to 4nm nowadays with their know how on what they pushed their last architectures

#

We would probably already have 9GHz cpus then

solemn latch
#

4nm intel cpus would be so expensive though

#

even with them being a fab

quartz kindle
#

AMD made a risky bet, and it paid off, got them back on the market, but intel still has the technical advantage, they are just behind schedule because AMD jumped several steps

boreal iron
#

Yes that's what I mean

quartz kindle
#

intel gen 13 is a beast

boreal iron
#

They can still beat amd here and there with a much older architecture

#

And a much older technology

quartz kindle
#

look at this beast

boreal iron
#

And when you remember how bad amd was like 10-15y ago especially their Java based drivers then you don't wanna switch to amd nowadays

#

Whatever people have to complain about intel but their consistency is great

solemn latch
#

that's kind of silly imo.

Judging a tech company from over a decade ago.

Most of the people here didn't know what a cpu was 10-15 years ago. some of them were not even born.

solemn latch
#

they have had 4 CEO's since then

#

4

boreal iron
#

Yeah

#

Still

quartz kindle
#

which means they are also quieter and colder

boreal iron
#

Which doesn't matter for me but yes

quartz kindle
#

its all that matters for me but yes

#

:^)

boreal iron
boreal iron
#

Even if Intel is moving forward slowly

quartz kindle
#

also, why the fuck would one pay thousands of bucks for a cpu when you have these

boreal iron
#

As they best AMD easily anyways

solemn latch
#

for home use? you done

#

dont

quartz kindle
#

server grade is so overexpensive

solemn latch
#

for server use you do

lyric mountain
#

how tf is that guy priced $573 in middle of two $3100 cpus?

solemn latch
#

Remember, those thousand dollar cpu's can have terabytes of ram, and 64-128 pcie lanes

boreal iron
lyric mountain
boreal iron
#

You should read about cpu ratings

solemn latch
#

if you need 128 pcie lanes, you have to use these cpus.

boreal iron
#

Especially when it comes to server cpus

quartz kindle
boreal iron
#

smh

#

Go get your cheap consumer cpu Tim

#

ENGLISH BROKEN

#

5 edits ffs

#

Which saves energy

#

Maybe it gives you energy back

#

Who knows

#

Core fusion cpus, putting 50W in getting 75W out

quartz kindle
#

check out this baby

solemn latch
#

chromebook cpu?

quartz kindle
#

lmao

boreal iron
#

Hmm laptop cpus are usually heavily limited when it comes to their enegery consumption

quartz kindle
#

if i were to build a desktop now, i'd go for a Ryzen 5 4500

boreal iron
#

But comparing them to desktop cpus isn't really fair

quartz kindle
boreal iron
#

Let's be honest if arm wouldn't have such a bad support it would be great to use it

#

Like the 84 core ones

#

Or even larger ones

#

Damn energy efficient

boreal iron
quartz kindle
boreal iron
#

brand new

quartz kindle
#

ultra cheap

boreal iron
#

You can get a 9900 for the same price

quartz kindle
#

a used one?

#

who buys used cpus

boreal iron
#

It just requires some luck to get a working one

#

Yeah

quartz kindle
#

lmao

#

tbh

#

cpus are usually pretty solid

#

unlike ram

#

used cpus should still work 10 years, used ram usually just bsods

boreal iron
#

Nah only thing I ever bought used were my gpus

quartz kindle
#

lol my gpus were literally the only things that broke on my old desktop

#

them and a couple ram slots on the mobo lol

boreal iron
#

1st had a hardware issue, back to seller, 2nd had the same issue, sent it to Asus, got a new card and sold it

quartz kindle
#

you know whats the saddest thing ever when it comes to building pcs? getting your gpu broken and not having enough money to replace it with a better one, so you have to replace it with a worse one

solemn latch
#

😔

boreal iron
#

And replaced it by an used 3080 which still had warranty

#

And it works great

quartz kindle
#

lmao

boreal iron
#

So guess I'm lucky

sterile brook
#

Used fake

boreal iron
#

You should have stayed in the eu

#

I would have bought you

quartz kindle
eternal osprey
#

how do i ghost reply to an interaction?

#

Like, i don't want any output, nor a fail nor a defer

#

no not like that

dry imp
#

i think interaction must be replied somehow first

#

damn imagine getting ghosted by a bot

quartz kindle
#

a slash command must be replied to

#

a button interation or other non-slash interactions can be ignored

eternal osprey
#

it's a button interaction

#

if i ignore it it will say interaction failed

minor olive
#

Well, I don't know why that's happening, but maybe a good way to get around it is to send an ephemeral message to the user confirming that they clicked the button. Something like, "Button clicked! This is what you did: ..."

lament rock
quartz kindle
#

^hey at least im fat, which means im getting tons of food

#

:^)

boreal iron
quartz kindle
#

give me a room, food, internet and 23 hours of alone time per day and im yours

lament rock
#

No bitches

boreal iron
#

No window, right ?

quartz kindle
#

xD

boreal iron
#

I take that as yes

#

Deal!

boreal iron
#

Without very good skills you won't get good money anywhere

#

ok then make sure to add as much references to your portfolio as possible

eternal osprey
#

never heard of it

#

i am using v13 btw

boreal iron
#

You can defer an interaction then delete it

#

If that's what u wanna know

#

In order to not respond to it

eternal osprey
#

i am rather trying to like, not reply to a button interaction

#

Oowh

boreal iron
#

(It still is a response of course)

eternal osprey
#

so it would be, interaction.deferReply(), interaction.delete()?

lament rock
#

type 6

boreal iron
eternal osprey
#

because i am creating a music bot

#

and have 1 static embed with buttons

boreal iron
#

At least send an ephemeral message saying whatever worked

eternal osprey
#

otherwise the user is flooded with those messages

lament rock
#

I would highly recommend against music bots but whatever. Read what I sent

eternal osprey
#

it has like 10 buttons or something

boreal iron
#

Ah well components not a command

#

Then use what Papi wrote

eternal osprey
lament rock
#

yes

boreal iron
#

Int 6, yes

lament rock
#

that's defer edit

eternal osprey
#

where's the usage of it stated as i only see the definition?

boreal iron
#

I assume djs has a method for it too

lament rock
#

POST /interactions/:interaction_id/:token/callback

{
type: 6
}

eternal osprey
#

post???

#

It's a button 🙈

lament rock
#

That's the HTTP request you make to respond with a defer edit

#

Djs has its own deferEdit method

#

or deferUpdate

#

whatever it is

solemn latch
#

👀 why are we giving a direct api response then

eternal osprey
#

oowh is it interaction.update()?

#

It takes parameters tho, so what should i input there?

lament rock
#

No update is type 7

eternal osprey
#

i am searching through the djs guide but can only find this .update() method

boreal iron
#

Technically without updating the original message the result should be the same

eternal osprey
#

strange taht you can't not reply to an interaction

boreal iron
#

For example updating an empty content

#

To an empty content

#

Will not cause discord to edit the message at all

#

(edited) will not be shown

eternal osprey
#

wah

boreal iron
#

You can for button interactions

eternal osprey
boreal iron
#

Not for other types

boreal iron
eternal osprey
boreal iron
#

You still have to tell the api that you don't wanna reply

solemn latch
#

ye

eternal osprey
#

how

boreal iron
#

Well Papi already explained how

#

I'm just not sure if djs had inbuilt methods for this

eternal osprey
#

hmm thats sad

boreal iron
#

You can also try what I told you

eternal osprey
boreal iron
#

Using updste() to edit the original message without updating it at all

eternal osprey
#

hmmm

boreal iron
#

For example updating an empty content

eternal osprey
#

so we could use interaction.update() without any parameters specified?

boreal iron
#

This is not what api expects but should also work

#

Not without

#

But with ({ content: "" }); for example

#

Unless your original has content

eternal osprey
#

I am basically hosting multiple music bots

#

they are connected through a simple express server

lament rock
eternal osprey
#

So the main bot that sends them to the other bots just needs to delete the interactions ig

boreal iron
#

But the method has the same name

#

As I can see

lament rock
boreal iron
#

Huh what ur link goes to main branch

#

Or is that a question?

lament rock
#

that wasnt a question

#

that was the answer they were looking for

boreal iron
#

yes and I added its also available for v13

#

Since your link goes to the main branch

#

Aka v14

lament rock
boreal iron
#

There we go

#

@eternal osprey

#

If you haven't noticed yet

#

Mr Papi has searched the deepest depths of the docs

lament rock
#

That was so easy to find it wasnt even funny

#

like I cant tell if you're trolling

boreal iron
#

But when you sent the link I remembered we had this a while ago already

#

But I couldn't remember anymore

#

Also what sort of trolling do you mean?

#

I wonder

#

I just said he's using v13 not the main branch

#

You have actually confused me more than I you I guess

lament rock
#

I meant Chitty

dry imp
#

lmao

quartz kindle
#

chitty chatty chit chat cheat sheet shit shat

boreal iron
#

Man Papi is more confusing than me

#

Didn't know that's possible

#

(and allowed)

#

So Tim... meanwhile I found a warm and dark room in my house you can live in

#

Even has cold water and electricity and internet

quartz kindle
#

oh my

boreal iron
#

Heating room

#

In between house and garage, yeah

#

But I will add some bars instead of the door to prevent Tim from running away make a save place for Tim

quartz kindle
#

xD

boreal iron
#

Yes I'm hosting my own blockchain, don't worry

lament rock
#

Lebron James Sprite cranberry shitpost.

// I have just one
const answer = await db.query("WANT A = $1", ["sprite cranberry"]);
console.log(answer); // clear
lament rock
#

This was a super powerful meme when it first came out

sharp geyser
#

lol

lament rock
#

If they dont reroll the ads for eternity I'll be pissed

radiant kraken
#

i love dealing with unicode

earnest phoenix
#

@radiant kraken you love decancer

radiant kraken
#

yes

#

because its one of my most popular projects

earnest phoenix
#

btw decancer is used in revanced bot

#

i told osumatrix about it months ago :teef:

radiant kraken
#

it has 52 stars now iara_uwu

radiant kraken
#

im currently working on a rewrite that uses binary search

earnest phoenix
#

o

radiant kraken
#

look at this beautiful mess

earnest phoenix
#

holy

radiant kraken
#

why are the projects that's hardest to maintain always get the most popular

earnest phoenix
#

fr

#

builder isnt hard to maintain but i cant rly maintain it

#

i can rn cuz i didnt go to school

#

because i cant 💀

rose warren
radiant kraken
radiant kraken
#

@earnest phoenix help my binary search is stuck on an infinite loop nevermind fixed it

crystal wigeon
#

hey umm

#

im wondering is there a way i can set a scope like an id for one specific execution instance which calls other functions

#

for example, lets say i have a logger configured and i want the logger ID to be same across multiple functions and change when there's a new request

#

keep in mind im not passing the req obj to all of these functions

#
    id
    constructor() {
    }

    setid(id) {
        this.id = id
    }

    log(text) {
        console.log("log id ---", this.id, text)
    }
}

const logger = new Logger()

const anotherFunc = () => {
    logger.log("something new another")
}

const boot = async (id, time = true) => {
    logger.setid(id)
    logger.log("before")
    if (time) {
        setTimeout(() => {
            anotherFunc()       
        }, 3000);
    }
}

boot(123)

setTimeout(() => {
    boot(555, false)
}, 2000)```


This for example. i want the logger id to be 123 when "anotherFunc" is called after 3 seconds even tho the id was set to 555 after 2 secs by another function call.
#

im sure this is incorrect, just want to find a way to implement this

#

or if its possible to do so. im sure there is a way cause google cloud logging does it when your app is running on their cloud run

quartz kindle
crystal wigeon
#

if i call new logger inside of boot

#

how will i be able to access it in anotherFunc?

quartz kindle
#

you create another logger there

crystal wigeon
#

but i want the id from boot and func inside boot to have same id

#

and not new ones

#

if boot is called once again only then have diff id

quartz kindle
#

you pass the logger instance as a function parameter

crystal wigeon
#

yeah thats what i wanted to avoid because then i will have to keep passing it into all of my inner functions

#

if there are more "anotherFunc"

quartz kindle
#

then put it somewhere you can access

crystal wigeon
#

that becomes a global object right?

#

which when there's a new request the id might be modified

quartz kindle
#

classes are meant to be created multiple times, and each instance will always keep its own id, it wont change

crystal wigeon
#

so if i call new logger without an id

#

it will have old id?

quartz kindle
#

no

#

it will not have one

crystal wigeon
#

mmm lemme try something ig

quartz kindle
#

what you're trying to do requires creating a context on which all your other functions run

crystal wigeon
#

yes

#

exactly

quartz kindle
#

thats usually done using a larger class that contains all your functions

crystal wigeon
#

mmm

quartz kindle
#

otherwise you will need to constantly keep passing the values

#

thats also known as funcional programming vs object oriented programming

crystal wigeon
#

i see

quartz kindle
#

functional programming is where everything is standalone functions, but all context needs to be passed as arguments to them

#

object oriented is usually classes and subclasses, where the context is always stored and accessed in some this

crystal wigeon
#
    id
    constructor(id) {
     this.id = id
    }

    log(text) {
        console.log("log id ---", this.id, text)
    }
}

export new Logger

This what i do? in a diff file

quartz kindle
#

dont export a new one, export the class and then create a new one in whichever context you need

#

if you want to go full object oriented, you would do something like this: