#development

1 messages · Page 136 of 1

frosty gale
#

but for some reason it's buggy

#

so I just use the starlink wifi

slender wagon
#

perhaps a skill issue

#

starlink?

#

that's amazing

frosty gale
#

yeah lmfao

#

we have starlink

slender wagon
#

where do you live

frosty gale
#

it's supposed to be a backup

slender wagon
#

like the exact cordinates

frosty gale
#

florida

slender wagon
#

no i need the full coordinates

frosty gale
#

😳

slender wagon
#

how much do you pay for starlink?

frosty gale
#

I wouldn't know its not mine:)

#

probably expensive though

#

it's a backup if the main network goes down

slender wagon
#

isn't it like $100+ a month

#

can you run my script and see how it does?

#

with a large apng

quartz kindle
#

set a maximum resolution limit, for example 1080p or 2k whatever
if the given image is bigger than that, either refuse it, or resize it first using a command line program

slender wagon
#

right

frosty gale
slender wagon
#

i updated it and got rid of telegram

#

wait that's not large at all

frosty gale
#

oh lord this will involve me installing canvas and setting up module support

#

fine only bc im so nice

slender wagon
#

npm i canvas upng-js fs

#

ez pz

#

and yes you kind of have to do module support

#

🤓

frosty gale
#

My wsl node thinks I am running Windows

slender wagon
#

have you got a large gif at around 10 - 15 mb

#

if yes send it over so i can convert it to apng

quartz kindle
#

lmao

slender wagon
#

to put it in the directory

#

when finito

#
fs.writeFileSync("watermarked.apng", Buffer.from(apngBuffer));
quartz kindle
#

i mean

#

why install it

#

its built in

slender wagon
#

oh is it

quartz kindle
#

ye lol

slender wagon
#

that's why it wasn't throwing an error at me when i declared it

#

Total execution time: 44.562s

#

and the cat image

frosty gale
#

i literally cant install canvas lmao

#

my nodejs thinks I am running windows

#

when I am infact on linux

slender wagon
#

weird

frosty gale
slender wagon
#

@quartz kindle wanna give it a go?

#

is it cuz of the changes you have done to your pc?

quartz kindle
#

is that actual linux or WSL?

frosty gale
#

that's wsl ubuntu

#

don't know why it's even doing that

quartz kindle
quartz kindle
slender wagon
#

woops

#

add these:
console.time("Total execution time");
in the beggining of the function
and in the end:
console.timeEnd("Total execution time");

slender wagon
#

that's a wooping 10 seconds faster

quartz kindle
#

is there an actual animation in those links?

#

i just see stills

#

give me a link that actually produces an animation

#

and im pretty sure performance can be improved

#

but i need to see a working animation to make sure i dont break it

slender wagon
#

the .png one

#

man i can't find anythin good on google for shit

#

like a large gif

quartz kindle
#

ah nvm

#

the animation only works on chrome lol

#

also, all the frame files are broken

#

because its raw bytes, not actual png images

slender wagon
#

yeah that messed up after i updated the code with the canvas.buffer

#

never bothered to change it

quartz kindle
#

and i dont see the watermark

#

like

slender wagon
#

instead of png/image i use this

quartz kindle
#

the original apng was cut into the size of the watermark, and its color changed

slender wagon
quartz kindle
#

but thats all

slender wagon
#

but testing it around now

#

with large apngs

quartz kindle
#

dumbo

slender wagon
#

yo

#

what did u do

quartz kindle
#

you have a major performance flaw

#

lmao

slender wagon
#

fr fr

slender wagon
quartz kindle
slender wagon
#

what is wrong with that

quartz kindle
#
for(...) {
  convert entire file to rgba8
  get 1 frame
}
slender wagon
#

are u sure u got the same results when u did that?

pale vessel
#

maybe convert the frames on the outside first lol

quartz kindle
#

i opened the image on the browser, looks the same again

#

but as i said, i dont know if what im looking at is the right thing

slender wagon
#

send it here

quartz kindle
slender wagon
#

nope

#

here is how it should be

#

for some reason yours doesn't have animation

quartz kindle
#

mine has and yours doesnt

#

for some reason discord links wont play the animation

slender wagon
#

download it first

#

then put it over on edge

#

or chrome

quartz kindle
#

but mine plays

torpid crystal
#

in the webhook url it should be http://ip:port/dblwebhook right, and in the authentication the webhook token?

quartz kindle
#

are you using a library like top.gg sdk?

slender wagon
#
// Creates an array to hold the frames
const frames = [];

// Set the delay for each frame (in milliseconds)
const frameDelay = apng.frames[0].delay;
// Decode the APNG image data
const apngRGBAData = UPNG.toRGBA8(apng);

// Convert frames to canvas images
const frameCanvases = [];
for (let i = 0; i < apng.frames.length; i++) {
  const frameCanvas = createCanvas(apng.width, apng.height);
  const frameCtx = frameCanvas.getContext("2d");

  // Put the RGBA pixel data onto the frame canvas
  const imageData = frameCtx.createImageData(apng.width, apng.height);
  imageData.data.set(
    new Uint8ClampedArray(new Uint8Array(apngRGBAData[i]).buffer)
  );
  frameCtx.putImageData(imageData, 0, 0);

  frameCanvases.push(frameCanvas);
}

for (let i = 0; i < apng.frames.length; i++) {
  console.log(`Processed frame ${i + 1}/${apng.frames.length}`);

  const frameCanvas = frameCanvases[i];

  // Clear the canvas
  ctxCanvas.clearRect(0, 0, canvas.width, canvas.height);

  // Redraw the user's image onto the canvas
  ctxCanvas.drawImage(userImage, 0, 0);

  // Draws the frame onto the main canvas
  ctxCanvas.drawImage(frameCanvas, watermarkX, watermarkY);

  // Save the canvas as an image
  const buffer = canvas.toBuffer("raw");

  frames.push(buffer.buffer);

  fs.writeFileSync(`watermarked${i}.png`, buffer);
  // Get the RGBA pixel data from the main canvas
  const mainImageData = ctxCanvas.getImageData(
    0,
    0,
    canvas.width,
    canvas.height
  );
    console.log(mainImageData.data.constructor);
        const mainRgbaFrame = new Uint8Array(mainImageData.data)

    // Adds the frame to the array of frames
    // frames.push(mainRgbaFrame);

    console.log(`Processed frame ${i + 1}/${apng.frames.length}`);
  }
#

@quartz kindle

torpid crystal
quartz kindle
torpid crystal
#

whats that thing thought, is it the end part of an discord webhook or smt?

quartz kindle
#

you literally invent something like 123

torpid crystal
#

oh ic ic

quartz kindle
#

whatever you decide to put in your code, is what you have to put in those settings

#

doesnt matter what it is, can be anything

pale vessel
#

imagine if interactions were like this

slender wagon
#

return new Canvas(width, height, type)
^
Error: out of memory
ah fuck

slender wagon
#

thank you for finding the flaw lmfao

torpid crystal
#

strange it used to work in the old host, but doesnt in the new one. does the format of ip changes any stuff? like my previous host had XXX.XX.XX.XXX and the new one has YY.YYY.YYY.YY else i dont see any reason why it wont work :/

quartz kindle
#

as long as its still ipv4 it should be the same

#

ipv4 = 0-255.0-255.0-255.0-255

pale vessel
#

I was about to send 999.999.999.999

quartz kindle
#

nice ip

#

mind if i hack it

#

:^)

pale vessel
#

yes, please xD

torpid crystal
quartz kindle
torpid crystal
quartz kindle
#

discord bot container?

torpid crystal
#

yep

quartz kindle
#

check your control panel/dashboard

#

see if there is any specific port you are allowed to use

#

should be in the same page as your ip address

north cairn
#
const sentMessage =  message.channel.send({embeds: [tossembed], components: [row, ]
});```
cannot read properties of undefined "channel"
#
 toss(message , interaction) {```
quartz kindle
#

how did you define message

#

how did you call the toss function

north cairn
#

const run = new Game("computer")
run.toss()

quartz kindle
#

you defined the toss function as toss(message , interaction) {} and tried to run it as toss() ?

north cairn
#

bruh

quartz kindle
#

you need to give the function the parameters you are expecting

north cairn
#

Game is a class

#

toss is a method

#

message,interaction are parametres

quartz kindle
#

still, methods also require parameters

#

you cant call a method without any parameter, if you defined the method as requiring parameters

#

if you want to call the method without parameters, you need to get that information from somewhere else

north cairn
#
run.toss(interaction,message)```
#

fine?

solemn latch
#

run.toss(message,interaction)

quartz kindle
#

no, the order has to be the same

north cairn
#

bru

#

great now it says interaction isn't defined

#

oh wait ig ik why this issue came

#

alright its working

#

thanks

quartz kindle
#

👍

rustic nova
#

Tim

#

You're swag

quartz kindle
tulip ledge
#

Anyone knows how to fix this? Type 'string' is not assignable to type 'APIPartialEmoji'.

#

just putting in a string with the emoji works

#

but when I try to get it from a json object it gives me this error

#

(typescript error btw)

lyric mountain
tulip ledge
#
  "consumables": {
    "health potion": ":healthpotion:",
    "slime bottle": ":bottleoslime:"
  },
#

that's the object

#

it has emoji like: <:emoji:id>

#

but discord does weird stuff and shows it like that

#
      options.push({
        label: `${toTitleCase(key)}`,
        value: key.toLowerCase(),
        description: `You have ${value} remaining.`,
        emoji: emojis.consumables[key] ? emojis.consumables[key] : undefined,
        default: false
      })

Thats the code

#

and it errors on that emoji property

#

and the weird part is if I make the json object just one key it doesn't give me the error but once I add a second key it does give me the error

quartz kindle
#

somewhere, somehow, something is expecting an emoji object

#

and you're trying to give it an emoji string

tulip ledge
#

yeah but if I just give it an emoji string it also worked tho

#

how do I convert the string into an emoji object?

quartz kindle
#

ApiPartialEmoji contains 3 props

tulip ledge
#

alr it works now

proven lantern
hushed robin
#

i don't think they've released that to the public yet

proven lantern
#

then check again once you finish

hushed robin
#

well, check the discord developers server

#

they would definitely have announced it there

proven lantern
#

your job is now to keep checking for me

hushed robin
#

and from i can see they haven't

#

🫠

proven lantern
#

pls ping me once it's out

hushed robin
#

i will

proven lantern
#

ty

frosty gale
#

if they cant even tell what the os is despite the binary files literally being compiled for that os 💀

quartz kindle
#

lmao

frosty gale
#

they probably bootstrap it

#

actually yeah npm does that

#

runs off nodejs

hushed robin
#

is it possible in discord.js to make collectors end once it’s been inactive for a certain amount of time

spark flint
#

y

#

yes

#
const collector = interaction.channel.createMessageComponentCollector({ filter: i => i.message.id === msg.id, time: 60000 });```
#

example

#

thats 60 seconds

#

and it does this

hushed robin
#

this will make it last 60 seconds

#

then end

#

I want inactive for 60 seconds makes it end

quartz kindle
#

make your own timer, on every event reset your timer

#

once your timer runs out, call collector.end()

#

you can also access the collector's internal timer

#

and keep reseting it

#

also, just looked at the code

#

collectors already have exactly what you want

#

the idle option

#
const collector = interaction.channel.createMessageComponentCollector({ filter: i => i.message.id === msg.id, idle: 60000 });
hushed robin
#

sorry I didn’t know

#

😁

#

how do u see that in the docs btw

quartz kindle
hushed robin
#

wow ok

#

w discord

hushed robin
#

how would I get an interactions type in discord.js?

hushed robin
#

that will give me like

#

MessageComponent

#

I need like specific one

#

button

#

select menu

#

etc

hushed robin
#

is there really nothing that just returns it for me

pale vessel
#

check how the code does it

hushed robin
#

isButton() {
return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.Button;
}

pale vessel
#

there's interaction.componentType

hushed robin
#

yay

pale vessel
#

use that then yay

#

!

hushed robin
#

how can i use \ on an emoji to get it's full format without nitro

rustic nova
#

By doing that on the server the emoji is on

hushed robin
#

discord turns it into :emojiname:

#

because i don't have nitro

#

wait i understand, i need to do it on the server?

rustic nova
#

On the server the emoji is on

#

Then it won't do that

pale vessel
#

toggle the emoji picker, open developer tools, and get the emoji url

radiant kraken
hushed robin
#

with \ it will do the formatting for me

pale vessel
#

that's very unfortunate

slender wagon
#

how the fuck do i rezise a 3840 x 3840 gif without losing its content

quartz kindle
slender wagon
rustic nova
#

Ffmpeg

slender wagon
#

ok ty

radiant kraken
#

ffmpeg my beloved

peak drum
#

XD true

lament rock
#

so true. so real

frosty gale
#

you might get better performance with apngs

slender wagon
#

I converted them to apngs myself

tulip ledge
radiant kraken
#

the video is trimmed down btw

#

it actually takes way more than 4 minutes to list the entire help command onesieKEKW

lyric mountain
#

@slender wagon by "losing content", what do u mean?

#

losing the frames?

slender wagon
#

No

#

So it has 10 watermarks

#

If i resize it i could only fit 2

#

More like cutting

#

Idk

#

Thats what an app did when i searched for one

#

I haven't tested ffmpeg just yet tho

lyric mountain
#

by resizing such a big gif you'll end with an unrecognizable blob

slender wagon
#

Got home and took a nice 💤

lyric mountain
#

as gif doesn't support smooth transitions between colors (nor antialias)

slender wagon
lyric mountain
#

lmao

#

tell him to send u a webp then

#

it can also be animated

slender wagon
#

I'll have to make that an apng too i guess

#

Aint no way i am rewritting the code

lyric mountain
#

webp -> apng is somewhat easier as they use the same color format

slender wagon
#

Ah great

#

Crossing my fingers rn and hoping that mf fixdd his shit

lyric mountain
#

people really need to let gif die

slender wagon
#

Cons of using cracked software to work with

hushed robin
slender wagon
#

What is it battle

#

Also what i should call u cuz battle sounds cring

hushed robin
lyric mountain
#

e0c

hushed robin
#

this is just my 3 letter username

#

my real name is battleless

lyric mountain
#

well u chose that username

hushed robin
#

it's battleless

lyric mountain
#

ok e0c

hushed robin
lyric mountain
quartz kindle
#

guys i have an ipv6 block on my linux server, how to i set it up as an ip pool for outgoing requests?

#

something about ip freebind or something

sharp geyser
hushed robin
sick agate
#

my handle is my nick lol

#

i tried to get taki

sharp geyser
#

gl with that one

sick agate
#

yeah

#

i aint getting that

hushed robin
#

BUSINESS IS BUSINESS

sick agate
#

ok

proven lantern
hushed robin
#

you need to wait sir

proven lantern
lyric mountain
deft wolf
hushed robin
lyric mountain
#

look at the color hash

hushed robin
#

ok

lyric mountain
#

just noticed ur nick is a valid hex value

hushed robin
#

w nickname

#

i am pick

lyric mountain
#

magenta

proven lantern
#

orange

#

light purple

#

tim, i remade the command using that new format. i need a code review

hushed robin
#

pinj

lyric mountain
#

that color is called magenta

#

pink is the tone in the circle u sent

hushed robin
lyric mountain
#

how what?

hushed robin
lyric mountain
#

colors can have many named tones

#

that full saturation pink is called magenta, it's also one of the primary colors in CMYK colorspace

proven lantern
# hushed robin i am magenta

people usually use the abbreviation, maga instead of saying the whole thing. make sure to tell everyone your hex color when you meet them

proven lantern
#

i am being helpful

hushed robin
proven lantern
hushed robin
proven lantern
#

never ask a man his age

#

why isn't this valid PartiQL?
DELETE FROM *

#

just delete everything pls

#

do i really need to write a delete statement for each table?

quartz kindle
#

there should be a query to iterate over all tables

#

most sql dbs have that

proven lantern
#

i see an inner join hack

neon leaf
#

is it noticable in any way if I cache db results for just row counts (with where clause)? or not because the database has a 0.01ms ping?

proven lantern
sharp geyser
#

if so you can cascade delete tables\

proven lantern
#

just to help people make the move to nosql

hushed robin
#

why need to delete them

proven lantern
hushed robin
#

so just delete elo table

#

🤨

lyric mountain
#

truncate the tables instead

#

it's faster than a delete

proven lantern
#

and if i recreate the tables i need to update the table names in my environment vars

#

i dont have a hardcoded name for the table. only refs

lyric mountain
#

TRUNCATE TABLE tablename;

#

use a loop + concat for iterating all tables

proven lantern
#

does partiql support this?

lyric mountain
#

idk, that's default sql stuff

proven lantern
#

checking

#

partiql is a subset

main forum
#

hi

hushed robin
proven lantern
hushed robin
#

development is the best channel

#

glad you decided to join it

main forum
#

😘💐

hushed robin
#

yay

#

do you need development help?

proven lantern
hushed robin
#

what language do you program in though?

proven lantern
#

i use js and rust for my bot

hushed robin
proven lantern
proven lantern
hushed robin
#

why

#

can’t you do it with js

proven lantern
hushed robin
#

wow

proven lantern
#

discord closes connections after 3 seconds

hushed robin
#

wym a cold start

proven lantern
hushed robin
#

oh ok

#

rust is faster than js so that makes sense

quartz kindle
#

for cold starts, startup time is much more important than running performance

#

thats one area where node.js is not very good at

hushed robin
#

why not improve

quartz kindle
#

its not their focus

#

nodejs and v8 focus on runtime performance

hushed robin
#

hm

quartz kindle
#

so all of their effort goes into developing strategies to analize and optimize the code in real time during running

hushed robin
#

node js should make it so I can generate number between two numbers

#

that would be useful

quartz kindle
#

thats like super easy to do

#

with basic math

#

lol

proven lantern
#

ask chatgpt

#

ezpz

hushed robin
#

but would easier if they did math for me

proven lantern
#

let me see if co pilot will write that for me

hushed robin
#

copilot is so annoying sometimes

#

actually most the time it is I might just remove it

proven lantern
hushed robin
#

tbh discord.js should be built into node.js

#

I bet like 70% of node.js programs are discord.js

queen needle
#

Not even close

proven lantern
hushed robin
quartz kindle
#

there goes battleless and his absurdities

proven lantern
hushed robin
#

no library ?

proven lantern
hushed robin
#

that must be hard

proven lantern
hushed robin
#
pale vessel
#

bLoAT /s

#

he doesn't need to

hushed robin
#

also why do you need to require node-fetch

#

can’t you just use the built in fetch?

proven lantern
#

i am using nodejs 16

hushed robin
#

16 doesn’t have?

proven lantern
#

you can have it with --experimental-fetch

#

i'm using the version that aws supplies me

hushed robin
#

I see

#

makes sense

lyric mountain
#

Djs is a tiny minority

slender wagon
#

Flaze suggested me webhooks

hushed robin
slender wagon
#

For my next discord bot

#

Right @pale vessel

hushed robin
#

I wanna but

#

I don’t wanna do all that shit to my internet to make it work

slender wagon
#

Did u finish your own discord.js

#

We waitin

hushed robin
#

yea

#

I finished the day before yesterday

pale vessel
tulip ledge
#

is it possible to create discord events using a bot? like the events in a discord guild?

proven lantern
tulip ledge
# slender wagon Flaze suggested me webhooks

I made this thing I like to call a webhooker for my RPG discord bot game and it makes it look like actual NPCs are talking and if it gets ratelimited or stuff it can just fall back to the bot it's really cool and I highly recommend it

slender wagon
#

So you overengineer'd it basically

#

Unlike the submarine

proven lantern
#

oh wait

#

you mean these events?

tulip ledge
#

yeah these

earnest phoenix
proven lantern
#

i dont want to custom install it

#

i just wait for aws to release images

#

because im lazy

earnest phoenix
#

AWS Linux 2 natively has it, unless that's not what you're using

tulip ledge
# proven lantern you mean these events?

my bot has weekly events that u can get other mobs and stuff and I'd like to add it to the support guild as events but idk if it's possible can't find it in docs, might be impossible since I'm using v13 still

proven lantern
#

why am i using x86

#

shouldn't i use arm?

earnest phoenix
proven lantern
#

a year later after rust is done installing

#

success!

#

so now i can remove node-fetch

earnest phoenix
#

Yes

proven lantern
#

and use axios again right??

earnest phoenix
proven lantern
earnest phoenix
#

AWS costs doesn't vary on architecture, all costs the same

hushed robin
proven lantern
#

i need 1MB of libs to do api calls

lament rock
#

use global.fetch on nodejs 17+

proven lantern
#

i can also remove all my aws library dependencies. nodejs18 comes with them preinstalled

earnest phoenix
#

Huh, I don't remember the prices varying for different architectures the last time I used it (which was fairly a long time ago)

proven lantern
#

their pricing is so confusing

#

i dont think in billions

wheat mesa
#

Amazon does 🧌

hushed robin
#

🧌

wheat mesa
#

I was doing that since before you were here lmao

hushed robin
#

your first troll was in late 2022

#

I was here in 2021

proven lantern
hushed robin
#

i don’t have any alt accounts here

#

i only use my alt account for testing stuff

proven lantern
#

it's okay, i need you here so you can keep checking for the alpha release

hushed robin
#

no

#

im not your servant

proven lantern
#

you already agreed

hushed robin
#

ok

#

there was no contract

#

i can leave

proven lantern
#

verbal contract on discord is binding

#

internation law

hushed robin
#

no it’s not

proven lantern
#

Interpol takes this very serously

hushed robin
#

I will block you

proven lantern
#

not me? 😦

hushed robin
#

BUSINESS IS BUSINESS

wheat mesa
#

it’s fine he’s gonna sue you for defamation later ben

#

since that’s his panic button

hushed robin
spark flint
hushed robin
#

what

#

simple french

quartz kindle
#

simple francais

sullen crater
#

timple francais

proven lantern
#

if you're recording matches for different leaderboards would it make sense to track an Elo rating that takes into account matches played on both leaderboards?

solemn latch
#

Cassie!

spark flint
#

i love how my entire point got washed away

#

i was referencing the 2021 part, not the simple french part 😭

proven lantern
#

i have 1/3

#

oh

hushed robin
hushed robin
#

what’s the best way to prompt someone with multiple questions using a message collector

#

I’m wondering how to do it efficiently and uncluttered

hushed robin
#

why am I getting Unknown Channel error sometimes?

wooden stream
#

Ig channel is deleted before that code runs?

hushed robin
#

?

wheat mesa
#

you have a setTimeout, the channel may potentially be deleted before you try to delete it

hushed robin
#

and it only occurs sometimes

hushed robin
#

the channel still deletes

#

but for reason produces that error

wheat mesa
#

you might be collecting multiple times?

#

it's difficult to tell without more context

hushed robin
#

what more context?

wheat mesa
#

like what you're doing to produce that error

hushed robin
#

i'm running that code

#

and it produces error

wheat mesa
#

ok I'm just not gonna bother then

#

bye bye

hushed robin
#

should i send all the code?

#

like i just did it 5 times and it didn't produce that error

#

but sometimes it does

#

🧌

sharp geyser
#

Send all the code for that collector

hushed robin
# sharp geyser Send all the code for that collector
collector.on('collect', async i => {
    if (i.customId === 'confirm') {
        await interaction.editReply({
            content: `Ticket will be closed in 5 seconds!`,
            components: []
        });

        setTimeout(async () => {
            await interaction.channel.delete();
            deleteTicket.run(ticket.id);
        }, 5000);
    } else if (i.customId === 'cancel') {
        await interaction.editReply({
            content: `Ticket closure has been cancelled!`,
            components: []
        });
    }
});
wooden stream
#

maybe you click it twice?

hushed robin
#

but the components are removed in the editReply

#

so that wouldn't be possible

wooden stream
#

do you wait a lot before clicking confirm?

hushed robin
#

but what relation would that have to the issue

wooden stream
#

well, you use variables from outside the callback in the callback function

wooden stream
#

well the main function could have already ended, then someone runs another interaction, cache for that variable might change, and you don't use the same variable data anymore in the callback.

#

I believe that's how it can work, but not completly sure

#

does your bot have many servers?

hushed robin
#

but the bot is only being used by me

wooden stream
#

Ah then nvm ig

lyric mountain
#

also put console.log("here") right before u delete the channel

#

let it run for a while, see if it appears twice before the error

unkempt ocean
#

I'm trying to understand singleton patterns and I read something about it that says I need to write a singleton pattern for database connection, so each shard use that pattern. The thing i don't understand is isn't this the same way if I just make the connection in main index file. Is this somehow prevents creating unique connection for each shard and uses only one connection for all shards

Can someone explain please?

lyric mountain
#

singleton is supposed to act as a model for database entities no?

#

like in orm libraries

#

afaik, regardless of how many shard you have it all depends on where u put the db connection

unkempt ocean
#

No not like a model, let's say i use mongodb: every connection has the same options. And I'm little worried about having a lot of connections, like different unique connection for each shard

#

So what would happen if I just make the connection in singleton pattern and use that connection in index file to define database for each shard

lyric mountain
#

to be fair, having a single connection isn't desired in most cases, but still it all depends on where u put the connection

#

if u put in a shared, global class it'll only create a single connection and pass it around

#

which I believe is what u mean with singleton

unkempt ocean
#

yes that's what it supposed to do i assume

lyric mountain
#

like my manager class

#

it's static so it'll only be created a single manager which is accessed from everywhere

#

I do use multiple connections (at most 15)

#

but it's a single entrypoint to the database

unkempt ocean
#

hmm cat_think

lyric mountain
#

multiple connections are desired if u have a lot of transactions

#

u can setup a pool to limit the ceiling for concurrent connections

unkempt ocean
#

Thank you, I think i can go for single connection at the moment and change it to multiple connection along the way

lyric mountain
#

yw

waxen tendon
#

@tired leaf

#

what else you can make with discord api ?

#

except bots

quartz kindle
#

you can use people's discord account to authenticate/login/register on your website

#

you can create an advanced server join flow that requires some precondition/registration before the user is able to join your discord server

#

you can make newsletters and updates using webhooks without a bot

waxen tendon
#

that's all ?

#

or there is more to it ?

quartz kindle
#

you can have slash commands without a bot too

waxen tendon
#

Yeah I heard of that before and about ( self bots)

quartz kindle
#

you can do all kinds of server automation

waxen tendon
#

okay thanks for letting me know Tim

hushed robin
lyric mountain
#

unless I'm understanding your system wrong, once you press "confirm" there's absolutely no way to abort the setTimeout

#

because you created an unnamed timeout

hushed robin
#

then it sends new message to either confirm it or cancel it

lyric mountain
#

why do u even have a timeout then?

hushed robin
#

why not

lyric mountain
#

because you add the possibility of async issues like u have

hushed robin
#

how

lyric mountain
#

"stale state"

#

where the to-be-ran task doesn't know the data it has is no longer valid

#

if the channel is going to be deleted without possibility of being cancelled, simply do it right away

peak drum
hushed robin
#

no

#

this way is cooler

lyric mountain
#

then contend with the unknown channel issue

#

you want aesthetics over functionality, so be it

peak drum
#

or check if the channel still exsist

hushed robin
lyric mountain
#

remove it then to see

peak drum
hushed robin
#

no

lyric mountain
#

then shut

hushed robin
#

how could it possibly be related

lyric mountain
#

if it isn't related, remove it to see

hushed robin
lyric mountain
#

t h e n s h u t

hushed robin
#

😐

civic scroll
#

you can just delete the chanel after sending the extra message instead

lyric mountain
#

that's what I told him

hushed robin
#

but having wait 5 seconds is cooler

civic scroll
sullen crater
rustic nova
#

@mental badge no ads

mental badge
#

No wam

frosty gale
#

anyone happen to know a faster way of getting the remainder of division?

#

i need it to be very fast and the number to divide by is always the same

#

dont know if modulus (%) in c is good enough

earnest phoenix
rustic nova
#

Is getting the reminder even resource-intensive?

earnest phoenix
#

Nope

rustic nova
#

Or generally any arithmetic operation

#

Fair enough

earnest phoenix
#

Besides, depending on the compiler you're using there can be an optimization CLI flag called -ffast-math that makes the arithmetic operations a lot faster but it's not standardized so be careful when using it

frosty gale
#

i like my math to be ⏩

earnest phoenix
#

But you shouldn't need that anyway, just use the highest optimization level (which is generally -O3)

quartz kindle
#

doesnt O3 include ffast-math?

earnest phoenix
#

Nope

quartz kindle
#

ah no, Ofast does

frosty gale
#

what does fast math even trade off

#

does it mess up floating precision?

earnest phoenix
frosty gale
#

isnt o3 the same as ofast?

earnest phoenix
#

No

quartz kindle
#

Ofast is O3 plus extras afaik

frosty gale
#

they both trade off performance for size

#

other way round actually

earnest phoenix
#

That's not the case at all, -O3 does not care about size, it only cares about optimizing the program as much as it possibly can

#

-Ofast doesn't care either, but includes optimizations that can be faster but poses dangers to correctness

#

-Os and -Oz are the ones dedicated for size compression

lyric mountain
hushed robin
civic scroll
#

"awaiting" is not a certain thing

#

how long exactly do you know the operation is gonna take

#

factoring in cpu time, runtime interruptions, internet speed, endpoint server processing and respond

#

it's something you can't control

#

so at least make it less faulty

#

it's not cool when your bot just dies from a unhandled rejection or have a memory leak due to unresolved timeout

hushed robin
#

what

#

?

civic scroll
#

read it again

hushed robin
#

no

#

you make no sense

civic scroll
#

you are never sure that the message is gonna send before channel deletion occurs

hushed robin
#

it's not even sending a message

#

it's editing one

#

and i can see it edited

#

😐

civic scroll
#

my bad, the channel that contains the interaction that you are editing

hushed robin
#

?

#

the error is coming from the interaction.channel.delete() not the editReply

#

i saw it in the stacktrace

civic scroll
#

it will come from the editReply

hushed robin
#

no it's not

civic scroll
#

Unknown Interaction to be exact

hushed robin
#

what..?

civic scroll
hushed robin
#

no

civic scroll
#

you will see what i mean

hushed robin
#

the editReply ain't the issue

civic scroll
#

that is an issue

hushed robin
#

no it's not

civic scroll
#

you are not nullifying the interaction response after the ticket is cancelled

#

aka. blocking users from interacting with the interaction embed

hushed robin
#

???

civic scroll
hushed robin
#

idk what your yapping on about

civic scroll
#

consider this scenario

#

you click on confirm

#

and after that you immediately click on cancel

hushed robin
#

that's not possible

civic scroll
#

idk, the user gets curious for some reasons

civic scroll
#

so the collector is gonna keep collecting

hushed robin
#

once you click a component, Discord will not allow you to click another till the component has been replied to.
and as you can see, when I respond to it, I remove all the components.

#

so that's literally not possible

civic scroll
#

you don't, the setTimeout is independent

hushed robin
#

???

civic scroll
#

the timer has been invoked already

hushed robin
#

that's not possible, as I said

#

I remove the components

#

with the reply

#

look at my code

#
collector.on('collect', async i => {
    if (i.customId === 'confirm') {
        await interaction.editReply({
            content: `Ticket will be closed in 5 seconds!`,
// COMPONENTS ARE REMOVED RIGHT HERE
            components: []
        });

        setTimeout(async () => {
            await interaction.channel.delete();
            deleteTicket.run(ticket.id);
        }, 5000);
    } else if (i.customId === 'cancel') {
        await interaction.editReply({
            content: `Ticket closure has been cancelled!`,
// COMPONENTS ARE REMOVED RIGHT HERE
            components: []
        });
    }
});
civic scroll
#

what if the interaction happens twice before the await call gets called

hushed robin
#

what?

civic scroll
#

the user clicks on both buttons

hushed robin
#

have you ignored everything i said

lament rock
#

multiple users can click the button at the same time depending on the filter

If you want the collect event to only fire once, use once instead of on

civic scroll
#

^

lament rock
#

I'd still only use once

civic scroll
#

async function doesn't get called until the end of event loop

hushed robin
#

that's physically impossible, so why would i consider it?

civic scroll
#

it's physically possible

hushed robin
#

no it's not

civic scroll
#

you can click two buttons in a very short time on mobile

hushed robin
#

nope

#

and regardless that's not the issue

civic scroll
#

plus like papi said, if you want to use it once, use .once

hushed robin
#

so idk what your yapping on about it

civic scroll
#

...

#

i'm out

hushed robin
#

thanks

civic scroll
#

thanks for wasting my last braincell on your "because it's cool" idea

hushed robin
#

what is happening here

rustic nova
#

Trying to use ActionRowBuilder, but is not a constructor

hushed robin
#

i'm not using it

earnest phoenix
#

(The parts under the error line you showed)

hushed robin
#

coming from this

await questionMessage.edit({
    embeds: [{
        description: 'To move on further, you are agreeing to abide by our terms of service.',
        color: Colors.Misc
    }],
    components: [{
        type: 1,
        components: [
            {
                type: 1,
                components: [
                    {
                        type: 3,
                        custom_id: 'tos',
                        options:[
                            {
                                label: 'Yes',
                                value: 'yes',
                                description: 'You agree to abide by our terms of service.',
                            },
                            {
                                label: 'No',
                                value: 'no',
                                description: 'You disagree to abide by our terms of service.',
                            }
                        ],
                        placeholder: 'Select an option from the dropdown menu...',
                    }
                ]
            }
        ]
    }]
});
earnest phoenix
#

Again show the stack trace

hushed robin
#

why

#

🧒

eternal osprey
#

hey guys

hushed robin
#

nvm i fixed

eternal osprey
#

i recently coded a javafx program, but i'd like to actually switch over to using the actual java gui builder instead of manual code. Is that possible?

earnest phoenix
# hushed robin why

The error could be coming from an erroneous library or part that isn't supposed to be used

eternal osprey
#

And what would you guys even recommend

rustic nova
eternal osprey
#

i was watching a tut of some guy on youtube

terse wagon
#

No

#

No

eternal osprey
#

honestly made the designing look very easy

#

cuz i am always fucking around

terse wagon
#

Yoyo

sullen crater
rustic nova
sullen crater
rustic nova
#

I had to work with java swing, is a bit more easy if you understand the general layout features it has

hushed robin
sullen crater
#

contender for top ten fish

earnest mural
#

Fish

spice notch
#

and

#

chips

eternal osprey
#

Well atleast it's better than coding in all yourself, in this gui thingy you can directly place components in a specific place etc

#

while in pl;ain javafx it's always a hassle to get everything together

rustic nova
#

Yeah just gotta keep in mind that it might not scale the same on different devices or screen sizes

eternal osprey
#

mhmm i see, i can live with that tho

sharp geyser
earnest phoenix
hushed robin
#

it has my full name

#

🧌

#

battleless chindle the third

sharp geyser
#

Because without a stacktrace how do you expect us to help you

hushed robin
#

but I fixed it

sharp geyser
#

Cool

hushed robin
#

im pretty smart

#

BUSINESS IS BUSINESS

sharp geyser
#

yea sure

lyric mountain
#

Smh e0c

hushed robin
#

it’s true

#

I’m a better programmer than the average person

#

😎

sharp geyser
#

yet you couldn't even solve your own issue

#

A "good" programmer knows how to listen to others

#

you on the other hand deny the possibility your shit code doesn't work how you think it does

lyric mountain
#

I mean, e0c said "average", so if we choose to use mode (which is "doesn't program") then he's better than someone who doesn't even know code

hushed robin
#

wym

sharp geyser
#

What are you confused about

hushed robin
#

that statement

#

it doesn’t make sense

sharp geyser
#

How come?

hushed robin
#

because it doesn’t

#

my code works exactly as I think it does

sharp geyser
#

Every day I see you in here, you ask for help but tell the person trying to help you that they are wrong

hushed robin
#

when?

sharp geyser
hushed robin
#

well yea

#

I’m correct in that instance

sharp geyser
#

Not really

hushed robin
#

where’s another?

#

I am

sharp geyser
#

cause sayuri is right

hushed robin
#

they’re not though

sharp geyser
#

okay bud

hushed robin
#

💀

hushed robin
#

how can I make discord.js not produce this error:
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!

solemn latch
#

👀

hushed robin
spark flint
#

i had same issue when making a suggestions bot, i had to fetch the channel separately so it was in cache

hushed robin
spark flint
#

well

#

are you doing awaitMessages() before or after the channel deletion

hushed robin
#

before

#

basically i'm making a ticket system and ask someone questions in the ticket channel after it's created

#

and there could be a case where the person closes the ticket instead of answering the questions

steady owl
#

hello. I am just getting into learning to make my own bots for my server. I am having issues with the bot token though. When i create the bot, there is no token displayed, nor is there a button to display the token. And when i attempt to reset the token, it still doesnt display a new token for me.

#

what am i doing wrong?

steady owl
#

Yes. But there's no token, or copy button, appearing.

hushed robin
#

uh

#

idk

#

seems like a bug

#

try creating a new bot

steady owl
#

I have. 5 different times.

#

Same thing for each one.

hushed robin
#

weird

steady owl
hushed robin
#

ah nice

hushed robin
warm surge
#

-ping

gilded plankBOT
warm surge
#

oh shit

#

Wrong place

hushed robin
sharp geyser
#

@lyric mountain love how my character just ignores the collider on the floor and falls straight through

#

Okay and now all of a sudden it works

maiden gazelle
#

does somebody know why it isn't sending the advert to all servers

const Discord = require('discord.js');
const ms = require('ms');
const {CommandCooldown, msToMinutes} = require('discord-command-cooldown');
const cooldown = new CommandCooldown('bumpServer', ms('2h'));
const { Database } = require("quickmongo");
const db = new Database('');

module.exports = {
  name: 'bump', 
  description: 'bump the server', 
  category: 'bumpsystem', 
  run: async(interaction, bot, args) => {
    const userCooldowned = await cooldown.getUser(interaction.guild.id);
      if(userCooldowned) {
        const timeLeft = msToMinutes(userCooldowned.msLeft, false);
        if(userCooldowned) return interaction.reply({ embeds:[new Discord.EmbedBuilder().setDescription(`You need to wait ${timeLeft.hours + ' hours, ' + timeLeft.minutes + ' minutes, ' + timeLeft.seconds + ' seconds'} before this server can be bumped again!`).setColor("#C73D43")] });
    }
      
    await db.connect()
    
    const data = await db.get(`advertisement-${interaction.guild.id}`)
    if (!data) return interaction.reply({ content:'No ad setup found.', ephemeral:true })
    
   
      
    let embed = new Discord.EmbedBuilder()
    .setColor('#B468FF')
    .setThumbnail(interaction.guild.iconURL())
    .setTitle(`**${interaction.guild.name} | ${interaction.guild.id}**`)
    .setDescription(`${data.description}`)
#
let row = new Discord.ActionRowBuilder()
    .addComponents(
        new Discord.ButtonBuilder()
        .setLabel('Join')
        .setURL(`https://discord.gg/${data.invite}`)
        .setStyle(Discord.ButtonStyle.Link),
    );

    let check = await db.get(`adschannel`)
    check.forEach(async (dta) => {
        let guild = await bot.guilds.cache.get(dta.guild)
        if(!guild) return;
        let channel = guild.channels.resolve(dta.channel)
        if(!channel) return;

        await guild.members.fetch();
        const delay = ms => new Promise(res => setTimeout(res, ms));

        if(!channel.permissionsFor(channel.guild.roles.everyone).has(Discord.PermissionFlagsBits.ReadMessageHistory)) {
            await db.delete(`advertisement-${guild.id}`)
            await db.pull(`adschannel`, e => e.guild == guild.id); 
        }

        let members = channel.members.filter(m => !m.user.bot)

        const sumFunc = async () => {
            if(channel.guild.id !== interaction.guild.id) {
                await channel.send({ embeds:[embed], components:[row] }).catch()
            }
            delay(500)    
        }
        await sumFunc()
    })
    let doneEmbed = new Discord.EmbedBuilder()
    .setColor('#B468FF')
    .setTitle("Bump Done!")
    .setFooter({ text: "Come bump again in 2 hours!"})
    await cooldown.addUser(interaction.guild.id);
    await interaction.reply({ embeds: [doneEmbed] })
    }
}
hushed robin
#

wheres the docs for modals on the discord documentation

#

can't find them

hushed robin
#

it's a bumping system you consent to

#

numerous other bots do it

sharp geyser
#

and its a dumb idea too

deft wolf
#

Looks like polish type of bot masnakappa

neon leaf
#

how can I define routes with matched params like /@{username} in the openapi 3.1 spec?

#

just like that or no?

maiden gazelle
deft wolf
#

It's just not gonna work at all

quartz kindle
#

:^)

deft wolf
#

Jokes aside, but at the beginning of 2020 there was a total flood of such bots in Poland. Everyone was doing something like this with the idea of ​​earning money from premium ads. Few got more than 1000 servers but by offering an ad for each server every hour at almost 1000 servers it really was more of a spam bot than something that actually helped promote the server

#

Some were even able to send premium ads to all members of other servers in private messages

#

So I don't really trust such projects, in most cases they are doomed to die sooner or later

quartz kindle
#

lmao

sharp geyser
#

You’ll see no substantial or constant growth

#

These bots have been around for years and they have yet to be successful. A server list is more successful than a bot and those server lists already have a bot that bumps your server to the front of the queue anyway

maiden gazelle
sharp geyser
#

To each the own I’m not telling you not to do it

#

Just prepare for the possibility it’ll flop and hell if you make it popular good on ya as well

lyric mountain
hushed robin
#

someone help me pls

coarse fjord
#

Instead of seeing the votes directly through my bot, you can put it in my API, and somehow get who voted, it's just that the host where I host my bot doesn't give the ip because they say the ip is temporary.

coarse fjord
hushed robin
#

idk your saying that without any context

coarse fjord
#

Sorry

#

Instead of directly accessing voting information through my bot, you can utilize my API to retrieve the voter data. However, the hosting service for my bot does not provide the IP addresses as they claim the IPs are temporary.

hushed robin
#

do you mean you can’t use webhooks because your hosting provider doesn’t provide you with an IP?

coarse fjord
wheat mesa
hushed robin
#

u need a publicly accessible IP to use webhooks

hushed robin
#

look up

rustic nova
lyric mountain
#

You can tho check for a specific users' vote status, but it'll require them to use a command

#

It won't be automatic, but at least you can know whether someone voted or not

lyric mountain
#

And no, he doesn't really need that 5s timeout, he simply refuses to test without because "lookz cool"

wheat mesa
#

💀

lyric mountain
#

(The popup to disable mention didn't appear)

wheat mesa
#

Ah yes the classic “scroll 15 conversations up to find my problem because I can’t be bothered to repost it”

hushed robin
#

how can I ignore this error so it doesn’t occur?

lyric mountain
#

by writing functional instead of aesthetical shit

hushed robin
#

this is a new issue

sullen crater
#
try {
  your code
} catch (not_useful_info) {
   const received_info = not_useful_info;
  setTimeout(() => ({
    if (not_useful_info && not_useful_info.message) {
    delete received_info.message;
}
}), 300)
  return
}
proven lantern
proven lantern
quartz kindle
#

i report you

hushed robin
#

i will give u a status report if u help with my issue

quartz kindle
#

mordekaiser is #1 huehueheuheheue

hushed robin
#

what

quartz kindle
hushed robin
#

look above a little bit

#

I replied to it

lyric mountain
hushed robin
#

i explained the situation

proven lantern
hushed robin
#

no

hushed robin
#

i know whats causing the error but i don't know how to prevent it

hushed robin
#

yea

quartz kindle
#

how did you define channel?

civic scroll
#

what's the stack trace

hushed robin
#

why

civic scroll
#

i wanna see where it's occuring

hushed robin
#

the stack trace isn't relevant

civic scroll
#

...

quartz kindle
#

there he goes again

proven lantern
#

battleless doesn't show stack traces. those have lat long info

hushed robin
#

how will the stack trace help

quartz kindle
#

and ip addresses

#

and his grandmother's name

hushed robin
#

i already know what's causing the error

civic scroll
#

so that same old code huh

proven lantern
#

never ask code it's age