#development

1 messages · Page 1985 of 1

boreal iron
#

I remember we had this already last night

#

Ahh yes I’m about right

jaunty tundra
#

Hey, suppose if I have a file index.js that exports a few classes, and those few classes are used internally so is there any way I can like replace the original class with my modified one.
Example:
index.js

exports.Util = require("./Util.js");
``` `example.js` ```js
const { Util } = require("./index.js");
const util = new Util();
util.someMethod()

There is a package let's say x and there are a few packages y and z they need a method from the package x Util class that is someMethod, and the package x removed it from their package but the package y and z are still dependants on that method, so I created my own modified Util class now I want to replace it with package x's Util class so the package y and z can work properly

cinder patio
#
require.cache["utils"] = { someMethod: () => ... };
#

Or more like:

const Utils = require("utils");
require.cache["utils"] = {
   ...Utils,
   SomeClass: class { ... }
}
jaunty tundra
#

will this update the utils class in all the packages

cinder patio
#

it should

#

you should put the code before you require any of the other libraries

jaunty tundra
# cinder patio you should put the code before you `require` any of the other libraries

Lemme ask more simple discord.js has a class named Util.js it had a static method delayFor but removed in latest version and few of my friends packages were using that and I don't want to fork them and it manually I also used that method in some places of my code what I did is ```js
const { Util } = require("discord.js");
class extend Util {
static delayFor(ms) {
//something
}
}

#

I can't wait for them to patch it

cinder patio
#
const { Util } = require("discord.js");

require.cache["discord.js"].Util = class extends Util {
    ...
}
jaunty tundra
#
require.cache[resolve(require.resolve("discord.js").replace("index.js", "utils/Util.js"))]!.exports = require("./extenders/Util.js");
``` this?
cinder patio
#

wh-I literally sent you the code

cinder patio
#

maybe the one u sent is right

jaunty tundra
#

I am learning js so it might make me learn something new 😊

#

still didn't work lol

#
import { createRequire } from "node:module";
import { resolve } from "path";
const require = createRequire(import.meta.url);

// replace the original Utils class to add support for delayFor static method
import { Utils } from "./Util.js";
require.cache[resolve(require.resolve("discord.js").replace("index.js", "util/Util.js"))]!.exports = Utils;
cinder patio
#

why are you using ESM imports?

jaunty tundra
#

My project is ESM

cinder patio
#

Any reason for that?

jaunty tundra
#

Top level await

cinder patio
#

Not sure if you can modify the cache then

#

Are you requiring your library before using discord.js?

#

how are u using it

jaunty tundra
#
import "./extenders/index.js";
import "dotenv/config";
``` this is my index file
jaunty tundra
heavy marsh
#

<Random Stream Link>
Is there a possibility to fetch from the current playing songs using an api

pale vessel
#

sussy link

heavy marsh
#

Cause fetch only gives the name of the radio name

Headers {
  _headers: { 'content-type': [ 'audio/aac' ], 'icy-name': [ '100.3 KISS FM' ] }
}
heavy marsh
pearl trail
pearl trail
#

ohh sorry my bad, i thought you are trying to get the stream uri from radio's name

heavy marsh
#

to do that

#

but I am looking to get the current playing song for the command nowplaying

pearl trail
#

the result from what i search on google is, you need to record the audio for a few sec, and then use music recognizer API to find the nowplaying. because it'd be hard if the radio doesn't have api for the current playing song. article: https://softwarerecs.stackexchange.com/questions/2277/free-music-recognition-api

pearl trail
#

you need to find it by yourself one by one per radio station

heavy marsh
#

ooh

earnest phoenix
split hazel
#

no?

#

some radio stations transmit the song that's currently playing in the meta data

#

most popular stations do this

spark flint
#

It pretty much always says as the stream name

heavy marsh
#
Headers {
  _headers: { 'content-type': [ 'audio/aac' ], 'icy-name': [ 'Y100' ] }
}
split hazel
#

are you using an api to play radio

heavy marsh
#

yes

#

I use this to play @discordjs/voice

split hazel
#

not sure about apis then

#

because in low level radio specs stations often transmit the song name in the station name

#

so if you can grab the station name it could contain the song name (potentially - often delayed) if the api keeps track of that

#

otherwise the only way would be music recognition

#

it's probably delayed because they only announce the station name every once a while

quartz kindle
#

you need to request the metadata my setting a header in your request

heavy marsh
#
  url: 'https://n02a-e2.revma.ihrhls.com/zc561?rj-ttl=5&rj-tok=AAABfyGiUG4Acwq4bNv38pgVWQ',
  status: 200,
  statusText: 'OK',
  headers: Headers {
    _headers: { 'content-type': [Array], 'icy-name': [Array] }
  },
  ok: true,
  body: PassThrough {
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: null,
      ended: false,
      endEmitted: false,
      reading: false,
      constructed: true,
      sync: false,
      needReadable: false,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: true,
      destroyed: false,
      errored: null,
      closed: false,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: false,
      dataEmitted: false,
      decoder: null,
      encoding: null,
      [Symbol(kPaused)]: null
    },
    _events: [Object: null prototype] {
      prefinish: [Function: prefinish],
      unpipe: [Function: onunpipe],
      error: [Function: onerror],
      close: [Function],
      finish: [Function]
    },
    _eventsCount: 5,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      constructed: true,
      prefinished: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      [Symbol(kOnFinished)]: []
    },
    allowHalfOpen: true,
    [Symbol(kCapture)]: false,
    [Symbol(kCallback)]: null
  },
  bodyUsed: false,
  size: 0,
  timeout: 0,
  _raw: [],
  _abort: false
}
#

Full

quartz kindle
#

not the response headers

#

the request headers

#

the headers thay you send

earnest phoenix
#

Can I push items in mongodb? Like instead of increasing/decreasing, i'd like to push into an Array

quartz kindle
split hazel
#

also sorry but ima repost this

#

now this is what I call a productive framework

earnest phoenix
#

the bot reviewer tag is not meant for spacing

#

use flexbox with column

#

actually doesn't it automatically put it on the next line

split hazel
#

fuck you 😡

#

it takes a year doing it with css

#

I don't have the 🕒

split hazel
earnest phoenix
split hazel
#

no

#

besides i want different spacing at different elements

earnest phoenix
#

add align-items: stretch: justify-content: center for good measure

split hazel
#

and im not good at css

#

I HATE IT

earnest phoenix
#

same

#

but flexbox is awesome

earnest phoenix
#

lmao

earnest phoenix
#

did you know

.important.important.important.important.important.important.important.important {
// important styles
}

is actually LESS worse than

.important {
style: somestyle !important;
}
split hazel
#

why

earnest phoenix
#

because !important breaks the cascade while repeating selectors just increases specificity

split hazel
#

this is why css is cringe

earnest phoenix
#

take a look at the default button styles

#

or the insane amount of polyfills needed for IE

split hazel
#

this is why you dont choose web dev as a career

wanton stone
#

css is jus annoying pro

earnest phoenix
#
profileModel.findOneAndUpdate({userID: message.author.id}, {$inc: {silver: 1}})
``` will this work?
stiff lynx
#

How can I create a channel in a category?

#

with a command

#

discord.js

earnest phoenix
#

can we add arrays inside of objects?

wheat mesa
#

like ```js
{
test: [
{object}
]
}

#

?

earnest phoenix
#

kinda

#
{ common: [CARDS], rare: [], Epic: [], legendary: [] }
#

like that

wheat mesa
#

yes

#

you can do that

earnest phoenix
#

ok

#

tysm

wheat mesa
#

👍

earnest phoenix
#

if I push a variable with ``, will it push with backticks or ""?

wheat mesa
#

backticks and "" are the same thing, backticks just allow you to use string interpolation

#

they'll both be type string

earnest phoenix
#

so then the final array will have the double apostrophes?

wheat mesa
#

double quotes

#

""

earnest phoenix
#

yeah that

#

i'm moving my code to mongo

#

so i'll be asking a few more questions if needed

quartz kindle
#

is your bot using guild commands or global commands?

#

are you sure? show code

#

the command registering part

neat ingot
neat ingot
# earnest phoenix can we add arrays inside of objects?

With javascript everything is an object that can be manipulated. Strings are objects, arrays are objects, objects, are objects. you can manipulate objects almost any way you see fit. If you want to create an object that holds arrays of objects that hold arrays of strings. that is allowed.

#

if you want to create an array and then reference properties on it like you would an object. also allowed. ~ assuming the properties exist or you are creating them

hollow oak
#

hey could someone here convert a image of mine to the supported format for the background image

lyric mountain
#

like shinies or shit like that

hollow oak
#

and imgur

lyric mountain
#

have you tried uploading to imgur?

hollow oak
#

yes

neat ingot
#

just google image converter online?

hollow oak
#

then its says either png or jpg

lyric mountain
#

yes

neat ingot
#

what format is your file?

lyric mountain
#

imgur outputs both

lyric mountain
#

he's just missing the point

hollow oak
lyric mountain
#

show me the url you're trying

neat ingot
#

https://cdn.discordapp.com/attachments/272764566411149314/945713896486998036/2D3C7B62-BD88-42E4-92CA-5CDEADF3CED7.jpg

#

^ there ya go, jpg

lyric mountain
#

no

hollow oak
#

💀

neat ingot
lyric mountain
hollow oak
#

k

#

https://imgur.com/a/9ZSkreI

lyric mountain
#

that's not an image url

#

that's the imgur page url

hollow oak
#

soooo?

lyric mountain
#

open the image in a new tab

hollow oak
#

k

lyric mountain
#

THAT's the correct url

neat ingot
#

i think you can just remove the /a from the url to get the image url?

hollow oak
#

got it

lyric mountain
#

dekita, please

hollow oak
#

thanks

#

mr dekita

#

please go away

#

thanks

neat ingot
lyric mountain
#

did u get the https://i.imgur.com url?

#

or is it still https://imgur.com?

boreal iron
#
< HTTP/1.1 200 OK
< Connection: keep-alive
< Last-Modified: Thu, 17 Feb 2022 19:27:27 GMT
< ETag: "6422f31aacaa7abd04091218ac9cbc22"
< Content-Type: text/html
lyric mountain
#

...what?

hollow oak
#

https://i.imgur.com/2d8Ml6F.png

lyric mountain
#

yes

boreal iron
#

That's a valid image URL

hollow oak
#

ty

lyric mountain
#

fake tf?

boreal iron
#

TF TF

#

https://imgur.com/a/9ZSkreI isn't a valid image URL

lyric mountain
#

yes, it isn't

#

I did say it

boreal iron
lyric mountain
#

so I told him to open the image in a new tab

#

which would give him the correct url

boreal iron
#

Aha....

#

You weird Brazilian guy

lyric mountain
#

...fake, still drinking yeah?

boreal iron
#

Trying not to drink too much, Sir

lyric mountain
#

ara ara topggDoge

boreal iron
#

Just don't speak your weird Brazilian language

earnest phoenix
#

kya chutiyapa ho raha hai yaha par

earnest phoenix
earnest phoenix
earnest phoenix
#

lol

boreal iron
cinder patio
#

That's not gonna work out

neat ingot
lyric mountain
#

sourceid=chrome hmmmm

earnest phoenix
#

nope

#

it's microsoft edge

lyric mountain
#

damn google

earnest phoenix
#

well i searched it from ms edge

earnest phoenix
neat ingot
#

ms edge uses chromium.

lyric mountain
#

was just about to sell to tencent the info that you're a chrome user

#

my plans were foiled

neat ingot
#

tencent already knows dw

earnest phoenix
#

lmao

earnest phoenix
#

ultra cringe

#

chrome eats 10x more comparing to ms edge with all functions disabled (literally all) in a potato pc like this one

lyric mountain
#

pubg?

#

did tencent also buy pubg?

earnest phoenix
#

they literally MADE pubg

earnest phoenix
lyric mountain
#

they made freefire no?

earnest phoenix
#

well i'm going to pass my bot fastly to mongo or they'll fire me, bot's offline since 2 weeks

boreal iron
#

bot's offline since 2 weeks

#

That's why there usually is a production and development site

coral sigil
#

:D

earnest phoenix
boreal iron
#

Something you should consider doing smirk

neat ingot
#

docker helps make going from development to production really nice and easy 🙂

feral aspen
#
const blocked = new MessageEmbed()
.setColor(red)
.setDescription(`Hey there, unblock me please.`)

const blockedRow = new MessageActionRow()
    .addComponents(
        new MessageButton()
            .setCustomId('unblock')
            .setLabel('Unblock')
            .setStyle('SECONDARY')
    );

const m = await interaction.followUp({ embeds: [blocked], components: [blockedRow] }).catch(error => console.log(error));

const filter = (int) => int.message.id === m.id && int.user.id === interaction.member.id;
const collector = interaction.channel.createMessageComponentCollector({ filter, max: 1, componentType: 'BUTTON', time: 30000 });

collector.on('end', async (ButtonInteraction) => {
    ButtonInteraction = ButtonInteraction.first();
    if (!ButtonInteraction) {
        blockedRow.components[0].setDisabled(true);
        return await interaction.editReply({ components: [blockedRow] });
    } else {
        switch (ButtonInteraction.customId) {
            case 'unblock':
                const unblocked = new MessageEmbed()
                .setColor(black)
                .setDescription('Successfully unblocked the user.')

                return await ButtonInteraction.update({ embeds: [unblocked], components: [] });
                break;
        };
    };
});

Why are other people able to use the button when I specified it so the author can, only?

#

I've been stuck for about an hour trying to figure it out. :/

#

Only the author can interact the buttons, according to filter, although, other users can too?

boreal iron
#

wtf int.user.id === interaction.member.id

boreal iron
#

You need to check if the message author is the interaction user

feral aspen
#

I have a custom property in interaction.

#

I'm using interactions?

boreal iron
#

A button always trigger an interaction, yes

#

Better say, a buttin is an interaction

#

English failed

lyric mountain
#

the lost cousin of the russian president

boreal iron
# lyric mountain

Well I'm only working on the production site, too but I'm just not gonna build bugs into it

simple stump
#

I'm trying to edit the permissions for a channel, but for some reason it doesn't work. The users with that role flash for a second and the permission is added, but then it quickly goes away. I don't understand why this happens.

      message.channel.permissionOverwrites.edit(roleID, { VIEW_CHANNEL: true }).catch((err) => console.error(err));
      message.channel.permissionOverwrites.edit(roleID, { SEND_MESSAGES: true }).catch((err) => console.error(err));
      message.channel.permissionOverwrites.edit(roleID, { READ_MESSAGE_HISTORY: true }).catch((err) => console.error(err));

This is the whole command I use, but it's quite messy and inefficient.
https://sourceb.in/77cRjaMFMh

lyric mountain
#

also, use a single permission override for all 3

#

just add them in the permission object

bitter adder
#

I wanted White games to be inline with Black games
My approach was to set White to False so they do not fall into the above section. And Black games to true but that does not work

#

Anyone knows how?

boreal iron
#

They shouldn't inline with the top section as there's a thumbnail

#

I mean it's not much of a big deal to test it out

bitter adder
#

@boreal iron I did

coral sigil
#

discord with their embeds 😍

boreal iron
#

Oh okay, try to work with line breaks then

bitter adder
#

Mh okay

boreal iron
#

Try adding a line break after total games

#

(an unicode one)

bitter adder
#

Sad that there already is one

boreal iron
#

\n \u200b

heavy marsh
bitter adder
#

Same results

boreal iron
#

Ok then last method

#

Try to add an inline field after total games with a title and value using the unicode line breaks I wrote above

bitter adder
#

Okay thank you

boreal iron
#

One or two

coral sigil
boreal iron
#

The downside is the mobile view on white games which will be pushed down hard

coral sigil
#

The use of embed fields looks terrible on mobile, even without all of these "hacks"

#

for example the fields have a completely different amount of padding compared to desktop

boreal iron
#

Only way which will work I can think of, is to add whitespaces for rating and total games, to give both code blocks the same size

#

Shouldn't be much of an issue as the font is monospace

#

(only for the last line of the value field)

#

for accuracy and draws in this case

bitter adder
#

@boreal iron That did work

#

Thank you

boreal iron
#

np

#

Well you added the whitespaces on white games

coral sigil
#

I think it gets added automatically

#

If you look the first pic they sent

boreal iron
#

I personally would bring white and black games to the same size

bitter adder
#

I am trying

#

And the gap between field 1 and field 2

#

Does not look very pleasing

coral sigil
#

But doesn't do that in a sensible way

boreal iron
#

Well just add a "few" whitespaces behind total games, white games and black games, not too much on one field

#

You can also work with TABS for the numbers instead of whitespaces

#

To proper align them

#

There's an embed generator somewhere around you can play around with easily

bitter adder
boreal iron
#

Wanna play around with it real quick

lyric mountain
#

with a huge gap between 2nd and 3rd fields

#

also what's the deal with those roundy embeds?

bitter adder
#

Added one line of u200b

lyric mountain
#

canary?

lyric mountain
bitter adder
#

Just an fork of material discord

#

Okay, that looks terrible

lyric mountain
#

blame on discord for not supporting inline fields on mobile

#

half-assed work

bitter adder
#

With out the white spaces it would look decent on mobile

#

But really bad on pc

lyric mountain
#

since codeblocks are monospaced, try right padding with space every text

boreal iron
#

@bitter adder

#

On mobile:

earnest phoenix
bitter adder
#

I need to find a better formatting solution, since games might not always be the same

boreal iron
#

omg

bitter adder
#

discord 🤞

boreal iron
#

Just by using spaces and \t for TABS in code blocks

#

Works great as you can see above

solemn cipher
spark flint
#

is anyone here good at digitalocean spaces

#

because uh

#

its being cringe

earnest phoenix
boreal iron
#

Find it out yourself, idk I’m on mobile

split hazel
#

Is there a way to make Linux kill a program if it uses too much ram

#

I made a program to keep allocating memory in an infinite loop and Linux did nothing to stop it as it froze the whole computer until it completely froze due to exhausted memory + swap

earnest phoenix
split hazel
#

that's not the point 😡

lyric mountain
#

I mean, python, java, js, c# and alikes all die when passing a certain memory threshold

#

c and c++ don't have such managers

#

so they'll go until the pc says "enough"

earnest phoenix
#

enough, get a room you two

split hazel
#

right time to stretch my fingers

split hazel
#

linux has an OOM killer correct me if im wrong

#

when memory runs to a critical level it should start killing applications using the most memory (or whatever the algorithm decides) not crash the system

earnest phoenix
split hazel
#

I AM ON LINUX

earnest phoenix
#

cringe

split hazel
#

i think the OOM thing is just buggy

earnest phoenix
#

ok bye thanks for coming to my ted talk

split hazel
#

i see people using user space program killers because OOM is not doing its job

earnest phoenix
split hazel
#

if i was the OOM i would want to go out with a bang instead of letting a malicious program slowly freeze the computer completely

azure lark
#

how do i install @discordjs/opus on repl?

grim aspen
#

npm i @discordjs/opus in console

azure lark
#

gives big error

split hazel
#

what big error

#

there are many big errors

azure lark
split hazel
#

the error tells you what to do

#

You need to install the latest version of Python.

split hazel
#

just guessing so i can give you a command to run

azure lark
#

no

split hazel
#

oh right you're on repl

azure lark
#

yes

split hazel
#

uh they should have that preinstalled?

simple stump
#

How do you set the default permission of a slash command?

azure lark
#

thats wha i thought

boreal iron
split hazel
#

and there isnt a good way to file a bug report on linux

#

because its behind a giant brick wall where behind there hide the "linux maintainers"

lyric mountain
#

just modify the source code smh mmLol

split hazel
#

not a bad idea but its too small of a thing to do that over

#

i wonder why big projects like linux and kde dont make use of github

#

they only have read only mirrors of their code on there

#

wouldnt it be better if people could file issues and pull requests and a team of contributors could vote on them

#

kind of how it is on nodejs

#

something tells me they dont like people complaining

boreal iron
#

complaining bitching around

lyric mountain
#

try sending them an email

split hazel
#

one sec i wanna go on the "how to file a report" page but my dns is fucked up

boreal iron
#

Try calling @earnest phoenix - the tech support men everyone trusts

split hazel
#

linux automatically after every reboot gives me my ISP's dns server which is shit and never resolves domains

#

and idk how to change that

boreal iron
#

Changing the network target for it in the GRUB settings

#

To make sure they’re active on a startup

#

ISPs over here are blocking any kind of streaming services and other illegal shit, too

#

That’s the freedom of the net

split hazel
#

i think theres some command to do it but i dont understand how

#

like this keeps happening

boreal iron
#

You should change the default DNS servers in your router, the OS will then choose the default DNS server he got provided via DHCP

split hazel
#

on my router?

#

idk if i can even do that

boreal iron
#

Of course he’s the one redirecting your requests

#

And getting a no no from your ISP

split hazel
#

i think i might just change the dns at /etc/resolv.conf and write protect it so it doesnt get overwritten

boreal iron
#

You gotta edit your grub config

#

As I said

warm swan
#

async def get_prefix(bot, message):
    guild = message.guild.id
    try:
        with open(prefix_path, "r")as f:
            prefixes = json.load(f)
    except FileNotFoundError:
        prefixes = {}

    if str(guild) in prefixes:
        return commands.when_mentioned_or(*prefixes.get(str(message.guild.id), "."))(bot, message)
    else:
        return commands.when_mentioned_or(".")(bot, message)
    
angel = slash_util.Bot(
    command_prefix=get_prefix,
    intents=discord.Intents.all(),
    case_insensitive = True,
    help_command=None
    )

why the get prefix won't work?

#

what im trying to do is to check if the guild id is in the json.. if is not the prefix to be "."

#

even tho

#

return commands.when_mentioned_or(*prefixes.get(str(message.guild.id), "."))(bot, message) if the guild id is none "." should work too but it doesn't

split hazel
#

who said ubuntu?

boreal iron
#

THEN FUCKING PROVIDE THE INFOS SOMEBODY NEEDS TO ASSIST

#

ffs

split hazel
#

lmao alright FAKE

#

im on arch

#

and i think networkmanager manages my network

azure lark
#

why dose this not play audio? The bot joins the voice chat and says it is making noise but i cant hear it.




module.exports = {
  name: "play",
  aliases: ["pl"],
  usage: "play <song>",
  description: "play a song",
  run: async (client, message, args) => {




 let stream = ytdl("https://www.youtube.com/watch?v=QnL5P0tFkwM", {
            filter: "audioonly",
            opusEncoded: true,
            encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
        });


    const { joinVoiceChannel, createAudioPlayer, createAudioResource, StreamType } = require('@discordjs/voice');

 

const player = createAudioPlayer();

    const connection = joinVoiceChannel({
    channelId: message.member.voice.channel.id,
    guildId: message.guild.id,
    adapterCreator: message.guild.voiceAdapterCreator,
})
connection.subscribe(player)
      
const resource = createAudioResource(stream, {
  inputType: StreamType.Opus
});

    

    

    player.play(resource)

    }
};```
lyric mountain
azure lark
lyric mountain
#

but...not formatting will make it more likely for u to miss something

azure lark
#

oh

lyric mountain
#

btw, I don't see you passing volume anywhere

#

maybe it's almost mute for that reason?

azure lark
#

i tried but i got an error

#

i will show

#

resource.volume.setVolume(0.5);
^

TypeError: Cannot read properties of undefined (reading 'setVolume')

lyric mountain
#

shouldn't it be only resource.setVolume(0.5)?

azure lark
#

i just copied from the docs but ill try

boreal iron
#

Oof

lyric mountain
#

sometimes I wonder how agonizing it might be to code without intellisense (ctrl + space)

azure lark
#

ya, resource.setVolume is not a function

spark flint
#

how can i set content type with aws-sdk

lyric mountain
azure lark
#

54 matches

earnest phoenix
#
let lvl = profileData.infoCards.ownedCardLow.lvl;
``` what's wrong?
#

profileData is the found data in author's profile

#

all works but not this one

#

ownedCardLow is the random card's name lowered without spaces

#

it's like randomC.low so I made it inside variable

wheat mesa
earnest phoenix
#

ownedCardLow is just a variable containing the real "variable" (object).

#

I can't put literally randomC.low there right?

rough current
#

Anyone know why I am still getting the Invalid OAuth2 redirect_uri error?

wheat mesa
#

That’s not how it works

#

If you have an object, you have to access that object with its keys. You can’t do <Object>.variable, you have to do <Object>.keyname

quartz kindle
#

profileData.infoCards[ownedCardLow].lvl

#

if you want to use a variable as a key, it needs the []

wheat mesa
#

that

solemn cipher
simple stump
#

How do you set the default permission of a slash command?

lyric mountain
#

all urls are encoded by default

solemn cipher
lyric mountain
#

yes

#

all urls are already encoded lul

#

else they arent urls

solemn cipher
earnest phoenix
#

Hi

rough current
solemn cipher
earnest phoenix
#

What to do if the bot does not accept emoji that I enter while the bot is on the server where these emoji are used

#
const fetch = require("node-fetch")    
module.exports.run = async (message, bot, client) => {
  if (message.channel.type == "dm") return;
const { link } = await fetch('https://some-random-api.ml/img/dog').then(response => response.json());
  if (message.author.avatar == null) { avatar = bot.user.avatarURL(); } else { avatar = message.author.avatarURL(); }

  let embed = new Discord.MessageEmbed()
    .setTitle(`:online: Random Dogs`)
    .setColor(`#303030`)
    .setImage(`${link}`)
    .setFooter(`Requested: ${message.author.username}#${message.author.discriminator}`, `${avatar}`)
  message.channel.send(embed)
};```
#

code

rough current
#

It is still not working https://discord.com/oauth2/authorize?client_id=812781946907787304&permissions=8&scope=bot&redirect_uri=https%3A%2F%2Fcheerbot.crd.co%2F%23

earnest phoenix
solemn cipher
rough current
#

Oh my bad ty

solemn cipher
#

yeah if you dont use a redirect uri added in the discord panel it wont work, to prevent people from stealing your apps data

#

does it work for you now?

rough current
#

Do I need to add this link into the panel https%3A%2F%2Fcheerbot.crd.co%2F%23thankyou or is the non encoded one fine?

quartz kindle
#

the nonencoded one is fine

solemn cipher
#

use the nonencoded in the panel

rough current
#

It is not redirecting

solemn cipher
#

weird

rough current
#

No errors

#

Is just this link fine

solemn cipher
#

yeah

#

im looking into it now

quartz kindle
#

the link is fine, otherwise it would show the error from before

#

the authorization works fine too, just tested it

#

the redirect doesnt work, it stays on the authorized page

#

whats your redirection code?

solemn cipher
quartz kindle
#

pretty sure discord expects the redirect url to go through the auth flow, ie receive code, exchange for token, etc

earnest phoenix
#

What to do if the bot does not accept emoji that I enter while the bot is on the server where these emoji are used

quartz kindle
lyric mountain
#

ye

#

emojis only work specifically in description and field descriptions

#

anywhere else doesn't support

earnest phoenix
#

I just tried that one and it doesn't work either.

lyric mountain
#

how are u typing?

#

:likethis: or <:likethis:\24125124112>

#

ignore the bar there

pearl trail
earnest phoenix
pearl trail
#

response_type=code

rough current
pearl trail
#

website, mostly in backend, but you can do it in frontend iirc

quartz kindle
# rough current Do you need to write code in your bot or website?

Advanced Bot Authorization
Devs can extend the bot authorization functionality. You can request additional scopes outside of bot, which will prompt a continuation into a complete authorization code grant flow and add the ability to request the user's access token. If you request any scopes outside of bot, response_type is again mandatory; we will also automatically redirect the user to the first URI in your application's registered list unless redirect_uri is specified.

boreal iron
quartz kindle
#

meaning you need to add another scope besides bot, need to add response_type, and need the redirect url to support full oauth2 backend

split hazel
#
std::cout << sizeof(your_mother);
18446744073709551615
quartz kindle
#

huehuehue

spark flint
#

how can i get the amount of mentions in a message

#

discord.js

crimson vapor
#

message.mentions last time I checked djs

spark flint
crimson vapor
#

message.mentions.users.length

spark flint
#

also was undefined

#
MessageMentions {
  everyone: false,
  users: Collection(1) [Map] {
    '471409054594498561' => User {
      id: '471409054594498561',
      bot: false,
      system: false,
      flags: [UserFlags],
      username: 'big.bun',
      discriminator: '6969',
      avatar: 'a_54d448ed90a8f64758d5507c49761e58',
      banner: undefined,
      accentColor: undefined
    }
  },
  roles: Collection(0) [Map] {},
  _members: null,
  _channels: null,
  crosspostedChannels: Collection(0) [Map] {},
  repliedUser: null
}```
#

thats what gets returned

wheat mesa
solemn cipher
wheat mesa
#

there is no length property on that

spark flint
#

yep .size worked

crimson vapor
#

Assumed it was an array

spark flint
#

same lol

solemn cipher
earnest phoenix
#

it's giving "identifier expected"

timber fractal
#

is there any way how i could use npm modules completely fine without any errors or something in a browser, with web js

pale vessel
#

maybe use bower

earnest phoenix
timber fractal
#

option 2

crisp quiver
#

How can I fix this

dry imp
#

npm install skill

#

cuz i think it is a skill issue

pale vessel
#

check your package.json

#

make everything lowercase

earnest phoenix
woeful pike
#

the co in copilot stands for cope

timber fractal
earnest phoenix
woeful pike
#

making excuses for me

timber fractal
earnest phoenix
#

maybe you are loading the cdn script AFTER your actual code is loaded

timber fractal
#

that could be

#

a possible problem

#

but at the same time, i impor() the cdn in the js file before using it

earnest phoenix
#

that's the problem

#

the cdn script is loaded via a script tag and not import

timber fractal
#

alright

#

thank you

#

one other question

earnest phoenix
#

ask away

timber fractal
#

how would i hide credentials like passwords, or tokens, so my code can use them but visitors or other people cant see them

#

or find them

earnest phoenix
#

cookies

timber fractal
#

no but like tokens for api or a mongoose connection url

pale vessel
#

you use a backend 🧠

timber fractal
#

yeah and how

sick agate
#

uh

#

you simply cant hide that easily

timber fractal
#

isnt there like an easy way with file permissin

crisp quiver
timber fractal
sick agate
#

you can use it with rest api perhasps

earnest phoenix
earnest phoenix
#

yep

timber fractal
#

but how

earnest phoenix
#

99% of the time your mongoose connection string will only be used by your backend

crisp quiver
sick agate
#

no distjs

earnest phoenix
#

If you need the data on the frontend you use rest apis

earnest phoenix
crisp quiver
earnest phoenix
#

npm i cross-env?????????

crisp quiver
sick agate
#

you did npm

#

not npm i cross-env

crisp quiver
slender thistle
#

Lowercase i

#

I'm gonna keep quiet on your ability to follow directions

spark flint
#

Lol

split hazel
#

what does hydrating mean in terms of react

#

do you give react water

woeful pike
spark flint
#

Oh no not mathjs

pale vessel
#

Your bot's calculate command can be used to crash/restart your bot. Please fix, or remove this command entirely before resubmitting.
Due to this, your bot went offline during testing and became unresponsive.

spark flint
#

^

#

Also please just use a non replit solution

sick agate
#

yes

boreal iron
#

lmao

#

Must have been some complicated meth

crisp quiver
#

@earnest phoenix @slender thistle now how can I fix this module not found

spark flint
crisp quiver
sick agate
#

read the damn error message

#

download ts-node

lyric mountain
crisp quiver
sick agate
#

yes

cinder patio
#

why are you even using ts-node?

crisp quiver
#

{
diagnosticCodes: [ 5023, 6046, 5023, 5023, 5023, 5023 ]
}

#

TSError: ⨯ Unable to compile TypeScript:
error TS5023: Unknown compiler option 'useUnknownInCatchVariables'.

#

now how to fix this

pale vessel
#

ts-node DoordTroll

#

usually you don't need it for prod

cinder patio
#

They're not even using typescript

sick agate
pale vessel
#

aren't errors already unknown by default in newer ts versions?

#

guess it uses an older version

#

wait huh

#

never mind

crisp quiver
spark flint
#

i can tell you

#

don't use replit

split hazel
#

that is so mean

split hazel
azure lark
#

why can i not install @discordjs/opus on repl?

split hazel
#

i swear someone asked this exact question yesterday

#

i think it was you

azure lark
#

yes

#

nobody gave an answer

split hazel
#

uh i guess i'll give it a try

pale vessel
#

don't say skill issue

split hazel
#

if it doesnt work for me you should contact repl.it supoport

#

unless tim knows something about it

azure lark
#

ok

#

the error is to do with python

split hazel
#

i remember:)

#

@azure lark i got it to install

pale vessel
#

tell us your secrets

split hazel
#

right so to do this

#

you first have to go to file -> show hidden files

#

then go into a file called replit.nix

#

you need add the python package to it but its easier if you just copy and paste this into the file

    deps = [
        pkgs.nodejs-16_x
        pkgs.nodePackages.typescript-language-server
        pkgs.nodePackages.yarn
        pkgs.replitPackages.jest
        pkgs.python38Full
    ];
}```
#

then you run npm i @discordjs/opus again

#

be warned the installation might take a while

azure lark
# split hazel then you run npm i @discordjs/opus again
npm ERR! path /home/runner/bot/node_modules/@discordjs/opus
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! sh: /home/runner/bot/node_modules/.bin/node-pre-gyp: Permission denied
split hazel
#

huh?

azure lark
#

i can npm i @discordjs/opus and i got that

split hazel
#

can you run python3 -v in the console

#

just to confirm

azure lark
#

yes

split hazel
#

you sometimes do get permission denied errors

#

run it again

#

npm i @discordjs/opus

#

it get them all the time

azure lark
split hazel
#

nope as long as it prints the python version it works

#

just run the install command again

azure lark
#

it printed a massive block of text

split hazel
#

as it should

azure lark
#

okay

#

should i just keep trying npm i @discordjs/opus cuz i keep getting Permission denied

split hazel
#

thats odd it installed for me fine

#

try restarting the console?

#

/ refreshing your page

azure lark
#

ok

#

is it meant to say loading Nix environment

split hazel
#

yes

#

after it should say "reloaded shell env due to changes"

azure lark
#

still the same error

split hazel
#

thats weird

azure lark
#

maybe its cuz im doing it on a team repl

split hazel
#

do you mind letting me into your repl?

#

i can have a go

azure lark
#

ok

#

its a team repl

split hazel
#

yeah send me an inv

#

that is weird

boreal iron
#

you gotta be careful when inviting Speedicus

split hazel
#

alright fake

#

you would usually run sudo with the command to fix permission errors but obviously you dont have access to that

boreal iron
#

👍

#

Use sudo to create another sudo user

split hazel
#

@azure lark would it be better if you made a new project and tried it on there

#

you dont seem to have anything in your project anyways

azure lark
#

sure idm.

split hazel
#

yeah i dont think theres much you can do other than contact repl

#

make a new project on the team

azure lark
#

i have

split hazel
#

@azure lark i think its installing now

#

you have to give it a bit of time

azure lark
#

ok

split hazel
#

the cpus on there are slow

azure lark
#

yes

split hazel
#

the smoke from the cpu bar is accurately representing the cpu in real time

boreal iron
#

1 GB RAM pepowot

#

Poor djs cache

split hazel
#

lmao

#

@azure lark there we go its installed now

#

i'll leave you to it now and leave the team

azure lark
#

okay thank you

split hazel
#

uh how do you leave teams lmao

#

nvm did it

earnest phoenix
pale vessel
#

nah

#

!calculate 1:999999999999999999999999999999999

neat ingot
#

the formula function of that lib is pretty dope 🙂

neat ingot
carmine summit
cinder patio
#

Divides 1 by 9999999999999999999999999999999

carmine summit
#

So solution is to limit it to like 5-10 length?

wheat mesa
#

Aka it freaks out because that’s out of 64 bit float range

carmine summit
#

Or maybe cancel the promise if it runs for more than 100 ms

wheat mesa
#

It probably crashes quicker than that

lyric mountain
carmine summit
#

So what do you think is the proper fix for that?

#

Virtual environment?

#

With like 10mb memory

#

Is that even possible

lyric mountain
#

you could try reverse engineering the lib that I use

cinder patio
#

I don't think there's a "proper" fix

lyric mountain
#

you can safeproof it to a certain degree

carmine summit
#

If it runs for more than 1ms xd

split hazel
#

yeah you have to be careful with math calculation commands

#

either you give eval access or to allow someone to run a very computationally expensive operation

lyric mountain
#

see if you can find anything useful for ur case in it

#

ik, it's java but same concept applies

split hazel
#

i think in nodejs you can make worker threads now

lyric mountain
#

"threads"

split hazel
#

so you can run the math on a worker thread and if it takes too long kill it

#

well

#

kind of threads but they're still threads

#

pretty sure its on the thread pool

lyric mountain
#

they're pseudo-threads

split hazel
#

THEY STILL DO THE JOB

cinder patio
#

That's gonna be pretty slow

#

An entire thread just to do some math on

split hazel
#

why not freerealestate

lyric mountain
split hazel
#

you dont even have to kill it straight away

cinder patio
#

Spawning the thread is gonna take more time than doing the math

carmine summit
#

Threading is way beyond my knowledge, but ill keep this in mind when i probably need it in like 10 years

split hazel
crisp quiver
#

code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]

split hazel
#

you can just make it sit idle and assign it a math operation when needed

lyric mountain
crisp quiver
# lyric mountain install whatever it said that wasn't found

`npm i internal/preload
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/internal/preload.git
npm ERR!
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-02-23T14_41_06_174Z-debug.log`

wheat mesa
#

All you have to do is write the parsing

cinder patio
#

mathjs should have a "maxNum" option

lyric mountain
#

like, is it your bot?

crisp quiver
#

Yea?

#

And no

carmine summit
lyric mountain
#

yea because you cloned it, no because u didn't write right?

crisp quiver
#

It's a bot in type script

carmine summit
#

You probably need an api key from the developer portal from that site

lyric mountain
sudden geyser
sudden geyser
#

and just contacting them (assuming it's a rest api) will probably take longer

lyric mountain
#

can't u just invite the original bot?

#

like, maintaining someone else's source code is EXTREMELY hard

crisp quiver
wheat mesa
lyric mountain
#

and if the readme doesn't contain setup instructions, chances are the author didn't mean for it to be cloned

wheat mesa
#

Wolfram would allow you to do tons of complex things that would take ages and lots of mathematical knowledge to do on your own

lyric mountain
#

like mine, it's open-source but I wont teach u how to setup it

sudden geyser
#

but that begs the question of why even have a calculator command

lyric mountain
sudden geyser
#

if all your results will come from the same guy

lyric mountain
#

you'll just fall the falacy of "the bragger"

carmine summit
earnest phoenix
#

Discord multi-purpose bot developers trying their best to shove as many commands to their bots as they can, like bro open a fucking calculator

sudden geyser
#

Like, I've seen latex bots that can format a math expression and give you the answer, which is a lot more useful.

earnest phoenix
#

People can't be bothered to click a few buttons

wheat mesa
#

I don’t see the point in a calculator command, although I saw a math bot that takes results from wolfram and puts it into a nice visual representation

#

That’s probably about the only use for it though

lyric mountain
#

I have one because of my tcg

#

people use to calculate final damage

#

or plan before equipping cards

earnest phoenix
sudden geyser
#

so desktops will usually make it easier, like mac's spotlight

wheat mesa
#

Identifier expected usually means a syntax error

crisp quiver
# split hazel not sure because i dont use typescript but can you show us your tsconfig file?

{ "compilerOptions": { "target": "ESNext", "module": "commonjs", "moduleResolution": "node", "checkJs": false, "noImplicitThis": true, "noUnusedParameters": true, "traceResolution": false, "allowUnreachableCode": false, "outDir": "dist", "declaration": false, "importHelpers": true, "inlineSources": true, "newLine": "lf", "noEmitHelpers": true, "removeComments": false, "sourceMap": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "noEmit": false, "useUnknownInCatchVariables": false, "lib": ["ESNext", "dom", "dom.iterable", "ES2020.BigInt"], "strict": true, "noImplicitAny": false, "strictNullChecks": true, "alwaysStrict": true, "allowJs": true, "isolatedModules": true, "noUnusedLocals": true, "noImplicitOverride": false, "strictBindCallApply": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "useDefineForClassFields": true, "jsx": "preserve", "skipLibCheck": true, "typeRoots": ["./node_modules/@types", "./typings"], "baseUrl": ".", "paths": { "structures/*": ["./src/structures/*"], "handlers/*": ["./src/handlers/*"], "models/*": ["./src/models/*"], "types/*": ["./src/interfaces/*"], "utils/*": ["./src/utils/*"], "@components/*": ["./src/dashboard/components/*"], "@commands/*": ["./src/commands/*"], "@scripts/*": ["./src/scripts/*"], "@locales/*": ["./src/locales/*"], "@config/*": ["./src/config/*"], "assets/*": ["./src/assets/*"] }, "incremental": true, "tsBuildInfoFile": ".tsbuildinfo" }, "exclude": ["node_modules", ".next", ".vscode", ".github", "**/*.md", "public/*.js"], "include": ["typings/next-env.d.ts", "typings/*.d.ts", "**/*.ts", "**/*.tsx"] }

lyric mountain
#

write ur own bot buddy

#

you're in for a lot of headache with that one

earnest phoenix
#

well

lyric mountain
#

pastebin...

earnest phoenix
#

that's why I made my own unique one

sick agate
#

learn how to do stuff

#

thats more easy-

lyric mountain
#

open-source doesn't mean something is free nor easy to clone

#

just means the author doesn't mind having the code exposed

earnest phoenix
#

Writing your own Discord bot and maintaining it would be way easier than setting up and maintaining someone else's bot

sick agate
#

yeah

lyric mountain
#

(or s/he wants to get jetbrains license/other benefits)

sick agate
#

oh

#

i can get jetbrains license then

earnest phoenix
#

Discord users on their way to clone Discord bots from GitHub without reading the license whatsoever troll

sudden geyser
#

99% of licenses allow you to do so

lyric mountain
sick agate
lyric mountain
#

you get to keep the license as long as you still work on it

sick agate
#

you still work on it

wheat mesa
earnest phoenix
#

111

#

there it's saying identifier expected

sick agate
wheat mesa
#

Don’t put a dot there

earnest phoenix
#

oh I don't

#

?

lyric mountain
#

just so people cant clone my repo and say it's theirs

earnest phoenix
#

but there should be one right?

sudden geyser
cobalt junco
# earnest phoenix 111

You can't do

profileData.infoCards.
[ownedCardLow].lvl

unless its

profileData.infoCards?.[ownedCardLow].lvl
wheat mesa
#

No

#

That’s wrong too

#

It’s profileData.infoCards[ownedCardLow].lvl

lyric mountain
#

tf .[something]?

earnest phoenix
#

ty

#

will see if works

lyric mountain
#

is that even allowed?

wheat mesa
#

Nope

#

Precisely why he was getting a syntax error

cinder patio
#

.infoCards?.[ownedCardLow] that's correct tho

cobalt junco
wheat mesa
#

I didn’t even know that ngl

#

I guess it makes sense

#

You can do things like something.someFunction.?() I think lmao

cinder patio
#

you can

wheat mesa
#

It’s just weird thinking of ?. As it’s own operator in a way so that confused me in that situation

earnest phoenix
#

is profileData.gold.inc.amount correct?

#

or I have to do all the findOneAndUpdate and then do the following things

slender thistle
wheat mesa
#

That ^

#

If you’re going to copy blatantly from someone, at least give them the credit

#

If you want to add on to something someone made, give credit where it’s due

#

That’s like me downloading a Kanye West song and then saying that I’m Kanye West

#

Can’t do that

earnest phoenix
#

wow mongodb made my code lighter

#

what is Date.now()? a string, number, array...

earnest phoenix
#

ok

cinder patio
#

you could've opened the console of your browser and just checked urself

split hazel
#

does react not fire an onclick event for disabled elements?

pale vessel
#

you mean just js in general?

split hazel
#

react in particular

#

because the onclick isnt firing for the disabled element

#

i want it to send an alert saying "this is not available"

woeful pike
#

but disabled should be enough imo

split hazel
#

yeah but i want to display a message on how to enable it

#

i might just attach an onclick onto the label

#

since its a radio button

earnest phoenix
woeful pike
#

pretty sure most screen readers can pick up on it

#

you use aria-disabled for additional semantics on visual-only cues

earnest phoenix
#

the input would no longer be focusable
iirc some screen readers won't even announce it exists

woeful pike
#

it doesn't need to be focusable for screen readers

earnest phoenix
#

Can I get the sum of all this in the object without suming?

earnest phoenix
#

values?

#

it returns an array with all the values of the property
so it would show [1, 0, 0, 0, 0, 0, 0] in your case

#

then you can use reduce to add all the values to get the sum

#

in case you're wondering why i didn't give you the 20 character long reduce function, ¯\_(ツ)_/¯

#

ok

simple stump
#

I'm trying to separate my 9k lines of code into separate files using module.exports. However, I've never used that before and am a bit confused how to go about that. What are some good tutorials I can look at?

earnest phoenix
#

9k line pepexplode

wheat mesa
#

Sorry but 9k lines would kill me

quartz kindle
#

i've seen worse xd

wheat mesa
#

Me too but I couldn’t imagine working with 9k lines reasonably

#

That would be a challenge

quartz kindle
#

module.exports is very easy to use

simple stump
#

lmao i made the mistake of not learning how module.exports works when i first started

lyric mountain
simple stump
#

somehow the bot functions properly blobshrug

wheat mesa
quartz kindle
#

if you want to do this: ```js
const myfunction = require("./myfunction.js");

then you just do this:
```js
function myfunction() {
  ...
}

module.exports = myfunction;
wheat mesa
#

Where you have like 200 lines of just imports

lyric mountain
wheat mesa
#

Your helper is still a good 3.4k lines though isn’t it

lyric mountain
#

3508

wheat mesa
#

Damn

lyric mountain
#

I mean, the whole file is a bunch of "things I might use somewhere else"

quartz kindle
wheat mesa
#

Lmao

lyric mountain
#

my latest one

#

to make array handling a bit less problematic

wheat mesa
#

Too many generic functions and collections for me to look at

#

Just finished my Java class for the day

simple stump
lyric mountain
#

generics are the cream in the coffee

quartz kindle
#

if you do module.exports = something you can only use it like something = require(); something()

#

if you want to export multiple things you need an object

#

module.exports = { a:something }
b = require(...); b.a()

#

you can also do const { a } = require()

simple stump
#

Ah ty. Is there any documentation/tutorials I can reference? The djs guide was a bit confusing.

wheat mesa
#

this is why I prefer es6 style imports/exports

lyric mountain
#

search for node tutorials, not d.js

#

that's a node thing

quartz kindle
#

just google module exports in node js and there should be plenty of stuff to read

simple stump
#

o mb. ty!

split hazel
#

REQUIRE 4 LIFE

#

DETEST THE MOVEMENT TO REPLACE REQUIRE

wheat mesa
#

I hope js and ts add in operator overloading

lyric mountain
wheat mesa
#

Is that a planned change

#

Thought I saw a proposal for that somewhere

split hazel
#

IDK

#

oops

quartz kindle
#

why do you want it?

wheat mesa
#

Because there’s so much to do with operator overloading

quartz kindle
#

like wut

split hazel
#

overloading would be cool but it doesnt really fit in a language such as javascript

#

idk tho

wheat mesa
#

I think it fits

#

Not in a lot of situations but still

lyric mountain
#

operator overloads are mild, the real chads are preprocessor directives

wheat mesa
#

It’s just a nice feature to have in general, I don’t know why somebody wouldn’t want them

quartz kindle
#

i mean, js already partially supports them in the form of toString, valueOf and toJSON

lyric mountain
#

oh cool, groovy allows operator overloading

wheat mesa
#

Yeah but that’s not really operator overloading (to Tim’s message)

sudden geyser
#

I don’t know why somebody wouldn’t want them
Because it doesn't really do anything. Is it really that bad to write .add?

earnest phoenix
wheat mesa
#

Why write .add when you could write operator+ KEKW

#

It’s a niche thing, but certainly wouldn’t be a BAD feature

sudden geyser
#

but it doesn't add anything

earnest phoenix
wheat mesa
#

Not necessarily but that isn’t really the point

#

C++ doesn’t “need” operator overloading because it technically doesn’t add anything that you couldn’t do before, but it’s a nice feature to have imo

#

And c++ still has it

#

I don’t see what it would take away from js tbh

earnest phoenix
sudden geyser
#

then what is the point? so you can feel good that you saved 3 characters?

split hazel
#

its very useful in c++ for me

#

for example smart pointers

earnest phoenix
#

js was never meant to be smart

split hazel
#

you can make it behave like a normal pointer when its anything but

lyric mountain
wheat mesa
#

Js is designed around trying to be convenient, is it not

earnest phoenix
lyric mountain
#

require

earnest phoenix
split hazel
#

people nowadays expect javascript to behave the same

wheat mesa
#

Think about the possibilities with complex number types in math libraries, or vectors in graphics, etc

split hazel
#

when you start adding + operators to classes it could confuse people

lyric mountain
#

and animating with it is so fckin easy

boreal iron
sudden geyser
#

No, it's designed so you can actually do stuff with it. Write to the DOM please! Run this calculation! Not "save me 3 characters!"

You lose a lot out of pulling this into an operator. You can't use + as a value and it's very specialized.

earnest phoenix
#

Why my class function doesnt leave the first value it gets ?

lyric mountain
#

what

sudden geyser
#

The only benefit I see from operator overloading is polymorphism

#

So if you provide object X that adopts operator+, it still works when it's used.

#

But you can already do that with regular old functions.

wheat mesa
#

I still don’t see why it’s a bad thing imo

earnest phoenix
#

i still don't understand what even is operator overloading

wheat mesa
#

It’s not like it would be a forced change

#

Changing the behavior of operators for classes

earnest phoenix
#

yes

lyric mountain
#

you make a class that add("Tomato", "Lettuce") and returns "Salad"

earnest phoenix
#

It should be

result {r}
result {your dead || your alive} 
result {r} 
result {your dead || your alive} 
result {r} 
result {your dead || your alive}
spark flint
#

does anyone have any clue how forms work yet

sudden geyser
#

I think it's bad to see this from a "what do you have to lose" perspective, because if you go down that route, you'll adopt any feature that saves you a few characters without actually improving the language.

lyric mountain
#

you just do var res = new Fruit("Tomato") + new Veggie("Lettuce")

#

res will be "Salad"

wheat mesa
earnest phoenix
boreal iron
wheat mesa
#

Think of the uses in math libs

spark flint
#

i want to use it for a report command instead of cringy legacy commands

sudden geyser
#

Promises in JS saved a ton of headaches and complexity associated with using callbacks, yet you get proposals with the sole intent of saving X amount of characters out of convenience like this: https://github.com/tc39/proposal-await.ops

GitHub

Introduce await.all / await.race / await.allSettled / await.any to simplify the usage of Promises - GitHub - tc39/proposal-await.ops: Introduce await.all / await.race / await.allSettled / await.any...

wheat mesa
#

ComplexNumberType + ComplexNumberType would be a nice representation

#

I’m aware that it doesn’t add functionality, but it wouldn’t be a bad change.

spark flint
boreal iron
wheat mesa
#

detritus