#development

1 messages · Page 41 of 1

radiant kraken
#

definitely not copied from node.h

earnest phoenix
#

Never

boreal iron
#

Is that the code to start a rocket? Looks like so…

radiant kraken
#

yes

#

because v8 is blazingly fast 🚀🚀🚀🚀🚀🚀🚀🚀

quartz kindle
#

i never understood dafuq does tolocalchecked to

boreal iron
#

Damn and I thought v1 and v2 was dangerous but v8

#

Oof

earnest phoenix
#

It starts your car's V8 engine blazingly fast

radiant kraken
#

in v8, there is v8::MaybeLocal, which is basically the Nullable version of v8::Local

earnest phoenix
radiant kraken
#

asidjjdfijdsfjdsifsdf

#

just think of it like ?String

quartz kindle
#

so toLocalChecked turns a MaybeLocal into a Local? like a null check?

radiant kraken
#

yes

quartz kindle
#

makes sense

radiant kraken
#

if it fails it will crash the v8 engine

quartz kindle
#

i prefer using node-addon-api tho

radiant kraken
#

awesome stuff

quartz kindle
#

gets rid of all that bs for me

#

:^)

radiant kraken
#

same

#

i personally use and prefer napi-rs

wooden ember
#

bruh i found out why the audio would die on my bot if it was left in a chat for too long

#

was nothing to do with my shit internet

#

just didnt have noSubscriber: NoSubscriberBehavior.Play setting before

#

dumb how that had to require restart to get audio to work after though

rustic nova
#

sounds like the player was defined in a global static scope, causing the entire bot to no longer work

green kestrel
#

got some interesting stats to share here

#

these figures are for the last month, up till now

#

on my bot

#

seems message commands are still winning out, but only just

#

i expect that over time, the message commands section of this chart will go down

sudden geyser
#

Intriguing.

green kestrel
#

this is on a bot with the message intent, where both types of command are still offered, with a push to get people to try the slash commands

rustic nova
#

then check your stats again

#

or is that stats from your bot

#

wtf, does cloudflare provide google certificates?

#

our cloudflare domain has a google certificate wtf

green kestrel
#

thats the stats from my bot @rustic nova

rustic nova
#

ye then thats because of people being used to the text based ones

fast bronze
#

this is my error rn my friend told me to registerFont but im not familiar with canvas so i legit have no idea what to do

#

this happened before i redownloaded node-canvas package

#

after i downloaded

#

need help since i dont rlly know canvas

earnest phoenix
#

For example

import { registerFont } from 'canvas';

registerFont('./my-font-file.ttf', { family: 'MyFont' });
feral aspen
#

In an express application, is it possible whereas if a form that has an input button, example:

<form id="inputwords" class="mb-5" method="post" action="/search-word">
    <div class="row">
        <div class="col-12">
            <input type="submit" value="Send Message" class="btn btn-primary rounded-0 py-2 px-4" id="wordsubmit">
            <span class="submitting"></span>
        </div>
    </div>
</form>

It would be disabled after it gets pressed.

#

Now, when I don't have such said feature, the post method works, however, when I have it whereas after the button is pressed, it would be disabled, the post method doesn't function, why that? Moreover, what's the alternative way?

#

My current code:

$(document).ready(function () {
    $("#inputwords").submit(function (e) {
        $("#wordsubmit").attr("disabled", true);
        return true;
    });
});
last tapir
#

im no expert but according to school, theres an onSubmit attribute you can use with forms

cinder patio
#

honestly why are you using JQuery and <form> and not a nice front-end framework

last tapir
#

use that, use document, get id of button and disable

manic crane
#

i am getting this error i am not working on ts

#

duh everyone stop typing after i come

cinder patio
#

It literally says how to solve the error

#

did you read it

last tapir
#

i think, cause of the classes

boreal iron
#

still doesn't change the fact he's using jQuery

last tapir
#

now, again im no expert, but what is the better solution to so

#

what he should use instead

boreal iron
#

Do you wanna disable the button permanently?

#

if so, just add a css class which prevents user from any input

feral aspen
#

How so? Example, if possible.

boreal iron
#

oops once again

#
.no-select
{
    -moz-user-select: none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    user-select: none;
    cursor: default;
}
$(document).ready(function()
{
    $("#wordsubmit").on("click", function()
    {
        $(this).addClass("no-select");
        ...
    });
});
boreal iron
#

you can of course remove the class later if needed, after time, after the submit event etc.

ancient nova
#

you can do write that wayy better FakE or is that not javascript?

#

I can't tell

boreal iron
#

don't forget to add any form validation if there are fields the user has to fill out, or the button is disabled (even on an invalid input since it has been pressed)

boreal iron
cinder patio
feral aspen
#

Well, I'm mostly with Express.JS when it comes to back-end.

cinder patio
#

that's for the front-end

ancient nova
#

better way is just to use document.querySelector(...)

#

and I think there is a builtin .onClick function for the querySelector as well

boreal iron
#

but it's not actually all that good

it's literally just native JavaScript, not more or less, it just tries to get rid of compatibility issues in browsers etc., still only native JS

#

so, there's no better or worse

ancient nova
#

querySelector always worked so far

boreal iron
#

oh god... i dunno what to say

feral aspen
#

And I mean a seriously simple one.

#

Not a portfolio, or the next google.

ancient nova
cinder patio
#

you'll never have to use jquery in 2022

ancient nova
cinder patio
#

document api does a better job

ancient nova
boreal iron
#

dude the $ is just an identifier of jquery() function NOT MORE, you can also call jquery() the entire time instead of using the shortcut $

ancient nova
#

it was never defined in the first place

neon leaf
#

does anyone know why requests wont come trough? this is my current code, 25252 is open

boreal iron
#

where do u host the code?

#

at home?

neon leaf
#

no, on a linux vps

boreal iron
#

well then check the default input policy for your firewall as well as the one your provider may put before the server

neon leaf
#

well going to it on my browser works

boreal iron
#

you need to allow incoming requests on that port (TCP)

#

oh really

#

does the auth key matches the one on topgg then?

neon leaf
#

webkey is this:

boreal iron
#

make sure both are matching each other exactly

neon leaf
#

they are

boreal iron
#

if you still have trouble, choose a different auth key, press save on topgg a few times, update the one in your code, try test send again

#

also check the webserver log if the incoming request is visible

#

*is logged

#

*has been logged

#

errr whatever

neon leaf
#

not sure how I would do that, there is no reverse proxy in place that could log it

boreal iron
#

not sure if express has a way of logging the requests, but I assume it has

#

still try what I told you above before

#

that mostly fixes the issue

#

you can also try to remove the auth key from topgg and your code

#

also hit save a few times

#

(on the site)

quartz kindle
#

instead of the dbllistener just do .post("dblwebhook", (req,res) => {})

#

that will give you the ability to log

#

btw what is your webhook url?

neon leaf
quartz kindle
boreal iron
#

oh didn't ask him about that so far... lol

quartz kindle
#

youre missing the /dblwebhook

boreal iron
#

oh your forgot the path

neon leaf
#

yup, that was it

#

last issue,

boreal iron
#

well make webhook listener an async function and await fetch

feral aspen
#

If I want to host a website on a vps by configuring a reverse proxy with NGINX...

#

I'm currently following my hosting provider's documentation, and it mentions to:

create a A record within your DNS manager pointing to your server’s IPv4 address
#

What should it exactly be? Eyes

neon leaf
boreal iron
boreal iron
#

The proxy doesn’t require an hostname but can also point to an IP address

boreal iron
#

If you’re proxy server also runs on the same machine then it’s useless

#

Usually the goal is to hide the actual webserver and/or do load balancing

neon leaf
#

is there any way of getting a users locale? i know interaction.guildLocale exists but first of, im not in an interaction and second, a dm isnt a guild afaik

boreal iron
#

The interaction should also provide locale which is the user locale

#

Impossible Outside interactions

neon leaf
boreal iron
#

No

#

Any interaction is always triggered by an user

neon leaf
#

could I just attach an button to that that just edits the message accordingly?

boreal iron
#

Still… unless somebody is actively pressing the button you won’t receive an interaction event

#

An (inter)action can only be triggered by an user

#

Either by executing a command, selecting an option im a select menu, pressing a button etc.

lyric mountain
#

Simply save the user locale when they first use a command, you have a database already

boreal iron
#

Well I mean it can change at any time

neon leaf
#

well, if he had it before imma guess he still understands that lang

boreal iron
#

True but why do you need it outside an interaction instance?

neon leaf
#

to tell a user he voted in his locale

lament rock
#

Can someone with regex experience help me?
I'm trying to make a regex that matches audio or video content types which can include application/ogg and application/x-mpegURL, but I do not want it to match any other application/.* content types.
This is my regex so far:
/^(?!application\/json)(audio|video|application)\/(.*)$/
But instead of just application/json, I want it to discard the match if it isn't application/ogg or application/x-mpegURL

earnest phoenix
#

I may be misunderstanding what you're actually looking for, but ¯_(ツ)_/¯

lament rock
#

True

boreal iron
lament rock
#

Imposes challenges I'll need to figure out for myself, but ok

boreal iron
#

Passing the locale to it

#

Once a locale isn’t available you fall back to your default

pure sage
#

how i can link my bot server counting to html website

lyric mountain
#

go to your bot's edit page in top.gg and copy the server count badge embedding code (if that's what u mean)

lyric mountain
#

because your bot isn't approved yet

pure sage
#

ok

#

ho time is taken to approve

lyric mountain
#

1-2 weeks ig

gleaming niche
#

how can I improve my bot's response times cause it sometimes doesn't respond in time and I receive an unknown interaction error and my application doesn't respond with a message but still executes the rest of the code fine. it's coded in python

wheat mesa
#

defer the message before trying to reply

#

and before you do anything else in the command

fast bronze
harsh tusk
#

Were do i start learing were to code discord.js?

#

youtube is not a big help

pine nova
# harsh tusk Were do i start learing were to code discord.js?
lofty hamlet
#

Hello, my Top.gg's bot picture does not work and same for: Widgets

bright thorn
#

Umm which os is better to host dc bots

graceful cobalt
#

Guys wtf, my bot CTR% is only 3!! What can I do to possibly increase it? Like how to make it more appealing? Can anyone dm me with a good short description please as I am too bad in marketing.

graceful cobalt
graceful cobalt
graceful cobalt
drifting cairn
#

what tag

graceful cobalt
#

Anyone can suggest me a better description

graceful cobalt
# drifting cairn what tag

Not tag, it means the ratio of the number of people who saw and ad and the number of people who clicked the ad

drifting cairn
#

yeah what tag is the ad on?

spring condor
#

is there any giveaway

graceful cobalt
graceful cobalt
quartz kindle
#

never used top.gg ads so idk what usually makes them work or not work

drifting cairn
drifting cairn
#

you could work on your bots description page to begin with, theres a bunch of things like stretched/warped images etc...

graceful cobalt
drifting cairn
graceful cobalt
drifting cairn
graceful cobalt
#

Btw can u tell me which pfp looks better

drifting cairn
#

uhhh

#

i like the 2nd one

graceful cobalt
#

Oh ok

#

Ty

lyric mountain
#

tbh, those colored pixels around the face look like a bad crop

lyric mountain
lyric mountain
earnest phoenix
lyric mountain
#

oh so it is indeed a crop

civic scroll
#

i thought they were nfts for a second

abstract schooner
#

Hello everyone, how do I make a system so that every time a member votes for my bot, it returns a certain message in a certain channel?

elder oxide
#

macOS 13 beta support desktop audio recording now

#

AND THEY ADD ALARM TO THE CLOCK APP! 👏

wheat mesa
#

woah basic features I would expect in $2000+ computers already have been added after a short 15 years!

earnest phoenix
#

They literally don't bother adding the most basic/important features and delaying them to be implemented after a very long time

#

Sounds like Discord when they delayed slash-commands for 6 years, and then implemented them

lyric mountain
neat ingot
#

so ive had reports from a client for a bot I wrote... basically, people are inviting the bot to their server, but the bot is never joining their server... this has only just started being reported recently, the bot is in 1700-ish servers. Anyone got any ideas? (bots written in discord.js)

#

also: when i tried to test, the bot joined every server i added it to, so it doesnt happen every time (i wasnt able to reproduce it once)

lyric mountain
#

maybe it's a bot kicking yours

#

don't u have logs like "Just joined server XXX"?

#

if not, try logging that to see if the event fires at all

neat ingot
#

it didnt seem to be firing at all ~ but im now being told that the person had 50 integrations on their server already ~ so fk em, thats their problem 😄

lyric mountain
#

ah yeah, that might be it

#

discord has limits on how many stuff can exist at once (hence why topgg doesnt invites bots here anymore)

neat ingot
#

yea lol, honestly, if they told me they had so many integrations at first i would have saved them hours of stressing 😄

violet haven
#

hello guys! i have a discord bot running with akairo but akairo isn't supporting discord js 13 and 14

#

do u know another framework that works with djs v14?

wheat mesa
#

I don’t know what akairo does but I would strongly recommend against using any frameworks that add on to djs

#

They’re subject to breaking changes and usually aren’t very well maintained

violet haven
#

i already found one named commando but it works with djs 13 and i can't see if it works with 14

wheat mesa
#

And you don’t even need them

#

Just use djs v14 without using a framework on top of it

violet haven
#

ok i'll do that

#

i'm having an issue with akairo rn cause some methods are deprecated T_T

#

guess i'll have to put many hours of work in it

#

thx for advice

eternal osprey
#

hey, how would i get the position of the array in the sortedDB?

#
let sortedDB = Object.entries(userdatabase).sort(function (a, b) {
    const [ aKey, aValue ] = a; // unpack a
    const [ bKey, bValue ] = b; // unpack a
    return (Number(bValue.points) + Number(bValue.points)) - Number(aValue.won) + Number(aValue.points) 
  });```
lyric mountain
#

it all depends on how intricate you want it to be

lyric mountain
#

most (if not all) databases allow sorting without requiring manual operations

#

also considering ur current code, is it really supposed to sum bValue.points twice?

violet haven
lyric mountain
#

well, yeah, u can also try to mimic their structure to keep current code

#

I imagine you're using single-command files right? if so you can try using "Replace in files" feature (if your IDE/editor has that)

lament rock
#

I made an entire cacheless Discord.js so I could only rewrite a portion of my bot

#

not worth it

eternal osprey
#

how do i reply to an interaction without actually replying?

#

So like ghost replies

lyric mountain
lyric mountain
lament rock
#

No I mean my bot ran fine aside from having memory issues because the imported module size was absurdly large

eternal osprey
#

thanks

lyric mountain
lament rock
#

discord.js' size and complexity is its downfall

boreal iron
#

Are modals yet actually available on all clients? also the "old" android client?

#

can't really find a client support list

wheat mesa
#

I believe modals are supported on all devices, but not all field types iirc

ancient nova
#

what yalls opinion on Heroku?

lament rock
#

It sucks

#

free and non free tier

#

how it divides up resources is stupid as noisy neighbors can take over your resources

vivid fulcrum
#

paid tiers are actually pretty good

#

and free tiers are about to be deleted from existence

#

we use paid tiers at work in combination with salesforce, everything flows together perfectly and from what ive seen the uptime is almost perfect

lyric mountain
neon leaf
#

does someone know how I can get ten random strings from here? they shouldnt be the same and should also end up in an array

earnest phoenix
# neon leaf does someone know how I can get ten random strings from here? they shouldnt be t...

You can make a temporary copy of that array, initialize another array, loop 10 times to get a random element from that array and remove it from the copied array, for example:

// Original array of values to get random elements from.
const foo = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

// Copy the original array as we'll be mutating it to not keep on landing the same value.
const copied = foo.slice();
// The array of random elements we've gotten.
const randomElements = [];

// In this example, we're looping 5 times to get 5 random unique elements.
for (let i = 0; i < 5; i++) {
  // Get random index.
  const randomIndex = Math.floor(
    Math.random() * copied.length
  );

  // Push the random element to the array.
  randomElements.push(
    copied[randomIndex]
  );

  // Remove the element from the array from the random index so we don't land on it again.
  copied.splice(randomIndex, 1);
}

// Now the `randomElements` array has 5 random unique elements.
#

There definitely are other ways to do so, but this is pretty efficient if you want unique random values

neon leaf
#

thank you so much!

earnest phoenix
#

You're welcome

lyric mountain
#

css

#

users aren't guaranteed to be cached at any time

#

yep, inside <styles> block

#

DO NOT ADD THE FULL HTML STRUCTURE

#

it'll not work

#

use JUST <styles>/</styles>

#

users.fetch

#

do note, u cant fetch someone who's not in a mutual server

#

that's called hackban, u simply add the id to the banlist

#

if user is an id, ig so

#

no

#

u cant members.get

#

no

#

u cant fetch someone who's not in any mutual server

#

because the bot doesn't know they exist

#

hackban is, by definition, a blind ban

#

check if both mention and fetch didn't return anything

boreal iron
#

By fetching a (local) guild member providing this ID

#

Either it’s in the list or not

wheat mesa
#

Or just ban by ID either way

thorny field
#

what does a pinged role look like in text?

sudden geyser
#

Like <@&265125253443878912>

thorny field
#

i mean like how a text channel is in text #development = [#development](/guild/264445053596991498/channel/272764566411149314/)

#

and a pinged user @thorny field = @~/.BeastieNate5#6243

#

oh

#

it converted it

#

but im wonder how it is for a role

quartz kindle
thorny field
#

nvm im good guys i got it

lyric mountain
quartz kindle
#

pretty sure i fetched many users who did not have mutual servers with my bot

#

when testing and stuff

#

you can fetch deleted users for example

lyric mountain
#

really?

quartz kindle
#

some deleted users will return 404, but others will return a valid user with a "deleted user djjejdj" username lol

earnest phoenix
#

Does anyone know how to solve this?

quartz kindle
#

pretty-ms is an ES module now

sudden geyser
#

Use import * as ms from "pretty-ms" instead (I think)

quartz kindle
#

you need to use an older version, or change your code to ESM mode, or import it using dynamic import()

#

the easiest way is to use dynamic imports, but dynamic import is async, so you cant do it top level, for example const ms = await import("pretty-ms") (inside an async function)

#

you will likely also need to use ms.default

earnest phoenix
#

Okay, i used an older version and now it works

quartz kindle
#

👍

earnest phoenix
#

thx

boreal iron
lyric mountain
#

I forgor 💀

earnest phoenix
#

has anyone got this error before?

Cannot read properties of undefined (reading 'component_type')
wheat mesa
#

Yes, cannot read properties of undefined is an error that has happened billions of times

#

But without any code to look at, it's very vague

#

Whatever you're doing, it's basically doing undefined.component_type

#

Which is an error

wheat mesa
#

@earnest phoenix explain yourself right the fuck now

sharp geyser
#

Wiat what

#

did that just turn into a string?

wheat mesa
#

Yes

#

I need an explanation

pale vessel
#

If you do -= [4] it becomes a number (-4)

#

It's just like [] + 1 and [] - 1

#

Concatenation treats it as a string and combines stringified versions of both, but substraction converts it to a number instead and performs the calculation

sharp geyser
#

explanation

prisma nebula
#

Someone always getting my bot token

#

And nuking

#

Servers

#

I dont even have a team member or worl in replit

#

Work*

rustic nova
prisma nebula
#

Flashnodes

rustic nova
#

since I have never heard of that, doubt the trust is reasonable either

#

is it free?

prisma nebula
#

The free plan isnt that good

#

But they have 10k memebrtd

#

Members*

drifting cairn
rustic nova
#

I can only suggest getting either a VPS or some other trusted host for your bot instead. I'm highly suggesting a vps instead if you want your bots access to be reasonably secure:

Why you shouldn't use free hosts: #development message
Popular VPS providers that have reasonable prices for discord bots: #development message

prisma nebula
#

Ty

#

Btw any application is open for top.gg rn?

rustic nova
#

You will likely continuously face your token being exposed, this could either be someone who has access to that sites backend or someone else has access to your own pterodactyl

#

-apps

gilded plankBOT
#

topgg Volunteer Applications

Hey! It seems like you're interested on volunteering for Top.gg. We're glad for any help we can get regarding our server events, support articles, bot reviewing, moderation, and more!

topggContributor Contributors
Contributors are not considered staff and there is no age requirement. Contributors help out with server events and providing support.

topggBotReviewer Bot Reviewers
Bot Reviewers are Top.gg staff and must be 18 or older. Bot Reviewers review the discord bots submitted to the site before they are listed to make sure they follow our rules.

topggModerator Moderators
Bot Reviewer is a stepping stone to Moderator - if you wish to be a Moderator you must first apply and be accepted as a Bot Reviewer.

topggDotRed Please read [this post](#announcements message) for more information and to apply!

prisma nebula
#

Tysm

#

@rustic nova It is by oppening ticket?

rustic nova
civic scroll
#

@rustic nova gaming

rustic nova
#

Hi

#

what are you doing in development

#

smh

sharp geyser
civic scroll
rustic nova
#

rude

civic scroll
prisma nebula
#

Why this server

#

Isnt longer

#

Verified

#

-verify

#

-top.gg

rustic nova
#

Top.gg was never verified nor partnered

crystal furnace
#

How to stop prettier act like this, the tool is good but sometime it is auto underline like this :))

earnest phoenix
earnest phoenix
crystal furnace
crystal furnace
#

with me at least :))

crystal furnace
earnest phoenix
#

The reason Prettier splits it into different lines by default is because it wants it to fit in general screen sizes instead of scrolling to the left or right to read the code

earnest phoenix
crystal furnace
#

30000

earnest phoenix
#

There's also a warning for readability purposes

crystal furnace
#

and nothing happen

#

:))

earnest phoenix
#

Show us how you're setting it

crystal furnace
#

I use eslint too

earnest phoenix
#

That's just too much, Prettier cannot go that far

crystal furnace
earnest phoenix
#

Setting it to 500 should already suffice

#

Your test won't work because that's an invalid value for Prettier

crystal furnace
#

I have sth to do now

crystal furnace
earnest phoenix
#

Hey there.. I'm trying to get the amount of roles in a server using DJS and it is not going well..

Here is what I have tried (attempting to following the docs):

let roleCount = 0

guild.roles.fetch().then(roles => roleCount = roles.size)

interaction.reply({ content: `${roleCount}` })```
^^ This returns an error saying content cannot be empty

I also tried just straight up:
```js
interaction.reply({ content: `${guild.roles.size}` })```
#

Both return errors.. Anything that I am missing?

earnest phoenix
#

i forgor about cache dead

#

Thank you!

#

You're welcome

boreal iron
#

Interesting the upper one returns content can’t be empty

earnest phoenix
boreal iron
#

then(…)?

earnest phoenix
#

That does not wait for the promise to resolve, the code execution will continue as is

lyric mountain
#

async cannot modify sync context

#

at least not within that execution

boreal iron
#

Can you actually await it then still using then(..)?

#

Or would that be nonsense

earnest phoenix
#

Yes, that's what you're supposed to do

boreal iron
#

Looks like I misunderstood then() a little bit

lyric mountain
#

imo js shouldn't even allow doing such kind of operations

civic scroll
#

.then() call async

earnest phoenix
#

Basically both of this do the same thing:

let roleCount = null;

// First solution
await guild.roles.fetch().then((roles) => {
  roleCount = roles.size;
});

// Second solution
const roles = await guild.roles.fetch();
roleCount = roles.size;
boreal iron
#

It just resolves a promise without the need to use await or an async function then

civic scroll
#

it will execute on the microtask queue iirc

lyric mountain
#

like, variables passed to async context should always be effectively final

boreal iron
#

But doesn’t await it

civic scroll
#

which is after sync exec

lyric mountain
#

else u run into weird issues

civic scroll
#

if you had no choice you will have to do async IIFE

earnest phoenix
#

It's basic understanding of asynchronous operations

boreal iron
lyric mountain
earnest phoenix
lyric mountain
#

at least js being monothread removes some possible concurrent variable modification issues

boreal iron
#

Thanks

lyric mountain
#

at topgg?

#

cuz iirc my css is long broken

green kestrel
lyric mountain
#

are u looking at the right shiro?

green kestrel
#

no longer so oldschool

lyric mountain
#

there's no bg

green kestrel
lyric mountain
#

ayo what, mine doesnt look like that lmao

#

but well, that image is set on the edit page

#

edge

#

ah nvm, she is there

#

I just didn't wait enough for it to load

lyric mountain
#

the black lines look a bit odd

#

.theelementclass { color: #rrggbb }

#

use F12 to find out the classnames

quartz kindle
#

nah

boreal iron
#

nah

lyric mountain
#

the scrollbar isn't a page element

#

it's a browser element

#

technically, you can, but it's heavily browser-dependant

#

browser-dependant

#

it might not work in other browsers

#

and mobile?

ember quarry
#

I am having doubt with using discord API, is it right place?

wheat mesa
#

Yes, ask away

ember quarry
#

I want to add button to my message sent using webhook, but this payload is not working as expected. Anyone having any idea about it?

{
            "embeds":[ some embed data ],
            "components": [
                {
                    "type": 1,
                    "components": [
                        {
                            "type": 2,
                            "label": "some label",
                            "url": "https://google.com/",
                            "style": 5
                        }
                    ]
                }
            ]
        }
lyric mountain
#

what's the expected vs actual result?

ember quarry
#

it is sending the embed as expected but it is not having any button in it

#

in response I check too, there is also component empty

ember quarry
lyric mountain
#

I not sure whether u can have buttons in actual webhooks, since they're decoupled from the bot

ember quarry
#

I am adding a link button, also I googled there were some results stating that we can add actually but they are using discord.js or discord.py

#

I want to do it with API request

lyric mountain
#

did you check discord docs?

ember quarry
lyric mountain
#

they don't mention buttons

ember quarry
#

there was not particulary written anywhere that we can add button to webhook too but if we can add to the webhook too

lyric mountain
#

well if it's not written then you probably cant

#

not to be confused with interaction webhooks

ember quarry
#

that we can add components to the webhook too

lyric mountain
#

there was not particulary written anywhere that we can add button to webhook
well then it is written

#

did u try using the exact same structure as the example?

lyric mountain
#

also why are u doing it without any lib?

lyric mountain
ember quarry
#

its same structure

lyric mountain
#

it's not

ember quarry
#

it is check again

lyric mountain
#

it is not

#

use the same structure, see if it works

ember quarry
#

I dont want to send the content, I want to send embed

lyric mountain
#

send the content for the sake of testing

ember quarry
#

ok

#

not working

#

only the content text is appearing

lyric mountain
#

is the webhook owned by the bot?

#

or did u create it manually?

ember quarry
#

I havn't seen that

lyric mountain
ember quarry
#

lets see that too

bright hornet
#

how do you get the sticker id?

pale vessel
#

Inspect element

thin sphinx
#

hi There is a section called WebHook port for logging the voter, what should I write?

bright thorn
#

why the ping is coming 16.666666666666668 ms

#

why its not 16ms only

graceful cobalt
#

My background code not working

<style>
background-image: url('https://media.discordapp.net/attachments/996766515124777070/1018083952822591558/istockphoto-1200898827-612x612.jpg');
background-size: cover;
</style>
earnest phoenix
#

They use background-color but it's essentially the same structure

graceful cobalt
earnest phoenix
#

Just look at the link...

#

There are all the examples and explanations you need

#

Use their navbar and search for what you need

#

And you even made a website, so you can compare the code you sent above with the one of your website and see what's going wrong

graceful cobalt
#

I out that in the top.gg long description of my bot

earnest phoenix
#

That's my point

#

If you made a website, you know how CSS works

earnest phoenix
#

You will see what's going wrong pretty fast

graceful cobalt
earnest phoenix
#

I gues you haven't made your bot's website then

#

Well the link I've sent has everything you need

graceful cobalt
#

As simply as thay

earnest phoenix
#

Should've been already done by now

graceful cobalt
#

@earnest phoenix I did that bruh

#

I sent the code too

earnest phoenix
#

No you didn't

graceful cobalt
#

this is my code -

<style>
background-image: url('https://media.discordapp.net/attachments/996766515124777070/1018083952822591558/istockphoto-1200898827-612x612.jpg');
background-size: cover;
</style>
earnest phoenix
#

And where has that gone?

#

Told you to look at the website, which you apparently haven't done - can't do more than that when there is even an example to copy paste kryptonShrug

graceful cobalt
#

@earnest phoenix i did, but can pls send me an ss of what u see in ur desktop or pc?

earnest phoenix
graceful cobalt
earnest phoenix
#

Low quality picture imo

#

Really blurry

graceful cobalt
#

how do make it good quality

graceful cobalt
earnest phoenix
#

Don't use a 612x612 pixels picture

graceful cobalt
earnest phoenix
#

No

#

istockphoto-1200898827-612x612.jpg

graceful cobalt
graceful cobalt
#

but in my gallery its very high quality

earnest phoenix
#

Not really high quality to me

#

Though using cover won't help making it better

#

I'd recommend something that you don't need to cover entirely

#

Like a 'loopable' background or simply a solid color picture

graceful cobalt
drifting cairn
graceful cobalt
drifting cairn
graceful cobalt
#

Not me lol

drifting cairn
graceful cobalt
#

@drifting cairn can u tell me what u see now?

#

I don't have pc so

drifting cairn
#

make it no repeat

#

and make it fit

graceful cobalt
graceful cobalt
drifting cairn
drifting cairn
graceful cobalt
drifting cairn
#

nope

#

im willing to help you but im not gonna spoon feed you, sorry

cobalt turret
#

Hello

graceful cobalt
drifting cairn
#

🤨

#

you're a baby on discord? eyes_sus

graceful cobalt
#

Baby on css

drifting cairn
#

then learn css peeposhrug

graceful cobalt
#

Lol

#

@drifting cairn can u check what u see now?

#

Also first click control shit r

#

To release cache

pearl trail
#

ah yes ctrl shit r

drifting cairn
#

lmao

#

i thought u put no repeat bruh

rustic nova
#

that background really does not fit with the colorful text, fyi

drifting cairn
#

yea

#

@graceful cobalt your bot has a website no?

boreal iron
#

Well instead of changing all the font colors, just choose a background based on the user selected style

#

Also possible with css

drifting cairn
civic scroll
#

with javascript

#

embrace

civic scroll
boreal iron
#

COUGH

drifting cairn
civic scroll
#

i mean

#

don't get outskilled by a prisoner amirite CoolSunglasses

graceful cobalt
graceful cobalt
drifting cairn
# graceful cobalt yea

why not put like an iframe as the description instead of all the weird colour text or something Confused

drifting cairn
graceful cobalt
graceful cobalt
drifting cairn
drifting cairn
drifting cairn
graceful cobalt
#

now its looking good ryt

drifting cairn
#

i’m on mobile rn i’ll check in a minute

spark flint
#

💀

#

@rustic nova bonk

#

o its gone

#

i love when they forget the scam link

rustic nova
#

uwu

graceful cobalt
spark flint
#

The scam was deleted

winged linden
#

yooo how can i await till interaction gets deffered before editing?

#

cuz some times it takes time sometimes it trys to reply before defer

#

anyone?

drifting cairn
winged linden
drifting cairn
idle coral
#

Replit user here, keep getting this.

drifting cairn
#

read it

idle coral
#

I am..

#

const { loadCommands } = require("./handlers/loadCommands");

drifting cairn
#

and whats inside of said file?

idle coral
#

You want the entire file?

drifting cairn
#

i just want to know how you export the function

idle coral
#

Oh shoot.

#

Typo.

#

LMFAO

drifting cairn
idle coral
#
module.exports = {
  loadCommandss,
};
#

I swear I'm a goofy goober sometimes.

drifting cairn
#

lmao

split cipher
#

How do I define aProperty's type that's either a function or null?

export interface IAnInterface {
aProperty: (aString: string) => void;
}

civic scroll
split cipher
#

Thanks

cobalt spruce
#

question

#

how is this made? like two infos next to each other in embed

peak mason
#

inline: true

cobalt spruce
#

❤️

boreal iron
#

tf is that resolution

peak mason
boreal iron
#

what don't u understand in that question?

peak mason
#

idk what you are referencing to

cobalt spruce
#

whats wrong with it?

solemn latch
#

its just a bit weird to have a 200px wide embed I guess

boreal iron
#

good old 640x480 resolution

solemn latch
#

it goes down to 200px at 720p iirc

boreal iron
#

looks horrofying on 4k

boreal iron
#

tim, why bot not working anymore?

boreal iron
#

imagine not knowing the footer text takes text only

knotty quartz
#

I need some hosting ideas

boreal iron
#

earn some cash, rent a server

#

or buy a server and steal the electricity of your neighbors

knotty quartz
#

Lol.

boreal iron
#

anything free is shit and you will be limited at some point

#

not much more to say about it

knotty quartz
#

Agree

lyric mountain
#

for some unknown reason

boreal iron
#

The footer… yeah idk why

#

Proves only drunk devs working at discord

#

Footer only doesn’t look that bad on mobile tbh

#

But anything bold… eww

#

Nice for like short status messages without people using emoji bullshit

#

Since it won’t take up much space

ancient nova
#

guys guess what

#

my bot now only uses 150mb of ram

civic scroll
#

damn that's alot

ancient nova
#

bruh 🗿

#

it was 300 before

wheat mesa
#

Has literally nothing to do with your error

ancient nova
#

this is an improvement

wheat mesa
ancient nova
#

rss

wheat mesa
#

Ok good

ancient nova
#

plus it's around 90 servers

#

almost 100 gonna have to apply for the last intent before that

lyric mountain
#

but well, it's a tcg bot that deals with huge images so...

ancient nova
#

I talked with a dude who has an image gen bot, it uses around 10GB

sudden geyser
#

vomit

lyric mountain
#

ok 10gb is a bit too much

wheat mesa
#

Cake’s notsobot uses around 100gb of ram

#

But it’s also on like 900,000 servers and caches nearly everything

sudden geyser
#

why though

ancient nova
#

my bot also caches everything, but I managed to optimize it a little bit

civic scroll
ancient nova
civic scroll
#

waffle and kuu

jovial nimbus
#

Does anyone know how to call the banner for the user in the dashboard of the bot?

civic scroll
#

you should check out the gaming in general

jovial nimbus
ancient nova
wheat mesa
#

Yeah right now it’s in 730000 guilds and 1.4 million applications (I’m assuming that’s an http server)

ancient nova
#

and u can use that hash to get the banner from the cdn

#

that's what I did

wheat mesa
#

That has nothing to do with the code you sent

#

You’re giving it an invalid bitflag, probably with Permissions

#

Just send it here

#

This code also has nothing to do with that error. Is that your only file?

lyric mountain
spark flint
#

my code isn't very optimised

civic scroll
spark flint
#

also because of the amount of events it handles i expected that

#

makes like 10 post requests a second

wheat mesa
#

Is that the full error you’re getting? Does it come with other stuff?

wheat mesa
#

Mine is in 32 servers and uses 80mb, I have not worked on it in like a year KEKW

drifting cairn
wheat mesa
#

Was mostly a passion project for learning typescript, but now I know typescript and I don’t have a reason to work on it anymore

drifting cairn
#

mines in i think 6k and uses just about 1gb

pale vessel
#

670 servers here

drifting cairn
#

😦

wheat mesa
#

199mb is pretty good for that

spark flint
#

i need to start properly tracking my bots stats

pale vessel
#

Yeah

wheat mesa
#

Send it

#

In a pastebin

spark flint
#

use that

#

better than pastebin as its not indexed on google lmao

ancient nova
#

does anyone got a command ideaholdingbacktears

spark flint
#

for my stat tracking i just have my aweful homemade tracking system that only works on the first few days of the month because of how bad i track stuff

drifting cairn
#

bru read the error tfFaint

#

line 19 in index.js take a look

wheat mesa
#

Still doesn’t really make sense

drifting cairn
#

huhh

wheat mesa
#

What djs version are you using?

spark flint
#

total ram across the entirety of my dedi which hosts my websites, bots etc (64gb ram dedi)

drifting cairn
spark flint
#

posts every 10 mins

ancient nova
#

is it safe to host your website on the same node as you host your bot?

spark flint
#

uh yeah

#

i host lots

solemn latch
#

It's best to not expose your ip if possible though

spark flint
#

also works as status monitoring too, I can tell if its my bot or the entire server

ancient nova
#

I want to but I'm reluctant to do it

spark flint
#

yeah true

solemn latch
#

But it is really common

#

You can always buy a second super cheap host for the website

spark flint
#

http://node1.churton.uk is exposed but mostly because I use it as my cname for many things when I cba to update my IP, also allows me to mass change all my sites

ancient nova
drifting cairn
#

try re-installing or something

ancient nova
#

but it's harder to make a dashboard that way

wheat mesa
#

final makes no sense as a variable. I think you need to read the documentation of the library you’re using

solemn latch
#

Not much harder. It'll be just as much work if you're programming it properly

#

Just a bit more configuration

wheat mesa
#

And not just look at the example of the package and copy paste that into your code without knowing what it does

ancient nova
#

well what would be the easiest way to send the stuff I need from my client to the website?

drifting cairn
spark flint
#

websocket would work for updating stuff

solemn latch
#

Websockets, webhooks, or an api all work fine

ancient nova
#

I still use 13.8 discord.js 😁

drifting cairn
solemn latch
#

Which you should be doing anyway because you want to keep the processes seperate

ancient nova
wheat mesa
#

I think it’s because you’re giving it something that it has no idea how to handle.

spark flint
wheat mesa
#

It’s an odd error but knowing javascript it’s freaking out because it doesn’t know how to handle the object

spark flint
#

oh I use an API for my dashboard

#

but I'm looking into a websocket system

ancient nova
#

do interaction.reply({ content: final }); maybe? lmao

wheat mesa
#

Either way it doesn’t know how to handle it

ancient nova
ancient nova
spark flint
#

I cache

#

and I also ratelimit using NGINX

drifting cairn
spark flint
#

because lol

pale vessel
#

Why you sending a stream as content

#

Convert it to a string

solemn latch
#

You shouldn't really need a ratelimit for internal API's between your bot and webserver.

pale vessel
#

Or read the output.pdf file content after piping it

spark flint
#

but I mean for dashboard

#

I ratelimit updating things to 10r/s

#

because I dont want the endpoint spammed

#

I also do the regular host checking etc for the dashboard specific API endpoints

ancient nova
drifting cairn
#

you can ignore that

spark flint
#

🤨

drifting cairn
#

doesnt mean anything rlly

pale vessel
#

What are you doing

solemn latch
pale vessel
#

Use fs.readFile(outputfile, "utf8") as content

solemn latch
#

For example public pages on my site get refreshed max every 60 seconds.
Private pages update every 5 minutes.

pale vessel
#

The output file is the file you're piping the converted content to

solemn latch
#

Excluding forced refreshes(which happen server side under specific conditions)

wheat mesa
pale vessel
#

I think because converted is a stream

wheat mesa
#

I don’t think it’s necessary to have operations done on the hard drive to get the value from the stream

elfin cape
#

A

spark flint
#

thats because its not a djs issue kek

solemn latch
elfin cape
#

Lol

wheat mesa
#

It’s going to be in memory either way

#

It’s not a djs issue like we’ve said

solemn latch
#

Isn't that the point of the stream? Only some of it is in memory at a time.

wheat mesa
#

It’s because you’re giving it an object that it has absolutely no idea how to handle

solemn latch
#

Oh nvm I see what you mean.

ancient nova
#

I wanna add some new commands to my bot 😔

#

I have no ides what to add 😔

lyric mountain
#

again?

ancient nova
#

yes 😔

wheat mesa
#

How about work on improving your current commands

ancient nova
#

I think most of my commands are as improved as they could be

wheat mesa
#

Idk about you but I dislike bots with a million commands that I’ll only use 4 commands of with a shitty experience compared to a bot with 5 very elegant and polished commands

#

And that’s simply not true. UX is never perfect

ancient nova
#

I meannn you're welcome to try for yourself

wheat mesa
#

I have no use for a bot like yours

ancient nova
#

I polished almost every command I have

wheat mesa
#

The only bot I use pretty often is esmBot

ancient nova
wheat mesa
#

I don’t think your UX is perfect no matter what you say, there’s always improvements to be made

ancient nova
#

well I don't know what else I could improve in them then

wheat mesa
#

That’s the thing with software development, there’s always improvements that can be made

#

How about refactoring your codebase to be better 😉

#

It doesn’t always have to do with UX, but your experience in developing the bot

#

Make things easier for yourself, create modular and easily modifiable parts to your bot that all go together to improve your experience with developing, “KISS; Keep it simple stupid” and “DRY; Don’t repeat yourself”

pale vessel
#

A DRY KISS doesn't sound too good

ancient nova
#

yeah that's what I'm doing though

#

my entire bot is modular

wheat mesa
pale vessel
#

lmao

wheat mesa
ancient nova
#

I can add commands easily, I kinda stole that format from my multitool where I kinda had my own language

ancient nova
#

users as well though

wheat mesa
#

Still using strings for booleans?

ancient nova
#

yes, but Voltrex said it's fine 😕

#

if it has any performance issues I'll change it

wheat mesa
#

That’s not a very good motto to go by

ancient nova
#

so far I managed to drop the ram from 300 to 125-150

wheat mesa
#

Comparing characters one by one until they all match is much slower than comparing two booleans with a simple bitwise operation

#

It might not make much of a difference, but it’s still an improvement you need to make to improve your code in general

#

Do you use raw database calls in your command run functions?

ancient nova
wheat mesa
#

Like do you directly access your database via your commands

lyric mountain
wheat mesa
#

You should make a class that manages those things for you so that you can modify the class easily for reasons like swapping databases in the future

#

That way you don’t have to go into every file and change your logic

lyric mountain
#

depending on what kind of data ur storing, not even booleans would be fine

ancient nova
#

yeah but I'm going to have to do it either way

lyric mountain
#

at least not if u need to store more than 2 bools

ancient nova
#

and I doubt I'll have to change it

#

so far enmap is doing fine

lyric mountain
#

enmap

#

please tell me ur not using enmap as a full-job database

wheat mesa
#

I’m just going to wait for the day that putting off all the improvements to your code “because it works” bites you in the ass

sudden geyser
#

that thing is still maintained?

ancient nova
#

I am 😔

lyric mountain
#

but using it as a database is blasphemy

ancient nova
#

why?

lyric mountain
#

because it's a cache

#

it's not meant to replace a full database

wheat mesa
#

Cache != database

#

You could use at as a caching layer on top of a database, but caches are in memory stores

lyric mountain
#

both enmap and redis are meant to be used like waffle said, in memory

sudden geyser
#

But it supports persistence via sqlite

ancient nova
#

yeah it's using a physical sqlite file

lyric mountain
#

tho I'd say nowadays having a intermediary caching database is kinda useless unless u got many clusters

ancient nova
#

so far it works fine

lyric mountain
ancient nova
#

no need to learn SQL directly

lyric mountain
#

...

#

easier for simple things, you'll miss sql when u need high performance and flexibility

ancient nova
#

of course though I take the settings on boot and put them in the message property

#

so doing message.settings is basically like cache

drifting cairn
#

respond to the interaction lol

ancient nova
#

and its exclusive for each guild so I don't have to deal with any slowness

#

same with warns

lyric mountain
ember ore
lyric mountain
#

and for raw sql, you could half that time

#

no joke

ancient nova
#

isn't enmap just literally sql under the hood

drifting cairn
#

so reply to the interaction instead of sending it directly into the channel

sudden geyser
#

yes

ancient nova
#

just makes it easier by using premade functions

pale vessel
#

Defer it first, I'm sure converting pdf to text takes time

lyric mountain
sudden geyser
#

I personally don't see what's wrong with using Enmap as a simple key-value database.

lyric mountain
#

you lose freedom when u need to do highly customized queries

sudden geyser
#

Writing queries in SQL is already a nightmare

lyric mountain
#

only if ur structure is bad

drifting cairn
#

any error?

ancient nova
sudden geyser
#

oh no

ancient nova
#

I basically store the key as whatever I want and pass the entire whole json as the value

#

then I just convert it back to json whenever I need it

#

it works well

drifting cairn
#

try doing what flaze said, just defer it first, then edit the reply

#

yw

#

what about it isnt working

#

i have a question for you

#

are you new to javascript or something

#

alr then this makes sense

spark flint
#

should probably learn js before making the bot sus

#

would help

drifting cairn
#

yea

#

what they said

spark flint
#

a bot is very different to react

sharp geyser
#

while they could learn js and should

spark flint
#
sharp geyser
#

tell emm at least why it isnt working

spark flint
#

.then({files: [{ attachment: "output.pdf" }]})

#

?

#
interaction.reply({files: [{ attachment: "output.pdf" }]})
#

why defer the reply and then do .then()

#

i'd only recommend deferring reply when doing something that make take time to reply

ancient nova
#

is this command good enough?

spark flint
#

add spaces between commands

#

theres no space sobby

pale vessel
drifting cairn
#

1st off defer the interaction before you execute all your code not after you've executed it all because thats dum dum, remove the .then from it as well because yes. Once you get to the part where the pdf has been created, use the .editReply function and then do what you did before, pass the file in it and then booms_duck_shrug

lyric mountain
spark flint
#
await interaction.deferReply()

// do the pdf stuff

const attachment = new MessageAttachment(<whatever>, `file.pdf`)
await interaction.editReply({ files:[attachment] })```
#

something like that

#

not sure how the pdf is returned?

ancient nova
#

wdym there's a coma

spark flint
#

command, command, command looks better than command,command,command

ancient nova
#

there is a space 💀

#

my phones font is just buggin

spark flint
#

ah

#

was gonna say kek

ancient nova
lyric mountain
#

preferrably, interrupt ur highlight after each command

#

like, this, see

ancient nova
#

I do that as well 😔

drifting cairn
ancient nova
#

my phones font does ruin everything lmao

pale vessel
drifting cairn
#

yes

#

what flaze quoted

#

then make it async

#

lol

spark flint
#

why can't you use await kek

#

make it async then

drifting cairn
#

but?