#development
1 messages · Page 1720 of 1
what does the commands do?
if you do image manipulation maybe make a internal API and run a external process for this stuff
i do this with Tensorflow for one of my Bots
or boost whatever you're doing with node gyp if you have enough knowledge with that (or if there's a library for it)
they're using python
I mean you can call c functions from python but not with node-gym
ight
you can also do postman if you don't fancy working with CLIs
thonk
{
"message": "401: Unauthorized",
"code": 0
}

should I send my whole code on a bin
sure
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.
are you able to dm the access token? i wanna check something
sec
k
if(reaction.emoji.name === ":white_check_mark:") {
let ad = message.channel.send("Veuillez rentrer le salon où envoyer l'embed:")
s2.channel.awaitMessages(filter, {max: 1, time: 300000, errors: ['time'] })
.then(async collected => {
const channel = message.mentions.channels.first() || message.guild.channels.cache.get(args[0]);
console.log(channel)
channel.send("hey")
})```
https://media.discordapp.net/attachments/223867697312694272/835421321583919104/unknown.png
channel is undefined
...get a channel that exists?
hi
Since I'm still confused about the privileged intents: What exactly would a bot need presence data for?
actually nevermind lemme ask that in discord developers
Yeah nevermind, definitely not gonna need any of these 
a good example is mod bots that have some anti ad system
checking for invite links in activity etc
i have anonymous dm system. when a user goes offline the dm session automatically ends
i totally did not have a client on fiverr that ordered a program that uses user tokens to display invite links as their activity
it good for those who want to notify who is streaming, with presence intent
and i totally did not make that
i require them to be online otherwise the bot will break
wiki12_#8466
how would an internal API help?
it would still take the same time, and hang the bot
it would run on another process?
btw 20 seconds is abit much, it ususally takes 2-5 seconds, rare cases are up to 8-10
child_process , IPC, and http APIs , are 3 ways to mitigate this
I am already using multiple sub process for this from within python
seems that your underlying issue is that you're executing commands in a blocking manner
How do I check if the emoji exists on the server? So if the user writes :thisEmojidoesntExists: --> this emoji doesnt exist on the server. And if you write ❌--> this emoji exists
anything that's async shouldn't block it
theoretically, awaiting it puts it in ordered execution which has a close enough effect to blocking
whats weird is that i am doing it asyncly
run_in_executor gang
asyncio.ensure_future(prefixed_command(message))
and prefixed_command
basically calls the DB for some info, and generates image/gif
I sometime also have that issue with gif manipulation...
The process stops responding and event execution is delayed for the time its being processed
and if its a gif, it uses multithreading for each frame
exactly
Maybe you just need a whole new level of computing power
gif encoding can be computationally expensive
btw python multithreading isnt multiprocessing
yes
qt
Worker threads dont work coz i can't pass a function though it.... or maybe
no u ily
You have a predefined script that acts as an api then make local IPC calls to it
Thats what I was thinking
How do I check if the emoji exists on the server? So if the user writes :thisEmojidoesntExists: --> this emoji doesnt exist on the server. And if you write ❌--> this emoji exists
Move all image stuff to an api
In my case, image manip isn't that expensive and the biggest bottleneck is actually uploading the image
api wont help
only way is to parse the message using regex to extract the emoji ID and then check if it's in guild.emojis.cache
u still have to await it
default emojis work on all servers, if thats what you're asking
await should not be process-blocking, though, Bentzy
2 threads doing 2 different things is better than 1 thread being blocked
I mean I don't use python so I don't know but async/await being blocking sounds absolutely wrong
but while im generating gif the bot hangs
Are you sure it's not in the same process
because that should only happen if it's in the same process
async functions aren't automatically async
yes that indicate a blocking function
well im just using on_message
and this apperantly isnt really fully async
so if one on_message event still being handled, it hangs
or atleast this is what it seems from gifs
but i did have random images sent (from different commands) out of order which indicates thats not the case
so i dont even know anymore
maybe its just a file lock
In that case, you should probably cache images in mem
unless that's totally unreasonable
sadly it is unreasonable
i have a web dashboard where u can drag avatars and text with timeline on gif
then it generates it real time every time
and depends on who you tag in ur command, it places different avatar
it all worked pretty good until i had surge in servers and users
now with over 5k servers it still works good
but a-lot of times it misses on_guild_join and on_member_join
even when gifs arent hanging the bot
maybe you should scale your web processes?
i assume it really messes with discord api when the bot stops responding and back
its on a pretty beefy server rn
hmm
this is why i was asking in the beggining
can i just seperate it
have the gif gen on a different python
yeah you could
and run it on the same shards
you could make, for example, a imagegen.py
that acts as an internal API server
and when you generate an image, you provide it with the necessary info to generate the image
how?
Look for custom emoji parsing regex on Google, I certainly don't have that sort of thing off hand.
@boreal pewter I was fucking around with websockets for a bit
oho
Server:
And I have two clients like this, one sends a request to server for elements in range from 0 to 1999, the other from 6000 to 7999
I'm running all 3 separately and the server seems to be handling stuff just fine
You mean aiohttp websockets or just aiohttp generally?
aiohttp websockets
Are they more feasible/performant compared to websockets?
I want to have the info, how much user have a role. But
let role = args[0]
var InfoRole = msg.member.guild.roles.cache.find(r => r.name == role);
InfoRole.members.size
doenst work. Can someone help me?
yes
considerably
Because I'm used to using the websockets module
I'll have a look at aiohttp websockets later
Also... you could look into UDP or TCP, which afaik use less resources than websockets
Tru
can someone help me please 😅
you have to be more specific
how does it not work?
any errors? something else happens?
No I dont get any errors. I just get back a random number, which is wrong
the cached amount of users might be different
how do I get then the number of users who have the role?
your method is correct, but to get the exact number of users with the role, you will need to fetch the data of all members in the guild
how? 😅
@slender thistle thats cool but how does that relate to me
this wouldnt help
i still have to upload that image to the text channel at the end
so i would need async jobs for that
which i can implement
Can the ID of the person clicking the reaction be taken with d.js
still no need for api
yes, you await the response from the other process
i am already doing that today
without api
all im asking
Ya true
is it considered good practice
to run 2 pythons
on same shareds
shards
different code
each one will handle different thing
cant say on py, but on js it wouldnt be very smart
the client itself will create bloat
its better to have 1 client and then re-emit stuff to other procecsses
if yes, how
interesting @opal plank
he meants 2 different processes
2 .py files
like running 2 processes with 2 clients on the same token
your clients will lose sync with each other
yeah i assumed no is the reasonable answer
including sync with ratelimits
i guess ill just use django channels
have the gif generation happen completely different
and have a collector of jobs that finds generated gifs, message and channel ids, and send the gif there
or something in that area
why do you want to do it in the first place?
i'm assuming it's because the command takes too long and blocks other commands from executing or something
How do I get the info, how much user having a role?
role.members.size
This does not work. For example, it returns 2 even if 3 users have this role
you have to cache all members in the guild
no
how
yes, can you show me how?
they're entirely different status codes
you have to return 2xx
ya but they do stop retrying and i do receive the post
??
yeah ig there's no retries for 4xx
role.members.cache.size doesnt work
same for 201 right
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=members
https://discord.js.org/#/docs/main/stable/class/GuildMemberManager?scrollTo=fetch
call fetch without any arguments and it will cache all members in the guild
keep in mind
this is resource intensive
I suppose
hmm ?
I'm currently trying to split my bot into multiple threads, how many clusters should I ideally run for a bot with 40 shards? 
I dont rly understand. role.guild.members.size returns undefined
because members is an object
precisely, GuildMemberManager
look at the doc links i sent you
var InfoRole = msg.member.guild.roles.cache.find(r => r.name == role);
InfoRole.members.size
I'm already searching in the cache
<Role>.members gets the members from the <Guild>.members collection
which stores only cached members, so you have to fetch all members
any npm package I can use to get frames of a video
maybe one with an fps option too
or some other way lol
I just need to extract frames of a video essentially and get them as image buffers or as image files
ffmpeg can do that
can't I just install ffmpeg as a npm module
mm I don't think so
I just need some kind of way
use the image
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module '/home/runner/REAL-TEST-2/events/client'
Require stack:
- /home/runner/REAL-TEST-2/real.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at /home/runner/REAL-TEST-2/real.js:48:23
at Array.forEach (<anonymous>)
at /home/runner/REAL-TEST-2/real.js:47:11
at FSReqCallback.oncomplete (fs.js:156:23) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/runner/REAL-TEST-2/real.js' ]
}```
please explain
urjently
can you show the first, like, 5 lines of your real.js file
oh wait
line 47? yeah what's line 47?
that function that loads something in a forEach, show that
@umbral zealot
fs.readdir(__dirname + "/events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(__dirname + `/events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
console.log("Loading Event: "+eventName)
});
});
hey
okay so my bot has 2 running prefixes. One isn't working as (i think) this line is preventing the second prefix to work:
if (!message.content.startsWith(Config.prefix) || message.author.bot && query !== true) return;```
how can i make sure that both prefixes (Config.prefix and Config.prefix1) can both be used?
do you have a file in your events folder called client , somehow?
that looks a whole lot like the code I wrote, so, can you show what's in your /events/ folder?
hmm
just those 2 files?
One message removed from a suspended account.
const { MessageEmbed } = require("discord.js")
const config = require('../configs/config.json');
module.exports = async (client, text, channel) => {
let embed = new MessageEmbed()
.setColor(embedcolor)
.setDescription(text)
.setFooter("Believe me i am REAL 🥺")
await channel.send(embed)
}
errror.js
module.exports = async (client, message) => {
if (message.author.bot) return;
//Prefixes also have mention match
const prefixMention = new RegExp(`^<@!?${client.user.id}> `);
const prefix = message.content.match(prefixMention) ? message.content.match(prefixMention)[0] : client.config.prefix;
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
//Making the command lowerCase because our file name will be in lowerCase
const command = args.shift().toLowerCase();
//Searching a command
const cmd = client.commands.get(command);
//Searching a command aliases
const aliases = client.commands.find(x => x.info.aliases.includes(command))
//if(message.channel.type === "dm")return message.channel.send("None of the commands work in DMs. So please use commands in server!")
process.on("unhandledRejection", (reason, promise) => {
try {
console.error("Unhandled Rejection at: ", promise, "reason: ", reason.stack || reason);
} catch {
console.error(reason);
}
});
require('events').EventEmitter.defaultMaxListeners = 25
//Executing the codes when we get the command or aliases
if(cmd){
cmd.run(client, message, args);
}else if(aliases){
aliases.run(client, message, args);
}else return
};
msg.js
One message removed from a suspended account.
One message removed from a suspended account.
hmm
@umbral zealot
One message removed from a suspended account.
One message removed from a suspended account.
yeah sorry
process is .... process
look the only reason you'd have a thing that says it can't find a module client is if you're trying to do something like require("client") or if you're trying to fs.readFile("client") or something
so you gotta have a weird require or readfile in there somewhere
trying to call a file that doesn't exist
Anyone here who knows discord.js well enough to tell me how do you get the channelID of a message with only the MessageID, i'm trying to do reaction roles and stuffs.
you should store the channelID if you're only storing the messageID. You cannot reasonably get a channel ID with only a messageID
rest get message has channelID as a part of the path
@umbral zealot hy
const Discord = require('discord.js');
const config = require('./configs/config.json');
const fs = require('fs');
const { Database } = require("quickmongo")
const db = new Database(config.database)
const http = require("http");
const path = require("path");
const express = require("express");
const chalk = require("chalk");
const moment = require("moment");
var Jimp = require("jimp");
const request = require("request");
const axios = require("axios");
const snekfetch = require("snekfetch");
const fetch = require("node-fetch");
const { Collection, Client } = require("discord.js");
const client = new Client();
client.commands = new Collection();
client.queue = new Map()
may be error in this section may be
am trying to find out clint call but
i dont got it
trying to use docker with pma, when I start pma it logs this, and does not work
https://i.callumdev.pw/npi0b.png
How can I get all arguments after the second argument?
Slice off the second arguement?
How does one use list, and or dictionary manipulation? (Discord.js)
Well most args that I see in discord bots are an array

so just use the slice function on the array and slice off 2 arguments?
how?
I legit just explained it...
Use the slice function on an array and slice off the first 2 arguments
There are few ways to do it:
const [arg1, arg2, ...other] = args; // If you need the first two as well
const other = args.slice(2);
That's what I was talking bout but didn't wanna spoonfeed 
Why are you importing 5 different libraries for making http requests?

Honestly the only library you need is axios there cause it's the best http request lib out there

well I guess I can't say the best tho.
args.slice(2) doesnt work
it will still take all arguments
lmao I use node-fetch some times
const other = [1, 2, 3, 4, 5].slice(2);
// other is [3, 4, 5];
It does work ^
slice doesn't modify the array it creates a new one
and for what stands [1, 2, 3, 4, 5]?
oh my...

Am I lost?
Do you know how .slice works?
it slices things into an array. If you are slicing ' ' it will remove the "space" and and slices the words into an array
but I dont get it how this works



[1, 2, 3, 4, 5] is an array with 5 elements, it was an example to show you that slice(2) is going to return all elements except the first two
the length of the array doesn't matter, as long as it has more than 2 elements, it's going to return all of them except the first 2
just realized that I wrote split instead of splice. that was the error
Im so dumb, sry for the issues
and thx for help
You need to setup worker, add "Procfile" at root with worker: npm run start
worker: npm run start
does anyone has a good tuto about quick db X discord js
show more code
ok
Use try-catch to catch the error and do whatever with it
const polle = new Discord.MessageEmbed()
.setTitle('New Poll')
.setDescription(`**${question}**`)
.addFields(
{ name:'Author', value:`${message.author}`, inline:false},
)
.setColor('RANDOM')
let msg = await pollchannel.send(polle)
await msg.react(':thumbsup:')
await msg.react(':thumbsdown:')
message.channel.send(`New poll had been created in ${pollchannel} by ${message.author}`)
if (error) {
message.channel.send(`I got an error. Bruh. How are you even getting these?! \n Error: **${e}**`)
}
console.log("Poll command had been ran..")
}
}
(not all)
I wanna to host my bot 24/7
Can anyone suggest me the best platform to host my bot
galaxygate, digitalocean etc
but they are paid
free or paid?@lavish bramble
hosting
Is it 24/7
yes
yep
Thnx
np
This website is on ur status too
yeah
So u host that web
Oki
When starting out, is it better to code with JavaScript or Python. I heard it’s easier to code in Python, but JavaScript has more functionality within the API. Any recommendations?
imho javascript is just english but you use . instead of
at least for the basics
ex. creating a bot:
const { Client } = require('discord.js')
const client = new Client()
client.login('token')```
JavaScript will prepare you for the other languages better imo
python is confusing for me but some people say its easier ¯_(ツ)_/¯
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
why triple quote? python string? lmao
One message removed from a suspended account.
Alright, I was just scared to learn a language that wouldn’t be that useful 😅 thx
One message removed from a suspended account.
sarcasm
One message removed from a suspended account.
All languages are useful
One message removed from a suspended account.
One message removed from a suspended account.
ehhhh
Have you seen lolcode
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Didn't they use fortran instead
One message removed from a suspended account.
what
and mongodb for the database
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
the same way tons of businesses still run windows 98
One message removed from a suspended account.
Aren’t all languages from that time?
One message removed from a suspended account.
One message removed from a suspended account.
new languages are invented all the time
One message removed from a suspended account.
Most popular languages are old, but not invented all the exact same time which is obvious
many times they are layers on top of other languages tho
One message removed from a suspended account.
For example C, the grandfather of all languages
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
and brainfuck was inspired by pain and suffering in 1993
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Wait so if learning JavaScript makes it easier to go into other languages, are all the other languages somewhat based on JavaScript? 😂
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
javascript is based on other langs mostly
One message removed from a suspended account.
By learning JavaScript, you learn the basics of programming and can easily learn other ones when you know the basics
One message removed from a suspended account.
One message removed from a suspended account.
the basics of programming and logical problem solving are the same in nearly all languages
One message removed from a suspended account.
Wow, so you know three languages. How long have you been coding?
One message removed from a suspended account.
Learning JS won't help you that much in staticly typed languages since JS is dynamically typed, so you can use TS, TS is just a superset of JS
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i regret not getting into programming sooner as well
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Getting into programming really early helps a lot
but what really helps is to have an actual goal
One message removed from a suspended account.
i only got seriously into programming when i came up with an actual goal of what i wanted to create
before that i couldnt
One message removed from a suspended account.
I am 15 lol, not sure if that’s early tho... 💀
What's the point of programming when you don't have a goal or don't know what to create at all
making a discord bot is a very common goal for many beginners here
İt is
That can be considered early
not that early tho
Some people here got into it at like 11 years of age or something
Oh wow...
wasnt there a popular discord bot that advertised itself as being made by a "9 year old programmer"?
Never heard of it
i think i remember something like that back in 2015 or something
In which lang I can create my own database?
Wait... a 9 year old made a bot for a platform that’s 13+ 💀
first chose which database software you want to use
Almost all of them
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i doubt they mean that
One message removed from a suspended account.
One message removed from a suspended account.
Is SQL good?
One message removed from a suspended account.
its a good language for interacting with relational databases
its not a complete programming language in itself tho
They might have gotten banned, might be the reason I never heard of them 
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
All the tutorials I watched recommended them, so idk
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
its a language specific for use with databases
Ahh okay
so when you get to the point where you want to use a database, you'll learn it
SQL is not bad at all, some people have reasons to go for non-SQL stuff, there's no bad reason to actually use SQL
i use sql myself
One message removed from a suspended account.
ORMs 💪
ordinary russian males
it stands for Object Relational Mapping
ORM
lmfao
Hey guys, you use google analytics in your bot's website?
no
Now I am conflicted
object relational mapping is the name used to refer to programs and systems that are built on top of databases to make them easier to use
you dont track the users?
Thx for the info 🙂
nope
i would likely track that on the koa app itself instead
would likely give a lot more specific things
time spent on it per ip
which pages they visited
how many visitors
how many clicks on invites
here's an example ```js
// normal sql database
let mydata = "abc";
mydatabase.sql("INSERT INTO mydata (name) VALUES (?)").execute(mydata);
// ORM database
let mydata = "abc";
myormdatabase.set("name", mydata)
theres a lot of data google cant track
imagine not ```ts
//Postgres BAE wink wink
let mydata = 'abc';
postgresBae.query("INSERT INTO mydata (name) VALUES ($1)", [mydata]);
// normal sql database
let mydata = "abc";
mydatabase.sql("INSERT INTO mydata (name) VALUES (?)").execute(mydata);
// ORM database
let mydata = "abd";
myormdatabase.set("name", mydata)```
😂
i have no reason to track data, i dont do anything with it
me neither, but being a dataphile is a hard task
depends on the lib lul
You wouldn’t care about views, or clicks, or time spent?
to be used to improve quality
postgres > all
i use mongo -.-
(:
'iev ehard good things about the other thingy
I use VS and it just automatically has it... so I kinda use it
fuck whats the name
scylla
thats the one
foundationdb and scylla
someone was telling me at how good at scale they are
do you need multi-process and/or multi-machine? use a regular db (mongo, postgres, mysql/mariadb)
no? use sqlite
its that simple
even though im reluctant to even try foundationdb cuz its from apple
What’s wrong with that? 😭
cuz apple
Apple makes quality things 👌
just knowing its apple, theres probably 58 overpriced paywalls behind it
apple makes shit things
^^
and overprices them
^^
Such as $999 TV stand?
Lmao
Understandable
phones without chargers
anyway, enough shitting on apple
Omg... everyone agreed on that, HOWEVER... that was one product
ONE
😂
and new chargers not compatible with old
iev heard good things about their foundationdb tho
apple was fined millions for selling phones without chargers in several countries
Every product made by them doesn't deserve the price they have
run away from apple while you can, dont let yourself degenerate into an apple fanboy
help, why do i get this error?
(node:24) UnhandledPromiseRejectionWarning: Top.GG API Error: 404 Not Found
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:96:9)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
i'll likely keep sticking with postgres/keydb though
postStats() failed
@slim heart
as to why, good question
Too late 😩 it’s def the ecosystem... the way everything just syncs together...
what in your code do you have as poststats() ?
or, shall i say, inside of it
except you never know wtf its going on in the background and when something breaks its a nightmare
a lot of apple shit has no indicators whatsoever
like syncing pics with icloud, you dont know how much its done, how much is left, or even if its actually doing something
yeah im not getting the same errors so im not sure
no users like errors on their screen
yes

that wasnt a yes or no question
what you have INSIDE there?
oh
i see why berry
@slim heart see their role? yeah, me neither
ah yes
looks like an unnapproved bot
not yet, still waiting
just today i uploaded it
-.-
you cant post to an unapproved bot
you cant use the api while its not a approved
oh
i see
actually
i think xetera showed me a way before to get token
maybe it was shiv or veld
i cant recall
though it was on v1
haxxor
What platform do you guys code on?
No I meant like OS, because I remember hearing someone say coding on Linux is better
why would coding on linux be better
gcc
gcc also works on windows
depends on the langs
for many low level languages, linux has better compilers and tools
intalling ANYTHING on linux is a major pain, specially with drivers and deps
but for high level languages such as js and py there is no difference
imo it's the opposite
Lmao that’s true 😂
anything you go offbrand will backfire gracefully on you
There is wsl
of course, mainstream stuff is very well maintained, no complaints there
i had issues before where compiling on linux worked out of the box and compiling the same thing on windows was a nigthmare
Download MinGW - Minimalist GNU for Windows for free. A native Windows port of the GNU Compiler Collection (GCC) This project is in the process of moving to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files f...
many native libraries have specific installation instructions for windows
often requiring additional crap
but it just seems to counter productive having to spend 15 minutes installing stuff with depedencies, drivers, etc when on windows we all have the same simple installer/wizzard
install/choose folder/i agree with terms(nobody reads)/ done
c3pO
its been a whole month procrastinating this
and i cant push it to prod until its done

hilp
wut
theres a big chunk of my code that needs rewriting, and thats literally the only thing preventing me from pushing updates to production
been hot-reloading this whole time

wanna du it fur me?
exdee

in ts?
sounds like a you problem 
this lmao
no thx :^)
Wait, you guys work together on bots?
never
not really, we just bounce ideas off each other
^^
and help with shit
its more of a "im too lazy to do it" rather than an actual "idk how to do this, please enlighten my ignorant self"
If c++ had a good package manager like cargo then I'd use c++ for everything
but alas
Oh, that was one thing stopping me from creating one lol, because bots like MEE6 have teams so it’s hard to compete with them... 💀
c++ with a package manager would be a nighmare
not really tho
imagine searching among thousands of shit libs
made by junior devs
during internships
Shit devs cannot write c++ come on now
it will take a good month or two to create a good bot if you pour some work everyday
this aint js 
interns and programming students who are forced to use c++
but have no idea what they're doing
do these people exist
sounds like the whole js community
xD
...
look mom, i made package with 12 lines, imma publish on npm and be famous
I feel attacked
is-thirteen
im willing to say 70% of npm packages are completely utter shit
I want to make a useless package one day
💀
the worst thing
safely, 50%
is when you need X
70% is my estimation based on opinion
but there are 500 packages that do X
and all of them claim to be the best
because everyone makes their own
why are there a million libs for making http requests 😩
and even worse then the ones with "fast" in their names are usually the slowest
I can name like ten http libs rn
should've gone out of the swarm tbh
3 days, final offer
weeb above
no u
fuck
does ourcord still exist?
no shit
tell us something new
😩 what isn't shit these days
Is it bad to get code off of StackOverflow? 😔
yes
its bad to copy paste code
if you LEARN from stackoverflow, yes, if you copy paste, then shame on uyou
imo it's not bad to copy paste if you know what the code's doing
though i used to do that a lot
Nooooo, I would never steal code...
copy apsting
nice
Lol, and I know, I don’t.
did you guys know that each js string takes up a minimum of 40 bytes?
even if the string is 1 byte long
Although I do get mad sometimes when I finally find someone with the same issue, but then they just say they found the answer without actually saying what it was....
sounds optimized
why
same
typical asshole
cuz it was meant for borwsers not for optimized code?
the problem is not the collection class per se
its with now many instances of them are used
howso?
So is discord.py faster?
a map object has like 60 bytes of overhead
and djs uses hundreds of thousands of instances of them
not really
py is a little more memory efficient
its structures probably have less overhead
but its mostly the same thing
Okay, what if discord.js light edited the collection class, instead of it extending a map it just uses a plain object under the hood
It’s not that bad... at this point it comes naturally
with full caches it would likely be very close
hmmmm interesting
not gonna make a difference
its still a Map object
have u tried on v16?
how
using the v9 engine?
8.9*
dunno if they did any optimizations
xd
isnt it on 9?
oh nvm it is v9
new engine, might worth a look
Doesn't look like there are many optimizations in v9
V8 release v9.0 brings support for RegExp match indices and various performance improvements.
faster super access
there u have it
hmmmm thats interesting
djs uses Collections for everything, like a collection of guilds, and each guild has a collection of channels and each channel has a collection of messages, etc
those quickly multiply themselves to hundreds of thousands
and that causes a massive memory overhead
no matter what you do to the collection class
its always gonna be there
each message has a collection of edits, each user has a collcection of presences, each channel has a collection of edits
yeah but what if instead of the class extending a map, it uses an object to store all pairs
it would improve a little
but not much
Objects also have a big overhead
the problem is how the caching is structured
too many layers of depth
too many multipliers
i have ideas for a better caching strategy
will experiment with it in the future
but not in djsl
class Map {
constructor() {}
get(val:any):any | undefined {
return this[val];
}
set(key:any, val:any):void {
this[val] = val;
}
}
let map = new Map();
what about this

get can be boiled down to return this[val]
it'll be undefined if it's not in the object
let me test something real quick
i couldnt recall if it would error if you tried that
so i added that, but if it doesnt, yeah
thats better
js wouldn't be very dynamic if it errored ;d
yup, that's good although iterating would be a little harder to replicate
i mean, not sure if theres anything better, but Object.keys()/entries()/values()
Yeah Object.entries
technically i dont even need that | undefined
that would work
the first
yup
cuz more objects
yup
the second is faster probably cause the arrays all contain values of the same type
a uses more ram than b and c combined
damn
nope
where you have tables with ids columns that reference keys in other tables
there is a trade of between access speed and storage
in dont remember which is which now, normalized or denormalized
but for example, instead of having a reference to another table, you have a key for another table
so you access table2 by getting the key from a column in table1 first
you essentially have duplicate data in table1 and table2
table1 has an id column with the ids for table1, and table2 has a "keysfortable1" column with the same data
thats done for faster access speeds
but doubles memory usage for that specific piece of data, becasue 2 different tables have the same values
in js you can basically do that exact same thing
and it actually uses less memory instead
its stupid
lmao
and this has been Tim's Ted Talk. Applaud everyone!
though thats an interesting thing to know
👏 smort
so the opposite can be done too
and instead read if off disk to preserve ram
though that would also decrease the speed
balance is everything
for example, keeping cache of the keys instead of values
postgres for example has a approximate value of entries
couldnt you keep a small cache of only keys to be accessed/checked?
instead of loading the whole table for indexing?
umm
yes you can keep only keys in memory and store the actual data elsewhere
heyo can someone help me set up a bot role system?
sign in into heroku
ive tried many times but its hard for me to figure out and i dont want to do it manually
I think its setted up on Discord Developer portal prommision thing, where when someone is inviting your bot, they can accpt certain prommisions, and on that info, the role gets created.
I'm changing my bots code to JS and I'm trying to ping/mention the author of the/a message
but why?
the Message object has an author property
the author property returns a User object
and finally the User object has a mention property
nevermind it does not
oh well
you can use the id property of the User object and then do this
ok, I'm listening
`<@${user.id}>`
Is there a way I can change it to the users name and not id?
you cannot ping a user without their ID, no.
You can however mention them and access message.mentions.first() to get their user
put that in a string and they get the ping
user.username would give you a username, while user.tag would give to the full tag, like my Hindsight#2020
tysm
you dont need that but ok lol
Hello, is there a way you check the id of two channel with the same name?
what's the context behind this question?
'guildMemberUpdate', (oldMember, newMember)
or 'nitroBoost', (booster) ?
there isn't a nitro boost event
or a boost event in general
detecting a boost is really iffy
ironically enough, the event exists for user accounts lol
but not for bot accounts
keep in mind
a guild can turn off boost messages
so
Try client.on('nitroBoost', (booster) => {
Oh
appellation's comment is the best one
vladfrangu's comment does not account for already existing boosters
the premium since timestamp does not change when an already boosting user
boosts again
so 🤷♂️
¯\_(ツ)_/¯
ok
@earnest phoenix I opened the yardım.js file in the commands section and pasted my code directly and deleted the LOG sections in the command handler, but encountered such an error. Note: I had to enter English, now you will translate xd
I can t translate sorry bro
if(!message.guild.roles.cache.find(x => x.name === "Møon-verification")) {
message.guild.roles.create({
data: {
name: "Møon-verification",
color: "BLUE",
permissions: [ "SEND_MESSAGES", "READ_MESSAGE_HISTORY" ]
},
reason: "Configuration du système de vérification"
});
}
const moonRol = await message.guild.roles.cache.find(x => x.name === "Møon-verification");```
When I get the id of a newly created role, it returns undefined (basically it can't find ...) and I have to issue the command a second time for it to find.
The awaits are not enough, .then () cannot be fixed here because in any case I get the identifier that it already exists or not, how I could do so that it does not do both at the same time ?
find is not an async operation
there's no need for await there
and
use the role that's returned from the create method
you're supposed to await that
Yes but if the role exists, it will not execute the role creation
yes it will
lol
you don't await so the code doesn't even wait for the role to be created and instantly jumps to trying to find it
and even if you do await it
you would be finding it as soon as it's created
and you still won't find it
because there's not enough time for it to go over the gateway, get parsed and added to the collection
Ok, thx
tldr you want this
const role = find(condition) ?? await create();
this will attempt to find such a role
if it doesn't exist
it will create it
and you're granted that the role variable will always be a Role object
unless you don't have permissions to create a role
in that case, it will error out
How I can fix this?
PS C:\Users\...> node ./dist/server.js
file:///C:/Users/.../dist/server.js:3
import { ShardingManager } from 'discord.js-light';
^^^^^^^^^^^^^^^
SyntaxError: Named export 'ShardingManager' not found. The requested module 'discord.js-light' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'discord.js-light';
const { ShardingManager } = pkg;
tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "ES2020",
"outDir": "./dist",
"rootDir": "./src",
"removeComments": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"noImplicitAny": false,
"moduleResolution": "Node"
},
}```
umm, discord.js-light doesn't exist I guess
how can a discord bot do this?
I cannot add commands to my bot
Discord.py

Oh nvm
@earnest phoenix need some help ❤️
did you try what it tells you to try?
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'discord.js-light';
const { ShardingManager } = pkg;
I can't, that's the result of the code in typescript
npx tsc node ./dist/server.js
ah thats the compiled code?
yes
😔







