#development

1 messages · Page 2052 of 1

wooden ember
#

fair enough, they are getting better but i still refuse to use them

#

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

winter pasture
#

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)
wooden ember
#

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

winter pasture
#

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

solemn latch
#

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.

hybrid cargo
# winter pasture Well… slash commands a few months ago was absolutely garbage. So I understand wh...

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

solemn latch
#

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.

fervent moss
#

Regenrated it 7 times

#

But doesn't work

winter pasture
rose warren
rose warren
#

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.

leaden zinc
#

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?

rose warren
#

Or just host it on a webpage and post a link to it in your response

#

Like "see leaderboard here"

fervent moss
# winter pasture Mind sharing the code where you set and use the Topgg sdk? (remember to remove t...
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!")});
leaden zinc
#

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

rose warren
# leaden zinc was thinking about making it an image too but there will be data that users migh...

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.

winter pasture
fervent moss
#

I will use it after that

#

Like to get monthly vote

#

See var a

winter pasture
#

Ah. I don`t see anything obviously wrong

#

And the token you are using, is it for the bot (960381632471240744) you are providing?

slender thistle
#

Has anyone introduced a Rust library for Top.gg API wrappers yet

leaden zinc
#

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 dblSmile

hybrid cargo
winter pasture
rose warren
slender thistle
#

LMAO it's 2 years old

#

And its GitHub homepage doesn't exist

leaden zinc
fervent moss
hybrid cargo
#

I dont think multiple images within embeds is a thing

winter pasture
leaden zinc
rose warren
#

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

winter pasture
# fervent moss Yes

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.

hybrid cargo
slender thistle
rose warren
#

Honestly if you're going to post 10 images in a single message I'd rather see you use pagination kekw

slender thistle
#

But you'd be surprised how many people rely on wrappers

winter pasture
leaden zinc
fervent moss
rose warren
winter pasture
fervent moss
#

I am on mobile

gilded plankBOT
winter pasture
#

You should be able to clear cache on mobile too

fervent moss
#

Umm...ic

fervent moss
#

With same code

wheat mesa
#

That’s a js error, not a top.gg error. What’s your code

wheat mesa
slender thistle
#

100% I agree with you Pancake

wheat mesa
#

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

fervent moss
#

Oh oc

#

Ic

winter pasture
#

You are awaiting it, but not assigning the results to a const

#

It’s what I mentioned earlier when the await was not used

fervent moss
#

But if i remove await then it will give error right?

winter pasture
#

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

wheat mesa
#

Well, a is a variable but not a const. For what @winter pasture meant though, it’s the same thing pretty much

winter pasture
#

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

fervent moss
#

Yeah i changed bot to cleint

#

And now it works

#

But throws undefined in console.log

winter pasture
#

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

fervent moss
winter pasture
#

Yeah

#

Not sure if you need to convert b to json first or if the lib does that for you

fervent moss
#

Works atlqst

#

Atlast

winter pasture
#

Nice 🎉

fervent moss
#

Thanks @winter pasture and @wheat mesa

winter pasture
#

Np

winter pasture
#

Lol. Feel free to reach out here if ya need any help

pine nova
winter pasture
#

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

pine nova
#

i see

#

thanks

lyric mountain
#

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

split hazel
#

welcome to java

earnest phoenix
#
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?

lyric mountain
split hazel
#

what length is he printing anyways

#

and why

earnest phoenix
#

Yea it was outdated discord.js bc of the new voice channel

pulsar bloom
#

The site dosen't show the servers my bot is in, how can I fix that?

#

Count of servers*

earnest phoenix
pulsar bloom
#

Oh, alright will do, thanks

earnest phoenix
#

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

slow ibex
#

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?

fervent moss
#

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

earnest phoenix
slow ibex
#

well.. any recommendations for a new library?

split hazel
#

can i rewrite lavalink in c++ :o

#

what does it even do

slow ibex
#

magical things

split hazel
#

meh not interested

#

looks like lavalink already achieves good enough performance with java

earnest phoenix
earnest phoenix
split hazel
#

typescript users realizing they have to strongly type every object

#

💀

earnest phoenix
#

Just like every statically typed programming language

split hazel
#

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

earnest phoenix
#

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)

split hazel
#

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

earnest phoenix
#

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

split hazel
#

python also has this kind of system but javascript needs it more i think

earnest phoenix
split hazel
#

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

split hazel
#

i dont really find myself using the python static type system (maybe because i dont use it often)

#

idk theres just something about python

slender thistle
#

Perhaps. I find the type annotations quite helpful, even if the IDE doesn't take them into account

split hazel
#

kinda like it has more types overall and has a better type inference system

earnest phoenix
split hazel
#

yeah

#

how will browser compatibility work

round cove
#

Does encountering a shard error just keep that shard offline? I imagine so.

split hazel
#

but mostly it should auto restart

round cove
#

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.

quartz kindle
#

djs?

round cove
#

yes

quartz kindle
#

djs only emits ready the first time all shards identify

round cove
#

Ah okay.

split hazel
#

otherwise it will cause a lot of bugs

quartz kindle
#

any shard error will likely either not do anything, or trigger a resume, and upon failing that, a reidentify

round cove
#

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

quartz kindle
#

afaik the shard manager doesnt emit shard logs, only process logs

round cove
#

Ah okay.

quartz kindle
#

the shard logs are in client.on("debug")

round cove
#

Each client instance can though.

#

Cool.

#

I'll probably just have it log in intervals then, thanks.

split hazel
#

who wants my account token

#

Lk97/Ay/RTkIADDZ1OP5TD0iSDFrnixXv/4d8Mh4ZBOvpp6sHfxB6dXWFknTTBkyyFCrMOXYvfvtVxnhRptq4Q2Jyfmw1OxIYK9HPvTG7E9aZh0tzKHpX1kKiZ4FZBJ4oaFsKMseCbLApi6MMxwT+709IA2+9gHma4DqPBdbxNi5YcxAMG6cXuvhZ3+sAWq5fLjaR02M16ijflAqBW2T852PQzdKjghNUBeS8nldMYv/kwkDIbvUQnjc0BO6pCG2tW7zNnoNFByYU1Pbl358/3sPW9AfE/0j4qSReLD4XnlZyX9urNEDdGTTD0EPlZFXc1c+41UrANKmlH8vd9R5QA==

#

oh sorry it is encrypted with asymmetric encryption

boreal iron
#

decrypted and already on eBay

split hazel
#

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

woeful pike
#

obfuscation, most likely

round cove
#

Hi xet unless

#

I think this is all I wanted really.

eternal osprey
#

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

spark flint
eternal osprey
#

it's not really what i mean

earnest phoenix
#

screen?

eternal osprey
#

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

woeful pike
#

they meant literally use the command called screen

eternal osprey
#

huh

spark flint
#

lol

woeful pike
#

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

eternal osprey
#

what would you then recommend?

#

I am trying to create an endpoint to receive data from a webhook

woeful pike
#

enter the IP i guess

spark flint
#

how can i do Discord oauth when I'm doing my bot dashboard in Vue?

eternal osprey
#

yeah but it needs to be port forwarded, as it needs to connect to another site

woeful pike
#

are you running a server on your home computer?

eternal osprey
woeful pike
#

so why can't you just enter the IP or allow the port through the VPS firewall

round cove
#

If you're using ubuntu as you claim you can do sudo ufw allow [PORT]

eternal osprey
#
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?

woeful pike
round cove
#

Xet viviooaahh

eternal osprey
#

I never used the server thingy before, will try

woeful pike
#

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

eternal osprey
#

yeah i knw

woeful pike
#

express already binds to 0.0.0.0 so all you need to do is open ports and ur good

eternal osprey
#

the site i need to receive the info from is sellix. They basically prompt you an url.

woeful pike
#

surely it accepts an IP and if not you can just use something like duckDNS

eternal osprey
#

yup on it dylan, one sec

spark flint
#

ew not duckdns

eternal osprey
#

Rule added
Rule added (v6)

spark flint
#

the amount of scams i catch on duckdns is just ridiculous

round cove
#

Now your VPS has the port open

eternal osprey
#

and now i can access it using 0.0.0.0:3000

#

?

round cove
#

(:

#

Get the ACTUAL IP of the machine and then do port 3000 sure

eternal osprey
#

wahahahah okiii

woeful pike
spark flint
#

nah i watch SSL certs

#

for keywords like verify, discord, dyno, captcha etc

#

also using jaro winkler

eternal osprey
#

omg it works!

#

Thanks guys

#

only love, spread the word ❤️

round cove
#

grats

woeful pike
#

saved another innocent soul from the claws of ngrok

round cove
#

What exactly is ngrok

woeful pike
#

basically just a tunnel that exposes a port on ur computer to the world

#

cloudflare tunnels p much

round cove
#

Lmfao

#

If people use ubuntu they gotta learn ufw

round cove
woeful pike
#

that's exactly what it is

round cove
woeful pike
#

ok i lied it's apparently not even 10 years old

round cove
#

Still bad regardless fuck it

#

We HATE third party programs

#

for ports

#

okay running it back

spark flint
#

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

solemn latch
#

I used Grafana with Prometheus in express.js for awhile.

#

never had an issue

eternal osprey
#

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?

void quartz
#

How many servers does the bot need to be on to be approved?

wheat mesa
#

Approved on top.gg? There is no minimum amount. Verified on discord? I believe you can start the application process at 75 servers

boreal iron
sharp geyser
#

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

round cove
#

I played this for a bit, pretty good

sharp geyser
#

That will be fun to practice regex but I think I need to learn it a bit more first

boreal iron
#

.* that’s all you ever need

sharp geyser
#

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 _

boreal iron
#

^[A-Za-z0-9]$

#

Or with flags

#

/^[A-Z0-9]$/i

#

This will not match whitespaces

#

As those are special chars, too

sharp geyser
#

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

boreal iron
#

You don’t have to but you can

sharp geyser
#

Alright thanks

boreal iron
#

If you validate the length somewhere else already don’t repeat it in your regex

sharp geyser
#

Yea that makes sense

boreal iron
#

This will increase the match iterations dramatically

#

Means it takes a lot more time than actually needed

sharp geyser
#

This should match no?

#

It matches if it is highlighted btw

boreal iron
#

You’re missing the +

#

Oh nvm I’m missing it

sharp geyser
#

Ah I see

boreal iron
#

Add the + behind the ] as the pattern can be repeated

sharp geyser
#

I tried adding it behind it but it did nothing so I added it after the closing bracket and it matched fine

boreal iron
#

This would have matched only one char

boreal iron
sharp geyser
#

I thought you meant behind as in +]

#

Also I notice ?= is used a lot in regex what exactly does this do?

boreal iron
#

No that would add + to the list of allowed chars the pattern can have

boreal iron
#

Hmm well I guess my English isn’t good enough to explain that

#

You gotta look up a few examples

sharp geyser
#

All good thanks :)

round cove
sharp geyser
#

I see

boreal iron
#

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

lyric mountain
#

Has a cheatsheet, examples, explains what u wrote, has unit tests and visual output

round cove
#

I use that to test my regex

sharp geyser
#

God building regex is so annoying

lyric mountain
sharp geyser
#

/^(?!.*(.)\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 mmLol

lyric mountain
#

Hmmm...what are u trying to match again?

sharp geyser
#

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

lyric mountain
#

Idk if this would be a good application for regex

#

Like, you'll most likely want to tell the user what they missed no?

sharp geyser
#

What else would I use?

lyric mountain
#

Normal if checks

sharp geyser
#

Uh that sounds horrible

round cove
#

What the fuck is that regex

#

lmao

lyric mountain
#

It's the only way to show the user what they missed in the password

sharp geyser
round cove
#

of course

lyric mountain
#

Regex will only tell u if it matches or not

round cove
#

NEVER trust sources for regex online

sharp geyser
round cove
#

99.999999999% of solutioons for regex online are wrong or the worst

sharp geyser
#

Dylan I have no fucking clue what I am doing regex is a new concept to me

round cove
#

I'm just letting you know.

#

Are you using a framework?

sharp geyser
#

As in?

round cove
#

.. a web framework.

#

React, Next, Angular, Svelte

sharp geyser
#

Using nestjs for the backend and will use next (or angular depends on what I am feeling) for the frontend

round cove
sharp geyser
#

That looks rather interesting

lyric mountain
#

Idk if this warrants yet another lib tho

round cove
#

If you want you could just store this then.

^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*"'()+,-./:;<=>?[\]^_`{|}~])(?=.{10,})
lyric mountain
#

Unless I'm missing something, this seems pretty easy to implement yourself

#

And I definitely wouldn't use regex for that

sharp geyser
#

I'd rather not use a lib myself as well

round cove
#

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.

lyric mountain
#

The "special character" part could be replaced by [^\d\w\s] no?

round cove
#

That introduces like random unicode and other options when you only want a handful, no?

lyric mountain
#

Aren't random unicode technically special characters?

sharp geyser
#

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

round cove
lyric mountain
#

True

round cove
#

Is my D key double pressing wtf

lyric mountain
#

Distributed DataBase mmulu

sharp geyser
#

Mm

round cove
#

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

lyric mountain
#

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

sharp geyser
lyric mountain
#

Compiler can do wonders with conditional blocks, not as much with regex

sharp geyser
#

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

sharp geyser
lyric mountain
#

Includes

round cove
#

regex lol

sharp geyser
#

string has includes?

round cove
#

also yes

lyric mountain
#

I believe so, or contains

#

It's contains in java at least

round cove
#

Doing includes with a string like this would be bad though

lyric mountain
#

You can also just iterate over pass chars

round cove
#
const lowerCaseLettersRegex = /[a-z]/g;

if (password.match(lowerCaseLettersRegex)) {
  //congrats I guess
}
else {
  // yell at user
}

// Do for upper/numbers/special chars
lyric mountain
#

Lower/upper chars don't need regex

#

Just check if any character is within upper/lower unicode range

round cove
#

Did you mean ascii

#

Also that would require a loop at that point

#

That's such a horrible solution lol

lyric mountain
#

Nope, stream

sharp geyser
#

stream?

round cove
#

WHAT

lyric mountain
#

Idk how it's called in js

sharp geyser
#

Does js have a stream api

#

At this point I am just using regex

round cove
#

Kuu I have no clue wtf you're even suggesting at this point

sharp geyser
#

Cba to do otherwise

lyric mountain
#

Found it, some

round cove
#

some lol

#

that still interates

#

What if my password was $@$@#*$#@*($(@#*$(*@!*(^!%@#)^@(#%)@!*%!(%)!%(!)%@#!*aA1

lyric mountain
#

Regex does too no?

round cove
#

lol honestly i don't know

lyric mountain
#

Afaik regex is just a compiled iterator

round cove
#

But if regex already solved it and made it better than why not use it

lyric mountain
#

Like, it tells what ur looking for in a string

round cove
#

Instead of making my own jank some loop checking ascii values

#

Like you're not doing anything better than regex is at that point

lyric mountain
#

Regex has to be compiled beforehand

round cove
#

Okay and?

#

What's the 0.0000000000000000000000000000000001nanoseconds of compilation going to add

#

to my deployment

lyric mountain
#

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

round cove
#

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

lyric mountain
#

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 expression new RegExp(Pattern, Flags) where RegExp is the standard built-in constructor with that name.

round cove
#

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

earnest phoenix
#
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
earnest phoenix
#

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)

feral aspen
#

Is it possible to fetch all the users who have joined a guild within a specific amount of time?

sick agate
#

How do I make bazel use my local jdk without bazel doing it's things

near stratus
feral aspen
near stratus
#

Fetch all members

#

And get ratelimited

#

Imagine fetching all members from a giant server
Like genshin

pine nova
#

💀

lilac vault
#

fortnite!

rustic nova
boreal iron
#

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

fervent moss
boreal iron
#

You can’t

#

That’s only possible with webhooks as Aurel said

fervent moss
#

Oh does topgg api have that feature? To get highest vote user?

boreal iron
#

You gotta listen permanently if an user votes and if so save this data in your database with the timestamp

fervent moss
#

Timestamp hmm...why tho 😬

boreal iron
#

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

fervent moss
lyric mountain
#

order by entry count

fervent moss
#

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

civic scroll
#

just use webhooks

#

and listen to them passively

#

timestamp is an integer

#

so just store something equivalent to Int64

#

and you're good

fervent moss
#

Kinda mongodb but would use quick db my mongo is about to get full 😬

lyric mountain
fervent moss
civic scroll
#

bruh

#

i thought you used sql

#

in that case it's not an issue then

fervent moss
civic scroll
#

set new timestamp

fervent moss
civic scroll
#

Int64 Trolled

lyric mountain
#

sql is easier than amongodb tbh

#

CURRENT TIMESTAMP (context deleted)

boreal iron
#

Sry got a call

#

You’re done?

fervent moss
#

Hmm....ic then after storeing date what to do? Like i have no idea ~

boreal iron
#

you gotta choose datetime as field type and insert now() as value or FROM_UNIXTIME(timestamp)

fervent moss
boreal iron
#

Or set the default col value as current timestamp

#

Which is the easiest option

lyric mountain
#

he's using amongodb

#

not sql

boreal iron
#

amongodb WTF

#

Is that

fervent moss
#

No i can use 2 db in one project ig

fervent moss
earnest phoenix
lyric mountain
#

considering the context, I don't think it'd be any easier to explain how to do it in a completely foreign database structure

fervent moss
#

And yeah i will have to learn about SQL first it has limits?

lyric mountain
#

depends on what u consider "limits"

fervent moss
#

Storage

lyric mountain
#

all databases have infinite storage (well, kinda)

#

as long as u have enough space available on your drive

fervent moss
#

On "free plan"

lyric mountain
#

there's no free plan for a self-hosted database

boreal iron
fervent moss
#

I can't afford to self host a bot lol

lyric mountain
#

I imagined it'd lead to that

fervent moss
#

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

boreal iron
#

You can actually the database you like, no need to just use SQL for this

lyric mountain
fervent moss
#

Why thonkku

boreal iron
fervent moss
#

My bot is online from last 3 months and verified by discord and yeah with replit and mongodb as hosting service and data service christmasthink

lyric mountain
boreal iron
lyric mountain
#

he is

boreal iron
#

Ah

#

Seems like I missed that

lyric mountain
boreal iron
#

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?

lyric mountain
#

as much as I hate it, mongo is the only one I'm aware of having free storage plan

fervent moss
lyric mountain
#

like, the code changing project files

fervent moss
#

.sqlite file exist in replit i belive

lyric mountain
#

if it does then ur fine

fervent moss
#

Is data stored in sqlite files?

#

And also replit has quick.db

boreal iron
boreal iron
lyric mountain
#

quickdb is terrible

fervent moss
#

Yeah it's kinda same as sqlite

#

But replit too has limits on ram

lyric mountain
#

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

boreal iron
#

Well if SQLite works then he’s fine I guess

#

I mean try it, install it and you will see

fervent moss
#

What i choose isnot to do bad idea very complex

lyric mountain
#

you what?

round cove
#

Bad idea very complex

fervent moss
#
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

lyric mountain
#

that wont work obv

#

do note tho, this wont get u a correct top monthly votes

#

since it's limited to 1000 votes

#

read the link (context deleted)

fervent moss
#
let b = await api.getVotes('960381632471240744/') // returns bot info 

Like this i believe then?

lyric mountain
fervent moss
#

I need to mention user too? Like Xignori. Etc...?

lyric mountain
#

oh my

#

please read the entire thing

fervent moss
#

Hmm...okay

lyric mountain
round cove
#

Yikes

lyric mountain
#

@solemn latch

fervent moss
#
 let c = await api.getVotes('') 
console.log(c)

How to map?

const map = c.map(username);

console.log(map); 

Like this?

solemn latch
#

so fast 👀

pine nova
#

💀

quartz kindle
#

to map or not to map, that is the question

pale vessel
#

to for loop

fervent moss
# pale vessel 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?

simple stump
#

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?

boreal iron
quartz kindle
#

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

boreal iron
#

Does the vote endpoint actually shows the last 1000 unique voters or last 1000 votes?

#

Which means repeats can occur?

solemn latch
#

I dont actually know 👀

quartz kindle
#

pretty sure it shows all votes, i dont see why it would show unique only, that would be a questionable design decision

boreal iron
#

Idk too and can’t test it on mobile

#

So it does list multiple votes for the same user multiple times or not?

pine nova
boreal iron
#

Ewww

pine nova
#

💀

boreal iron
#

When I said I can’t test it atm I expected someone of you lazy dudes would do it

pine nova
#

lmao

quartz kindle
#

id do it but i dont wanna go hunting for bots that had the same user vote today and yesterday

boreal iron
#

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.

fervent moss
quartz kindle
#

did you or someone else vote for your bot multiple times in the past few days?

fervent moss
#

And yeah same with other users too

quartz kindle
#

then yeah you can make a leaderboard for the last 1000 votes only

fervent moss
#

Hmm...but how do I get started?

boreal iron
#

I can give you my ID

lyric mountain
#

still having issues with that smh

quartz kindle
#

so either create an object, then loop over the array, or use array.reduce

#

the former is easier to understand

boreal iron
#

cough map cough

fervent moss
boreal iron
#

Ok… so all votes not unique ones

quartz kindle
fervent moss
#

Create an object wdym? I can't understand something's by brain is slow 🧠

boreal iron
#

or a map

quartz kindle
#
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
  }
}
fervent moss
quartz kindle
#

how would that be useful? thats basically the correct solution to exactly what you want to do

boreal iron
#

You gonna save the user id in your object and the actual vote count?!

fervent moss
boreal iron
#

Or exclude them for privacy reasons if you want to

quartz kindle
#

sure, you can use a collection or a map too

boreal iron
#

How you save it is up to you

quartz kindle
#
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
  }
}
fervent moss
boreal iron
#

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

fervent moss
#

So what about using object 😅

quartz kindle
#

sigh...

boreal iron
#

It’s basically all the same in JS

#

Arbghhhhhh don’t punish me!!!!!!1!!‘

quartz kindle
#

you want to count the number of times a user has voted, correct?

fervent moss
#

Yeah

boreal iron
#

Spoonfeed or I will do it

fervent moss
quartz kindle
#

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}"
}

fervent moss
quartz kindle
#

that doesnt matter

#

then you take this item

#

and you check if you have seen this item before

#

if(!obj[item.id])

#

item.id is the id of the current item, if the current item is {id: 1} then item.id is 1

#

obj is the object you created

fervent moss
#

So like i need to add up 1 in an another var for if id exists?

quartz kindle
#

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 }

fervent moss
#

If it doesn't exist

#

But what if it exists?

quartz kindle
#

if it already exists

quartz kindle
#

then you add 1 to it, so it becomes 2

boreal iron
#

wtf is ??=

lyric mountain
quartz kindle
#
if(!obj[item.id]) {
  obj[item.id] = 1;
} else {
  obj[item.id]++
}
``` for example
boreal iron
#

Never saw that operator

fervent moss
#

Like 1+1 won't work

lyric mountain
#

discovered it thanks to xexe

quartz kindle
#

which is the same as obj[item.id] = obj[item.id] + 1

lyric mountain
#

or put if not exists

fervent moss
boreal iron
#

Hmm didn’t know that exists

#

Good to know

fervent moss
#

And if exist then add 1 to existing integer

lyric mountain
#

neither did I, xexe appeared out of nowhere last time and showed it

fervent moss
#

Whose xexe christmasthink

lyric mountain
#

xetera

boreal iron
fervent moss
#

What is Tim typing for so long christmasthink

lyric mountain
boreal iron
quartz kindle
#

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

fervent moss
boreal iron
#

Tim trying so hard instead of spoonfeeding

lyric mountain
#

to retrieve that data for all users you'd explode the ratelimit

boreal iron
#

He’s so cute

quartz kindle
#

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)

quartz kindle
boreal iron
fervent moss
#

Okay so now i need to try this stuffs

fervent moss
# quartz kindle f u
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

lyric mountain
#

second and third option

boreal iron
#

Replace ??= with = 1

#

obj = obj + 1 by obj += 1

lyric mountain
#

obj should be myObject

fervent moss
#

Yeah i get that

fervent moss
lyric mountain
#

I believe so

boreal iron
#

No

#

obj = obj + 1 by obj += 1

lyric mountain
#

ah, missed that

#

btw myObject[item.id] = myObject[item.id] = 1 can become myObject[item.id]++ no?

boreal iron
#

you still have obj = obj += 1

lyric mountain
#

it does

boreal iron
#

Make it = 1

#

Oh I thought you meant the first case

fervent moss
#

Wait what

boreal iron
#

Yeah since it’s defined as integer ++ also works

#

I wonder if there’s actually a difference

fervent moss
boreal iron
#

But I would always prefer += 1 in cases it’s not an integer

boreal iron
#

myobject = myobject += 1

#

Is what you got atm

#

Which doesn’t make any sense

fervent moss
boreal iron
#

You did, yes

near stratus
#

Typescript Moment

lyric mountain
#

totally helpful tooltip

fervent moss
boreal iron
lyric mountain
#

that's why I suggested it

boreal iron
fervent moss
#

Umm...doesn't make any different code working remains same? So no need lmao

boreal iron
boreal iron
fervent moss
#

I corrected christmasthink

boreal iron
#

obj = obj += 1 is nonsense

fervent moss
#

Then wdym me to change that with?

pine nova
boreal iron
#

obj += 1 or obj++

#

As we mentioned

fervent moss
#

obj or myObject? Ig myObject makes a sense with common snese

boreal iron
#

Im just too lazy to use your weird var names

fervent moss
#

Lol

#

Done did you meant this?

boreal iron
#

Yes

fervent moss
#

Umm...yeah then ready to go 👍

#

Bruh ik i did something more stupidest

boreal iron
#

Why tf is it still like this

#

I thought you changed it

fervent moss
#

Dint you mean this then why you meant?

quartz kindle
#

whats your current code?

boreal iron
#

The first, second and now third time: Yes

#

That’s what you have to change

fervent moss
boreal iron
fervent moss
# quartz kindle whats your current code?
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) 
quartz kindle
#

just do ```js
} else {
myObject[item.id]++
}

fervent moss
#

Umm..

boreal iron
#

Or this… @.@

quartz kindle
#

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

boreal iron
#

As we have already explained

near stratus
#

At this rate it'd be easier to write the code for him

quartz kindle
#

yeah but we dont do that here

boreal iron
#

You did that already

#

So shut up

quartz kindle
#

fish for someone once, and they will beg you for fish for the rest of their life

boreal iron
fervent moss
#

Best moment

boreal iron
#

Tim please continue to write my code, I’ve got no time atm

#

PLEASE TIM

near stratus
#

Obejct

quartz kindle
fervent moss
#

Oh shit

quartz kindle
#

very nice obejct

#

gonna rename all my obejcts now

boreal iron
#

At least console.log is correct

split hazel
#

if you get the joke you get the joke

int getRandomInt() {
  int* d = malloc(4);
  int result = *d;
  free(d);
  return result;
}
boreal iron
quartz kindle
#

nice meme

split hazel
#

no memory leaks

#

the perfect c code

boreal iron
#

Just free the entire RAM and that’s it

#

All problems solved

split hazel
#

but rust users wouldnt like the code because they consider an uninitialized value undefined behaviour

fervent moss
# quartz kindle

Now it shows myObject.keys isn't function should i change it to .key ?

split hazel
#

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

pine nova
#

💀

split hazel
#

i was very disappointed when i found that out

lyric mountain
quartz kindle
#

Object.keys(myObject)

split hazel
#

stupid voltrex and his crew

#

quitting javascript now

lyric mountain
#

strings are a pain to deal with at low level

split hazel
#

only optimization problem i can think of is maybe a hash recompute since i assume js uses that to compare strings quickly

near stratus
split hazel
#

who was the guy that stole a string in rust again

near stratus
#

Instead of copying

lyric mountain
#

for java but I believe it's the same for js and python

split hazel
#

i dont think any of those are really a problem for js

#

idk about thread safety but js somehow takes care of that anyways

lyric mountain
#

www.<language>point.com as it seems lmao

split hazel
#

ima just ask volt

#

@earnest phoenix pls

#

no someone here stole a string in rust

#

they stole it

boreal iron
#

Eww such an ugly syntax

#

My eyes …

split hazel
earnest phoenix
split hazel
#

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

fervent moss
#

@quartz kindle @lyric mountain (sry to ping) it returns all IDs (unique) but not votes amount :(

boreal iron
fervent moss
#

Oh so values?

boreal iron
#

Log the entire object and see the magic

fervent moss
#

Umm...

near stratus
earnest phoenix
# split hazel cant lie the fact no exception was thrown threw me off and i never knew strings ...

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

fervent moss
split hazel
#

but like nnnnn

#

i see people splitting a string then joining it again just to change a character

fervent moss
split hazel
#

and i go 💀

cinder patio
#

string copying is cheap

split hazel
#

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

cinder patio
#

removing a single character without copying a single byte?

split hazel
#

if js wont let me i will write a native node addon which supports modifying strings by index :troll:

cinder patio
#

store the string as an array of characters

split hazel
#

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 +=

quartz kindle
split hazel
#

yeah it will

cinder patio
#

well that still copies bytes so

lyric mountain
cinder patio
#

still copies bytes assuming V8 doesn't optimize it

split hazel
#

you get the penalty of making a new array and then constructing it again 💀

#

but its probably the fastest out of all of them

quartz kindle
boreal iron
lyric mountain
#

park the car first

quartz kindle
#

shush Kuhueakababkulalala

boreal iron
#

Shhhh

#

I can’t spell this name

split hazel
#

will fork the v8 engine just to make strings mutable 💀

#

you think i wont do it

quartz kindle
#

you're willing to destroy v8 just for that

#

damn speedy is woke

split hazel
#

based

#

dont let others stop you

cinder patio
#

You could store the string in a buffer

boreal iron
#

You gotta destroy the entirety to create something new

cinder patio
#

but turning it into actual string probably copies it

boreal iron
#

That’s how the world works

split hazel
#

and would be a better word to use

quartz kindle
#

whatever you do, its always going to be orders of magnitude slower than just merging strings

fervent moss
quartz kindle
#

yes

fervent moss
#

Hmm thanks :)

split hazel
#

idea for js: make it use the stack :troll:

#

dont ask me how just do it

quartz kindle
#

just make js++

#

low level compiled js

split hazel
#

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

fervent moss
# quartz kindle yes

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) 
earnest phoenix
#

guys

#

client.user.avatarURL() work in v12

#

but v13 not

#

can i have the v13 change ?

lyric mountain
#

did you check the docs?

earnest phoenix
lyric mountain
#

no you need the docs

earnest phoenix
fervent moss
#

Same thing as for var noice

earnest phoenix
#

so ?

#

i need to add

#

({dynamic: true })

fervent moss
#

First is noice and second is for hi

earnest phoenix
#

or

#

client.user.displayAvatarURL

quartz kindle
#

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]

fervent moss
#

Like values are amount of votes so yeah

quartz kindle
#

since a and b are [id, value], a[0] would be id, and a[1] would be value

fervent moss
#

Umm...ic

ancient nova
#
    if (member.user.id === message.guild.ownerID) acknowledgments.push("Server Owner");
#

any one know why this doesn't work?

lyric mountain
#

context?

ancient nova
#

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

lyric mountain
#

does user.id return a long or a string?

ancient nova
#

not sure let me look at the docs

#

should I convert both of them to strings?

lyric mountain
#

like, long usually has some issues on js because it gets truncated unless you explicitly use long/bigint

#

idk if that applies here

earnest phoenix
rocky dagger
#

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 })), );

ancient nova
#
        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?
earnest phoenix
#
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

ancient nova
#

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

lyric mountain
#

make sure to limit maximum user-defined value to 99

lyric mountain
#

is your issue about bulk-deleting messages?

ancient nova
#
    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

lyric mountain
#

args[0] >= 100

earnest phoenix
#

The args array contains only strings in your case, so you would have to cast it to a number to do that

ancient nova
#

ah I thought it automatically returned whatever the arg value was

earnest phoenix
ancient nova
#

which func should I use to cast the string to a number?

earnest phoenix
lyric mountain
earnest phoenix
#

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

lyric mountain
#

remember banana

ancient nova
#

😭 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

earnest phoenix
#

I don't see how it would look bad in any way

quartz kindle
#

you dont need isNaN at all

ancient nova
lyric mountain
#

it'll enter the first if check

quartz kindle
#

if messageToDelete is NaN, it will fail the if(!messagesToDelete)

lyric mountain
#

NaN is falsy

ancient nova
#

oh

#

I think I get it

ancient nova
#

cause it it doesn't parse into an int because it isn't a number it would return as not defined

#

right?

earnest phoenix
#

What?

quartz kindle
#

parseInt either returns a number, or returns NaN

#

and NaNs work as false for if()s

earnest phoenix
#
  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 ?

rocky dagger
# quartz kindle inconsistent how?

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

ancient nova
earnest phoenix
quartz kindle
quartz kindle
#

something that could cause the startsWith to fail

quartz kindle
# earnest phoenix oh ok

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

earnest phoenix
#
            .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

earnest phoenix
#

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