#development

1 messages · Page 2077 of 1

winter pasture
#

srry

ancient nova
#

do you know how to embed images into the long description?

lyric mountain
#

for example, u mention this but gives no examples

digital swan
#

nah just saying thats probably why it doesnt get many invites

#

people click and get blinded

lyric mountain
#

anyone could say "never seen commands" but what commands?

gilded plankBOT
winter pasture
#

For markdown

#

<img> tag for HTML

lyric mountain
#

oh and remember the first rule of advertising: the first 20 words are the ones that'll define whether you'll grab the viewer's attention or not

winter pasture
#

Also not going to hate on the name, but "Anonymous Hater" gives off a weird vibe imo

eternal osprey
#
Uncaught DiscordAPIError DiscordAPIError: Invalid Form Body
data.components[0].components[5]: The specified component exceeds the maximum width
data.components[0].components[6]: The specified component exceeds the maximum width
data.components[0].components[7]: The specified component exceeds the maximum width```?
lyric mountain
#

character limit

eternal osprey
#
new MessageButton()
                    .setCustomId('0week')
                    .setLabel('Warn')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('1day')
                    .setLabel('1 Tag')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('2day')
                    .setLabel('2 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('3day')
                    .setLabel('3 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('4day')
                    .setLabel('4 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('5day')
                    .setLabel('5 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('6day')
                    .setLabel('6 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('1week')
                    .setLabel('1 Woche')
                    .setStyle('PRIMARY')```
#

Doesn't look like i meet the limit right?

ancient nova
boreal iron
#

MAX 5 components per ROW

eternal osprey
#

oowh bruhf

boreal iron
#

max 5 action rows

ancient nova
#

if I'm gonna change I need to do it right now cause my bot is a couple servers away from verification

winter pasture
#

Finding a name is hard. You could go for a name that matches a theme.
Like Mimu goes for a "cute" theme

boreal iron
ancient nova
#

I know this may sound stupid but could anyone grab the screenshots for me?

#

I have a CSS script extension and it will look quite sketchy

eternal osprey
#

i guess not right

boreal iron
#

yeah 2 actions with a total of 5 per row

#

max 5 rows = 25 total

eternal osprey
#

how would i add mutliple rows? i suppose it needs to be on a different embed each time right

boreal iron
#

those are components

#

not embeds

winter pasture
#

Would't a select make more sense when it comes to selecting days?

eternal osprey
winter pasture
#

In web dev you always say if there is more than 3 buttons, use a select

boreal iron
#

you simply add another row to the component

eternal osprey
#
const row1 = new MessageActionRow()
            .addComponents(
                new MessageButton()
                    .setCustomId('0week')
                    .setLabel('verwarnung')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('1day')
                    .setLabel('1 Tag')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('2day')
                    .setLabel('2 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('3day')
                    .setLabel('3 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('4day')
                    .setLabel('4 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('5day')
                    .setLabel('5 Tage')
                    .setStyle('PRIMARY'),
                    
            );
            const row2 = new MessageActionRow()
            .addComponents(
                new MessageButton()
                    .setCustomId('6day')
                    .setLabel('6 Tage')
                    .setStyle('PRIMARY'),
                    new MessageButton()
                    .setCustomId('1week')
                    .setLabel('1 Woche')
                    .setStyle('PRIMARY'))
                
            const embed1 = new MessageEmbed()
                .setColor('GREEN')
                .setTitle('Verwarnung- 1 woche options')
                .setDescription(`Wähle mit wievielen Wochen der User bestraft werden soll!`)
                .setTimestamp()
                .setFooter({ text: 'Arcadia Henker | Strike'});
              interaction.reply({ embeds: [embed1], components: [row1, row2] })```Like this lmao?
#

srry for the code bomb lol

boreal iron
#

dude for real

eternal osprey
#

yeah?\

boreal iron
#

the first row has 6 buttons

eternal osprey
#

oowh lmao

boreal iron
#

But yes it works like this

fathom sonnet
#

yes

boreal iron
#

You simply add those rows to the array of your components

#

But with the correct amount of buttons per row

ancient nova
sharp saddle
boreal iron
#

And maybe a first row with common timeouts

#

5m, 15m, 30m, 1h, 12h

lyric mountain
#

also 6h

boreal iron
#

eyes rolling

quartz kindle
#

eyebrows waving

boreal iron
ancient nova
#

is that better then?

vivid fulcrum
#

and have the effect appear on the page load

sharp saddle
#

ok

vivid fulcrum
#

the UI is clean though

#

loving the color palette

sharp saddle
#

really don't know what to add more

#

I'm totally out of ideas

vivid fulcrum
#

another thing id suggest is when entering the URL to play the music, maybe give the use feedback that it's loading in, i.e. disabling the input and adding a loading indicator like a spinner

sharp saddle
vivid fulcrum
#

ah

sharp saddle
#

I just put the URL because I was not able to put the name

#

the bot probably didn't find the song or something

vivid fulcrum
#

much better UX

#

also loving the backdrop-filter touch on the navbar

sharp saddle
mint rock
#

hi, why is this happening? it worked just fine and now it throws this error

sharp saddle
#

are you using v14?

mint rock
#

i guess it installed the latest

#

its v13 code

sharp saddle
#

yea, you installed v14

#

try using npm i discord.js@13

mint rock
#

nah, time to browse new documentation bugga

#

thanks tho! didnt know its out

sharp saddle
#

lmao

#

you can know in official djs server

mint rock
sharp saddle
mint rock
#

aaa is it worth switching to v14?

boreal iron
#

That’s up to you

sharp saddle
#

yea

#

is the most recommended, as it is more stable

boreal iron
#

Not much of a difference between 13.9 and 14.0 now

#

I’m terms of features and api support

sharp saddle
boreal iron
#

Once you don’t plan to rewrite your entire code and put a lot of time into it anyways it’s not really worth atm

sharp saddle
#

I'm too lazy to change to v14, there are many things

boreal iron
#

But expanding the code just to edit way more code later if you update it might also not be considered great

mint rock
#

i sent message to djs server by accident and now they are crying

boreal iron
#

It actually up to you how

#

And how familiar youre already with djs, it’s syntax and changes

mint rock
#

read up cringe

lyric mountain
#

you'll eventually have to, better do it so you don't need to rush later on

earnest phoenix
#

Hi guys, there is a way to make the bot to send a message when someone votes on top.gg? without webhook

lyric mountain
#

no

boreal iron
#

Yes

earnest phoenix
#

i saw there it is

boreal iron
#

But not just in time

earnest phoenix
#

doesn t matter

boreal iron
#

Only then when you send a request to the API

lyric mountain
#

I mean, if ur ok with having a considerably huge delay between voting and notifying...

#

ur users wont be happy probably

boreal iron
#

I won’t be happy to get random messages anyways

earnest phoenix
#

xD

mint rock
#

give them 50 virtual bucks for voting 😎

lyric mountain
#

user votes

1 hour later

"thanks for voting"

user: "Wtf?"

vivid fulcrum
#

either do what kuuhaku suggested, querying the API periodically or have the user execute a command to confirm their vote

earnest phoenix
vivid fulcrum
#

other than that, there's nothing else but using webhooks

earnest phoenix
#

love it

boreal iron
earnest phoenix
#

works fine with webhook

#

ngl

boreal iron
#

But that’s still not really comfortable

earnest phoenix
#

it didn t fking work

boreal iron
earnest phoenix
#
const express = require('express')
const app = express();
app.get('/', (req, res) => res.send('E on'));
const port = 65476
app.listen(port, () =>
console.log(`it s on`));
app.get("/bot-data", async function (req, res) {
    res.send({users: client.guilds.cache.reduce((a, b) => a + b.memberCount, 0), servers: client.guilds.cache.size})
})
const Topgg = require('@top-gg/sdk')
const fetch = require('node-fetch')
const webhook = new Topgg.Webhook("maybe no?")
app.post("/dblwebhook", webhook.listener(vote => {
    console.log("User with id - " + vote.user + " Voted!")
    let value = JSON.stringify({
        embeds: [
            {
                description: `<@${vote.user}> (${vote.user}) [voted](https://top.gg/bot/993041677243654144/vote) for **shard**`,
                color: "#000dff"
            }
        ]
    })
    fetch("https://discord.com/api/webhooks/some-id-lol/hehe", { 
        method: 'POST',
        headers: {
            'Content-type': 'application/json',
        },
        body: value
    }).catch(e => console.log('Error occured while posting webhook : ' + e))
}))
#

that s my express

#

where s the issue?

#

if you're wondering about if i'm that dumb and forgot to set in top.gg

#

let me show

boreal iron
#

Where’s is that code running? At home or on a server?

earnest phoenix
boreal iron
#

I’m on mobile

earnest phoenix
#

you can enter it

boreal iron
#

How tf would I manage to send a post request lol

earnest phoenix
#

or let me ss it

boreal iron
#

The code will react on post requests

earnest phoenix
boreal iron
#

Aka webhooks

earnest phoenix
#

it s working only first part

#

that with servers

wheat mesa
earnest phoenix
#

for site

wheat mesa
#

your vps is probably blocking it

earnest phoenix
#

but for website works

boreal iron
#

Requiring an authorization

wheat mesa
#

fair

earnest phoenix
#

damn

#

my brain is dead

boreal iron
#

Can you actually receive and log a vote?

earnest phoenix
#

yeah

#

only log

#

but in channel via webhook

#

i recive only hope 🙂

boreal iron
#

Well is see your initiated client var in the code above

#

Just fetch the server and channel and send the message

#

Using the log data, we probably just the user Id

earnest phoenix
#

fetch it

#

but how

#

like

#

it would'nt be

#

reconized

boreal iron
#

Fetching what?

earnest phoenix
#

server and channel and send the message

boreal iron
#

client.guilds~~.cache~~.fetch(…)

#

then <guild>.channels.fetch(…)

#

OR get() as both are cached by default

#

In order to not let @earnest phoenix cry about it again

#

BUT since I don’t know about the caching behavior of the guy I’m helping I always take the safe way aka fetch Mr. Voltrex

#

Is the webserver part of your bot code?

#

I can’t see shit on mobile

boreal iron
#

Oh I see

#

That’s what he means

wheat mesa
boreal iron
#

Using the rest api to send a webhook

#

Damn

#

Code blocks suck hard on mobile

#

Not my fault

earnest phoenix
#

bruh

wheat mesa
#

client.guilds.cache.fetch is about as real as ohio

#

doesn't exist

earnest phoenix
#

:))

boreal iron
wheat mesa
#

it doesn't dingus

#

cache is a collection in almost all occurrences of the word in djs

boreal iron
#

Oh lol

wheat mesa
#

which is just a fancier map

boreal iron
#

I added cache property accidentally

#

Damn I’m a dingus

wheat mesa
#

😉 dingus

lyric mountain
#

bingus dingus

boreal iron
#

Dingus

#

Fuck that proves that drinking writing and driving ain’t a good idea

wheat mesa
#

lol

boreal iron
#

I just tested you folks of course

#

Mission passed

wheat mesa
#

can we just appreciate rust for one moment ```rs
fn find_number(&self, num: f64) -> Option<usize> {
self.constants.iter().position(|c| {
if let Constant::Number(num2) = c {
(num - num2).abs() < f64::EPSILON
} else {
false
}
})
}

#

god it's amazing

boreal iron
#

No!

#

Move on with its ugly syntax ffs

#

My eyes

wheat mesa
#

not ugly syntax!

#

what about it is ugly!

#

I don't like the lack of parenthesis that much but I can deal with it for the benefits of the language

lyric mountain
wheat mesa
#

implicit returns

#

position is a function that takes a lambda essentially

boreal iron
#

Looking for tree to end this mess, don’t wanna watch rust code

lyric mountain
#

what abt if let?

wheat mesa
#
Searches for an element in an iterator, returning its index.

position() takes a closure that returns true or false. It applies this closure to each element of the iterator, and if one of them returns true, then position() returns [Some(index)]. If all of them return false, it returns None.

position() is short-circuiting; in other words, it will stop processing as soon as it finds a true.
wheat mesa
#

more beautiful rust ```rs
pub fn write_constant_string(&mut self, string: String) -> usize {
if let Some(id) = self.find_string(&string) {
id
} else {
self.write_constant(Constant::String(string))
}
}

boreal iron
#

thats better

ancient nova
boreal iron
#

Represents how i see rust

quartz kindle
#

the shit i do just to avoid having to use ts

wheat mesa
#

my god

winter tapir
#
let lock = false;

app.post(
  '/dblwebhook',
  webhook.listener((vote) => {
    if (!lock) {
      lock = true;

      console.log(vote.user);

      bot.emit('vote', vote, bot, app);

      lock = false;
    }
  })
);

Is this how you properly create a mutex? For some reason I tried to attempt making one and this piece of code sometimes execute twice. Sometimes it will run fine and execute once, then some other times it will run twice, however it doesn't execute three times. Any help will be appreciated!

wheat mesa
#

spamming your question every 5 minutes isn't going to get you an answer :p

#

I think your underlying problem isn't about mutexes, you need to figure out why you're getting two webhook events

ancient nova
hybrid cargo
boreal iron
#

Nope

ancient nova
#

perhaps that would be hard to do?

hybrid cargo
ancient nova
#

how for example?

hybrid cargo
#

People using user bots to send vote messages on timed intervals

ancient nova
#

that's what I meant by people who are connected to the top.gg auth app, meaning real people that are registered on the website

#

not bots

hybrid cargo
#

"user bots"

quartz kindle
ancient nova
# hybrid cargo "user bots"

even so that's pretty much what you'd do with the normal websites, just harder and more of a pain to do to watch an ad

quartz kindle
#

the only thing in js that is remotely similar is sharedArrayBuffer atomics

lyric mountain
ancient nova
#

meaning people will just not vote unless they have a reason to

hybrid cargo
#

¯_(ツ)_/¯

ancient nova
#

:/

winter tapir
quartz kindle
winter tapir
#

I think a possible reason why my code could be executing twice is because the webhook is retrying itself

quartz kindle
#

unless the top.gg lib is broken somehow

ancient nova
#

I would rather have that for the sake of convinience

winter tapir
#

But I don’t see a reason why a webhook would need to retry itself however as the first one that was sent is successful

quartz kindle
lyric mountain
#

But doesn't it use pseudo threads for events? (aka promises)

quartz kindle
#

nop

lyric mountain
#

Weird

#

So a faulty event could technically lock the entire process

winter tapir
quartz kindle
lyric mountain
#

Yes but, if an event gets deadlocked wouldn't it prevent further events from happening?

ancient nova
quartz kindle
#

however it is possible for a second event to enter execution before the code in the first event finishes, if the code is async, and i mean truly async, it does i/o stuff or uses timers, just slapping the async keyword on it doesnt make it async

quartz kindle
lyric mountain
#

Damn

quartz kindle
#

or anything else in your entire code

lyric mountain
#

I knew js was mono thread, but I though events were handled like promises

quartz kindle
#

they are just tools that allow you to use async

#

them by themselves do not make any code async

winter tapir
quartz kindle
#

since a user can only vote once every 12 hours on top.gg you can simply create an object and add the user's id to that object

#

if it already exists, ignore

#

then delete the user from the object after 12 hours

boreal iron
#

Is the second event being fired before you can respond to the first one?

#

I think I’ve seen multiple webhooks being sent, too even after responding as expected

#

So… most likely an API issue

lyric mountain
#

Ik top.gg retries if u don't return 2xx status in time

boreal iron
#

Yeah

#

Even then I think I saw multiple requests rarely

lyric mountain
#

I'd say create a promise to handle the processing and return an status asap

boreal iron
#

Maybe their code fails on parsing the response data

#

Sending the request again

#

For whatever reason

lyric mountain
#

To debug that I'd bombard the handler with requests to see if something fails

#

Like, simulate 5 or so votes per second

boreal iron
#

Guess nobody will ever debug the API

lyric mountain
#

Nono, I mean his handler, not topgg api

boreal iron
#

Also doubt anyone actually actively working on an improved version of it

boreal iron
#

But I still assume like it’s an issue on topgg

#

Since we’ve seen that issue for multiple people

#

Not all of them are using sdk

#

Chances are low something goes wrong on the client side on many different environments

#

But haven’t really tried to debug that at all

#

Not so important

ashen orbit
#

is there a way to have it so every embed my bot makes is the same

#

or something

ancient nova
#

so I timed out a person for 30 seconds using member.timeout() and after that passed they dmed me that they we're still muted? I had to manually time them out again for that to be fixed

#

discord bug?

quartz kindle
#

which imo is a bad design

ashen orbit
#

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.

#

djs 14

quartz kindle
ashen orbit
#

assuming that it's my client

// Variables
const bot = new discord.Client({intents: [discord.GatewayIntentBits.GUILDS, discord.GatewayIntentBits.GUILD_MESSAGES, discord.GatewayIntentBits.GUILD_MEMBERS, discord.GatewayIntentBits.GUILD_MESSAGE_REACTIONS, discord.GatewayIntentBits.GUILD_PRESENCES]})

whats wrong with it

#

i updated to v14

winter tapir
#

so Guilds, GuildMessages etc

ashen orbit
#

ohhhh

#

i didn't realise they werent all uppercase anymore

#

thanks guys

winter tapir
ashen orbit
#

is that new?

winter tapir
ashen orbit
#

oh ok

#

thanks

#

:)

winter tapir
lyric mountain
#

Maybe, worth a try

#

Tho I think u need to handle your callback async instead

winter tapir
# lyric mountain Maybe, worth a try

I would be unsure how I would integrate those params within my listener

app.post(
  '/dblwebhook',
  webhook.listener((vote) => {
    console.log(vote.user);

    return bot.emit(vote, bot, app);
  })
);
lyric mountain
#

Since the lib will also return 2xx when u end it

#

Oh is that express?

winter tapir
lyric mountain
#

Idk how express works, but u could always simply ```js
new Promise(() => {
// code
})

return // whatever u need to return in express

boreal iron
winter tapir
#
app.post(
  '/dblwebhook',
  async (req, res) => webhook.listener((vote) => {
    res.sendStatus(204);

    console.log(vote.user);

    return bot.emit(vote, bot, app);
  })
);

I think this should send the response to top.gg

#

So the webhook doesn't retry

boreal iron
#

I was actually close to ask if you already figured out to send a legitimate response to the request

#

But thought no, you would have been through this already

winter tapir
boreal iron
#

lol

#

Ik how you feel

#

sometimes

ashen orbit
#

the joys of v14

sharp geyser
#

That's not a lot tbh

naive relic
#

v14 of what?

#

discord js?

sharp geyser
#

yes

naive relic
#

i haven't tried out v14 yet, how is it? what new changes are there (been sticking with the python discord api wrappers lately so haven't even been doing much js)

lyric mountain
#

Changes = once again, adding a new word to property chain

wheat mesa
#

inb4 djs devs complaining about changing 3 lines of code because of a major version change

winter tapir
#
2022-07-18T04:24:08.245962+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/dblwebhook" host=den-utilities.herokuapp.com request_id=e61d0b4a-93a3-4131-b3e4-880737d00e75 fwd="159.203.105.187" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https

I get this request timeout, I'm not sure what this means.

winter tapir
sharp geyser
#

Took too long to try and form the request

winter tapir
#
app.post(
  '/dblwebhook',
  async (req, res) => webhook.listener((vote) => {
    res.sendStatus(204);

    console.log(vote.user);

    return bot.emit(vote, bot, app);
  })
);

this is all my code for the app.post

wheat mesa
#

Why are you returning an event emit?

#

Not all functions need to return something. Just emit the event and move on

#

Perhaps try using the actual example from the node SDK’s readme: ```js

const express = require('express')
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook('topggauth123') // add your Top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware

app.listen(3000) // your port

winter tapir
wheat mesa
winter tapir
wheat mesa
#

Try it exactly as the example shows

near stratus
#

Did discord.js released 2 versions overnight?

#

I went to sleep seeing 13.9

winter tapir
#

Crawl released v14 today

near stratus
#

now I see 14.0.1

winter tapir
#

With builders and installation

compact pewter
#

how to get the topgg api

#

token

#

to use it in sdk

winter tapir
near stratus
#

no

winter tapir
#

Did they not mean the auth?

near stratus
#

You copy it from bot webhook page

near stratus
winter tapir
#

My mistake

compact pewter
near stratus
compact pewter
near stratus
near stratus
compact pewter
#

it will take 1-2 weeks

near stratus
#

now wait

compact pewter
near stratus
compact pewter
near stratus
#

yea

#

they were short on stuff or something

compact pewter
#

oo

near stratus
stable eagle
pale vessel
#

Bruh...

#

That's actually sad to hear

pine nova
#

damn v14 released

#

imma stick to 13 fr

near stratus
#

That's what I said with v12

pearl trail
#

v14 released?

sharp geyser
#

yye

sharp geyser
#

@round cove ok so prisma is kinda nice ig mmLol

#

I am liking it so far

#

At this point all I gotta think about is design

#

prisma handles everything else for me

#
model Profile {
  id            Int @id @default(autoincrement())
  race          String
  currentWeapon String @default("Rusty Sword")
  user          User @relation(fields: [userId], references: [id])
  userId        String @unique
  balance       Int @default(1000)
  level         Int @default(0)
  xp            Int @default(0)

}

model User {
  id            String @unique @db.VarChar(22)
  iventory      Item[]
  profile       Profile?

  @@index([id])
}

So I have these two prisma models and I am starting to think I don't even need the two of em. I could just combine the data they store into one no? That would make sense to me, but I am horrible at database design so idk if there is any benefit to doing it this way

pearl trail
#

yay this simple thing didn't work!

pine nova
boreal iron
near stratus
sharp geyser
#

that doesn't matter

pearl trail
sharp geyser
#

forcing it to have that type isn't a fix.

boreal iron
#

Sure just wanted to say that as the result is an API error

#

Invalid form body thingy

near stratus
# pearl trail 💀

For buttons const HelpButtonRow: ActionRowBuilder<ButtonBuilder> = new ActionRowBuilder()

near stratus
sharp geyser
#

It shouldn't be an issue in the first place

#

failed typings causes shit like this

near stratus
sharp geyser
#

yes because djs codebase is a shit show

near stratus
#

it was never made for ts

#

They just kept adding patches

pearl trail
sharp geyser
#

They should just start from scratch imo

#

instead of trying to add typings themselves

near stratus
sharp geyser
#

It isn't that hard

#

I could do it myself if I had more knowledge in ts

#

I just am not ready yet

boreal iron
#

Instead of using the builders

#

Also this will prevent you from updating your code over and over again on each djs relrease

near stratus
#

at this rate making my own builder sounds better

pearl trail
#

well for some reason, i use builders but i collect all of them in 1 file lmao from now on

sharp geyser
#

One thing I don't get, all these people complain about djs but do nothing about it

boreal iron
#

It’s easier to complain about things than changing your life dingus

near stratus
sharp geyser
#

you do have a choice

near stratus
#

same with djs

sharp geyser
#

people just choose not to do anything

pearl trail
near stratus
sharp geyser
#

cause its better to complain then do anything like fake said

#

nah just grow some balls and go libless

near stratus
#

I stopped complaining long ago

sharp geyser
#

learn the discord api yourself and make your application 10x more performant in the process

near stratus
boreal iron
#

Imagine nobody would complain anymore. What a sad world if anybody just smilies 24/7

near stratus
#

Discord api is fucking huge

sharp geyser
#

meh

#

I am planning on getting a group together to make a better package.

#

Lets see if that ends up happening

near stratus
sharp geyser
#

pretty sure fake has a job

#

although sometimes i am not certain

#

with the amount of time he is on discord

near stratus
#

plot twist: he works at discord

boreal iron
# sharp geyser learn the discord api yourself and make your application 10x more performant in ...

Let’s be honest for the most projects the lib is totally okay
Using this instead of developing your own entire wrapper is much easier and less time consuming
Also you usually only run into issues like this if you’re getting deeper into using a library issuing internal inconsistencies
The common user copy and pasting his code together who literally has no clue about what he does is okay with this

near stratus
#

Anyways
How do I rotate a text box in css?

boreal iron
#

your account will be suspended soon

near stratus
#

*smirk, I'm in danger

sharp geyser
#

more experienced devs are left with the lack luster performance the other libs provide

#

They get barely any control on how things like caching is done

boreal iron
#

That’s what I said
The deeper you’re getting into this the more issues and inconsistencies you experience
But that won’t even happen for the most users I guess

near stratus
sharp geyser
#

Thats cool and all

#

but djs is a bloat to begin with

near stratus
#

yes

#

They made it easier for new users

#

and anything on the surface

sharp geyser
#

I'd rather use something that has only the bare basics and give more control to the user

#

yes djs is perfect for newer users

boreal iron
#

True but let’s be honest it’s actually nicely documented and regarding its popularity it provides tons of examples and support anywhere

sharp geyser
#

but once you start developing a bot that relies on performance djs just doesn't cut it

sharp geyser
#

indeed tim's lib is amazing as well

near stratus
#

noone uses it tho
Not that anyone knows

sharp geyser
#

I use it from time to time

boreal iron
#

Maybe this will start getting an issue after 10000s of guilds

sharp geyser
#

And it is very hard to make a user friendly performant lib

boreal iron
#

Including sharding etc

near stratus
sharp geyser
#

I prefer starting from scratch

near stratus
#

I don't have metal balls

#
  • I go to med school
sharp geyser
#

I've worked with discords api enough by now that I am used to it

sharp geyser
#

though that balance is hard to achieve

near stratus
#

The only thing I tried raw is oauth2
And normal stuff like webhooks, users, guilds

sharp geyser
#

first thing I ever did with the discord api itself was oauth

#

Now its second nature to me

near stratus
sharp geyser
#

yes

boreal iron
# sharp geyser though that balance is hard to achieve

After of developing community panels managing servers, players and backends of gaming communities which was made to be idiot-save it turns out it wasn’t
When I was thinking I created something easy to use and understandable it turns out people around the world had issues using it
So I got feedback and started to design things differently and had to readjust many things over and over again to make them more user-friendly even if they were already

sharp geyser
#

you can also send stringified json iirc

#

I don't remember tho

boreal iron
#

Just because of a few plebs around the world

near stratus
sharp geyser
#

ah ic

sharp geyser
boreal iron
#

Building something really user-friendly and accessible but also following development principles is damn complicated

sharp geyser
#

I'd love to get people together and make a lib that can be a better alternative when looking for performance

boreal iron
#

It’s always a mix of driving in between all of them

sharp geyser
#

I've found the hardest challenge when programming is finding a team

#

hardly anyone has the motivation to actually do the goal

boreal iron
sharp geyser
#

I dislike doing everything myself

#

it brings me no joy at all

boreal iron
#

Even if that ended up getting projects stretched like close to 2 years

near stratus
sharp geyser
#

pfft

near stratus
#

no seriously

sharp geyser
#

Im not working for some corporate company

#

They don't care about the people who use their products

near stratus
#

noney

sharp geyser
#

all they care about is the money they generate

near stratus
#

You need money to care about users

sharp geyser
#

I'd sooner just quit the career than work for a company like that

boreal iron
sharp geyser
#

Nah

#

I'd sooner just make my own company

#

smh

boreal iron
#

But you will be payed with bread and water

sharp geyser
#

I will pay you back with a foot in the ass

near stratus
sharp geyser
#

nah but seriously

boreal iron
#

Seriously running your own business is hard and much more work than just being an employee

sharp geyser
#

While that is true

#

I don't really care about the hardships

#

Anything to achieve my goals

near stratus
#

Being a employee ensures safe income

sharp geyser
#

Yes but then to me that just brings lack of value to life

near stratus
#

Almost all the time

sharp geyser
#

No hate to people who want a safe life

#

but I feel if you aren't taking risks are you truly living?

#

I don't wanna die with regrets

boreal iron
#

Nothing is save these days, companies tend to throw out people quicker than you think

near stratus
boreal iron
#

Sometimes even companies running in a good state

boreal iron
near stratus
sharp geyser
#

Meh this is just my babbling pay no mind to it

boreal iron
#

Which is good

near stratus
#

I-

boreal iron
#

-|

sharp geyser
#

I feel a lot of people take programming the wrong way

#

A lot don't understand how valuable it can be

near stratus
sharp geyser
#

While that may be true

near stratus
#

Like everyone knows how to code

near stratus
sharp geyser
#

there are also a lot who take advantage of programming and use it for bad

#

rather than what it should really be used for

near stratus
#

that's russia

sharp geyser
#

no

#

you can't just push that to one place

#

A lot of places do it

near stratus
#

most of that comes from there

sharp geyser
#

Asia, Europe, Australia, US

sharp geyser
near stratus
#

Like most scam call centers are in India
Hackers in Russia
Karens in US

sharp geyser
#

US as well

boreal iron
#

Not really most of it comes from the US and Korea

sharp geyser
#

^

boreal iron
#

But we don’t read about that every day

near stratus
sharp geyser
#

how naive

near stratus
#

dunno about north

#

all I see in nukes from there

sharp geyser
#

😔

boreal iron
#

Since Russian propaganda is easier to bring under people then telling them their entire country and world is being spied and controlled by the US

sharp geyser
#

That convo just now Akio made me extremely sad

near stratus
#

It's not me okay

#

I open news and I see that

boreal iron
#

World largest amount of hackers are working for the US intelligence agencies

sharp geyser
#

The news isn't always right

#

in fact a lot of it is bs to begin with

near stratus
sharp geyser
#

The news is just a political tool

boreal iron
#

Public news are only meant to keep people stupid and control their fears

sharp geyser
#

Anyways if anyone wants to team up and form a small dev team dm me

#

I gtg

boreal iron
#

While there’s some interesting well researched article sometimes 99% is just the same propaganda

near stratus
#

I dunno what to think anymore

boreal iron
#

A lot of people understand that over time

#

Later in their life

#

Unfortunately not enough people tho

#

How they’re getting controlled and manipulated 24/7

near stratus
#

Imaa stop watching new at this rate

sharp geyser
#

The news used to not be so bad

boreal iron
#

Like the US people think healthcare is something bad and socialism regarding this will destroy their entire country

#

Just to@mention one example

sharp geyser
#

but it slowly became a political tool for the politicians in the US

boreal iron
#

But yeah… that’s moving into a political discussion

#

At the end there are only two sorts of people, those who understand and those who don’t understand or wanna believe what’s going on

#

Trusting what they see and read everyday

#

Blindly falling to any propaganda

earnest phoenix
#

deprecated weirdsip

pine nova
#

💀

boreal iron
#

FINALLY

#

No more breaking changes

ancient nova
earnest phoenix
#

idk man i am confused

ancient nova
#

"published 2 hours ago" "no longer supported" wot man wot

#

the discord.js devs trippin

pine nova
#

there is no select menu component in discordjs? its showing me in the docs tho

near stratus
#

there is

#

lemme get docs

winged temple
near stratus
#

Your vsc broken

pine nova
earnest phoenix
#

or something like that

pine nova
pine nova
near stratus
#

@pine novahttps://discord.js.org/#/docs/discord.js/main/class/SelectMenuComponent

winged temple
pine nova
winged temple
#

annoying af

pine nova
winged temple
#

that shit haven’t worked for me in ages

near stratus
pine nova
sharp geyser
pine nova
earnest phoenix
#

¯_(ツ)_/¯

near stratus
sharp geyser
#

Sadly djs is not deprecated

#

😔

pine nova
#

bruhga

#

why is not showing for me

#

💀

near stratus
pine nova
#

i am getting only 3

#

copium

winged temple
pine nova
#

just press ctrl+space

winged temple
#

I know how to do it bruh 💀

pine nova
#

💀

winged temple
#

it’s just that it only displays what I’ve previously written

ancient nova
winged temple
#

instead of all available options

sharp geyser
pine nova
winged temple
#

💀

#

bruh

#

straight up bullying us

near stratus
boreal iron
#

Is this once again the right moment to tell you not to use the builders at all?

near stratus
winged temple
#

cant view that on a phone

winged temple
near stratus
#

It's me showing the 1000 component options

winged temple
#

bruh

pine nova
#

tried using import syntax too

#

fr

near stratus
pine nova
#

yea lmao

#

is select menu only in v14 or in v13 too?

winged temple
#

what version of discord.js?

pine nova
#

version of js?

#

o

#

13.8.1

winged temple
#

hmm

#

try reinstalling it

pine nova
#

is it not available in that version?

winged temple
#

idfk honestly

boreal iron
#

Take a look into the docs

pine nova
#

ah yes

#

there is no

#

select menu

#

in v13

#

mf

#

discordjs

winged temple
#

L

winged temple
pearl trail
#

it is MessageSelectMenu v13

pine nova
winged temple
#

the select menu yes

near stratus
pine nova
#

selectmenucomponent

#

no thats not the same

#

💀

winged temple
#

it’s literally just renamed

pine nova
#

bro

near stratus
# pine nova no thats not the same

sorry thishttps://discord.js.org/#/docs/discord.js/13.8.1/class/MessageSelectMenu

pine nova
#

o wait

winged temple
#

what r you even tryna do

pearl trail
winged temple
#

select menus

#

or modals

pine nova
boreal iron
winged temple
#

yes

winged temple
#

I believe

#

he wants that drop down stuff

boreal iron
#

Omg i was on modals

winged temple
#

but inside a model

boreal iron
#

Sry

pine nova
ancient nova
#

I don't think changing the top.gg page helped at all with the problem of no one adding the bot

winged temple
pine nova
#

idk

pearl trail
#

afaik it doesn't

pine nova
#

should be tho

pearl trail
#

it just supports short and paragraph

near stratus
pine nova
pearl trail
#

yep, afaik

pine nova
#

bruh

#

imma

#

quit

winged temple
pine nova
#

:copium:

winged temple
#

why do you even need

#

a select menu

#

inside of a model

pearl trail
pine nova
#

display all channels of guild and select one of them

near stratus
winged temple
#

and then from there

pine nova
#

i wanted to use modals tho

winged temple
#

read the information from that chabbel

pine nova
#

otherwise i would have done that ages ago

#

modals kinda cleaner

#

💀

winged temple
pine nova
#

no i mean

#

i want to use modals

near stratus
winged temple
#

well too bad

pine nova
#

yea

#

ig i will do that

#

now i have nothing to work on again

winged temple
#

ticket system?

#

make that

near stratus
pine nova
#

o no i dont mean just discord bots

pine nova
sharp geyser
#

doing that in js just sounds painful

pine nova
#

will try that ig

#

yea

sharp geyser
#

@woeful pike aren't you making a raytracer?

near stratus
winged temple
#

poor dude

pine nova
near stratus
winged temple
#

fr

sharp geyser
pine nova
#

WHAT

#

RN

winged temple
#

LOOL

near stratus
pine nova
#

YA ALL SAID U CANT USE

sharp geyser
#

It has been a thing for a decent bit

pine nova
#

bruh

winged temple
pine nova
#

i have something to work on now

near stratus
sharp geyser
#

I don't think djs supports it yet

pine nova
#

i figured like why the f wouldnt there be select menus in modals

sharp geyser
#

but you 100% can

pine nova
pearl trail
sharp geyser
#

Yes I am sure

#

I've seen people do it

pine nova
#

u mean inside the modals right?

sharp geyser
#

mhm

pine nova
#

i see i see

woeful pike
boreal iron
#

Those aren’t fully supported yet

winged temple
#

try it 🤷‍♂️

sharp geyser
#

it is still highly experimental

sharp geyser
pearl trail
#

and will be available only to a small percentage of discord users

woeful pike
#

ye

sharp geyser
#

nice nice

ancient nova
#
if (settings.antiSpam === "true" && permlevel(message) === 0 && !message.member.permissions.has("MANAGE_MESSAGES")) {
``` is there any way to optimise this? It's in the messageCreate event
sharp geyser
#

@earnest phoenix what do you think of this code

#

anyway to optimize it

ancient nova
#

I know it's bad that's why I'm asking if there is a better way to do this

earnest phoenix
#

=== "true" I may need to bleach my eyes

sharp geyser
#

Lmfao

ancient nova
#

it's just the way I wrote my settings sytem

sharp geyser
#

one thing you can do is

#

not use strings

#

and use actual bools

ancient nova
#

settings.antispam returns a string

earnest phoenix
#

And why is that?

sharp geyser
#

then make it return a bool dingus

ancient nova
#

becausse that's the way I wrote my settings system

near stratus
ancient nova
sharp geyser
#

just use bools for the love of god

earnest phoenix
sharp geyser
#

why did you even think of using strings

ancient nova
earnest phoenix
#

Then do it, simple

sharp geyser
#

"accident"

near stratus
#

when you add " in sql

ancient nova
near stratus
sharp geyser
ancient nova
#

😐

#

ok that's kinda true

earnest phoenix
#

Trust me, it wouldn't; rewriting documents across the whole database to a different value won't take much time

#

You have to work smarter, not harder

sharp geyser
#

just tell the users fuck you and wipe the db

#

they will understand

#

trust me

ancient nova
#

wait voltrex it'll show you how I made that

near stratus
#

ppl are dumb

sharp geyser
#

Lmao

ancient nova
#
// this is the value that will be settings.someSetting
const joinedValue = value.join(" ");

// Update the setting
settings.set(message.guild.id, joinedValue, key);
earnest phoenix
near stratus
#

I have no idea what that is

ancient nova
#

this is basically what I do, now before you say anything, I would have to delete my entire db because people already saved joinedValue as a string before PLUS rewriting those couple commands, events and handlers

#

would you really bother with that

sharp geyser
#

yes

#

I 100% would

ancient nova
#

key is the setting

quartz kindle
#

sqlite >>>>>> enmap

earnest phoenix
near stratus
#

Pp

earnest phoenix
#

And you don't have to delete the entire database, you just have to edit the documents with the certain values to a different value

near stratus
earnest phoenix
#

Yeah, backing up the database is a good idea

sharp geyser
#

you guys are way too meallow

#

i'd just tell the people to fuck off

near stratus
#

that works too

sharp geyser
#

wipe db start over

ancient nova
near stratus
sharp geyser
#

might as well

#

I am scared to look at his bot's source code

#

you'd probably find regex everywhere

ancient nova
#

I only used regex where it was necessary

near stratus
#

eww regex

sharp geyser
#

doubt

ancient nova
#

also the bot is quite decently responsive actually

earnest phoenix
#

You look at the source and it looks like a parser with regex

ancient nova
#

it uses around 80-90mb of ram and 4% cpu even under load

near stratus
sharp geyser
#

80-90mb of ram?

#

I know you capping now

ancient nova
#

no

sharp geyser
#

djs eats hella

near stratus
ancient nova
#

I'll take a screenshot for u

sharp geyser
#

aint no way he doesn't use djs he was asking for help with djs earlier

near stratus
#

...........

#

Just with guild cache it'd take 200mb

earnest phoenix
#

I think they meant they're not using discord.js if it doesn't consume way too much RAM

ancient nova
#

well it's a little bit higher now, because I added a lot of new stuff yesterday

#

but it's still adequently low

earnest phoenix
#

How many guilds does your bot even operate on?

ancient nova
#

~67 last I checked

#

I'm close to verification

near stratus
sharp geyser
#

do you use djs?

near stratus
#

bruh

ancient nova
#

yeah

sharp geyser
#

ok boutt to say

#

would of made me very confused why you'd ask for help with djs and not use it

near stratus
#

nah djs descent with low servers

quartz kindle
#

descent

#

into darkness

ancient nova
#

what are you trying to say?

sharp geyser
#

djs is bad

wheat mesa
#

Fax

near stratus
sharp geyser
#

someone uses 70gb of ram for 700k servers with djs

ancient nova
#

I'm aware, but I already started so not gonna edit the entire bot into a different language now

wheat mesa
#

Nobody said different language

sharp geyser
#

not cap

#

Reaction Roles bot

wheat mesa
#

Different lib

sharp geyser
#

700k servers 70gb ram

ancient nova
#

no way it uses 70gb ram lmfao

quartz kindle
near stratus
earnest phoenix
#

Rythm used 5TB+ RAM for 16 million servers

#

That is a lot of RAM

quartz kindle
#

good riddance

sharp geyser
earnest phoenix
#

Google Chrome is drooling

boreal iron
#

I’ve got like

near stratus
ancient nova
wheat mesa
#

Cake’s notsobot is in 734k servers and uses ~120gb of ram give or take, but it has a LOT cached

#

It uses detritus

quartz kindle
#

jeez

earnest phoenix
quartz kindle
#

idk why nobody uses lmdb for caching

lyric mountain
#

5TB ram wtf?

wheat mesa
#

Is that overall though? I’m assuming they had load balancing to some extent

ancient nova
#

okay but 5TB????

sharp geyser
#

okay so it was less than 70 but it is getting close

lyric mountain
#

is there even any mb that can handle that much ram?

ancient nova
#

lmfao probably not

quartz kindle
#

its likely not a single machine

boreal iron
#

90M cached members tf

earnest phoenix
#

5TB is nothing for that many servers, I'm sure Rythm doesn't use a single machine

#

Yeah

quartz kindle
#

its probably a clustered database

sharp geyser
ancient nova
#

man that's insane

boreal iron
#

Well if they need to

sharp geyser
#

for a bot of that kind they have to

ancient nova
#

that inspired me to go and rewrite my saving system

boreal iron
#

I mean I’ve got like the default caching options set up too

#

But still

sharp geyser
#

If you want a successful bot use good coding practices

boreal iron
#

Don’t need to optimize them yet

sharp geyser
#

no one is going to use a shit bot excluding mee6

wheat mesa
#

I feel like a lot of bot devs have high mem usage because they’re lazy and don’t optimize their caches

ancient nova
#

from 120MB how low do you guys think it'll go after removing all the string comparision checks?

wheat mesa
#

Literally nothing will change lol

ancient nova
#

then what's the point?

#

😐

sharp geyser
#

cause it is dumb to store bools as strings

wheat mesa
#

RAM is not the only thing you have to worry about

sharp geyser
#

^

wheat mesa
#

Comparing strings instead of bools is a LOT slower

#

It has to compare character by character

quartz kindle
#

a lot of bot devs were never expecting their success so now they race against time trying to figure out how to improve it

ancient nova
#

if it's only dumb and doesn't cause that much of a performance difference what's the point

wheat mesa
#

Whereas bools only need to compare 1 bit

ancient nova
#

yeah fine

sharp geyser
#

cause like waffle said

#

it is faster

ancient nova
#

I'll rewrite it we'll see how much faster it is

sharp geyser
#

speed is another factor to take into account

wheat mesa
#

Which is extremely fast and probably optimized into bitwise operations which are incredibly fast

quartz kindle
#

ferpormance

wheat mesa
#

You probably won’t notice a difference, but it’s still a good practice to not sacrifice speed where you don’t need to

sharp geyser
#

it def won't be noticeable for how little severs your bot is in

wheat mesa
#

Gm

pine nova
#

hey can someone help me with this? i am getting this error in modals

DiscordAPIError: Invalid Form Body
data.components[0]: Value of field "type" must be one of (1,).
    at RequestHandler.execute (C:\Users\hp\Documents\GitHub\Utility-Bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\hp\Documents\GitHub\Utility-Bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async CommandInteraction.showModal (C:\Users\hp\Documents\GitHub\Utility-Bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:240:5)
    at async Object.execute (C:\Users\hp\Documents\GitHub\Utility-Bot\commands\announce.js:27:9)
    at async Client.<anonymous> (C:\Users\hp\Documents\GitHub\Utility-Bot\index.js:58:9) {
  method: 'post',
  path: '/interactions/:someid/asasasasa/callback',
  code: 50035,
  httpStatus: 400,
  requestData: { json: { type: 9, data: [Object] }, files: [] }
}

this is my code

const announcementModal = new Modal()
            .setCustomId('announcement-modal')
            .setTitle("Make an Announcement")
            .addComponents([
                new MessageSelectMenu()
                    .setCustomId('announcement-channel')
                    .addOptions(
                        {
                            label: "Channel1",
                            value: "Channel1",
                        }
                    )
            ])

        await interaction.showModal(announcementModal)
sharp geyser
#

did you see my mention in detritus?

#

idk if that is what you were looking for

wheat mesa
pine nova
sharp geyser
#

it is still experimental

pine nova
#

i see

#

so i can only use

#

text menu

boreal iron
#

My gosh it’s not officially released or finished yet

pine nova
#

component

ancient nova
#

you guys are getting me to want to rewrite it and then not want to rewrite it at the same time

ancient nova
wheat mesa
#

I got it to work with detritus but I was unable to get the response from the user

near stratus
wheat mesa