#development
1 messages · Page 2052 of 1
and 90% of the servers im in people dont like them and would rather use normal prefixed commands
prefixed commands are just easyer to use and implament and i cant help but think on the bot end they are massivly over complicated to make work
To be fair, I have felt that slash commands have been easier for me
- No need to implement my own permission system (Slash commands v2 allows server admins to set their own in the Discord UI)
- No need to store users locale, able to provide localized commands out of the box
- Input validation on the client, users make less mistakes when trying to run a command
- The users have used more of the commands of the bot, as it is easier to explore the commands using the slash command list
- With the new Bot Discovery you get automated list of what commands the bot has, no need to manually paste it to the bot overview
- Ability to run my Bot Gateway and Slash Commands handler in separate services (using the HTTP endpoint option in the discord developer panel)
i mean i will say its a much more solid way of implementing bot stuff
but like my bots are really simple and / commands are just like trying to push a nail in with an anvil
but then im betting thats discords way of discouraging people who dont know how to code to make bots so that they dont have to deal with so many dead bot accounts and badly made bots
but idk
Well… slash commands a few months ago was absolutely garbage. So I understand why people hate it and it got a awful reputation from the start
I think slash commands are actually more for user benefit.
How many times do bot support servers get asked how to run a command, or ask what the prefix is?
It's also a great way for users to see every command they can run instead of looking through each bots help command for what they want.
We are not that far away from bots that don't support slash won't be invited by server owners just because they are harder for users to use or may be confusing to new discord users.
Long term you'll be only hurting your bot by not supporting slash
Thankfully if you use a good command handler it's really not that hard to upgrade to slash, or to support both.
Tbh the hate it received was mostly due to the fact that discord just shut down doors for message intent and bots that require that just for the message based commands. New developers started shitting on slash cuz it was a bit hard for them to understand the concept of command, sub command group and sub command and the awful nesting of stuffs it has. But yeah imo slash command was always the better way as u didnt have to worry about dealing with parsing arguments. Plus the query could be perfect, reducing so many error checks that we need to do with normal message based commands
It also received hate just because it's change.
We have had this awful prefix system forever, it's really hard sometimes to see a change is for the better.
Mind sharing the code where you set and use the Topgg sdk? (remember to remove the API key)
Fr. Now bots on Discord are actually treated properly like bots instead of basically being user clients.
Also this ☝️ 💯
Making slash commands really isn't any different if you've made a good handler. My bot runs both prefixed commands and slash commands off the same file using the same code. If you make a good handler then your life becomes much easier. I actually enjoyed refactoring my code for slash integration. I didn't think I would before I started (I was kinda dreading it) but it's really not that hard.
If I was making a new bot today, I'd go 100% slash commands. I can't do that with my current bot because I have an established userbase and it would be a really bad idea to force it upon all my users, but I'd love to remove prefix support entirely one day.
I'm already going to add a feature where my users can disable prefixed commands in their servers so they can benefit from slash permissions if they want to.
Hey. what's the best way to send a tabular format data in an embed? table2ascii works but the formatting breaks in mobile. I have three columns and can have at most 10 rows, any ideas on what's the best way to show this in an embed?
Either make your table max width narrower so it works on mobile or use canvas and embed it as an image.
Or just host it on a webpage and post a link to it in your response
Like "see leaderboard here"
import express from 'express';
const server = express();
import client from "./index.js";
import { MessageEmbed } from 'discord.js';
import Topgg from'@top-gg/sdk';
const api = new Topgg.Api('what you wanna see') //token
const webhook = new Topgg.Webhook('see this guy again') // add your Top.gg webhook authorization (not bot token)
server.post('/dblwebhook', webhook.listener( async (vote) => {
await api.getBot('960381632471240744') // returns bot info
let a = bot.monthlyPoints
console.log(a)
// vote is your vote object
let channelId = client.channels.cache.get(`971718503914680340`)
const user = await client.users.fetch(vote.user)
let x = Math.floor((Date.now() / 1000) + 43200)
let y = Math.floor((Date.now()) / 1000)
const exampleEmbed = new MessageEmbed()
.setColor('RANDOM')
.setTitle(':doge_disco: New Vote On Top.GG :crazy: ')
.setURL('https://top.gg/bot/960381632471240744/vote')
.setAuthor({ name: 'Role Icon#3800', iconURL: 'https://i.imgur.com/Gm6IiXu.png', url: 'https://youtu.be/dQw4w9WgXcQ' })
.setDescription(`**${user.username}#${user.discriminator} Voted** For **Role Icon!** \n**Thanks** To Vote ❤️ ! \n[Vote Here Directly](https://top.gg/bot/960381632471240744/vote) `)
.setThumbnail(user.displayAvatarURL())
.addFields(
{ name: 'Voted At:', value: `<t:${y}:f>` },
{ name: 'Can Vote Again At :', value: `<t:${x}:R>` }
)
.setTimestamp();
channelId.send({ embeds: [exampleEmbed] });
user.send("You Voted!");
setTimeout(() => {
user.send("You fan agin vote");
}, 1 * 60 * 1000) //inwill change this to 12 hrs
}))
server.listen(3000, ()=>{console.log("Server is online!")});
was thinking about making it an image too but there will be data that users might want to copy, that's what stopping me from doing that. Hosting on a webpage is out of the question for me, the data is dynamic and can change and it can have stuff like server id too. so staying away from that too
Whole code @winter pasture
Then your only option might be to code something yourself that makes it the right width and accounts for string length etc. I did this on my bot but had to code the whole thing myself so it could dynamically load the server's data into the table and respect max lengths and column widths. And it's just wide enough to work on mobile (but probably breaks on smaller devices or depending on a user's Discord settings like their zoom level). There's no perfect solution to this.
Why are you calling await api.getBot("960381632471240744"); you dont seem to be using it anywhere?
Ah. I don`t see anything obviously wrong
And the token you are using, is it for the bot (960381632471240744) you are providing?
At this point I'm thinking just having a string with '-' as separator and informing the users first one relates to one field and second one to other is the best way lol 
Would really love to see discord implement a feature like inbuilt table with pagination
https://docs.rs/top-gg/0.1.0-alpha.0/top_gg/ maybe. Never used it tho
API documentation for the Rust top_gg crate.
Fr. Tables and pagination could be made simpler.
Yes
and an option to include multiple images in embeds. or is it already supported?
Should I share a ss of token with you for any reasons?
Not within an embed.
I dont think multiple images within embeds is a thing
Lol. It is just a HTTP endpoint. No wrapper is really needed tbh
yup. It would be good if they allow it in embeds
But you can have multiple embeds in a message so you could just use your first embed and then have the other embeds after that just have images in them
Kinda hacky / spammy though
Humm these two
const api = new Topgg.Api('what you wanna see')
const webhook = new Topgg.Webhook('see this guy again')
Just checking. These are two different secrets
Webhooks are the one you provide in "Authorization" field
https://i.imgur.com/xZsgf5K.png
The Topgg.Api is the one you generate and get one provided by Top.gg.
10 to be exact, so if they wanna have more than 10 images, then they gotta paginate it, or use multiple messages
tbh true, Rust's community in general are more experienced if we compare them to Python/JS
Honestly if you're going to post 10 images in a single message I'd rather see you use pagination 
But you'd be surprised how many people rely on wrappers
Try clicking the regenerate button, then clear cache + reload your tab, then copy it into your code (dont share it)
I saw somewhere that if you send two embeds with same title and stuff, discord merges the two embeds. Is that true? When I checked last time it didn't work for me
Yeah one is auth and other one is token auth provided by me and one token by topmyg
Never heard that and seems highly unlikely
Nice. Just wanted to verify. Try what I mentioned above by clicking regenerate then cache clear + tab reload
In order to clear your cache for the site, press CTRL+F5.
If this does not work, try one of these resources below:
Instructions on Microsoft Edge
Instructions on Google Chrome
Instructions on Mozilla Firefox
Instructions on Safari
Instructions on Opera
Instructions on Brave
You should be able to clear cache on mobile too
Umm...ic
Yeah doing that throwed a new error
With same code
Rust’s community is so incredibly helpful and nice, I love it
@wheat mesa
100% I agree with you Pancake
You’re trying to use bot before bot is ever defined
In fact you never defined bot
It seems you’re importing your client from index.js, replace every occurrence of bot with client in that code pretty much
You are awaiting it, but not assigning the results to a const
It’s what I mentioned earlier when the await was not used
I wonder that's why it's giving me undefined
But if i remove await then it will give error right?
I’m cooking food atm. So can’t see it. But if I remember correctly no where in your code do you define “bot”
You need to assign your await to a const, then have it be json for you to use on the line below
Yeah solved that
a is const right?
Well, a is a variable but not a const. For what @winter pasture meant though, it’s the same thing pretty much
You are just awaiting the getBot. But your not doing anything with it
And the line below you are trying to access bot. But you never defined bot anywhere
Yeah i changed bot to cleint
And now it works
But throws undefined in console.log
Yeah a DJS client does not have a monthlyPoints value on it
You need to use the getBot await your doing on the line above
So like let b = await......
And then b.monthlyPoint for var a?
Yeah
Not sure if you need to convert b to json first or if the lib does that for you
Nice 🎉
Thanks @winter pasture and @wheat mesa
Np
Hey. Just create a POST endpoint that validates the authentication header and give that to top.gg under the Webhooks setting
Docs here https://docs.top.gg/resources/webhooks/
Lol. Feel free to reach out here if ya need any help
can topgg nodesdk be used with other frameworks than express? like koajs and stuff?
Not sure about the Webhook part of it, but the rest of the sdk, yeah
But again, it is literally just a POST with a Authentication header. Any decent JS dev should be able to create their own handler for the incoming POST
not busy, I was just sleeping lmao
you can use a non-buffered stream
it might be faster since it'll be directly printing to stdout (no need to buffer)
buffer is mostly useful when dealing with images or files in general
you can also chunkify the string into, say, chunks of 1024 characters each and chain print (not println due to newline) calls, it might be faster than doing it all at once
or 512 chars, find out what's the best chunk size
oh and don't use printf, it's slower because the runtime needs to check for replacements, process the string before printing (unless the compiler changes this, idk)
you can also use JNI to go low level and a simple cpp cout function, although idk if print doesn't do that already
welcome to java
TypeError: Cannot read properties of undefined (reading 'cache')
1|cb3 | at MessageCreateAction.handle (/root/cb3/node_modules/discord.js/src/client/actions/MessageCreate.js:13:41)
1|cb3 | at Object.module.exports [as MESSAGE_CREATE] (/root/cb3/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
getting an unexpected error since some days , 0 code changes , whats the best way to find its issue?
I mean, the issue isn't the language but the sheer size of what he's printing
welcome to java
what length is he printing anyways
and why
Hmm, what discord.js version are you using?
Yea it was outdated discord.js bc of the new voice channel
The site dosen't show the servers my bot is in, how can I fix that?
Count of servers*
You need to post your bot's server count using the Top.gg API
Oh, alright will do, thanks
Depending on what programming language you're using, you can use a wrapper for it, for example; for JavaScript you can use https://npmjs.com/package/@top-gg/sdk
Official Top.gg Node SDK. Latest version: 3.1.3, last published: 6 months ago. Start using @top-gg/sdk in your project by running npm i @top-gg/sdk. There are 6 other projects in the npm registry using @top-gg/sdk.
Hey its me again.. im doing some maintenance on my bot and noticed that lavacord stopped working on Discord.JS v13 (Bot is mute -.-)
any workaround so i dont have to rewrite everything for a new library?
Umm...yeah i can get all votes and voters but how do I make them together so that i can view it in a msg like-
User#1 - 1 vote
User#2 -2 vote
Lavacord was last updated around 6-7 months ago, you can't do much other than either using Lavalink natively or rewriting Lavacord yourself to be compatible with Discord.js v13

well.. any recommendations for a new library?
magical things
meh not interested
looks like lavalink already achieves good enough performance with java
There's also https://www.npmjs.com/package/lavalink but that might also be outdated
Thx. i will take a look
You just map them if they're in an array using the Array.prototype.map() method, and join them to a string with the separator of choice using the Array.prototype.join() method, or you can also use a for loop to achieve the same thing
Thanks i would try 😃
Just like every statically typed programming language
its actually more lenient than you think
some json drivers anyways
you usually just do object["item"] or something like object.get("item")
and then cast it and then the language will do the rest
Although as I've seen, most of the TypeScript users think the object (or Object) type implies an object, but it actually implies the any type without any context
(They don't know Records exist)
typescript users realizing the any type defeats the whole purpose of the language
javascript users realizing they have to remember what type is what because everything is basically the any type :c
hows the proposition that adds optional typing to js that replaces jsdoc by the way
probably got denied
JavaScript users mostly just rely on JSDocs to declare the types of things when they don't want to use TypeScript, or just pray for the IDE to figure it out
The proposal for optional typing is still up there
python also has this kind of system but javascript needs it more i think
tc39 committee trying to find a good enough explanation to deny this
i really dont like how a lot of things have committee boards consisting of specific people
it adds a hell lot of bias
Both do imo
i dont really find myself using the python static type system (maybe because i dont use it often)
idk theres just something about python
Perhaps. I find the type annotations quite helpful, even if the IDE doesn't take them into account
kinda like it has more types overall and has a better type inference system
It'll probably get approved rather than being denied and thrown away in my opinion, this makes things a lot better but it can a burden to implement, considering the contexts, scopes, syntax grammar, and much more
Does encountering a shard error just keep that shard offline? I imagine so.
depends what you're using
but mostly it should auto restart
Hmm, I assume my starting logs would've outputted if they actually did restart, that or it doesn't re-emit ready for the bot.
djs?
yes
djs only emits ready the first time all shards identify
Ah okay.
otherwise it will cause a lot of bugs
any shard error will likely either not do anything, or trigger a resume, and upon failing that, a reidentify
Then maybe I can log all shards with the shard manager for djs? Surely I can get shar dinfo there.
Yeah noticed this earlier today
[ ERROR - 6/12/2022, 5:26:48 PM ] - [ RoleBot ] Encounted shard error.
[ CRITL - 6/12/2022, 5:26:48 PM ] - [ RoleBot ] Error: WebSocket was closed before the connection was established```
So I was like hmmmmmmmmmmmm
afaik the shard manager doesnt emit shard logs, only process logs
Ah okay.
the shard logs are in client.on("debug")
Each client instance can though.
Cool.
I'll probably just have it log in intervals then, thanks.
who wants my account token
Lk97/Ay/RTkIADDZ1OP5TD0iSDFrnixXv/4d8Mh4ZBOvpp6sHfxB6dXWFknTTBkyyFCrMOXYvfvtVxnhRptq4Q2Jyfmw1OxIYK9HPvTG7E9aZh0tzKHpX1kKiZ4FZBJ4oaFsKMseCbLApi6MMxwT+709IA2+9gHma4DqPBdbxNi5YcxAMG6cXuvhZ3+sAWq5fLjaR02M16ijflAqBW2T852PQzdKjghNUBeS8nldMYv/kwkDIbvUQnjc0BO6pCG2tW7zNnoNFByYU1Pbl358/3sPW9AfE/0j4qSReLD4XnlZyX9urNEDdGTTD0EPlZFXc1c+41UrANKmlH8vd9R5QA==
oh sorry it is encrypted with asymmetric encryption
decrypted and already on eBay
for some reason when discord sends you the token when logging in with a qr code it encrypts it with a public key you specify which you then have to decrypt
i dont see the point
the connection already uses tls
obfuscation, most likely
hey, how can i put my ngrok online 24/7 even when using ctrl + c (quit hotkey) on my ubuntu vps?
The server boots up, but as soon as i hit ctrl + c it quits
it's not really what i mean
screen?
here look
i used ngrok http 3000 to start the server and now want to navigate to my root folder
but for that i need to use ctrl + c, but that quits the ngrok process
not sure if you guys understand me
they meant literally use the command called screen
huh
lol
but ngrok will also randomly die because it's not meant to be used this way in the free tier
so this sounds like a horrible idea
what would you then recommend?
I am trying to create an endpoint to receive data from a webhook
enter the IP i guess
how can i do Discord oauth when I'm doing my bot dashboard in Vue?
ctrl+z -> bg ?
yeah but it needs to be port forwarded, as it needs to connect to another site
are you running a server on your home computer?
No the vps has a server made with express
so why can't you just enter the IP or allow the port through the VPS firewall
If you're using ubuntu as you claim you can do sudo ufw allow [PORT]
const express = require("express")
const bodyParser = require("body-parser")
const app = express()
const PORT = 3000
app.use(bodyParser.json())
app.get('/', (req, res) => {
console.log(req.body)
res.status(200).end()
})
app.post("/hook", (req, res) => {
console.log(req.body)
res.status(200).end()
)
})
app.listen(PORT, () => console.log(`Server running on port ${PORT}`))
can i?

Xet 
I never used the server thingy before, will try
what does this code have to do with anything
code has nothing to do with this. You need to make sure the connection can reach your application
yeah i knw
express already binds to 0.0.0.0 so all you need to do is open ports and ur good
the site i need to receive the info from is sellix. They basically prompt you an url.
hmmm okay i will try
Again this
surely it accepts an IP and if not you can just use something like duckDNS
yup on it dylan, one sec
ew not duckdns
Rule added
Rule added (v6)
the amount of scams i catch on duckdns is just ridiculous
wahahahah okiii
i mean as long as you're not scamming anyone lol
nah i watch SSL certs
for keywords like verify, discord, dyno, captcha etc
also using jaro winkler
grats
saved another innocent soul from the claws of ngrok
What exactly is ngrok
basically just a tunnel that exposes a port on ur computer to the world
cloudflare tunnels p much
Feels like this is some 20yearold program
that's exactly what it is

ok i lied it's apparently not even 10 years old
Still bad regardless fuck it
We HATE third party programs
for ports
okay running it back
What would be the easiest way to monitor my APIs usage?
I'm looking at Grafana but IDK how to integrate that into Express.js
I just opened the port of my vps, and it worked like a charm. I closed the vps and it also closed the port?
Well, as I assume as the endpoint isn’t working anymore. How would I be able to open the ports 24/7?
How many servers does the bot need to be on to be approved?
Approved on top.gg? There is no minimum amount. Verified on discord? I believe you can start the application process at 75 servers
You may wanna use iptables instead of the useless ufw interface or nowadays the even more powerful nftables
Anyone know a good resource to read up on regex?
One that has made it easy for you to understand how to read/write it
Yeah you should play the regex crossword game
I played this for a bit, pretty good
This makes no sense to me 
That will be fun to practice regex but I think I need to learn it a bit more first
I really just wanna write a regex to check the input of a user to make sure they only use alphabetic and numeric characters
I don't want any special characters like ! or _
^[A-Za-z0-9]$
Or with flags
/^[A-Z0-9]$/i
This will not match whitespaces
As those are special chars, too
I see thanks
Do I have to specify how long I want it to match for? so like ^[a-zA-Z\d]{3,12}$
I am unsure if I actually need to as I already limit it's length in other places so I am not entirely sure if that is needed as no matter what the input to the regex should be between 3 and 12
You don’t have to but you can
Alright thanks
If you validate the length somewhere else already don’t repeat it in your regex
Yea that makes sense
This will increase the match iterations dramatically
Means it takes a lot more time than actually needed
Ah I see
Add the + behind the ] as the pattern can be repeated
I tried adding it behind it but it did nothing so I added it after the closing bracket and it matched fine
This would have matched only one char
Yes behind the ] (bracket) as I said
I thought you meant behind as in +]
Also I notice ?= is used a lot in regex what exactly does this do?
No that would add + to the list of allowed chars the pattern can have
That’s like to be used to match a capture group but without actually including it to the match
Hmm well I guess my English isn’t good enough to explain that
You gotta look up a few examples
All good thanks :)
You're supposed to figure out what letters or numbers that intersect
I see
Let’s say you have /[a-z]+(?=[0-9]+)/
That would match for example:
tshjdz082
hdndkj097
Only the letters would be added to match result not the numbers but the entire will only match if letters and numbers are in your string
djhdhdhdjj // no match
0973jdjdjjd // no match
Like i said it’s actually not that easy to explain, at least for me

The result of the upper match would be
tshjdz
hdndkj
The numbers are required to match the pattern but will not be part of the match result
Pretty late but, https://regexr.com
Has a cheatsheet, examples, explains what u wrote, has unit tests and visual output
I use that to test my regex
God building regex is so annoying
I use it to convert pdf to csv at my work lmao
/^(?!.*(.)\1{1})(?=(.*[\d]){2,})(?=(.*[a-z]){2,})(?=(.*[A-Z]){2,})(?=(.*[@#$%!]){2,})(?:[\da-zA-Z@#$%!]){15,100}$/g this would be nice minus the consecutive char thing that is apparently added but I have no idea how to read this 
Hmmm...what are u trying to match again?
Trying to make sure the user supplies a strong enough password
This would work perfectly but it doesn't allow consecutive characters so
I am pretty sure the first part is actually what denies consecutive characters but I am not entire sure how it works
Idk if this would be a good application for regex
Like, you'll most likely want to tell the user what they missed no?
What else would I use?
Normal if checks
Uh that sounds horrible
It's the only way to show the user what they missed in the password
No idea just something i found online
of course
Regex will only tell u if it matches or not
NEVER trust sources for regex online

99.999999999% of solutioons for regex online are wrong or the worst
Dylan I have no fucking clue what I am doing regex is a new concept to me
As in?
Using nestjs for the backend and will use next (or angular depends on what I am feeling) for the frontend
That looks rather interesting
Idk if this warrants yet another lib tho
If you want you could just store this then.
^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*"'()+,-./:;<=>?[\]^_`{|}~])(?=.{10,})
Unless I'm missing something, this seems pretty easy to implement yourself
And I definitely wouldn't use regex for that
I'd rather not use a lib myself as well
Then use the above.
It uses regex groups.
4 groups, left to right, lowercase, uppercase, numbers, special chars
Oh and the 5th group is saying minimum 10 length
Also also
The lib is like 1 file
I'd rather someone who knows what they're doing to handle it especially if it ever needs updating.
Then makes my code more readable.
The "special character" part could be replaced by [^\d\w\s] no?
That introduces like random unicode and other options when you only want a handful, no?
Aren't random unicode technically special characters?
If I don't have to use regex then I won't
I also would rather writing my own code during this project rather then using too many libs that can be easily done myself
Ddon't trust your OS or DDB to save unicode the same or even recognize unicode across systems and front end.
True
Is my D key double pressing wtf
Distributed DataBase 
Mm
I feel like if someone read the repo asusming you're wanting this to be public and read by job people, then they would ask why not use a maintained lib so that you don't have to maintain it and create more things to maintain
Why didn't you just make your own web framework tooooo XdDxxDxDddDDDD
But well, I'd just make 3 or 4 if guard clauses to check password before submitting the form
Might not be flashy or elegant, but is fast and quite readable on the long run
Don't really care what people think anymore
Compiler can do wonders with conditional blocks, not as much with regex
I have gotten to the point where my code is so shit people's opinions stopped mattering to me as they just tend to try and 'fix' my code with things I don't understand so I never end up being able to continue working until I go to learn it
Yea but how would you even use if statements here to check the things you want included in the password
Includes
regex lol
string has includes?
also yes
Doing includes with a string like this would be bad though
You can also just iterate over pass chars
const lowerCaseLettersRegex = /[a-z]/g;
if (password.match(lowerCaseLettersRegex)) {
//congrats I guess
}
else {
// yell at user
}
// Do for upper/numbers/special chars
Lower/upper chars don't need regex
Just check if any character is within upper/lower unicode range
Did you mean ascii
Also that would require a loop at that point
That's such a horrible solution lol
Nope, stream
stream?
WHAT
Idk how it's called in js
Kuu I have no clue wtf you're even suggesting at this point
Cba to do otherwise
Found it, some
some lol
that still interates
What if my password was $@$@#*$#@*($(@#*$(*@!*(^!%@#)^@(#%)@!*%!(%)!%(!)%@#!*aA1
Regex does too no?
lol honestly i don't know
Afaik regex is just a compiled iterator
But if regex already solved it and made it better than why not use it
Like, it tells what ur looking for in a string
Instead of making my own jank some loop checking ascii values
Like you're not doing anything better than regex is at that point
Regex has to be compiled beforehand
Okay and?
What's the 0.0000000000000000000000000000000001nanoseconds of compilation going to add
to my deployment
Well, things do sum up if u have many regexes being compiled during runtime
There's a reason regexes are used only when loops are unreasonably complicated or long
Using regex literals don't get compiled on runtime
Like my solution above
VS using the RegExp constructor
Where I guess you would use it if you wanted to dynamically change the regex
I think I do this for my automod bot for banned words
Which I might've changed to .includes Xd
Two regular expression literals in a program evaluate to regular expression objects that never compare as === to each other even if the two literals' contents are identical.
...
... each time the literal is evaluated, a new object is created as if by the expressionnew RegExp(Pattern, Flags)where RegExp is the standard built-in constructor with that name.
No JS object passes the === check since each object is unique.
Sadly 😔
Here's a more in depth 2015 answer.
I don't even know what we're arguing about anymore
I think your post proved my point
Compiled once, ignored after
literals good
log.temp(__dirname)
// ADD COMMAS INTO INTERIM
let comma
confSettings = ""
for (let i = 0; i < uniconf.settings.length; i++) {
console.log(i)
log.temp("?")
if (uniconf.settings[i][0] != "ownerid") {
console.log(uniconf.settings.length)
comma = ""
console.log(i)
console.log(uniconf.settings[i][0] == uniconf.settings[uniconf.settings.length][0])
if (uniconf.settings[i][0] == uniconf.settings[uniconf.settings.length][0]) {
comma = ","
}
confSettings += " \"" + uniconf.settings[i][0] + "\": \"" + req.fields[uniconf.settings[i][0]] + "\" " + comma + "\n"
} else {
//getOwner(req.fields.token).then(result => {
// confSettings += " \"" + uniconf.settings[i][0] + "\": " + result + "\n"
//}).catch(err => console.log(err))
}
}```
feel free to rip my guts out and suggest improvements but i cannot for the life of me to get this code working. the for loop begins but then in what looks like the first cycle, it... stops? any code after it just does not run
what is it supposed to do
the intent is to allow the user to save the configuration file with the settings they saved
uniconf.settings displays all the settings
(it's laid out that way so that if we want to add new settings, we can do so in a quicker manner)
Is it possible to fetch all the users who have joined a guild within a specific amount of time?
How do I make bazel use my local jdk without bazel doing it's things
Yes
There are two ways actually
- Fetch all guild users and
sortfilter them based on join time (extremely inefficient) - You can set your own member join collector (suggested)
Either way you probably won't be able to fetch it directly from discord's API
However, how about if it happened in the past?
First method
Fetch all members
And get ratelimited
Imagine fetching all members from a giant server
Like genshin
💀
fortnite!
not possible without webhooks, also #topgg-api
Well he could do an API request on the last day of the month to fetch the last 1000 voters
To grant rewards at the 1st of the new month
Then how do I get the most vote user? And also i resended that msg in #topgg-api (as told to me) can you explain there?
Oh does topgg api have that feature? To get highest vote user?
You gotta listen permanently if an user votes and if so save this data in your database with the timestamp
Timestamp hmm...why tho 😬
You will receive the webhook from topgg when somebody votes and you have to store that database in your database
Then at the 1st or last of a month you process that saves data
Get the data and sort it for example by the user with the most votes
There isn't any sort available for that ig i may be wrong and idiot
order by entry count
Only vote then yeah without timestamp right
Btw how is it even possible to store timestamp? You can store a Unix code with date.now() but timestamp
just use webhooks

and listen to them passively
timestamp is an integer
so just store something equivalent to Int64
and you're good
Kinda mongodb but would use quick db my mongo is about to get full 😬
long 
Hmm...
I understood till listening webhook and then logging id but what after that?
do whatever you want
set new timestamp
Ready to use SQL but it's complicated
Int64 
Hmm....ic then after storeing date what to do? Like i have no idea ~
you gotta choose datetime as field type and insert now() as value or FROM_UNIXTIME(timestamp)

No i can use 2 db in one project ig
.
AmongUsDB...
considering the context, I don't think it'd be any easier to explain how to do it in a completely foreign database structure
And yeah i will have to learn about SQL first it has limits?
depends on what u consider "limits"
Storage
all databases have infinite storage (well, kinda)
as long as u have enough space available on your drive
On "free plan"
there's no free plan for a self-hosted database
Limits you will never reach, no worries about that
Oh wait mb as i told never used SQL lol
I can't afford to self host a bot lol
I imagined it'd lead to that
So can I use simple collection (d.js) store things in it make map and do things after that delete whole data on first month
You can actually the database you like, no need to just use SQL for this
your bot wont stay online for an entire month
Why 
Your bot doesn’t?
My bot is online from last 3 months and verified by discord and yeah with replit and mongodb as hosting service and data service 
I use a vps instead of a free hosting service
Yes, me too, and?
he is
^

Anyways you will need a database to keep the data of the voters
You will have to deal with it
Can’t he just use sqlite on replit?
as much as I hate it, mongo is the only one I'm aware of having free storage plan
You can!
idk if repl allows file-based dbs
like, the code changing project files
.sqlite file exist in replit i belive
if it does then ur fine
Yes
We don’t know, you gotta figure that out
quickdb is terrible
nono, quickdb only uses an sqlite file
the structure it saves data is entirely different
it saves everything in key-json pairs
which literally negates all the advantages of using sql
Well if SQLite works then he’s fine I guess
I mean try it, install it and you will see
What i choose isnot to do bad idea very complex
you what?
Bad idea very complex
let b = await api.getBot('960381632471240744') // returns bot info
let a = b.votes
console.log(a)
I am tryna get last 1000votes of bot this doesn't work i am pretty sure i am doing this whole wrong
that wont work obv
Documentation for @top-gg/sdk
do note tho, this wont get u a correct top monthly votes
since it's limited to 1000 votes
read the link (context deleted)
let b = await api.getVotes('960381632471240744/') // returns bot info
Like this i believe then?
I need to mention user too? Like Xignori. Etc...?
Hmm...okay
Yikes
@solemn latch
let c = await api.getVotes('')
console.log(c)
How to map?
const map = c.map(username);
console.log(map);
Like this?
so fast 👀
💀
to map or not to map, that is the question
to for loop
I am tryna make a leaderboard thing so i will map username with vote and then use it to make leaderboard amo doing something wrong tho?

I'm trying to use the NodeJS OpenGL library to create an overlay for my Electron app (specifically over a full-screen game such as Minecraft which uses OpenGL to render stuff like text). How can I accomplish this? As of now, I'm using electron-overlay-window to create a basic overlay, but that doesn't appear in-game since the application is full-screen. How can I learn how to use OpenGL in Node/create an application that will overlay in Minecraft?
Missed the last hour… but if you still going to use SQL then selecting and grouping the results as well as limiting them, for example let’s say max. 15 results can be archived with a simple query to your database
doesnt sound like hes going to use sql at all
he just wants to query the votes endpoint and organize it by user
like a leaderboard for the last 1000 only
Does the vote endpoint actually shows the last 1000 unique voters or last 1000 votes?
Which means repeats can occur?
I dont actually know 👀
pretty sure it shows all votes, i dont see why it would show unique only, that would be a questionable design decision
Idk too and can’t test it on mobile
So it does list multiple votes for the same user multiple times or not?
Ewww
💀
lmao
id do it but i dont wanna go hunting for bots that had the same user vote today and yesterday
You and your excuses…
Im sure you’ve got no time because youre benchmarking stuff again
Wow.,. I can’t even open the docs to get the endpoint
Well fuck it…
At least the topgg website looks different everything I open the site, sometimes dark, sometimes light, saving my settings, sometimes not, and yeah not to speak about all the bugs and issues
🤦♂️
Somehow I thought things may get better over time
But no.
Yeah tryna do tha Mt have any idea on how to get started?
first you need to make sure it does actually return all votes, and not unique votes
did you or someone else vote for your bot multiple times in the past few days?
Yeah return all votes like when i checked it showed same result of my like 10 times
And yeah same with other users too
then yeah you can make a leaderboard for the last 1000 votes only
Hmm...but how do I get started?
I did but I can’t test it
I can give you my ID
still having issues with that smh
you need to create an object so you can organize entries by id
so either create an object, then loop over the array, or use array.reduce
the former is easier to understand
cough map cough
Umm...yeah like i have a var asinged to result called (c) so wha should I do like array.redice exists but it has many field some what like this-
Ok… so all votes not unique ones
like i said, create an object, then loop
Create an object wdym? I can't understand something's by brain is slow 🧠
or a map
const myObject = {}
for(const item of c) {
if(!myObject[item.id]) {
// do something if id does not exist in object yet, for example add it to the object
} else {
// do soemthing if id already exists in object, for example add a new vote to the existing object
}
}
How would that be particularly be usefull as it is guaranteed to have user name in it ;-;
how would that be useful? thats basically the correct solution to exactly what you want to do
You gonna save the user id in your object and the actual vote count?!
What about collection i have worked with collection before
Or exclude them for privacy reasons if you want to
sure, you can use a collection or a map too
How you save it is up to you
const myObject = new Collection()
for(const item of c) {
if(!myObject.has(item.id)) {
// do something if id does not exist in object yet, for example add it to the object
} else {
// do soemthing if id already exists in object, for example add a new vote to the existing object
}
}
Umm...i don't understand my brain really slow sry but the truth lol
But you need to loop your results and to add the user ID or name as key to your map/collecting and count the actual votes as value
So what about using object 😅
sigh...
Here what's what's meant by item.id?
you want to count the number of times a user has voted, correct?
Yeah

so lets say you have a list like this (simplified): [{id: 1}, {id: 2}, {id: 1}] which would be an example to 3 votes, 2 of them by the same user
to be able to count the number of times the same user voted, you need to organize the list by something they have in common, which means in this case its their id. all the items in the list with the same id should be grouped together
in order to do this, you need to create an object, or a Map, something that works with keys
const obj = {}
``` for example
now you loop through your list: ```js
for(const item of c) {
// here, the variable "item" represents one item from the list, for example "{id: 1}"
}
But this includes other things too so i need to like first filter array?
that doesnt matter
then you take this item
and you check if you have seen this item before
if(!obj[item.id])
obj is the object you created
So like i need to add up 1 in an another var for if id exists?
yes
if(!obj[item.id]) {
// do something
}
``` this means if this item id does not exists in the object, do something
so what you want to to, is if it doesnt exist, add it
if(!obj[item.id]) {
obj[item.id] = 1;
}
``` for example, set this id to 1
so your object now looks like this obj = { 1: 1 }
if it already exists
obj[item.id] ??= 1
then you add 1 to it, so it becomes 2
wtf is ??=
if(!obj[item.id]) {
obj[item.id] = 1;
} else {
obj[item.id]++
}
``` for example
Never saw that operator
Like 1+1 won't work
discovered it thanks to xexe
which is the same as obj[item.id] = obj[item.id] + 1
null-coalescing assignment operator
or put if not exists
Oh nice and by !id it is meant that I'd doesn't exist and make one?
And if exist then add 1 to existing integer
neither did I, xexe appeared out of nowhere last time and showed it
Whose xexe 
xetera
Hmm you’re never to old to learn new tricks
What is Tim typing for so long 

so after item {id: 1} your object becomes {1:1}, then after item {id: 2}, your object becomes {1:1, 2:1}, then after item {id:1} again, your object becomes {1:2, 2:1}. lets change the example id to become less confusing:
so after item {id: "a"} your object becomes {"a":1}, then after item {id: "b"}, your object becomes {"a":1, "b":1}, then after item {id:"a"} again, your object becomes {"a":2, "b":1}, and here is your result: the id "a" exists 2 times in the list, meaning it was voted two times, and id "b" exists 1 time in the list, meaning it was voted 1 time
Umm...yeah now i understand and how would I retrive that data for all users like i have to provide user id and get results?
Tim trying so hard instead of spoonfeeding
to retrieve that data for all users you'd explode the ratelimit
to get the number of votes for a specific id, yes, you need to have the user id you want. but you can get the list of all unique user ids using Object.keys(obj)
f u

Oh ic
Kinda true
Okay so now i need to try this stuffs
const myObject = {}
for(const item of c) {
if(!myObject[item.id]) {
myObject[item.id] = 1;
} else {
myObject[item.id] = myObject += 1
}
}
let something = myObject.keys(myObejct)
console.log(something)
So this is kinda correct?
Or i didn't understand
And did sit
Shit
second and third option
obj should be myObject
Yeah i get that
Okay updated code and now gonna use this so it this correct?
I believe so
ah, missed that
btw myObject[item.id] = myObject[item.id] = 1 can become myObject[item.id]++ no?
you still have obj = obj += 1
The key doesn’t exist yet
it does
Wait what
Yeah since it’s defined as integer ++ also works
I wonder if there’s actually a difference
What you told
But I would always prefer += 1 in cases it’s not an integer
Look closely
myobject = myobject += 1
Is what you got atm
Which doesn’t make any sense
In case 1 right?
I forgot myObejct oh
You did, yes
Typescript Moment
totally helpful tooltip
Okay so now done and wha did kuuhaku meant?
variable++ is the same as variable += 1 and variable = variable + 1
that's why I suggested it
He was talking about the same I was, we just confused each other because he’s a Brazilian and those guys are weird
Umm...doesn't make any different code working remains same? So no need lmao

At least you need to correct your stuff as I mentioned
I corrected 
obj = obj += 1 is nonsense
Then wdym me to change that with?

obj or myObject? Ig myObject makes a sense with common snese
Im just too lazy to use your weird var names
Yes
whats your current code?
What this than? 
const myObject = {}
for(const item of c) {
if(!myObject[item.id]) {
myObject[item.id] = 1;
} else {
myObject[item.id] = += 1
}
}
let something = myObject.keys(myObejct)
console.log(something)
Umm..
Or this… @.@
myObject[item.id]++ is the same as myObject[item.id] += 1 which is the same as myObject[item.id] = myObject[item.id] + 1
you can use any of them
As we have already explained
At this rate it'd be easier to write the code for him
yeah but we dont do that here
fish for someone once, and they will beg you for fish for the rest of their life

Best moment
Obejct
Oh shit
At least console.log is correct
if you get the joke you get the joke
int getRandomInt() {
int* d = malloc(4);
int result = *d;
free(d);
return result;
}

random int from existing memory garbage
nice meme
aka "Scavenger's RNG"
but rust users wouldnt like the code because they consider an uninitialized value undefined behaviour
Now it shows myObject.keys isn't function should i change it to .key ?
by the way i only found out yesterday you cant modify a single character in a js string
if you do str[index] = some_char it just ignores it
it doesnt even error
💀
i was very disappointed when i found that out
well yeah string are immutable, you never modify it at all
Object.keys() is a global function
Object.keys(myObject)
why D:
stupid voltrex and his crew
quitting javascript now
optimization reasons iirc
strings are a pain to deal with at low level
only optimization problem i can think of is maybe a hash recompute since i assume js uses that to compare strings quickly
Well at least js don't hand the string over like rust
who was the guy that stole a string in rust again
Instead of copying
Why String is Immutable or Final in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
for java but I believe it's the same for js and python
i dont think any of those are really a problem for js
idk about thread safety but js somehow takes care of that anyways
Christian Johansen covers what immutability is, how to use immutability in JavaScript, and why it's useful.
www.<language>point.com as it seems lmao
ima just ask volt
@earnest phoenix pls
no someone here stole a string in rust
they stole it
Hm?
why are strings immutable
like doing str[index] = value is ignored
doesnt even error
cant lie the fact no exception was thrown threw me off and i never knew strings were immutable
i kinda expected it to work
@quartz kindle @lyric mountain (sry to ping) it returns all IDs (unique) but not votes amount :(
Because you logged the object keys only
Oh so values?
Log the entire object and see the magic
Umm...
console.log(myObject)
Strings are usually immutable by nature, strings aren't meant to be mutated through accessing their indexes, naturally standards recommend to mutate them by the provided methods, so it doesn't cause unexpected behaviors (some people reported it, but I don't exactly remember what it was, rather an edge case), and JavaScript usually doesn't throw errors for such things, for example mutating an immutable or frozen object
Although it should throw an error on strict mode
Ik that much lmao
yeah it does
but like nnnnn
i see people splitting a string then joining it again just to change a character
Can your sort myObject with increasing to decreasing amount of vote i belive i have to use sort or filter
and i go 💀
string copying is cheap
for the most part cpus are optimized in that aspect
still tho
cant think of a way to do it in js otherwise without a messy solution
regex maybe idk
removing a single character without copying a single byte?
if js wont let me i will write a native node addon which supports modifying strings by index :troll:
replacing it
store the string as an array of characters
you can do it by copying and replacing the character when you encounter that index but its still a performance penalty
mainly because of the +=
pretty sure the overhead from that will vastly outweight slicing and merging string pieces
yeah it will
well that still copies bytes so
convert string to char array > change desired char > rebuild string from array
still copies bytes assuming V8 doesn't optimize it
you get the penalty of making a new array and then constructing it again 💀
but its probably the fastest out of all of them
objects cannot be sorted, in order to sort the results, you need to convert it back to an array, one of the ways to do that is to use Object.entries(myObject) which then you can use .sort() on
Im sleeping now but Kuhueakababkulalala will assist you
park the car first
shush Kuhueakababkulalala
You could store the string in a buffer
You gotta destroy the entirety to create something new
but turning it into actual string probably copies it
That’s how the world works
was thinking that too but i dont know the overheads of .tostring or Buffer.from if you're converting it from a string
and would be a better word to use
whatever you do, its always going to be orders of magnitude slower than just merging strings
.entries will make it array but retuning all the values like id and votes?
yes
Hmm thanks :)
nah that needs to be a thing
like cpython
what if
hear me out
i port nodejs to my os
without network or disk bc i dont support that yet
Is this correct way to sort doesn't work for me tho -
let noice = Object.entries(myObject)
let hi = noice.sort((a, b) => b-a);
console.log(hi)
guys
client.user.avatarURL() work in v12
but v13 not
can i have the v13 change ?
did you check the docs?
i only need the code
no you need the docs
Kuuhaku any idea?
what does it output?
Same thing as for var noice
First is noice and second is for hi
Object.entries() returns the object in this format: [[id, value], [id, value], [id, value]]
inside the .sort() function, the a and b parameters represent those values, so you cannot do b - a because that means doing [id, value] - [id, value]
so you need to decide what you want to sort it by, if you want to sort it by value, then you need to sort b[1] - a[1]
Like values are amount of votes so yeah
since a and b are [id, value], a[0] would be id, and a[1] would be value
Umm...ic
if (member.user.id === message.guild.ownerID) acknowledgments.push("Server Owner");
any one know why this doesn't work?
context?
trying to do a whois command, and one of the acknowledgments can be that the user is the owner of the server
but when I try using it on the owner it doesn't seem to work member is the mentioned use
rr
does user.id return a long or a string?
like, long usually has some issues on js because it gets truncated unless you explicitly use long/bigint
idk if that applies here
The ownerID property was renamed to ownerId
https://discord.js.org/#/docs/discord.js/stable/class/Guild?scrollTo=ownerId
makes sense
so im trying to make a command with autocomplete but it works very inconsistently, can someone tell me why? name is an array of every option thats available js const focusedValue = interaction.options.getFocused(); const filtered = name.filter(choice => choice.startsWith(focusedValue)).slice(0, 25); const response = await interaction.respond( filtered.map(choice => ({ name: choice, value: choice })), );
await message.channel.bulkDelete(messagesToDelete).then(messages => {
message.channel.send(`Successfully purged ${messages.size} out of ${args[0]} messages from the chat.`);
});
``` can anyone tell me how why doing `args[0] + 1` creates numer1 instead number + 1 like wtf?
interaction.reply({buttons: [button,button0,button1,button2], embeds: [embed]})
this a code right but when i execute the command it didn't show any button
I'm trying to have the selected number of messages + 1 since I need it to delete the command itself first, before deleting so it actually gets the right amount
make sure to limit maximum user-defined value to 99
me ?
is your issue about bulk-deleting messages?
I am, I think
if (args[0] > 100 || args[0] < 1) return message.channel.send('You can only purge between 1 to 100 messages at once.');
``` yea
but that doesn't really solve the issue
args[0] >= 100
Because args[0] is a string, not a number
The args array contains only strings in your case, so you would have to cast it to a number to do that
ah I thought it automatically returned whatever the arg value was
There's no such option as buttons, those are supposed to go in the components option, but you would have to add those buttons to an action row first
which func should I use to cast the string to a number?
You can either use the global parseInt() function or the global Number constructor (can be called as a function)
oh ok
parseInt it is
make sure to check if it's a number to begin with
I am
Both of those functions return NaN if it's not a number, so you can check with that
Using the global isNaN() function of course
remember banana
😭 NOOOO
// Lets define our number of messages to purge.
let messagesToDelete = parseInt(args[0]);
if (!messagesToDelete) return message.channel.send("You have to give me a number of messages to purge.")
// Lets now check our number for validity.
if (messagesToDelete >= 100 || messagesToDelete <= 1) return message.channel.send("You can only purge between 1 to 100 messages at once.");
if (isNaN(messagesToDelete)) return message.channel.send("Couldn't purge because the value provided isn't a number.");
try {
// We are adding and removing 1 to both include and exclude the number.
await message.channel.bulkDelete(messagesToDelete + 1).then(messages => {
message.channel.send(`Successfully purged ${messages.size - 1} out of ${args[0]} messages from the chat.`);
});
} catch {
return message.channel.send(`Couldn't purge because the messages are more than 14 days old.`);
}
I'm gonna have to move the isNaN statement above and now the syntax will look bad
I don't see how it would look bad in any way
you dont need isNaN at all
how come?
it'll enter the first if check
if messageToDelete is NaN, it will fail the if(!messagesToDelete)
NaN is falsy
inconsistent how?
cause it it doesn't parse into an int because it isn't a number it would return as not defined
right?
What?
bro
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('1')
.setLabel('😂')
.setStyle('BLURPLE'),
);
const row2 = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('2')
.setLabel('😀')
.setStyle('BLURPLE'),
);
const row3 = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('3')
.setLabel('⚒️')
.setStyle('BLURPLE'),
);
const row4 = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Invite me !')
.setStyle('URL')
.setURL("https://dsc.gg/zylem")
);```
is this correct one ?
i can for example search Tek then a bunch of things starting on Tek is showing up but then when i further try to refine it to for example Tek rifle (i can see it as an option) then nothing shows up
great
You don't have to create a new action row for every button, every action row can contain 5 components
console.log the value and compare it to the names in your array, and see if there is any subtle difference
oh ok
something that could cause the startsWith to fail
each row is a new line, you use more rows if you want to create buttons in new lines instead of in the same line
like this
.addComponents(
new MessageButton()
.setCustomId('1')
.setLabel('😂')
.setStyle('BLURPLE'),
new MessageButton()
.setCustomId('2')
.setLabel('😀')
.setStyle('BLURPLE'),
new MessageButton()
.setCustomId('3')
.setLabel('⚒️')
.setStyle('BLURPLE'),
new MessageButton()
.setLabel('Invite me !')
.setStyle('URL')
.setURL("https://dsc.gg/zylem")
);```
That would work yes
nope
DiscordAPIError: Invalid Form Body
data.components[0].components[0].style: This field is required
data.components[0].components[1].style: This field is required
data.components[0].components[2].style: This field is required
data.components[0].components[3].style: This field is required



