#development
1 messages · Page 1985 of 1
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
You can modify the require.cache
require.cache["utils"] = { someMethod: () => ... };
Or more like:
const Utils = require("utils");
require.cache["utils"] = {
...Utils,
SomeClass: class { ... }
}
will this update the utils class in all the packages
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
const { Util } = require("discord.js");
require.cache["discord.js"].Util = class extends Util {
...
}
require.cache[resolve(require.resolve("discord.js").replace("index.js", "utils/Util.js"))]!.exports = require("./extenders/Util.js");
``` this?
wh-I literally sent you the code
Try both ways... it doesn't hurt to try
maybe the one u sent is right
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;
why are you using ESM imports?
My project is ESM
Any reason for that?
Top level await
Not sure if you can modify the cache then
Are you requiring your library before using discord.js?
how are u using it
import "./extenders/index.js";
import "dotenv/config";
``` this is my index file
the first file is this
No, I am not the issue is, it's getting updated in my code but not in that package
<Random Stream Link>
Is there a possibility to fetch from the current playing songs using an api
sussy link
Cause fetch only gives the name of the radio name
Headers {
_headers: { 'content-type': [ 'audio/aac' ], 'icy-name': [ '100.3 KISS FM' ] }
}
<Random Stream Link>
nodejs module for radio-browser API (http://www.radio-browser.info/webservice). Latest version: 2.1.10, last published: 16 days ago. Start using radio-browser in your project by running npm i radio-browser. There is 1 other project in the npm registry using radio-browser.
https://de1.api.radio-browser.info/#Advanced_station_search
Doesnt seem to give the current song
ohh sorry my bad, i thought you are trying to get the stream uri from radio's name
I use radio-browser
to do that
but I am looking to get the current playing song for the command nowplaying
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
What if it has an api
you need to find it by yourself one by one per radio station
Ok google, what's this song
Free music recognition
no?
some radio stations transmit the song that's currently playing in the meta data
most popular stations do this
It pretty much always says as the stream name
On fetch I dont seem to find that
Headers {
_headers: { 'content-type': [ 'audio/aac' ], 'icy-name': [ 'Y100' ] }
}
are you using an api to play radio
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
you need to request the metadata my setting a header in your request
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
Can I push items in mongodb? Like instead of increasing/decreasing, i'd like to push into an Array
also check this https://github.com/eshaz/icecast-metadata-js/tree/master/src/icecast-metadata-js#readme
the bot reviewer tag is not meant for spacing
use flexbox with column
actually doesn't it automatically put it on the next line
that's what it does
form {
display: flex;
flex-direction: column:
}
add align-items: stretch: justify-content: center for good measure
Nou, i'm already there
did you know
.important.important.important.important.important.important.important.important {
// important styles
}
is actually LESS worse than
.important {
style: somestyle !important;
}
why
because !important breaks the cascade while repeating selectors just increases specificity
this is why css is cringe
take a look at the default button styles
or the insane amount of polyfills needed for IE
this is why you dont choose web dev as a career
css is jus annoying pro
profileModel.findOneAndUpdate({userID: message.author.id}, {$inc: {silver: 1}})
``` will this work?
ty
can we add arrays inside of objects?
👍
if I push a variable with ``, will it push with backticks or ""?
backticks and "" are the same thing, backticks just allow you to use string interpolation
they'll both be type string
so then the final array will have the double apostrophes?
yeah that
i'm moving my code to mongo
so i'll be asking a few more questions if needed
is your bot using guild commands or global commands?
are you sure? show code
the command registering part
are you making some collectable card game type thing? 🙂
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
hey could someone here convert a image of mine to the supported format for the background image
I'm afaid for your future if you plan on adding card modifiers
like shinies or shit like that
jpg you mean?
and imgur
have you tried uploading to imgur?
yes
just google image converter online?
then its says either png or jpg
yes
what format is your file?
imgur outputs both
that's not the issue at all
he's just missing the point
show me the url you're trying
https://cdn.discordapp.com/attachments/272764566411149314/945713896486998036/2D3C7B62-BD88-42E4-92CA-5CDEADF3CED7.jpg
^ there ya go, jpg
no
💀

show the url ur trying
soooo?
open the image in a new tab
k
THAT's the correct url
i think you can just remove the /a from the url to get the image url?
got it
dekita, please

It's not
< HTTP/1.1 200 OK
< Connection: keep-alive
< Last-Modified: Thu, 17 Feb 2022 19:27:27 GMT
< ETag: "6422f31aacaa7abd04091218ac9cbc22"
< Content-Type: text/html
...what?
https://i.imgur.com/2d8Ml6F.png
yes
That's a valid image URL
ty
fake tf?
so I told him to open the image in a new tab
which would give him the correct url
...fake, still drinking yeah?
ara ara 
kya chutiyapa ho raha hai yaha par
yeah, it's a Clash royale "simulator" in discord
kya bolraheho? mujhe bahut hindi nahi pata
oh no... some even more weird language
That's not gonna work out
I understood 'discord' 🙂
sourceid=chrome hmmmm
damn google
well i searched it from ms edge
yeah
ms edge uses chromium.
was just about to sell to tencent the info that you're a chrome user
my plans were foiled
tencent already knows dw
lmao
pubg moment
ultra cringe
chrome eats 10x more comparing to ms edge with all functions disabled (literally all) in a potato pc like this one
they literally MADE pubg
"That browser is so 2008!"
literally uses chromium
they made freefire no?
no they sued free fire
well i'm going to pass my bot fastly to mongo or they'll fire me, bot's offline since 2 weeks
bot's offline since 2 weeks

That's why there usually is a production and development site
:D
what's that
Something you should consider doing 
docker helps make going from development to production really nice and easy 🙂
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?
wtf int.user.id === interaction.member.id
The interaction user is always the member (if in a guild)
You need to check if the message author is the interaction user
A button always trigger an interaction, yes
Better say, a buttin is an interaction
English failed
the lost cousin of the russian president
Well I'm only working on the production site, too but I'm just not gonna build bugs into it

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
maybe?
also, use a single permission override for all 3
just add them in the permission object
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?
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
@boreal iron I did
discord with their embeds 😍
Oh okay, try to work with line breaks then
Mh okay
Sad that there already is one
\n \u200b
Just sow this
let RSN = await fetch(Stream, { method: 'HEAD' });
console.log(RSN.headers)
Headers { _headers: {} }
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
Okay thank you
One or two
That will most likely work, I think they used that method in some of discord.js guide's embeds
The downside is the mobile view on white games which will be pushed down hard
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
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
I personally would bring white and black games to the same size
It gets added because the first line has 3 inline fields, so the second line tries to be equally wide
But doesn't do that in a sensible way
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
Will look into it later thank you
Can you copy the whole embed text for me, please?
Wanna play around with it real quick
sadly, that'll look shitty on mobile
with a huge gap between 2nd and 3rd fields
also what's the deal with those roundy embeds?
Added one line of u200b
canary?
you can't prevent a gap on mobile
since codeblocks are monospaced, try right padding with space every text

I need to find a better formatting solution, since games might not always be the same
omg
discord 🤞
Just by using spaces and \t for TABS in code blocks
Works great as you can see above
funni emote
what kind of font is this
There's an embed generator somewhere around you can play around with easily
Find it out yourself, idk I’m on mobile
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
And that's why you don't use C
that's not the point 😡
use a runtime manager?
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"
enough, get a room you two
right time to stretch my fingers
its not about the programming languages
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
You see, linux is not windows
I AM ON LINUX
cringe
i think the OOM thing is just buggy
ok bye thanks for coming to my ted talk
i see people using user space program killers because OOM is not doing its job
OOF
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
how do i install @discordjs/opus on repl?
npm i @discordjs/opus in console
gives big error
no
oh right you're on repl
yes
uh they should have that preinstalled?
How do you set the default permission of a slash command?
thats wha i thought
Writing a simple shell script scanning the tasklist, greping RAM and PID to kill every process above XX MB
i was thinking more of a linux kernel way but yeah
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"
just modify the source code smh 
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
complaining bitching around
try sending them an email
one sec i wanna go on the "how to file a report" page but my dns is fucked up
Try calling @earnest phoenix - the tech support men everyone trusts
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
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
i think theres some command to do it but i dont understand how
like this keeps happening
You should change the default DNS servers in your router, the OS will then choose the default DNS server he got provided via DHCP
i think i might just change the dns at /etc/resolv.conf and write protect it so it doesnt get overwritten
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
How about that?
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)
}
};```
ik formatting is optional but goddamn
ik ik, its cuz i wanted to make sure i didnt miss something.
but...not formatting will make it more likely for u to miss something
oh
btw, I don't see you passing volume anywhere
maybe it's almost mute for that reason?
i tried but i got an error
i will show
resource.volume.setVolume(0.5);
^
TypeError: Cannot read properties of undefined (reading 'setVolume')
shouldn't it be only resource.setVolume(0.5)?
i just copied from the docs but ill try
Oof
sometimes I wonder how agonizing it might be to code without intellisense (ctrl + space)
ya, resource.setVolume is not a function
how can i set content type with aws-sdk
did ya try to use ctrl + space to see if anything relevant pops up?
54 matches
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
What is ownedCardLow there for? I don’t see anything like that in your object here
ownedCardLow is the random card's name lowered without spaces
ownedCardLow is just a variable containing the real "variable" (object).
I can't put literally randomC.low there right?
Anyone know why I am still getting the Invalid OAuth2 redirect_uri error?
You can’t do that
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
profileData.infoCards[ownedCardLow].lvl
if you want to use a variable as a key, it needs the []
that
make sure you use that url when redirecting to the discord url, and encode it first
How do you set the default permission of a slash command?
all urls are encoded by default
i meant in the discord url
i mean when redirecting to the discord api url you put redirect_uri=https%3A%2F%2Fcheerbot.crd.co%2F%23thankyou
Hi
Would you need & before the redirect
if its not the first parameter
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
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
is it https%3A%2F%2Fcheerbot.crd.co%2F%23thankyou
Oh my bad ty
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?
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?
the nonencoded one is fine
use the nonencoded in the panel
It is not redirecting
weird
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?
ive never seen discord redirect to https://discord.com/oauth2/authorized, thats so weird
pretty sure discord expects the redirect url to go through the auth flow, ie receive code, exchange for token, etc
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
i dont think emojis work in titles? try using the emoji in the description
ye
emojis only work specifically in description and field descriptions
anywhere else doesn't support
I just tried that one and it doesn't work either.
how about add response_type query?
response_type=code
Do you need to write code in your bot or website?
website, mostly in backend, but you can do it in frontend iirc
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.
But titles support an icon which is quite nice
meaning you need to add another scope besides bot, need to add response_type, and need the redirect url to support full oauth2 backend
std::cout << sizeof(your_mother);
18446744073709551615
huehuehue
message.mentions last time I checked djs
when i do message.mentions.length it returns undefined
message.mentions.users.length
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
try .size
there is no length property on that
yep .size worked
Assumed it was an array
same lol
np
it's giving "identifier expected"
is there any way how i could use npm modules completely fine without any errors or something in a browser, with web js
maybe use bower
- Use a bundler like esbuild or vite
OR - Use a CDN to load the module
i did but that still gives errors
option 2
How can I fix this
Show your html
the co in copilot stands for cope
<script src="link">
goto .replit file
[packager]
ignoredPackages=["@components", "components"]
making excuses for me
<script src="link">
your entire html
maybe you are loading the cdn script AFTER your actual code is loaded
that could be
a possible problem
but at the same time, i impor() the cdn in the js file before using it
ask away
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
cookies
no but like tokens for api or a mongoose connection url
you use a backend 🧠
yeah and how
isnt there like an easy way with file permissin
Doing its installing all files again
ah, great!
you can use it with rest api perhasps
why the heck would you send that to the user's browser anyways
Like this right?
yep
well what about not sending it
but how
99% of the time your mongoose connection string will only be used by your backend
no distjs
If you need the data on the frontend you use rest apis
cross-env is not installed
yes so how
How can I install it?
npm i cross-env?????????
It's showing this
Lol
basically having client side react continue where the server side left off
Than this
Oh no not mathjs
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.
yes
@earnest phoenix @slender thistle now how can I fix this module not found


npm i ts-node???
yes
why are you even using ts-node?
Now this
{
diagnosticCodes: [ 5023, 6046, 5023, 5023, 5023, 5023 ]
}
TSError: ⨯ Unable to compile TypeScript:
error TS5023: Unknown compiler option 'useUnknownInCatchVariables'.
now how to fix this

They're not even using typescript
skill issue
aren't errors already unknown by default in newer ts versions?
guess it uses an older version
wait huh
never mind
bruh can you pls tell me
not sure because i dont use typescript but can you show us your tsconfig file?
why can i not install @discordjs/opus on repl?
uh i guess i'll give it a try
don't say skill issue
if it doesnt work for me you should contact repl.it supoport
unless tim knows something about it
tell us your secrets
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
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
huh?
i can npm i @discordjs/opus and i got that
yes
you sometimes do get permission denied errors
run it again
npm i @discordjs/opus
it get them all the time
do u want the output from this?
nope as long as it prints the python version it works
just run the install command again
it printed a massive block of text
as it should
okay
should i just keep trying npm i @discordjs/opus cuz i keep getting Permission denied
thats odd it installed for me fine
try restarting the console?
/ refreshing your page
still the same error
yes it did
thats weird
maybe its cuz im doing it on a team repl
you gotta be careful when inviting Speedicus
alright fake
you would usually run sudo with the command to fix permission errors but obviously you dont have access to that
@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
sure idm.
yeah i dont think theres much you can do other than contact repl
make a new project on the team
i have
ok
the cpus on there are slow
yes
the smoke from the cpu bar is accurately representing the cpu in real time
lmao
@azure lark there we go its installed now
i'll leave you to it now and leave the team
okay thank you
lemme guess !calculate process.exit()
what lib are you using to handle the math functions? i used https://www.npmjs.com/package/exact-math when i was doing math functions 🙂
the formula function of that lib is pretty dope 🙂
this would only work if you were using eval to math. which if so... stop it.
What dis do?
Divides 1 by 9999999999999999999999999999999
So solution is to limit it to like 5-10 length?
Aka it freaks out because that’s out of 64 bit float range
Or maybe cancel the promise if it runs for more than 100 ms
It probably crashes quicker than that
or just 1:(10 ^ 100 ^ 100)
So what do you think is the proper fix for that?
Virtual environment?
With like 10mb memory
Is that even possible
you could try reverse engineering the lib that I use
I don't think there's a "proper" fix
you can safeproof it to a certain degree
If it runs for more than 1ms xd
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
see if you can find anything useful for ur case in it
ik, it's java but same concept applies
i think in nodejs you can make worker threads now
"threads"
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
they're pseudo-threads
THEY STILL DO THE JOB
why not 
a spoon can do the job of a fork
you dont even have to kill it straight away
Spawning the thread is gonna take more time than doing the math
Threading is way beyond my knowledge, but ill keep this in mind when i probably need it in like 10 years
solution
code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]
you can just make it sit idle and assign it a math operation when needed
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`
Even better: use an API like wolfram alpha to do your math calculations
All you have to do is write the parsing
mathjs should have a "maxNum" option
How do I fix this

wth are you even trying to execute?
like, is it your bot?
Was gonna ask this question
yea because you cloned it, no because u didn't write right?
It's a bot in type script
You probably need an api key from the developer portal from that site
you're not planning to submit it to top.gg are you?
but now you're dependant on wolfram alpha
Nah
and just contacting them (assuming it's a rest api) will probably take longer
can't u just invite the original bot?
like, maintaining someone else's source code is EXTREMELY hard
I want my bot
||I want to loom cool between my homies||
It’s easier than writing your own calculator tbh
and if the readme doesn't contain setup instructions, chances are the author didn't mean for it to be cloned
Wolfram would allow you to do tons of complex things that would take ages and lots of mathematical knowledge to do on your own
like mine, it's open-source but I wont teach u how to setup it
but that begs the question of why even have a calculator command
that wont work
if all your results will come from the same guy
you'll just fall the falacy of "the bragger"
Google or opening calculator app too inefficient
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
Like, I've seen latex bots that can format a math expression and give you the answer, which is a lot more useful.
This
People can't be bothered to click a few buttons
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
I have one because of my tcg
people use to calculate final damage
or plan before equipping cards
identifier expected
opening a specialized app to do something simple (like math) is annoying
so desktops will usually make it easier, like mac's spotlight
Provide more info and code
Identifier expected usually means a syntax error
{ "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"] }
well
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
pastebin...
confirmed
that's why I made my own unique one
dont do for that
learn how to do stuff
thats more easy-
open-source doesn't mean something is free nor easy to clone
just means the author doesn't mind having the code exposed
Writing your own Discord bot and maintaining it would be way easier than setting up and maintaining someone else's bot
yeah
(or s/he wants to get jetbrains license/other benefits)
Discord users on their way to clone Discord bots from GitHub without reading the license whatsoever 
99% of licenses allow you to do so
3 month-old open-source project
i can still get license
you get to keep the license as long as you still work on it
What line is the error on? I don’t really want to look through every single line of code on mobile trying to guess where the error is
111
there it's saying identifier expected
Best license 
http://www.wtfpl.net/
turkey moment for me D:
best license sspl
I like to use lgpl
just so people cant clone my repo and say it's theirs
but there should be one right?
https://unlicense.org is actually better since you don't open yourself to getting sued
You can't do
profileData.infoCards.
[ownedCardLow].lvl
unless its
profileData.infoCards?.[ownedCardLow].lvl
tf .[something]?
is that even allowed?
.infoCards?.[ownedCardLow] that's correct tho
TS allows it?
I didn’t even know that ngl
I guess it makes sense
You can do things like something.someFunction.?() I think lmao
you can
It’s just weird thinking of ?. As it’s own operator in a way so that confused me in that situation
is profileData.gold.inc.amount correct?
or I have to do all the findOneAndUpdate and then do the following things
You'd look cooler if you actually knew your shit instead of showing others' work as yours
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
number
ok
you could've opened the console of your browser and just checked urself
does react not fire an onclick event for disabled elements?
you mean just js in general?
react in particular
because the onclick isnt firing for the disabled element
i want it to send an alert saying "this is not available"
use cursor: not-allowed instead
but disabled should be enough imo
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
disabled destroys accessibility
pretty sure most screen readers can pick up on it
you use aria-disabled for additional semantics on visual-only cues
the input would no longer be focusable
iirc some screen readers won't even announce it exists
it doesn't need to be focusable for screen readers
would a tooltip on hover be a good substitute?
Can I get the sum of all this in the object without suming?
Object.values(yourobj).reduce(add all the values);
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
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?
9k line 
Jesus Christ
Sorry but 9k lines would kill me
i've seen worse xd
Me too but I couldn’t imagine working with 9k lines reasonably
That would be a challenge
module.exports is very easy to use
lmao i made the mistake of not learning how module.exports works when i first started
I'm a third of the way
somehow the bot functions properly 
Yeah I saw your helper class
if you want to do this: ```js
const myfunction = require("./myfunction.js");
then you just do this:
```js
function myfunction() {
...
}
module.exports = myfunction;
Where you have like 200 lines of just imports
wasn't talking abt the helper kekw
3508
Damn
I mean, the whole file is a bunch of "things I might use somewhere else"
dont worry, in the early versions of my bot, i used to do this
eval(fs.readFileSync("./otherfile.js"));
Lmao
Too many generic functions and collections for me to look at
Just finished my Java class for the day
So I could do:
file one:
const someLibrary = require("somelibrary");
function doSomething() {
// do something with someLibrary
}
module.exports = doSomething;
index.js:
const fileOne = require("./fileOne.js");
fileOne.doSomething();
lol
generics are the cream in the coffee
not exactly
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()
Ah ty. Is there any documentation/tutorials I can reference? The djs guide was a bit confusing.
this is why I prefer es6 style imports/exports
just google module exports in node js and there should be plenty of stuff to read
o mb. ty!
I hope js and ts add in operator overloading
require 4 life
^^^^^^
unknown token
why do you want it?
Because there’s so much to do with operator overloading
like wut
overloading would be cool but it doesnt really fit in a language such as javascript
idk tho
operator overloads are mild, the real chads are preprocessor directives
It’s just a nice feature to have in general, I don’t know why somebody wouldn’t want them
i mean, js already partially supports them in the form of toString, valueOf and toJSON
oh cool, groovy allows operator overloading
Yeah but that’s not really operator overloading (to Tim’s message)
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?
Operator overloading was proposed to us in the TC39 agenda, but there have been no updates on it whatsoever
Why write .add when you could write operator+ 
It’s a niche thing, but certainly wouldn’t be a BAD feature
but it doesn't add anything
This man has been living under a rock since 2020
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
then what is the point? so you can feel good that you saved 3 characters?
js was never meant to be smart
you can make it behave like a normal pointer when its anything but
It’s convenient
Js is designed around trying to be convenient, is it not
what
require
Funny how css is the exact opposite
i would say it could complicate it
people nowadays expect javascript to behave the same
Think about the possibilities with complex number types in math libraries, or vectors in graphics, etc
when you start adding + operators to classes it could confuse people
css is actually quite convenient, especially after u learn how to use variables
and animating with it is so fckin easy
tf is that resolution, can't even read it on 4k
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.
Why my class function doesnt leave the first value it gets ?
what
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.
I still don’t see why it’s a bad thing imo
i still don't understand what even is operator overloading
It’s not like it would be a forced change
Changing the behavior of operators for classes
for example
yes
you make a class that add("Tomato", "Lettuce") and returns "Salad"
It should be
result {r}
result {your dead || your alive}
result {r}
result {your dead || your alive}
result {r}
result {your dead || your alive}
does anyone have any clue how forms work yet
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.
you just do var res = new Fruit("Tomato") + new Veggie("Lettuce")
res will be "Salad"
It’s a small change. I know it doesn’t add anything previously impossible with the language but I wouldn’t say it’s pointless
But when i call it for first time i restarted bot it gets any value and keep sending it
what do you need to know?
Think of the uses in math libs
how to use them 
i want to use it for a report command instead of cringy legacy commands
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
ComplexNumberType + ComplexNumberType would be a nice representation
I’m aware that it doesn’t add functionality, but it wouldn’t be a bad change.
ah found in docs, its called modals so that threw me off https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
You either use a library which already includes the classes and builder methods or do it yourself, like I did to test it
detritus



