#development
1 messages ยท Page 1798 of 1
yes
umm
app.get("/route", (req, res) => {
// Calculate leaderboard data
// After you're done send the data:
res.set("Content-Type", "text/html");
res.send(`
<div>
Leaderboard data
</div>
`);
});
Ok....? Did not get it yet
sorry but i cannot explain better
Ok np
Why not do a db like when the user votes fetch the user then add a point then fetch the highest to lowest vote like 10 people each page
Is there anything on yt?
@lucid prawn that is exactly what he's doing but anyone can steal api keys on the website so the server should do it
Cuz this is like 
yt tutorials suck unless it's a video made by fireship.io
is it possible to give a bot a custom tag?
nope
Still
or like a about me section
not sure about that tho
so you trying to hide the api keys what host he using
Replit
oh
Yes
The server that sends your bot website can also be the one calculating the leaderboard data
Ok leave the api key
then use import
I will hide it
What
forget DDOSing top.gg we'll ddos his bot page
it's builded in replit
How is server side rendering so hard?
umm ?
use react and split the api somewhere else
do you see a lock
Exactly what i said
on replit
For this
I have already used that
well with plain html and js it'll be hard af and will end up coding like hell
Can someone help me withthe code for this
So I've never made a bot before and I'm trying to learn for a friend. He wants me to make a bot for his discord server so when he streams a game we all can play it. Like if I type "up" in his channel, it will send that input to his pc and emulator. Namely we want to do this so we can play pokemon together. But like all on his device when he streams it. Is this something that's even possible?
Not possible with bots but it's possible with the game sdk
I can't I'm trying to make something like a dashboard for my bot It's hard af
It is possible with bots
sdk? Isn't that only for android games?
Nodejs is able to send system input
- create a webhook
- save data on vote in a db
- make an api to send top 10 with queries or something
- Render it in html in client side
might want to look into this @hushed adder https://robotjs.io/
Node.js Cross Platform Desktop Automation. Control the mouse, keyboard, and read the screen.
Is there some thing better
Dosen't that mean he'll have to run the bot on everyone's pc which dosen't make any sense
use react
Cuz i told u that i am new
If I understood correctly he wanted to be able to use chat commands to send basic input to his friends emulator
oh I thought they all wanted to play together so like
someone sends "up" and the game pops up on everyone's pc
can someone help me 
^
If i am correct then react is a package right?
do you need a host?
No
You need to use member.roles.add(role) not message.member.roles.add(role) since you're assigning the first mentioned server member to let member wich does not change the member property of message
I tried that I got a add error
what error
does both 'role' and 'member' exist ?
like try
if(!member){ return false }
if(!role){ return false }
@wary flame Hi can u help me also
@gaunt ermine Don't ping people asking for help
Just send your problem and see if someone helps you
React is a framework (or maybe a library I don't know the difference) which is built for Client side development
It's a framework iirc
(node:25) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'add' of undefined
Some one already tried
Sorry
that means member.roles is undefined
With this
Try checking if message.mentions.members.first() exists before trying to add roles
@lucid prawn
SUPER_PROPS, AUTHORIZATION, USER_AGENT, REFERER, COOKIE, CHANNEL ID
Your member is most likely a user
@near stratus you were faster then me lol
Change from users.first() to members.first()
....
ehm
like in what context ?
Helloooo
Also I don't like SAO
bad anime
i just want know where to get all of the above info
ya
like the definition for the terms?
For what ?
a discord bot ?
a website ?
a webhook ?
React ?
I already told you how to
so stfu
And i told you that i dont know becuz i am nee
a discord bot
New
thxs message.mentions.members.first() fixed it
That you're new doesn't mean your incapable of googling basic issues or being able to follow simple steps
They cant understand the spoonfeeded express code too
Authorization is a header you send in request
for bots it's in this format Bot BOT_TOKEN
User_Agent: Also a header. Defines what agent the user is using (Mozila, Edge, Chrome etc)
Referer Cookie: If someone refers you and forwards a cookie (Mostly Google)
Channel Id: The id of the channel eg: 16376359301726535378
Ok last thing is there a yt tut on it
thank you
You wont understand the yt tutorial cuz youre new
I will
So 69 year old yt tutorials are better than us?
Idk css or html
he'll just copy the code if I'm not wrong
Write in md then
OK do you have it or no ?
Alright thanks
Or in plain with nothing else
and use <br> when breaking lines
No
Use the search bar in yt and Google
If you find it you find it
Otherwise no
OK
Beware security problems from yt tutorials
guys anyone help ? how to increase the MaxListerner limit in node.js ?
require('events').EventEmitter.defaultMaxListeners = 100;
process.setMaxListeners(100);
ty
How do I store that member roles I removed
Who tag me in every channel's ๐
Has anyone had their bot be disabled by Discord before without any explanation? And a note saying that you should contact support to figure out why?
This is the second time it has happened to me, and they (Discord support) are very slow with responding
It's been a week since I filed a ticket but haven't had a word on what my bot is doing wrong
Previous time they took two weeks and then my bot magically got enabled again, and they didn't bother telling me what it did wrong aside from saying that it violated the terms
I got this:
let muteRole = message.guild.roles.cache.find(x => x.name === "Muted");
```
But it gives me error saying it cant read property of 'roles' or undefined, meaning it doesnt know what guild means...
(Ping if helping.)
did you by any chance spammed the API by accident?
I think I might've hit the cloudflare limit yeah
Might need to keep track of the amount of requests I'm doing to make sure I'm not going over
My bot is in 7000-ish servers and sends messages to many of them if a specific event occurs. I thought I put in an artificial delay anyway but I probably didn't
i suggest to add cooldowns to stuff like commands, and start caching frequently used stuff
so you will lower the amount of requests that go to the API
Yeah. Just realized that if 1% of servers does a command then I'm already reaching the global rate limit
There is no guild i.e. the message is in a dm
hmm
;s
Hello!!
const work = { jobs: [ { points: 2 }, { points: 5 }, { points: 3 } ] };
console.log(work.jobs.map((x, total) => total += x.points))
Did I do this wrong?
I'm trying to add all values of points.
.. or am I supposed to use a for loop?
+= doesn't return the object
You have to return the object back after incrementing the points
I want it to return a number which is the total of all the points:
I think reduce would work..
Yes
.. but is really hard to understand.
I barely understood it. ๐
Every time I use it, I have 10k questions in my mind on why this and that is needed.
array.reduce(
(
accumulatedValue, // The accumulated value, you'll define this as 0 and it will increase as it traverses the array
currentValue // The current value, which is the current element or object from the array
) => accumulatedValue += currentValue.points, // Add current value (the object)'s points to accumulatedValue. variable += number already returns the sum so you don't need to return accumulatedValue again
0 // Starting value for accuumulated value
);```
I've copy pasted your response for my understanding as well.
Alright.. I tried this multiple times...
It works.
God that profile picture
whats ie
how to team mambers in Creator
?
how to add team mambers in Creator
ok sir
?
how to get super props
what super props?
Heyo.
work.points += jobs.find((val) => val.id.toLowerCase() === jobToWork).pointsSallary;
work.cooldown = Date.now();
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).points += 1;
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).coins += 500;
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).hours += 1;
work.save().catch(err => console.log(err));
Work.findOneAndUpdate({
userID: message.author.id
}, work);
I'm having this code of me saving values in an object. I'll show you how the object looks like.
Somehow.. points and cooldown are changed in the main object but the values inside the object inside the array are not being changed.. ๐
I did work.save() to save the points: and cooldown:, but the properties inside the array of objects aren't changing saving.
Hey everyone?
Did you log work and made sure that everything inside the array changed?
It's not even changing.
Let me check
I'll log it before saving, right?
Sure
.. edited.
The cooldown doesn't seem to have changed either?
It does.. but this is a picture before any of the code above takes place.
Here is the updated document.
Logged to console before saving..
{
jobs: [ { id: 'member', points: 1, coins: 500, hours: 1 } ],
_id: 60dd892628262830d8143090,
userID: '528256079101034506',
job: 'member',
points: 1,
cooldown: 1625134468382,
changeCooldown: 0,
__v: 1
}
Try providing everything directly ```js
work.jobs.find().points += 1;
...
Work.updateOne({
points: work.points + ...,
cooldown: Date.now(),
jobs: work.jobs
});```
fineOneAndUpdate() returns the previous document
You don't need that if you're not assigning it to anything
Both works ig
I usually use that when updating objects in a document.
.. not sure why it doesn't work when it's an array of objects, instead.
suppose a property in this was:
lmao: { x: 0 }
.. and I wanted to update x, I would use findOneAndUpdate.
.. but
lmao: [ lmao2: { x: 0 } ]
.. findOneAndUpdate, doesn't work in this case, idk why.
updateOne(filter, { "lmao.$.lmao2.x": newValue }) should work iirc
Hmm, naw
.. but how am I supposed to update the values that are inside the array of objects. This won't work.
You can do that
anyone here use botghost? just wondering...
Not really dude, sorry.
There are plenty of people who use botghost @frozen topaz
updateOne({ "lmao.lmao2.x": 0 }, { "lmao.$.lmao2.x": newValue })
You'd have to know the value
ohh.
k as far as I can tell the general consensus is that its ok but could be better...?
lmao is the array and lmao2 is an object inside
I don't have any experience with it myself, but I think it's an easy way for you to build your own bot if you don't have any technical skills.
lmao.$ refers to the index of object inside lmao
Could you show me an example if I would want to change the coins but applying the find() method to find the object that has an id of "member"
Example.
find((val) => val.id.toLowerCase() === "member")
I've got no clue how your structure looks like, but this is how I did it for my tags
Rust, egui
What's the optimal way to add an Area widget to my screen? If I add it in the update function, my area acts in an eerie manner whenever I move the mouse around. https://puu.sh/HT5Tm/8ca399e81f.mp4
Is this behavior an issue with egui or the way I implemented it?
Attached is my entire app.rs that I use in my main.rs.
yeah makes sense
With queries or just by modifying the original object and updating it using updateOne/findOneAndUpdate?
.. to be honest dude, I just want to modify them using the original way like in the code I wrote then use findOneAndUpdate, but it's not working.
.. save(), won't work, since we are modifying objects, not properties only.
that looks cursed af
.. updateOne, I can use this, but I'm trying to figure out how to use the find method as well.
Did you try this?
.. how is it going to know which object to modify if there are multiple objects inside the array?
Could you show me an example on how to add the find method?
Example.
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).points += 1;
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).coins += 500;
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).hours += 1;
You weren't supposed to copy paste that. My point is provide everything to the update field instead of modifying the original object (except for jobs)
Instead ofjs obj.points = 10; updateOne(filter, obj);Dojs updateOne(filter, { points: 10 })
Except for work.jobs. You use your find methods to modify the array and provide it as js updateOne(filter, { jobs: work.jobs });
you forgot the $set
OR you can use replaceOne() instead. That replaces the whole document
.. wait, we're not trying to modify all the documents, aren't we?
Only one?
No, that's updateMany.
My bad.
Okay try this
This should be easier. Simply change findOneAndUpdate to replaceOne
That replaces the whole document. You already have the complete object so you only need to modify it and replace the old one with the new one
updateOne/findOneAndUpdate() in mongoose uses $set internally
oh i thought it was the original mongodb driver
Well we're only trying this since updateOne doesn't work with arrays (for some reason)
So try to replace the whole document instead
Forget about #development message for now
Alright? .. no replacing though.. since I should increment values.
@latent heron Just another example of, leave the PC, take a break and come get back later if you're stuck.
RewriteEngine On
RewriteRule ^/?(.*) /index.php?lookup=$1 [PT,QSA]
Instead of doing things complicated I'm just appending the query string to the request URI with QSA
Which solved the issue...
You can keep this code #development message
Just change findOneAndUpdate to replaceOne
work is already the full object so you don't have to worry about missing properties
If you're still stuck with your RewriteRule just let me know.
I'll try.
Didn't work yet...
I'm not trying to replace but update.
work is the object returned by findOne() right?
Hmm, all right then. Did the document change in any way or no?
Nope.
The problem right now is that it just doesn't want to update the jobs array even if you modified the original document
Yes.
Yes.. .save() works to save the other parts but the only problem is trying to find a way to update the jobs array meaning modify it.
No replacing, but updating, just like incrementing, and such.
Let's try #development message again. Your code should look something like this ```js
work.points += jobs.find((val) => val.id.toLowerCase() === jobToWork).pointsSallary;
work.cooldown = Date.now();
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).points += 1;
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).coins += 500;
work.jobs.find((val) => val.id.toLowerCase() === jobToWork).hours += 1;
Work.findOneAndUpdate({
userID: message.author.id
}, { points: work.points, cooldown: Date.now(), jobs: work.jobs });```
it works... kinda
Notice how it's { points: work.points, cooldown: Date.now(), jobs: work.jobs } instead of work
and save() isn't needed since you already have findOneAndUpdate. That updates the properties already
I'll try.
If this doesn't work, then I'm not sure what's wrong
Still replacing, so didn't work. ๐
I appreciate your help dude. ๐
I'm reading the docs as well.
It's not replacing
Ah, you mean jobs?
I asked if you wanted to use queries but you said no and you wanted to use array.find() instead
Yes..
You could try something like this js Work.updateOne({ userID: message.author.id, "jobs.id": jobToWork }, { points: work.points + jobs.find((val) => val.id.toLowerCase() === jobToWork).pointsSallary, cooldown: Date.now(), $inc: { "jobs.$.points": 1, "jobs.$.coins": 500, "jobs.$.hours": 1, } });
That doesn't need array.find() or any modification to the document you got from findOne()
I'll be trying that, I'll stop for a bit and update you once I'm back.
@rustic nova
Imagine sharing .ru URLS as trustful 
you can't really hack accounts anymore
brute forcing will get you ip banned instantly
they're just dumb and click random links
and sign into fake discord replicas
don't abuse my name
Ah, understandable.
How could I make a command that is for users that are in a discord server only?
in which library
My school library
discord.js
well
ok
If you want it to work for other servers, access cache
check if Message#member is defined
because if the command is in a dm, member won't be defined
accessing the guild id will throw
but same idea
Oh I thought they meant if the member is in a specific discord server
Yeah check the channel type or if message.guild is null
so i want to make is so only people can use some other commands if they are in the main discord server
Main discord server?
Check the guild where the message was sent
I assumed you wanted that (or #development message)
for example
the bot idleminer
you can do the command ;supporter
if you are in their server
Yeah
message has the guild property
Make sure message.guild exists and compare message.guild.id with your support server ID
If it matches, allow the command usage, else don't
ok
ty
let guildA = client.guilds.cache.get("GUILD ID");
let requiredRole = guildA.roles.cache.get("ROLE ID");
let member = guildA.members.cache.get(message.author.id);
if (member.roles.cache.has(requiredRole.id)) {
message.channel.send("You have the required role.");
} else {
message.channel.send("You do not have the required role");
};
so what that sort of thing work
and ill give my member a member role
const EventEmitter = require('events')
EventEmitter.defaultMaxListeners = 20
i added this but i still get the error
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 21 message
you dont modify the original
thats now how it works
you need to modify the eventEmitter instance thats throwing the error
ooh
Bruh my message handler is too damn long
Does anyone know of a way to check if a category exists?
Yes.
yo dude, there's an IP in there
๐
https://sourceb.in/KqE9VSBnbA
it is not editing the embed, when i tried from a another bot it worked perfectly fine but now when i use in my public bot it is not working.
everything is perfectly working when i tried in another bot, but when i used the same code in my bot it is not working
https://media.discordapp.net/attachments/821972674380038166/860141082251624458/unknown.png
https://media.discordapp.net/attachments/821972674380038166/860141168322543626/unknown.png
no errs
i did copy some code, but changed almost everything
๐
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send(`**You missing required permisison __ADMINISTRATOR__**`)
checking for manage messages, asking for admin
why does my meme commadn takes years to send
it's your code, you tell us
const https = require('https');
const Discord = require('discord.js');
const url = 'https://www.reddit.com/r/meme/hot/.json?limit=100'
module.exports = {
name: 'meme',
description: 'sends meme',
execute(message, args) {
https.get(url, (result) => {
var body = ''
result.on('data', (chunk) => {
body += chunk
})
result.on('end', () => {
var response = JSON.parse(body)
var index = response.data.children[Math.floor(Math.random() * 99) + 1].data
var image = index.preview.images[0].source.url.replace('&', '&')
var title = index.title
const imageembed = new Discord.MessageEmbed()
.setTitle(`${title}`)
.setImage(image)
.setColor(000000)
message.channel.send(imageembed)
}).on('error', function (e) {
console.log('Got an error: ', e)
})
})
},
}
is there something extra in this
or my bot is just dum
no errors but its
monke
can someone help me with this?
imagine using https lib
Did you get the code from this SO post https://stackoverflow.com/questions/61350023/discord-js-meme-command-with-meme-subreddit-returns-image-as-403-forbidden ๐ฌ
Does Button get supported by discord mobile?
i got it from a friend then i reduced the long code so that i can understand i didnt knew that he took it from stackoverflow
can u tell what is the problem ;-;
nope
u think its good
1 sec
ill show u
its like this with the help
i just sent all of them to show commands
yk
API ratelimits go brrrt
the api aside, it actually looks very messy
like one embed or maybe a button menu
could work
yea im working on that next week
gonna add buttons
....................
honestly, your code is such a mess its very hard to read, so its hard to help.
hate to be rude but i'm gonna have to agree with Woo
it's really messy
I can't really distinguish what's going on here
like, what is going on here?
let first = args[1];
let user = db.get(`1suggest_${first}_user`)
let ededembed = new Discord.MessageEmbed()
.setAuthor(client.users.cache.get(user).username, client.users.cache.get(user).displayAvatarURL())
you are getting a user from an arg, to get it from a database, to get it from cache, to get its username? the user may not even be cached, since it doesnt seem to be a mention
index.preview.images[0].source.url.replace('&', '&')
The code you're looking for is
decodeURIComponent(index.preview.images[0].source.url)
ah\
wait actually no, that's an html entity not an encoded uri char
Does anyone know how I can loop trough all users in a guild?
await msg.guild.members.fetch().then(users => {
users.forEach(user =>{
console.log(user.username)
})
})
This does not work
Hi
Member#username doesnt exist
not sure about the fetch stuff, but your current loop will log a bunch of undefined's assuming it fetches them like that
But username does exist
But when I am loggig. user.username it returns undefined
ah, i assume here you where logging a users properties?
because in your code, your logging a members username, which doesnt exist.
you just named a member object as a user
When I am logging just "user" instead of "user.username" I can see the username property in the console
how are you getting that user?
await msg.guild.members.fetch().then(users => {}
await msg.guild.members.fetch().then(users => {
users.forEach(user =>{
console.log(user)
})
})
ok, try changing
console.log(user.username)
to
console.log(user.user.username)
i think you may just be reading the user properties inside of the member object.
thx thats it
i think my point was just being missed ๐
because username is a property of user
yeah
Does anybody know how I can track errors better. I am logging erros into a database so I can look into this later. But the error doesnt show the line of code where it is caused so idk how to find it
Thats how I log the error:
Does anybody know how I can track errors better. I am logging erros into a database so I can look into this later. But the error doesnt show the line of code where it is caused so idk how to find it
Thats how I log the message:
module.exports.logError = function logError(e) {
try {
const mysql = require('mysql')
let con = mysql.createConnection({
host: "hoist",
database: "bot",
user: "bot",
password: "wefwwf"
charset: 'utf8mb4'
})
console.log("Error: " + e.message + "\nPath: " + e.path + "\nStack: " + e.stack)
con.query('INSERT into exceptions ( message, stack, path, httpstatuscode) VALUES(?,?,?,?)', [e.message, e.stack, e.path, e.httpstatuscode])
con.end();
} catch (e) {
console.log(e);
}
}
to ../commands/${dir}/${file}
on line 19
just add ../ for all your readdir lmao
if you run prod and you want some top notch error logging look into sentry.io
Why doesn't this shorten the link?
because you did that backwards
oh
function getWorstJSLibrary() {
// return "*"
}
hello
i've recently modified an object that is inside an array in mongoose.
i've modified that object, but .save() isn't working
anyone knows why my visual studio code isn't autocompleting brackets anymore?
Example I used to be able to type ( and it'd become () but now it just doesn't work anymore
i cant seem to save that object that is inside the array
it sais ctrl +
but that zooms in
and doesn't open the settings
I'm not sure..
Are you using an extension?
Try removing that...
idk it happened after I installed github copilot
still not working
ok
I managed to fix it
github copilot turned this to never
"[javascript]": {
"editor.autoClosingBrackets": "always"
}
@quaint wasp

Ladies and gentlemen.
I present to you the idiot who forgot to add await to his method who finally wasted a fuking 12 hours of his day trying to figure out why.
Me.

Visual studio code is now a dating platform for developers
if you run into that issue and dont get a bunch of errors or warnings screaming at you with what ever language you're using, you're concurrency structure is shit and should probably be redesigned and / or stop silencing your errors and warnings
what the heck..
other way around
and this is why we use typescript and detritus 
[text](url), not (text)[url]
[] = text
o right
() = link
man
or just learn how to use the stupid debugger
the only option i didnt try
that too
imma work now on the collector for u btw @lusty quest
shouldnt take long
Bro.
.findOneAndUpdate()
await .findOneAndUpdate()
.. i had to do the second one.
. I made SO MUCH RESEARCH.
I FORGOT THE AWAIT
damn dude, that solved my issue as well, thanks ๐
๐
..
Lmfao.
yo the heck is this
it just send an embed when joining a new guild in one of its firsts channels.
error says exactly what it means
^^
you're trying to access discord before the initialization point
Don't use Discord. before the const Discord = ...
and if you read whats AFTER, it should show u exatcly the line too
ya but the discord const is my 4 line and embed is my 59th.
are you by chance using var?
Kuu bout to have a stroke is yes.
no i am not
I just simply do const Discord = require('discord.js')
for the embed I mean
no
hoister is hoisting the var
doesn't the error contain the line?
Probably should share the code so were not guessing
its just that I think veld randomly gave me the nick when i got on his stream channel and started streaming
ok
Veld gave me my name too
client.on("guildCreate", guild => {
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). \n This guild has ${guild.memberCount} members!`);
const introOnJoinE = new Discord.MessageEmbed()
.setTitle('Hey, thanks for adding me!')
.setDescription('If you need any support, please run ++support command!')
.setColor('BLUE')
.addField('Prefix', prefix)
.addField('Bugs', 'The bot is always in development, so new features are added all the time, very often. If you find any bugs, please use ++report (bug) and then after the bug list as much info on how you caused it.')
.addField('Your my..', `${client.guilds.cache.size}th server!`)
.addField('Help and list of commands', 'To get that you will need to run ++help. You will get that, and most likly answer your question. If you still have it, please tell us about it in our support server.')
const channels = guild.channels.cache.filter(channel => channel.type == "text");
channels.first().send(introOnJoinE).catch(e => console.log(e));
const newC = config.newC
const Discord = require('discord.js')
const newE = new Discord.MessageEmbed()
.setColor('#27FF00')
.setTitle('NEW SERVER JOINED')
.addField('MEMBERS', guild.memberCount)
.addField('NAME', guild.name)
.addField(`ID:`, guild.id)
.addField(`GUILD OWNER:`, guild.owner)
.setFooter('Time joined', client.user.displayAvatarURL())
.setTimestamp();
client.channels.cache.get(newC).send(newE)
});
my const Discord is wayyy up
You made the embed way before the const discord thing
hoist this const Discord = require('discord.js')
Introjoin embed is like 100000 lines above const discord require discord
atom?
uhh
doubt atom wouldnt catch that
either you really overlooked it, or atom is not setup for js coding
Atom doesn't have built in typescript
ya i am not home so I cant really use VSC... so I use pebblehost code editor as my code editor..
And the community one it has always crashes my ubuntu
notepad wouldnt 
wait should const discord even be there or should I get rid of it?
or put it somewhere up
like above the intro message embed
i love my pc's error handling
try { shit } catch() { Object.freeze(process) }
cuz u use it twice
so it wont pull from the first one
it'll try from the second cuz its inside the function
Put it right at the start
Nothing other than command files should be imported anywhere other than the top
@quaint wasp
a, as you can see, should be highlighted
like i said, any IDE should've given u that error before u event ran ur bot
i'd recommend switching if whatever u using isnt doing at the very least, this
ye..
if you have a student email you can get a free version of intellij ultimate
Pass in โaโ to the function :)
It was
good
Lol
gotta make sure, some people here do that
reassigning variables is a code smell
scope blocked variable declaration is the term i think
or shadowing a variable
cuz it makes it inacessible
you'll never be able to acces the first "a" from inside the function
But erwin why are you reassigning the variable like 10000 times
mutation in general is a code smell
imma bonk u
teenage mutant ninja turtles
more like
teenage immutable scoped variables
they didn't know about all the issue around "mutantation" back then
Best. Post. Ever.
javascript (mocha at the time) was made in 1996
there were some real FP languages before that so i guess they knew already, but didn't care


@lusty quest i got good news and bad news

good news is that i managed to do what i wanted
bad news is that i cannot find a way to implement it in ts
intellisence, at least
the moment i extend and re-declare it, it doesnt like it
but the usage is still there
it just doesnt like the way im extending it
oop much?
composition over inheritance
what?
dont build inheritance structures
y not?
less flexible
thats exactly what i need
less flexibility?
Composition over inheritance (or composite reuse principle) in object-oriented programming (OOP) is the principle that classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class. This is an ...
not even ts-ignore gets rid of that
im not doing that tho
lib exports a class.
i redeclare it so everywhere else u have the new types
however i need to modify its prototypes to add the actual logic/function
thats it
i already do that quite a bit tbh
that's tricky
but this case is a bit finicky
like programming on quicksand
basically value interfaces and abstractions over inheritance
i need inheritence
im not the dev of the lib
i'd like to avoid modifying other people's stuff
you probably don't
but inheritance and composition are just two different ways of modeling
so pick either one
im still confused tbh
inheritance is fine in some cases
here's a youtube video about it
๐ Support the show by becoming a Patreon
https://www.patreon.com/funfunfunction
This is a weekly show where we try to become more confident and excited about programming by learning intriguing things that we didnโt know before. Today, we are are going to talk about composition over inheritance. Inheritance is when you design your types after wh...
//lib code//
declare class Message extends Base{
a:number;
}
//my code
<Message>.b = 2;
thats literally what i need
without casting it everytime
i already do that
but i need to modify the constructor itself
not only add a property in it
so everytime the native constructor is called, it has what i need
aka b
//index.ts
export class customMessage extends Message {
clap() {
console.log('clap');
}
}
function mixin(target: any) {
const parent = Reflect.getPrototypeOf(target);
for (const key of Reflect.ownKeys(target.prototype).slice(1)) {
//@ts-ignore
parent.prototype[key] = target.prototype[key];
}
}
mixin(customMessage);
//overrides.d.ts
declare module 'detritus-client/lib/structures' {
interface Message {
clap: () => void;
}
}
//usage command.ts
message.clap();
if i choose not to use extends, and instead use implements, the declaration wont properly work
sometimes you just need to add logic to classes' methods, that's where inheritance comes in
like, I have a list where a value gets assigned to every object added to it
best i could do is call super() and implement my own, but thats janky as fuck
all I had to do was extend the ArrayList class and modify add methods
ah fuck it, im adding a helper rather than doing this shit
import the helper and use it instead

why are you making your own classes?
why would i not make my own classes?
can't u?
no benefit and it makes the code less flexible
we still going on the "less flexible" route, but im looking for a solution here
not improvements
use a helper class
,
export class Custom extends OtherClass {
let customParam;
constructor(a, b, c, custom) {
super(a, b, c);
customParam = custom;
}
}
but the helper class should have no member functions
doesn't js have something like this?
only real functions
also what i said
,
it'd be best to actually change the original constructor
kinda afraid fo fucking that tbh
yolo, doing my way with a helper outside this whole mess
too much shit in this already
the mess of oop
nah, oop is very clean
dont use the bad parts of ts
this does the trick for me on transpile
cuz it pulls the Message
its just on the IDE side that u get an error
but it compiles just fine
but that annoyance is bothering me too much
oop is a mess. you can call the same function twice and get different results. that's confusing
not really
shit code exists everywhere
if you call a function twice you'll get the same result twice UNLESS you're modifying variables
if you make an object and then set the state of that object and then call a function on that object that depends on the state then you messed up
well, that's how real objects work
if you make a hole in a hardwood plank it'll still have a hole if you try again
why reuse the hardwood? just get a new piece and do the same operation
then you get the same answer always
what if you want to fill the hole with epoxy?
const holeFilled = fillHole(woodWithHole)```
const plankWithResin = makeHole(woodWithoutHole).fillHole();
vs
fillHole(woodWithoutHole)```
fillHole(woodWithoutHole) at this point woodWithoutHole actually has a hole
yes
broken
So you're suggesting to basically make everything immutable and change values by cloning
why have twice the variables when you could make sequential modifications?
like, imagine building a car
functional programming rules for 99% of the code
but you buy a new piece for every operation
then the imperative shell can mutate stuff
it'd result in a huge code with a shitton of variables
each holding a reference until gc runs
Even worse, wouldn't it create a bigger memory footprint
especially in langs which aren't optimized for this
you can do this too const woodWithHoleFilled = fillHole(makeHole(woodWithoutHole));
that's...what I said
then you have a huge chain of internal method calls
compare with this
they can run on multiple processors since they dont share state
easier to run in parallel
or concurrently
I think the issue here is you're trying to fight against the language's native paradigms. You probably wouldn't be writing software utilizing concurrency in JavaScript in the first place.
the main thing is that it make code easier to reason about
now, let's step up a bit: ```js
const hardWoodTable = makeHole(woodWithoutHole)
.setColor("Royal blue")
.fillHole()
.addLegs(4)
.paint();
The builder pattern sucks anyway
does paint() rely on there being legs added first?
yes
now, let's step up a bit: ```js
const hardWoodTable = makeHole(woodWithoutHole);
hardWoodTable.setColor("Royal blue");
hardWoodTable.fillHole();
hardWoodTable.addLegs(4);
hardWoodTable.paint();
non-builder pattern
just...remove the legs?
or use methods to modify the state
That's the same problem with the builder pattern I have.
that's still the builder pattern tho
and update the paint method to forget about the legs
Type interference languages 
isnt
I'm not building anything there
I'm just modifying the state with ops
hardWoodTable.convertToMetalTable()
Too many builders imo have required fields that they don't require you to set when initializing the builder.
now hardWoodTable is actually a metal table
imperative bad, declarative good
In that case yeah
yes, what about it?
You can still be declarative while using a "builder" design.
e.g. SwiftUI & Jetpack Compose
that's the problem with mutations. you start off with something and then change it a bunch. the order in which you change it matters so it ends up being really confusing to reason about
You can still use imperative programming and avoid that problem though.
I don't really get what the issue is
that's not really an issue regarding OOP but logic
logic doesn't have that issue
Why does writing a thread pool implementation suck
because you're using threads
identity!
threads aren't that bad. Not needing the threads to send arbitrary ops to the parent or vice versa is good and easy to implement
you cant do f(x) = x and then say actually f(x) = z now
I mean, if you went the way you were saying, you'd have:```js
const woodWithHole = makeHole(woodWithoutHole);
const WoodWithColoredHole = setColor(woodWithHole, "Royal blue");
const woodWithBlueHole = fillHole(coloredWoodWithHole );
const woodWithLegs = addLegs(woodWithBlueHole , 4);
const hardWoodTable = paint(woodWithLegs );
that screams spaghetti
put that in a function in it's own file. rule of thumb to not have the line numbers go past 150-200
logic is also "if you kick a dog, dog will bite"
you still have a shitton of variables
one for each mutation
logic is quite arbitrary
I'm talking about coding logic
that's sets and logic
pseudo-random number generation somewhat breaks set and logic since you theoretically can predict the logic, but it's not guaranteed to follow a shallow expectation
coding logic isn't exactly set and logic. Plus, protocols change
a fp random number generator takes a seed value to work off of. it'll always produce the same random numbers with the same seed
that's why I was saying you could predict the output, but I'm sure no one bothers to try to predict it
their methods don't exactly follow prediction, but brute forcing
they observe the patterns after gathering enough of the output
computers are not good at actually being random
The security of cryptographic systems depends on some secret data that is known to authorized persons but unknown and unpredictable to others. To achieve this unpredictability, some randomization is typically employed. Modern cryptographic protocols often require frequent generation of random quantities. Cryptographic attacks that subvert or exp...
actually, true random doesn't exist
perhaps
Not perhaps.
no, it really doesnt
It's fact.
everything is reversable
depends on the source of randomness
There is no such thing as true randomness.
and the general guessability of a number
say a source that is truly random
the important metric isn't really "randomness" but more "guessability"
of course pseudo-random generators follow specific logic which can be "static", that doesn't mean logic has to be described as static because variance still occurs.
By your logic, we cannot be random because our environment as well as our hormones affect our behaviors.
entropy?
entropy is reversable
like, not necessarily possible to achieve
but is reversable
once again, randomness isn't really the metric here...its guessability
like after all energy has been used it'll collapse and then to another big bang?
"how hard would it be for [xx malicious party] to guess this number?"
thats really all that matters, not randomness...those things happen to be very similar but the difference is that hard-to-guess-ability is achievable, randomness....well its a lot harder
no, like, if you reverse time entropy will go backwards
since it is time-dependant
but going back in time is not a thing
also entropy goes backward on negative kelvins
that's what I said
I think this is getting a bit de-railed from "development"
it IS reversable, just not achievable
It's still development-related, but better discussions could take place
random number generation is pretty reasonable of a discussion to have for development
as are the security implications of improper number generation
it seems to no longer be such
doesn't that mean it's not reversable?
not being achievable doesn't make something impossible
what the difference?
former implies that it's not possible to do something with current technology/knowledge
after something hasn't happened it's impossible for that thing to have happened because it didn't happen
not achievable - we currently can't do it but eventually we might be able to (ex a quantum computer in your pocket)
impossible - laws of the universe, etc. (ex surpassing speed of light)
it's only possible before the time passes
quantum tunneling as data transfer is an example of non-achievable but possible thing
doing that yesterday is impossible
unless it did happen
i'd say that currently, truly random numbers are not achievable...but the alternative (the randomness apis built into your OS) is good enough for anything that anyone in a discord bot development server would be making
laughs in threads
os threads or discord threads
it seems that the universe has sources of randomness (positions of parts of certain particles can appear/disperse rapidly and in random positions that show no short or long term patterns and can't (as far as we can tell) be influenced by outside sources....but that won't be built into your phone anytime soon
discord threads
they're pretty good
going to be a massive pain in the ass but ya know, pretty cool
need a thread bot here tbh. When something is getting too heated, just do !thread, if 5x people do it within x time, open a thread for them to clean chat off their shit.
(i want royalties if u stealing this idea)
also going to kill basically all ticket bots lol
yeah they would be nice
that's reversable by time manipulation too
I plan on using them in a server of mine for spoiler-oriented discussions so chat won't look like a classified CIA document
a true random thing would have to be something that isn't influenced by anything other than itself
discord will release this in like a month with proper ui and not some garbage solution...we've waited 5 years or whatever, we can wait another 2 months
not even time (as in, if you reverse time that "thing" wouldn't be there anymore even at the same moment it appeared before)
threads require permissions to be opened. i had threads for almost 2 months now
hence the need for a bot, otherwise people would just spam open them
yes for encryption applications this is 100% true
sadly, time does influence it
threads have only been available for like 4 days...
Threads have been available in select guilds previously
for you, perhaps
yes
no, for the entire platform...
no...
they've only be fully available for anyone to opt in in the last 4 days
sure they released for their special beta guilds a while back, but not platform-wide
in the same way select buttons have been around for about a month and have only just released them to the public
the opt-in thing is now platform-wide for those of us who can't manipulate random number generation lmao
it wasn't even just for official guilds
i was in whitelist way before they were out my dude
they released them for libdevs
and big bot devs
cool

good for you?
thanos beta...again
so dont call me out then
yeah, for the public
you are 1 person with early access
the public has had it for 4 days or whatever (I think its more like 2)
what does publicity have to do with what i said?
maybe there were 100 people with early access, i'm assuming all the big lib devs got it
man, i would just give in and admit you were incorrect at trying to call him out on it lol
everything? a feature being public or private literally defines its existence/availability
?
i said u need permission to open a thread, so instead of giving everyone permission, just use a bot when its out
it ahs nothing to do with how it works
being public or not
it requires permissions
period
normally discord does the so called "thanos beta" where half the ids get it and half doesn't
i never even stated the fact that it was public or not
what do you want me to say? sorry I didn't know about some niche early access program where a tiny select group of people had access to it?
that does not change the fact of what i said
plus some special individuals like famous streamers and big devs
threads are already a thing since official docs were released
the docs for threads have been out for a long time
I was unaware anyone had access to them since the docs dropped
then what does it ebing public or not change the fact that it requires a permission?
no, like, the final docs
I figured they were putting the docs out in advance before they had a final-ish UI out
Man has been under a rock for a while
๐งต so not achievable is just currently not achievable, but maybe someday or maybe not someday
it doesn't and I said nothing of the sort
yes
or maybe I just don't care

#development message u did tho
i can agree with that
I was responding to the second section of that message, after the period
i was commenting on the fact a bot could be used to prevent having to add @ everyone with permissions to open threads. then out of nowhere u implied that it wasnt out. like it changes what i said tho
I could care less about the permissions lol
how does that change the fact tho?
it's couldn't* care less
i added dropdowns an hour after it was out
yes but thats also the saying so I won't change it
but yeah I agree very annoying
i've learned to just accept it ๐
that technically means he cares so much that he's at the ceiling of caring
it doesn't...?
then?
exactly, very stupid expression...really should be "couldn't care less" being at the "floor" of caring
you should stop dragging out this pissing contest?
you could've stopped anytime
and then goes on to post that
What is this?
Is there a way to check if a channel exists at all?
You tried making a request to a URL but it wasn't found
yes, what lib are you using?
disc.js
Use <Collection>.has() on <Client>.channels.cache
The only request think should be the autoposter sooo.
May you show us the full error message? That doesn't seem to be coming from @top-gg/autoposter or anything
So something like message.guild.channels.exists(<CHANNEL ID>)
<Guild>.channels.cache.has(<Channel ID>)
for music bots, ytdl-core is good or ytdl-core-discord?
Going for ytdl-core should be fine, the other one is just a wrapper for it and its bloated
Not sure, are you using the top.gg's autoposter? If so what version of it are you using?
but that says, ytdl-core-discord will improve perfomance greatly
It won't
does ytdl-core, takes opus streams by default? from youtube?
yes, basically just takes a YouTube URL and downloads it and converts it to a readable stream
I mean you could use ytdl-core-discord if you want as its made by the owner of discord.js, but not sure if it actually improves performance
You could compare their efficiency and performance by trying both I guess
Now im having even more errors, so if a user does NOT ping a channel it just crashes because how can you find the id of undefined?
So can i check if the user actually pinged a channel
Idk, but it doesnโt happen often. Like 1 in every 1000 posts it gives the error while the other 999 are successful.
Then use <Message>.mentions.channels.first() and check if its not undefined with an if statement
durr
const channel = ...;
if (!channel) { ... }
...
yep
also can u tell me, what sodium is used for?
thats it
when mixed with chloride it makes salt
When mixed with bleach it makes mustard gass
Then nothing much you can really do about that, its a common error
Oops, i mean in discord bots
I know, just messin with ya
hmm interesting
Lib sodium aka the black-box, its used in discord.js to create random bytes and stuff like that
https://github.com/jedisct1/libsodium
ah, like salt (as in "salting the hash")
