#development

1 messages · Page 1843 of 1

earnest phoenix
#

it hasn't been updated to the current api version ti seems

solemn latch
#

Does anyone know how to do presets to fill in fields in JS?
IE: I have like 4-5 buttons that when I click should fill out some fields.
My current plan is just to have a map of objects that the key's will be the buttons ID and fill out the fields with that data.
I dont think thats the cleanest solution though.

modest maple
#

any frontend framework?

quaint wasp
#

umm

#

well.. my bot has administrator permission

#

and every other one

#

but says it has no perms of changing nicknames

quartz kindle
#

is the bot role above the role of the member you want to change?

quaint wasp
#

yea

#

wait never mind its equal to it

tulip ledge
#

Is it possible to use an array of strings (which originates from the keys of an object) as a type? So that the type is one of those strings eg

[“apple”, “pear”] into type = “apple” | “pear”

sudden geyser
#

sounds like you're trying to mix dynamic typing with static typing

tulip ledge
#

I guess

#

Is it possible tho?

#

I have a json file with itemnames and id’s

#

And I don’t want to add a new string to the itemname type every time I add a new item

earnest phoenix
#

cant you just import the stuff from the json file as a type?

tulip ledge
#

No

#

As they are objects not strings

quartz kindle
#

if the array has a type, yes

#

if it doesnt, then no afaik

signal estuary
#

I want to send a message when a user does something on a website. For example clicking a button a bot is sending a message to a discord server. I dont have a webserver and dont know at all how to it.

digital ibex
#

when the button is clicked, just make an api req

balmy sierra
#

Hello guys, how can I update my bot code on top.gg?

signal estuary
digital ibex
#

i dont even know what language ur using

signal estuary
earnest phoenix
#

They could also make their own api that runs alongside their bot and send a message when an endpoint is hit

#

Would be a lot easier

digital ibex
#

it wont for him, it'd be another 10 tasks

amber thistle
#

so im making a api for my users to upload their sever count to my dbl, but im afraid of malicious users that send 100 request every minute, so i was wondering if is there a way to like blacklist a ip or something so that my backend does not receive the request

i know i can do something like

app.post("/api/bot/servers", async (req,res) => {
 if(blacklist.includes(req.bodyID)) return res.json({ success: false, msg: "you have been rate limited" })
})

but my backend will still be able to received their request

sudden geyser
#

You could use debouncing behavior by adding a time gap between requests and restarting it if a request is sent in that time period.

#

But that's generally inefficient.

quartz kindle
#

if you want to block something before it reaches your node.js server, you have to block it elsewhere

#

for example in nginx, if you use it

#

or iptables

#

on linux you could even configure fail2ban for that

marble juniper
#

just Implement ratelimits

#

you can set ratelimits per ip and a global ratelimit

#

using something like express-rate-limit

lyric mountain
#

I think he want to block before reaching the api

flat iron
#

do i have to wait for my bot to be approved to add in posting stats

lyric mountain
#

yes

flat iron
#

okay thanks

unkempt thorn
#

Need commands for bot plz

solemn latch
unkempt thorn
lament rock
#

What do you want your bot's theme to be? Music? Moderation?

unkempt thorn
#

Yes

lament rock
#

Welp. Then look into integrating basic commands from the categories you want

#

Then work from there

valid frigate
#

what's the best way to return a static list of commands in golang? currently i have code that looks like this

func GetCommandList() []api.Command {
    return []api.Command{
        &HelpCommand{},
                ...
    }
}```
but i was wondering if anyone else does it differently
inner fulcrum
#

wait if i need to fetch the everyone role by name it should be "Everyone" or "everyone"?

proper bolt
#

you can just use the guild id

#

as the role id

inner fulcrum
#

;-;

#

ok

proper bolt
#

<@&264445053596991498>

inner fulcrum
#

hm

proper bolt
#

why are you fetching it

inner fulcrum
#

idk i was testing out things lol

low bone
# inner fulcrum wait if i need to fetch the everyone role by name it should be "Everyone" or "ev...

if you use djs
and want to get the everyone role manager so u can edit the permissions for it

https://discord.js.org/#/docs/main/stable/class/RoleManager?scrollTo=everyone

inner fulcrum
#

kkk

earnest phoenix
next eagle
#

How many of y'all use Node version 13.x?

#

and how much different it is from Node version 12.x?

earnest phoenix
#

Why node v13

#

Node v16 is the poggest version

next eagle
next eagle
earnest phoenix
#

Yea it adds cool stuff

next eagle
earnest phoenix
#

v16

#

cause its the latest stable

next eagle
vale garden
#

hi

radiant kraken
#

hi

vale garden
#

is it possible to get the message to which a user replied?

#

from the reply message itself

vivid fulcrum
#

no

#

you have two options and none of them are viable

#

wait nvm

#

i misread what you're asking

#

if you want to get the message the user replied to, totally possible

vale garden
#

i dont see any attributes or functions

proper bolt
#

a help command or something?

slender thistle
#

iirc

#

Cbf to check the docs KEKW

hushed plank
#

im not able to search my bot on the search bar, how can i?

earnest phoenix
#
let gg = client.guilds.cache.get("819932711665401856");
    if(!gg) return;
    if(!gg.member(message.author).roles.cache.has("871417011685720174")) return
#

Why i get member is not function error

#

I am using v13

vivid fulcrum
#

because it isn't

lament rock
#

They removed that function

#

You need to get the member from the member cache

valid frigate
earnest phoenix
summer torrent
#

guild.members.cache.get

lament rock
#

GuildMemberManager.cache.get

proper bolt
earnest phoenix
#

guild.members.cache.get(message.author).roles.cache.has ?

#

Okay i did thanks

valid frigate
#

interesting

proper bolt
#

not sure if its the best way to do it but its the way i did

valid frigate
#

thats definitely an approach i should consider

#

scuffed code LOL

#

i dont do discord bots much so this is all i came up with

proper bolt
#

yea that looks pretty good

#

maybe make it a common struct like Command

#

since they will all be the same structure

valid frigate
#

o yeah it implements command

#

yeeeeeeeeeap

hot star
#

Y they changed " ` " in mobile

#

It's looks so bad

proper bolt
valid frigate
#

css issue i guess

hot star
#

It's only looks good on desktop now

proper bolt
#

test

hot star
#

Before that it's was same in mobile also

#

See

#

So bad

valid frigate
#

go is weird because no generics n shit but i hear thats changing soon

proper bolt
valid frigate
#

bout time

hot star
valid frigate
#

huuuuuuuh are you talking about yo this thing

#

yeah

#

not your fault

proper bolt
#

the only other thing id like would be ternary statements

hot star
valid frigate
#

rofl id be down for that too

hot star
#

What you guys use in your bot?

vale garden
#

thanks

valid frigate
#

well i recently started using go

#

migrated from rust since async traits are funny

#

yeah yeah you can fix with a macro but id rather wait for it to come into nightly channel at least

hot star
#

I am leaving it as it is

#

Not destroying my brain today trying to figure it out

valid frigate
#

what used to bother me a lot was circular import errors in go but as it turns out that only comes as a result of poor package structure supposedly

hot star
proper bolt
#

yea you need to split up code a lot more

valid frigate
#

i mean the design choice kinda makes sense

#

and i did end up sorting things around

#

so maybe...

#

but stack overflow nerds say otherwise

inner fulcrum
#

me when

eternal elbow
#

How can I go about the "remember me" option? (Normally I was using express-session but I need to make a system with tokens)

inner fulcrum
#

the latest version or above 8.9.1

#

nothing is mentioned in there

#

;-;

#

nvm i got it lol

mild agate
#

can someone link me to <t:1628836884126> docs?

boreal iron
shrewd hazel
#

Have everyone thought of backup server just incase the electricy goes down or problem accured on your network

near stratus
shrewd hazel
#

So when the main server die the backup server that have it own battery will turn on and the alt server is just for like !emergency where it tell why the bot off

#

Just so the user feel that no, the bot is not abandoned

near stratus
#

why would I need a backup server

shrewd hazel
#

Incase electricity die if you live in not so rich country

near stratus
#

*hosted

shrewd hazel
#

Or like a PI cluster so if one PI broken

shrewd hazel
near stratus
shrewd hazel
#

I host my bot myself

#

Since its free and i can control the electricy use and also im in full control

#

Also as security things so i can brag in desc how user data in encrypted for no reason

thorny arch
#

i dont host my bot myself

#

its a pain

#

i dont keep my pc on all the time

shrewd hazel
#

Well not as free...

thorny arch
#

and even if i do host it myself it has a very high ping

shrewd hazel
thorny arch
shrewd hazel
#

No

thorny arch
#

oh ok

shrewd hazel
#

But i use mobile data

thorny arch
#

but still id rather u go for a hosting service

shrewd hazel
#

@thorny arch i host on tablets >:D

thorny arch
#

bruh

shrewd hazel
#

And hosting there is probably better than pc (:))

cold ruin
#

what do i have to do

#

im using javascript

cold ruin
thorny arch
#

@shrewd hazel u have a credit card?

shrewd hazel
#

No... Im not legally be able to have one

thorny arch
#

understandable

long crow
#

Can you give me one?

thorny arch
#

no

long crow
#

Sad

thorny arch
#

i dont have one either

cold ruin
cold ruin
#

anyways, can someone help me with this

thorny arch
#

sry man cant help with java script

thorny arch
#

thats what i use

thorny arch
#

k

cold ruin
#

heroku kinda bad

#

but if i put card

thorny arch
#

hmmm

cold ruin
#

its fine

thorny arch
#

oh

#

k

thorny arch
shrewd hazel
thorny arch
#

huh

shrewd hazel
#

LoL

thorny arch
#

i am confusion

shrewd hazel
#

Discord.pyjs

shrewd hazel
cold ruin
#

someone please help

#

please stop talking here

#

your messages flood my error :(

thorny arch
#

maybe post the part of the code that is giving the error instead of just the error code

rocky hearth
#

For seo, the content should be around 1500 words. So would it affect negatively if i duplicate a para multiple times and make the text size of 0.1px (not visible)

crimson kindle
cold ruin
#

fbi is knoking at door

#

quick

crimson kindle
cold ruin
#

wdym

#
const { AutoPoster } = require('topgg-autoposter')

const ap = AutoPoster(process.env.TOPTOKEN, client)

ap.on('posted', () => {
  console.log('Posted stats to Top.gg!')
})``` this is waht i have
cold ruin
#

im trying to show server count

cold ruin
crimson kindle
#

retype the code

cold ruin
#

how will that change anything

crimson kindle
#

it always work

cold ruin
#

let me check again

cold ruin
crimson kindle
cold ruin
#

what with this

#

same error again

#

i tried regenning the token

earnest phoenix
quaint wasp
#

Whats the rate limit at which you can change a channel name?

#

ping in replies...

earnest phoenix
#

@quaint wasp most rate limits are 5 - 30 seconds so use 30 seconds just to be safe

mild agate
#

can /cmds have dash in name (-)?

pale vessel
#

No, only underscores

earnest phoenix
#

is it possible to have a streaming on twitch activity while keeping the mobile presence?

quaint wasp
#

no

#

well

#

I mean if you wanna keep the phone icon

#

no

#

But if in activity, then yes

earnest phoenix
#

ah nevermind then, i def wonna keep the mobile icon

quaint wasp
#

Since you can only have one icon at ones

#

alright

earnest phoenix
#

yeah, i was trying to have it so the presence was mobile but the activity was a button to the twitch profile like the streaming status has

pale vessel
#

That's nit possible since it would have the streaming icon

#

not*

earnest phoenix
#

i kinda figured so

quaint wasp
#

ye

spark breach
#

does anyone know how to get find a category by name instead of ID? I've been trying to figure it out and I can't seem to. And on google I keep finding solutions that require an ID to work

near stratus
spark breach
#

alr ty!

near stratus
#

np

errant flax
#

how tf did u even do that vvGFXRT_flushedspin

novel snow
#

Hey uh, This is like another thing;

So how in gods name would I give someone the ability to make a custom embed?
Because I don't want to make a entire if chain within the database to check if a title or a description was set for the embed, So say for example the title of the embed in the database is as '' that it won't add a title

#

But I don't want to make a couple hundred thousand char long if chain to test every possible match up

errant flax
#

store it in the db as a object?

novel snow
#

What do you mean precisely?

errant flax
#

since discord.js accepts raw data

novel snow
#

Okay so here;

errant flax
#
<MessageEmbed>.toJSON()

?

novel snow
#
if (!db.get(`Guild-${member.guild.id}`)) {
    db.set(`Guild-${member.guild.id}.welcomeChannel`, 'None');
    db.set(`Guild-${member.guild.id}.embed.text`, 'Placeholder Text');
    db.set(`Guild-${member.guild.id}.embed.enabled`, 'False');
    db.set(`Guild-${member.guild.id}.embed.color`, '#f3ad4c');
    db.set(`Guild-${member.guild.id}.embed.title`, 'Placeholder Text');
    db.set(`Guild-${member.guild.id}.embed.URL`, 'None');
    db.set(`Guild-${member.guild.id}.embed.author`, 'None');
    db.set(
      `Guild-${member.guild.id}.embed.description`,
      'Placeholder Description'
    );
    db.set(
      `Guild-${member.guild.id}.embed.thumbnail`,
      'https://cdn.discordapp.com/icons/839309957908004894/a_a77505a0c6821f7a6b02c4ffb0bacb91.png'
    );
    db.set(`Guild-${member.guild.id}.embed.field`, 'None');
    db.set(
      `Guild-${member.guild.id}.embed.image`,
      'https://cdn.discordapp.com/icons/839309957908004894/a_a77505a0c6821f7a6b02c4ffb0bacb91.png'
    );
    db.set(`Guild-${member.guild.id}.embed.footer`, 'Placeholder Footer Text');
  }```

So say I get all of this, How would it just not add in a embed piece if there is no value attached, Like I can change the `'None'` values
boreal iron
#

Escape the object and save it as string in your database aka. serialization

novel snow
#

Hmmm

#

Lemme actually try that out

#

Just confused how I would execute that at first but let me try

#

Does anyone have a example I could try? Because I don't even know how to start working on just making the embed itself then

boreal iron
#

Then parse the serialized string in a try-catch block to check if it’s a valid object

#

console.log your embed and you will see the structure

#

Take its var and serialize it

novel snow
#

Okay so say I get them to use a command to make it at first-

#

AAAAA

boreal iron
#

Serialize / deserialize objects is what u need

novel snow
#

I am confused I don't know how I would handle people adding in a title or a description and then removing it or adding it

boreal iron
#

let embed = embed builder…
embed.title = title
embed.url = whatever

#

It’s an object

#

You can access its properties however you want

#

Adding them, deleting them, changing them

#

if(title) embed.title = title

#

That’s why I said just create a random embed for testing and log it to your console

#

To see it’s structure

novel snow
#

I'll try that yeah

boreal iron
#

(docs will show its structure, too of course)

novel snow
#

Yeah

#

I am just overwhelmed at how I am going to make this rn

#

WAIT

#

AH

#

I DIDN"T KNOW YOU COULD DO;

#

embed.setTitle(thing)

AND THEN SOMEWHERE ELSE

embed.setDescription(thing2)```
#

I

#

YES

#

Okay byeeeee

#

That makes things so much easier

#

Like I was planning this entire thing out

#

My ass is dumb sometimes

#

I can't believe it

boreal iron
#

Well you can also use the methods

#

If you pass null as argument it should not set a title, description etc.

earnest phoenix
#

i use objects for embeds

#

i like my embeds pure

boreal iron
#

Keep in mind using the methods required embed to be a valid structure

#

Yeee

#

That’s always easier to work with

meager lily
#

@boreal iron hi pleas credits

boreal iron
#

But he doesn’t seem to know okeh

#

?

cold ruin
#

can someone help me design my top.gg bot page

spark breach
eternal osprey
#

hey guys!js if(args1[0][1] == 'spotify'){ let tokens = fs.readFileSync('./codes.txt', 'utf8'); message.delete() const links4 = tokens.split('\n'); const index4 = tokens.indexOf(`${args1[0][2]}`); if (index4 > -1) { links4.splice(index4, 1); console.log(links4) const newlinks2 = links4.join("\n") fs.writeFileSync('./codes.txt', newlinks2);
why is this little snippet not removing the line from the file? (The 'index4')

meager lily
#

@boreal iron hi pleas credits

boreal iron
#

🤦‍♂️

#

@meager lily hi pleas credits

earnest phoenix
cold ruin
#

idk any css

cold ruin
#

can you give code if possible?

earnest phoenix
#

add me to the team

cold ruin
#

like basic code

#

for background and float

earnest phoenix
#

.entity-header__image {
animation: float 5s ease-in-out infinite;
}

#

thats for float

cold ruin
#

okay

cold ruin
earnest phoenix
#

yes

cold ruin
#

it doesnt

#

work

#

let me try refreshing

eternal osprey
cold ruin
#

nope not working

cold ruin
# earnest phoenix yes
<style>
.entity-header__image {
    animation: float 5s ease-in-out infinite;
}
</style>``` this is what i have
#

in the beginning of my description

boreal iron
#

Changing CSS properties usually requires to clear your browser cache

cold ruin
#

can you check if its floating for you?

#

my bots logo

boreal iron
cold ruin
#

right

boreal iron
#

CTRL + F5 or SHIFT + F5

cold ruin
#

id hve to sign in again on all websites

boreal iron
#

Depends on the browser

#

Cache !== cookies

cold ruin
#

nope still isnt

#

i tried

pale vessel
earnest phoenix
#

hello how can wee add website in top.gg description

boreal iron
#

Nope damn cloudfare caches topgg

rose warren
boreal iron
cold ruin
#

what should i do now?

rose warren
pale vessel
boreal iron
#

It should

cold ruin
#

it doesnt

#

i tried

pale vessel
#

I c

rose warren
#

I find clearing cache and reloading a couple of times works for me.

cold ruin
#

i mean i did do that

pale vessel
#

Since you'd have to wait until it's refreshed/purge the cache manually

boreal iron
#

But doesn’t always work for topgg… sometimes clearing the cache will result in an even older version of the website

earnest phoenix
#
@keyframes float {
  0% {
    box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
    -webkit-transform: translatey(0px);
            transform: translatey(0px);
  }
  50% {
    box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
    -webkit-transform: translatey(-30px);
            transform: translatey(-30px);
  }
  100% {
    box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
    -webkit-transform: translatey(0px);
            transform: translatey(0px);
  }
}
#

@cold ruin

boreal iron
#

It’s so ridiculous

earnest phoenix
#

forgot to give you the keyframs lol

rose warren
#

Then has your page saved? You could always right click on the long description and inspect element to see if the CSS is there. If it is, then your code is wrong.

cold ruin
#

do i have to pu tthis in sstyle tag

rose warren
cold ruin
#

so i have to put this in the style tag?

rose warren
#

Yes

cold ruin
#

after the .entity-hear__image ?

rose warren
#

Before

cold ruin
#

man i need to go learn css

rose warren
#

Although idk if it really makes a difference. I just always declare keyframes before.

cold ruin
#

yep works

#

how can i make the logo rounded ?

earnest phoenix
#
    border-radius: 50% !important;```
rose warren
#

border-radius: 50% on the logo's class

cold ruin
#

ok

earnest phoenix
#

and also learn css.

#

won't spoon feed no more

cold ruin
#

yep works

#

thanks

earnest phoenix
#

np.

cold ruin
#

its annoying to spoonfeed

#

i spponfeed people c++

cold ruin
#

this changes the whole page's bg right

earnest phoenix
#

no.

cold ruin
#

then?

rose warren
#

No that's your card in search results / page background on beta mode.

cold ruin
#

oh

#

so id have to use html/css right?

earnest phoenix
#

no ;-;

cold ruin
#

then

#

how will i change it

rose warren
#

Yes for the page background you need css

cold ruin
#

i want a theme

cold ruin
#

ill figure that out myself

earnest phoenix
#

for your pages bg yes

rose warren
#

Yeah that's easy to find online

cold ruin
#

🥄

cedar stag
#

@cold ruin If you find the option on the background, let me know, I found an html code but it did not work

cedar stag
#

the description?

cold ruin
#

for the page's bg youd have to use css/html as mentioned by mac

cold ruin
#

then click SHIFT + F5

#

after saving

rose warren
#

It's literally the most basic CSS task. You'll find lots of help online for setting a page background in CSS.

cedar stag
#

you mean something like this? that's what i have in my bot

cold ruin
#

no

#

i mean the whole page

cedar stag
#

. -. xD

cedar stag
cold ruin
#

is this correct

novel snow
#

Am I stupid or am I blind or does this just not work? Like all of the values are defined but it doesn't change them because of the if (!thing === 'None") statement

pale vessel
#

Because you turned them to booleans

novel snow
#

I am stoopid ples explain

pale vessel
#

false/true === "None" will never be true

cold ruin
#

ill try

boreal iron
#

if(!title) …

novel snow
#

Because I am stupid

#

As you can see

pale vessel
#

Remove the negation?

#

And use !== instead

signal estuary
#

I want to make a cooldown for a user like the bot returns in the code if the user is still on cooldown. But the timer runs well but it runs further in the negative area -1, -2, -3,...:

const { RichEmbed, Collection } = require("discord.js")
const cooldown = new Collection();
const { convertMS } = require("discordutility");
let time = 4000;
        if (cooldown.has(msg.author.id)) { // if user on cooldown

            const timeLeft = cooldown.get(msg.author.id) - Date.now();
            const converted = convertMS(timeLeft); // Changes the ms to time
            //add message here if code  
            console.log("cooldown for: " + timeLeft)
        } else {

            cooldown.set(msg.author.id, Date.now() + time); // <- saves the time 
            setTimeout(() => cooldown.delete(), time)

        }
novel snow
#

Lemme try

cold ruin
#

@cedar stag it doesnt

#

i gtg

#

ill giure it out later

#

figure

#

and tell you

cedar stag
#

ok

boreal iron
# novel snow Lemme try

Why would u even save none as string in your database?
Save the entities as null and check if(field) …

#

or if(!field) to check if they aren’t set.
Whatever…

eternal osprey
#

since when does discord have buttons in v12?

earnest phoenix
eternal osprey
#

oops okay

#
client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    if (interaction.commandName === '!setup') {
        const row = new MessageActionRow()
            .addComponents(
                // ...
            );

      let embed1 = new Discord.MessageEmbed()
      .setColor("#0000FF")
      .setAuthor('FoodFactory Tickets' , `${client.user.displayAvatarURL()}`)
      .setDescription(`Réagissez avec le bouton pour créer un ticket.`)
      .setFooter("FoodFactory Services")
      .setTimestamp()

        await interaction.reply({ephemeral: true, embeds: [embed1], components: [row] });
        console.log(interaction.user.id);
    }
});

i have this little code. How would i now console.log() the user who clicked the button?

#

ah tthere is a collector nvm

earnest phoenix
eternal osprey
earnest phoenix
eternal osprey
#

inside the same handler right? Just like this (edited the code block above)

earnest phoenix
#

How do i send bot error to specific channel

#

I tried error event but didnt work

boreal iron
eternal osprey
#

How do i check if a certain button was used?

#

Like a button named testrow for example

pale vessel
#

Check the button ID

boreal iron
#

Or loop through the option‘s data and check if the element name matches your hopefully unique name

#

(to bring up another way)

errant flax
#

is it ok to constantly update a data in mongodb?

lyric mountain
#

how constantly?

errant flax
#

in a for loop ig?

lyric mountain
#

...I meant frequency

sudden geyser
#

Rather, what are you updating?

#

and how frequently

errant flax
#

it will only update if a run a command

lyric mountain
#

so it's not "constantly" at all

errant flax
#

no?

#

oh just realized i said "constantly"

lyric mountain
#

lul

#

yeah it's fine to do what u want

errant flax
#

k thx danceydance

quaint wasp
#

hello

#

I have added the logs-..... stuff to the database (using my shitty brain) and when I check for it, the promise returns false..

#

when its defenetly in there since the db.lenght shows 1...

#

ping in replies

lyric mountain
#

hm, did you console.log to see what was returned by the db?

quaint wasp
#

it returned "< pending >" for some reason

#

:/

#

to put an id into the database I did this

marsh bluff
#

you need to await promises

quaint wasp
#

(Obviusly after I figure this out I will add more error handlers like if the id has letters in it and ect)

quaint wasp
drifting flower
#

im using discordpy
when i restart the bot, all the cooldowns reset
how do i prevent this from happening
i need to restart the bot to update it

pale vessel
#

Keep your cooldowns inside a database and fetch your database on startup

pale vessel
#

Store the timestamps

drifting flower
boreal iron
#

Doesn’t matter you can convert string to timestamps and vise versa

#

(as long as they are valid of course) okeh

#

Saving them as INT consumes less storage even if that won’t matter at all

quaint wasp
#

returns not setted up

marsh bluff
#

If you fetch something from db, it most likely is an object, not a boolean

quaint wasp
#

but I just need the promise

marsh bluff
#

better check like if(logs) { ... }

quaint wasp
#

oh ok

boreal iron
#

You’re checking if your string is a boolean true which will always be false

quaint wasp
#

oh...

#

btw ping in replies

boreal iron
#

const muteRole = await …

const muteYesNo = (muteRole) ? "Set up" : "Not set up";

quaint wasp
#

what does ? stand for?

boreal iron
#

It’s a ternary operator

#

if(true) true else false
(true) ? true : false

#

aka. shorthand if statements

signal estuary
#

I have a basic webserver:

const http = require('http');
const port = 3000
const fs = require('fs');
// const express = require("express");
// const app = express();
const server = http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/html' })
    fs.readFile('index.html', 'utf8', function (err, data) {
        if (err) {
            resizeBy.writeHead(404)
            res.write('Error: File not found')
        } else {
            // res.write(data)
            res.write('Site loaded')
            res.end()
        }
        // res.end()
    })
})

server.listen(port, function (error) {
    if (error) {
        console.error(error)
    } else {
        console.log('listening on port ' + port)
    }
})

When someone joins the site, an API request should be made so my bot sends a message

quaint wasp
#

ok

tired panther
signal estuary
tired panther
signal estuary
signal estuary
tired panther
signal estuary
cinder stratus
#

Use webhook lol

#

As he said

#

Not a big deal

signal estuary
cinder stratus
split hazel
#

quite a big deal for someone that doesn't have a clue lol

cold ruin
#

guys how to make a theme

#

on bot page

cinder stratus
#

Css

cold ruin
#

i tried to do it

cinder stratus
cold ruin
#

oh

tired panther
#
const Discord = require("discord.js")
const webhook = new Discord.WebhookClient({id: ID, token: TOKEN})

webhook.send("User on Page")
signal estuary
#

in the webserver's code?

tired panther
tired panther
signal estuary
tired panther
signal estuary
#

oh wait

signal estuary
tired panther
#

Copy webhook url , the last part is the token and the one before: the id

signal estuary
cinder stratus
#

Can you show how you are passing it?

tired panther
#

And which version of djs?

signal estuary
# cinder stratus Can you show how you are passing it?
const http = require('http');
const port = 3000
const fs = require('fs');
const Discord = require("discord.js")
const webhook = new Discord.WebhookClient({ id: '875723949911203840', token: 'heres the token' })

// const express = require("express");
// const app = express();
const server = http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/html' })
    fs.readFile('index.html', 'utf8', function (err, data) {
        if (err) {
            resizeBy.writeHead(404)
            res.write('Error: File not found')
        } else {
            // res.write(data)
            res.write('Site loaded')
            webhook.send("User on Page")
            res.end()
        }
        // res.end()
    })
})

server.listen(port, function (error) {
    if (error) {
        console.error(error)
    } else {
        console.log('listening on port ' + port)
    }
})
cinder stratus
#

You are missing the token.

signal estuary
signal estuary
cinder stratus
#

here goes the token replace with your webhook token

signal estuary
cinder stratus
#

Oo

tired panther
hexed sedge
#

Just finished uploading all my docs and guides to gitbook, feeling good

signal estuary
quaint wasp
#

so this just returns a "Provide a valid ID" every time... even if I actiually put a correct id..

#

wait I changed <, and > here, but even when they were different same thing happened

#

ping in repllies

boreal iron
#

< 19 or > 17

hexed sedge
quaint wasp
quaint wasp
hexed sedge
#
  • Id recommend you to update to d.js v13
#

You can easily get a channel id with slash commands

hexed sedge
#

Why are you checking if the id has more than 19 characters or whatever

#

Id recommend to just remove those two lines

quaint wasp
#

alright..

hollow depot
#

you could try instead of checking if args[0] is a number, just checking if there is a channel with that id

low bone
hollow depot
low bone
#

Js will convert the id to number

#

Which will always be invalid in ur case

quaint wasp
#

oh

low bone
#

Use channelid.length

quaint wasp
low bone
quaint wasp
#

true

#

well

#

I did this

#

        if(!message.member.hasPermission('ADMINISTRATOR')) {
          return message.channel.send('Dude, you must have admin perms or else what are you even thinking?')
        } 

        const channell = args[0]
        if(!channell) return message.reply('Please specify a channel!')
        if(isNaN(channell)) return message.channel.send('channel must be an ID.')

        const chan = message.guild.channels.cache.get(channell)

        if(!chan) return message.reply('I could not find that channel anywhere')

        db.set(`logs-${message.guild.id}`, chan)
        message.channel.send('Succesfuly setted up logs channel!')```
And it works
low bone
#

Yep that should be okay

boreal iron
#

You got your answer already.

cinder stratus
#

Smh

placid python
#

Sus

boreal iron
#

If you wanna send a request to Discord then do it or include a library, init a client and let it do the job for you.

low bone
#

Just curious, since you included express why not use directly?

signal estuary
low bone
#

XD, why not just see small tutorial for express instead of building a web server from scratch

#

Then use discord.js package to send message
You can use webhook as well

solemn latch
#

honestly "I dont know how to" is never a valid thing to say when developing.
If you don't know how to use a library, learn.

being a developer is a majority about learning, If you are not learning, you are not developing imo.

earnest phoenix
#

! prefix is illegal

hollow depot
#

agreed

signal estuary
solemn latch
#

what a convenient time to get pinged

earnest phoenix
signal estuary
# earnest phoenix ???what

wrong question bruh:
Here is the right one:
I have here a basic webserver:
the file is called app.js and is in the folder "webserver"

const http = require('http');
const port = 3000
const fs = require('fs');
const Discord = require("discord.js")


// const express = require("express");
// const app = express();
const server = http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/html' })
    fs.readFile('index.html', 'utf8', function (err, data) {
        if (err) {
            resizeBy.writeHead(404)
            res.write('Error: File not found')
        } else {
            // res.write(data)
            res.write('Site loaded')
            res.end()
        }
        // res.end()
    })
})

server.listen(port, function (error) {
    if (error) {
        console.error(error)
    } else {
        console.log('listening on port ' + port)
    }
})

The bot is in the same folder than the "webserver"
How can I interact with the bot when the site is loade?
This code runs when someone loads the site:

        } else {
            // res.write(data)
            res.write('Site loaded')
            res.end()
        }
earnest phoenix
signal estuary
earnest phoenix
#

yeah

#

and then require() it in your server file

signal estuary
# earnest phoenix yeah

to be honest I dont know really how to export the user to the webserver 🥴
Would be very nice if you lead me

signal estuary
earnest phoenix
#

where is your bot code stored in

#

index.js?

signal estuary
#
let indexjs = require ('./DiscordBot/index.js');

like this?

earnest phoenix
#

you're exporting the client so name the variable client as well ¯\_(ツ)_/¯

earnest phoenix
#

or bot

#

whatever you name your variable in index.js

cold ruin
signal estuary
earnest phoenix
#

export the client from index.js

#

then your server file can interact with the bot

tulip ledge
#

I ran npm install

boreal iron
#

wut 13.1 (o.O )

rose warren
#

Yes. It has context interactions.

tulip ledge
#

but

#

how do I fix? x)

boreal iron
#

Oh, alright looks like I'm not up to date

#

I think I've a similar issue these days.
Just guessing but try to restart your editor and make sure to exit the process 100%

rose warren
#

Try uninstalling and reinstalling djs maybe?

tulip ledge
#

how do u reinstall a pakcage?

#

also, I just pulled this code from github

rose warren
#

npm uninstall discord.js

tulip ledge
#

oh silly me

rose warren
#

Then npm i discord.js

tulip ledge
#

nope

#

still

#

same issue

boreal iron
#

Then try this:

Just guessing but try to restart your editor and make sure to exit the process 100%

tulip ledge
#

kekw moment

#

that fixed it

boreal iron
tulip ledge
#

oh my vsc just crashed

#

😐

boreal iron
#

Use Notepad++, that hasn't crashed the last 14 years

#

at least for me

rose warren
#

Vsc has never crashed on me

tulip ledge
#

Since when do collections not have an array property anymore?

#

Property 'array' does not exist on type 'Collection<string, ApplicationCommand<{}>>'.

boreal iron
#

Yeah was wondering about that one, too

#

.toArray() is the method

tulip ledge
#

I literally just returned from vacation and pulled my code from github

#

lul

#

it used to work

#

Property 'toArray' does not exist on type 'Collection<string, ApplicationCommand<{}>>'.

boreal iron
#

method, not property

#

aka. function

tulip ledge
boreal iron
#

hmm lemme check myself

earnest phoenix
#

.values() ??

boreal iron
#

ahh nvm... .array()

tulip ledge
#

so it is .array?

boreal iron
#

Isn't documented somehow but works for me (o.O )

tulip ledge
#

You know what the weird part is

#

let existingCommands: Collection<Snowflake, ApplicationCommand>;

#

It should say Snowflake

#

not string

boreal iron
#

idk TS

#

MS trash

zealous trellis
#

trying to make my client globally accessible, but it has this type error, Ive never encountered it before.

Anyone got any clues? This is my first time using typescript..

tulip ledge
#

I've never used global

zealous trellis
#

its a default feature in node

#

its accessible in any file

#

oh wait, I might need @types/node

#

since its a node feature

tulip ledge
#

yeah

#

Just found it on stackoverflow B)

zealous trellis
#

same

#

lol

#

hmm

#

wait

#

that didnt fix it

#

:3

#

lovely

tulip ledge
#

same error?

zealous trellis
#

bruh... I might have to literal initialize everything

#
declare global {
  namespace NodeJS {
    interface Global {
      someValue: string;
    }
  }
}

// Assignement works fine now
global.someValue = 'My hovercraft is full of eels';
#

tf

#

ack

tulip ledge
#

thats how ts works

#

in classes

#

you also have to declare all the properties

#
class Something {
  public item: string;
  constructor() {
    this.item = "something";
  }
}
zealous trellis
#

sigh

tulip ledge
#

f

tulip ledge
#

is it possible they removed the .array method in v13?

zealous trellis
#

Im considering just going back to Javascript :L

#

TS is a pain in the ass for no reason

tulip ledge
#

Stick with ts

#

trust me

#

it's way better

zealous trellis
boreal iron
#

It doesn't anymore

tulip ledge
#

bruh$

#

So what would I do now then?

#

Array.from(collection.values())?

boreal iron
#

hmm dunno what u wanna do oldEyes

#

why do you need it to be an array at all?

tulip ledge
#

to loop over it

boreal iron
#

for(const [snowflake, collection] of collection_resolver)

#

that doesn't somehow exist in TS?

tulip ledge
#

I'll just map it

boreal iron
#

that doesn't somehow exist in TS?

#

Yes, no, maybe, maybe not?

tulip ledge
#

No clue

#

I'm too lazy to test it

boreal iron
zealous trellis
#

okay, so since I cant use declare or node's global, how can I make the variable Bot accessible anywhere in any file

tulip ledge
#

by passing it to each file

zealous trellis
#

how?

tulip ledge
#

If you use classes as your commands

boreal iron
#

You're calling your exports somewhere, probably in your main file

zealous trellis
tulip ledge
#

you can do

// Ping.js
class PingCommand extends Command {
  private client: Client;

  constructor(client: Client) {
    super({
      // Command name and stuff
    })
    this.client = client;
  }
  
  run(message) {
    console.log(this.client) // logs your client
  }
}

// index.js
new Command(Bot)
#

u want to prob put the Command in a collection or something

#

then you can use this.client in each command

boreal iron
zealous trellis
zealous trellis
tulip ledge
#

Thats better

near grotto
#

how to grab boost level of a server in discord.js?

tulip ledge
#

I edited the message

#

to make it a bit more clear x)

tulip ledge
#

That's if you use classes tho (my example)

boreal iron
#

In this case async execute(interaction)

zealous trellis
boreal iron
#

Oh... didn't know that one

tulip ledge
#

Typescript is js but strongly typed

#

usually it should still work

sudden geyser
#

You can still use regular JavaScript in TypeScript.

boreal iron
#

damn Microsoft fanboys anywhere these days

tulip ledge
#

I don't use ts cuz it's from microsoft

#

I just like using it

#

Error: connect ECONNREFUSED IP

I can't connect to my mysql server in my VPS how do I fix that again? x)

boreal iron
#

You can't connect to your own hosted server? lmao

tulip ledge
#

shush

boreal iron
#

ECONNREFUSED IP looks like a non-whitelisted IP

tulip ledge
#

I probably have to change the bind address

#

but forgot

#

no the IP is my vps's ip

boreal iron
#

doesn't matter you can bind it to 0.0.0.0

tulip ledge
#

yeah its bound to 127.0.0.1

bleak jungle
#

help meh with a error in my bot pls

boreal iron
bleak jungle
#
 node index.js
Bot made by MR.X and The Ash
Loaded Moderation Bot v2.0
Fontconfig error: Cannot load default config file

/home/runner/Dank-United-Premium/node_modules/enmap/src/index.js:949
      .prepare(
       ^
SqliteError: database disk image is malformed
    at Map.[init] (/home/runner/Dank-United-Premium/node_modules/enmap/src/index.js:949:8)
    at new Enmap (/home/runner/Dank-United-Premium/node_modules/enmap/src/index.js:214:18)
    at Object.<anonymous> (/home/runner/Dank-United-Premium/index.js:75:14)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
exit status 1
 ```
#

pls

boreal iron
#

Not really needed tho if you don't add firewall rules for incoming connection to it anyways, but doesn't matter at all

boreal iron
tulip ledge
#

Error: Host '(Some id idk if I can show it).access.telenet.be' is not allowed to connect to this MySQL server

#

I've never seen this error before

boreal iron
#

Your SQLite file is corrupt

bleak jungle
#

mine?

boreal iron
#

Yeah

bleak jungle
#

..

#

what to do then ;-;

boreal iron
bleak jungle
#

i never went to this problem before ;-;

boreal iron
#

Change your default INPUT policy to DROP and allow connections you want and trust only

tulip ledge
#

Alright

bleak jungle
boreal iron
#

Or block the ports to your MySQL server if you dont wanna change the INPUT policy

#

(DROP them)

bleak jungle
#

..

boreal iron
bleak jungle
#

..

boreal iron
#

Just google if there's a way to fix it

tulip ledge
#

Or

#

could I just change the Host of the user to *?

#

would that work?

boreal iron
#

As long as your firewall doesn't refuse or block requests on that port, automated crawlers will always try to brute force accounts

#

If you use the database locally on that server only, restrict any access from the outsite

tulip ledge
#

I have a dev database and a main database

#

the main is only used on the vps

#

I just set the host of the dev to *?

#

Or is that bad?

outer perch
#

guys, how can I have a timeout for message deletion now on D.JS 13?

boreal iron
rose warren
tulip ledge
boreal iron
#

You could generally DROP incomming connections to the database port

outer perch
tulip ledge
boreal iron
#

sudo iptables -A INPUT -p tcp -m tcp --dport 3306 -j DROP

rose warren
boreal iron
#

As first INBOUND rule

outer perch
tulip ledge
#

yeah I'm really new to this stuff you're just talking chinese to me atm

boreal iron
#

lol

outer perch
boreal iron
#

You should know the risk of hosting an own server without being able to secure it well enough hashflushed

#

The crawlers are continuesly attacking your system trying to brute force the password for all possible account names

spark sage
#

do you know how can i make slash command with live search for option ? like /tenor command or /giphy

boreal iron
#

If you haven't restrict that access it only takes a while until they're in

tulip ledge
#

You have like a documentation or something I can use?

boreal iron
#

I can send u (probably) billions of lines of webserver logs of attackers/crawslers scanning each possible IP every few minutes for weak points

#

A MySQL server responding to the request with INVALID LOGIN data is the total WIN

#

That will cause other script getting into place and trying to brute force that access since it's not secured

tulip ledge
#

Well, I'm not an IT security expert and I don't have money to pay one to secure my stuff I haven't even finished high school yet

boreal iron
#

That might be true and don't get me wrong, but that doesn't protect you from being attacked without your knowledge

tulip ledge
#

I know that but you telling me over and over that people WILL attack me does not help me to solve it lol

boreal iron
#

Not people, but bots, scripts etc.

tulip ledge
#

ok still

#

doesn't help me

boreal iron
#

Well I told you to add a firewall rule in the first place to DROP incoming requests for the port 3306 (default MySQL port)

#

I sent the example above anywhere

tulip ledge
#

And I told you I didn't know how to

hexed sedge
tulip ledge
#

I am currently

boreal iron
#

You just hammer that command into your VPS shell

tulip ledge
#

but I can't find anything

hexed sedge
#

Adding a firewall rule is very easy

tulip ledge
boreal iron
#

after identifying as sudo user

tulip ledge
#

U were talking about inbound rules and shit I thought I had to do other stuff first

boreal iron
#

That's an inbound rule

tulip ledge
#

ok

#

So I did that

boreal iron
#

A rule to drop incoming connections on port 3306

tulip ledge
#

I still want to connect to it tho

boreal iron
#

But it needs to be on top the inbound rules list

proper bolt
#

Run your dev db on your local machine

boreal iron
near grotto
#

does anyone have a bot which adds emoji?

boreal iron
#

You will always be able to connect to it locally, no matter what u write down in the firewall

tulip ledge
proper bolt
#

What

tulip ledge
proper bolt
#

If you host it on your machine you just do localhost:3360 or whatever the port is

tulip ledge
proper bolt
#

They can't block internal stuff

hexed sedge
#

^

proper bolt
#

It doesn't work like that

tulip ledge
#

oh yeah my brain is exploding rn

hexed sedge
#

Plus if you forgot the admin password, just reset it

#

But usually the password is the password behind the router

boreal iron
#

Well if you somehow need to connect to your MySQL server externally then change at least the default port and block the access for the user root

proper bolt
#

Those blocks are in place for port forwarding, where it's exposed on your public ip

tulip ledge
boreal iron
#

You can additionally whitelist your public IP (if you got a static one) for access from it only

tulip ledge
#

And the dev database only contains my discord id and some data that isn't rlly usefull

#

ok but how do I undo the inbound rul then?

#

I'll change the port

boreal iron
#

That doesn't matter, as soon as you got access to the database, SQL injections and other methods will at the end grant you access to the storage and the system

tulip ledge
#

even if the user has practically no privileges?

#

it only has privilages on the dev databse

stark hollow
#

bark

tulip ledge
#

Is there a way to whitelist my IPs? Because I also can't host locally as my parents are divorced and I change pc's every week

boreal iron
tulip ledge
#

You know what I'll do

boreal iron
tulip ledge
#

both

boreal iron
#

The rule I mentioned can be extended.
sudo iptables -A INPUT -p tcp -m tcp --dport 3306 -j DROP
to
sudo iptables -A INPUT -s <your_ip>/32 -p tcp -m tcp --dport 3306 -j ACCEPT

#

That rule would make sense only if the default input policy is DROP

#

That mean you would whitelist single connections only

tulip ledge
#

yeah, as I said

#

I swap pc's

boreal iron
#

Well you can add multiple IPs

#

As well as on the database site

#

User root@localhost

tulip ledge
#

Also, don't IP's change?

boreal iron
#

Or user user@12.34.56.78

#

will allow access from the source IP 12.34.56.78 only

#

If you haven't a static one, then yes sometimes

zealous trellis
#

why does readdirSync not recognize a folder that very obviously exists...

tulip ledge
#

I just checked, I have a dynamic Ip

boreal iron
tulip ledge
#

I'll look into it later, gotta have diner now ty for the help tho

wary flame
zealous trellis
#

that makes no sense

wary flame
#

use require('path').join(__dirname, 'commands') for the path

boreal iron
wary flame
#

to get the path relative to current file

zealous trellis
#

goddamnit why does node have to be so fuckin inconsistent with files like this

#

half the packages recognize /src as the working dir

#

half dont

#

:L

wary flame
#

No

tulip ledge
#

Ok but I can use % in mysql and then whitelist my ips on the firewall?

wary flame
#

It depends on from what dir you start the process

boreal iron
wary flame
#

If you start from src/ working dir is src/. If you start from root working dir is root

boreal iron
#

But at least on one of course

zealous trellis
#

look at this, its stupid... I have to grab the files from ./src/commands but when I require them, I use ./commands

tulip ledge
#

Ok ty

zealous trellis
stable eagle
#

I created a channel with discord.js, when I try to type in it tho it says the message couldn’t get delivered? Why?

zealous trellis
#

the whole point of having a src folder is to build it later on

boreal iron
#

bc require supports relative paths

wary flame
#

that's why you should use absolute paths or build absolute paths by combining __dirname with relative paths

boreal iron
#

readdirSync(__dirname + "/src/...)

zealous trellis
#

I got it working

#

still thats absolutely stupid

#

but oh wells

boreal iron
#

errr no it makes sense if you understand why KEKW

zealous trellis
#

whatever ya say

boreal iron
#

doesn't matter unless you learned something

zealous trellis
#

:|

boreal iron
wicked pivot
#
const JSONSTATS = require('../../../data.json')
const fs = require('fs')
function JSONSAVE() {
    fs.writeFile("./assets/data.json", JSON.stringify(JSONSTATS), (err) => {
        if (err) console.log(err)
    })
}
await delete JSONSTATS[r.user]
await JSONSAVE()
``` not remove why ?
digital ibex
#

:/

boreal iron
#

```language
code
```

rich ledge
#

Ohh

boreal iron
#

```js
// javascript code
```

let whatever = true;
javasriptCode();
long crow
boreal iron
#

At least it's responsive, yaay

#

Your side menu font size is larger then it's width

quartz kindle
#

javasript

boreal iron
#

javasript

What does Tim wanna tell us with this?
Anybody...?

long crow
#

jekyll theme with md weirdsip

vivid fulcrum
#

did anyone work with flutter

#

i need some opinions on it

#

is it worth picking up etc

boreal iron
fickle cypress
boreal iron
# quartz kindle

Damn you search deep until you can find something to complain about, yee? oldEyes

quartz kindle
#

not complain

#

troll

boreal iron
#

aye shame on me

boreal iron
#

life would be boring without trolling

earnest phoenix
#

Whats trolling?

quartz kindle
#

its less fun if its done on purpose tho :^)

boreal iron
#

You will never know if or if not

lyric mountain
#

you can know whether it's trolling or not by looking at deez

boreal iron
#

deez

lyric mountain
boreal iron
#

damn wanted to ask that, too

#

sounds like nuts

#

but wouldn't make much sense in that context

#

but who knows how dirty KuuHaKu's mind is

lyric mountain
earnest phoenix
#

KuuHaKu doesn't have a mind

quartz kindle
#

you have to ask joe

lyric mountain
boreal iron
#

Won't happen again, Sir.

cinder patio
#

for the command pages, you could style it differently, make use of the space on the right