#development

1 messages Ā· Page 1938 of 1

earnest phoenix
#

iirc

lyric mountain
#

if u remove the bot the commands go away with it

neat ingot
#

hmm, idk, my command updater script is basic af šŸ˜„

earnest phoenix
#

When you add it back, the commands stay.

#

o-o

quartz kindle
#

yes

earnest phoenix
#

I've tried why

earnest phoenix
quartz kindle
#

no, guild commands do

earnest phoenix
#

As soon as it joins a server it adds the global commands.

#

if its already been active for 1 hour w/the globals

quartz kindle
#

it doesnt "add"

#

its global

#

it doesnt care about guilds

earnest phoenix
#

it "sets"

#

True

spark flint
#

i still don't get slash commands

earnest phoenix
#

They're so easy, I'm still learning myself tho

spark flint
#

theres way less documentation and support on it then you'd expect

#

its hard with python

#

like how do i get info

earnest phoenix
#

Yeah, but you kinda gotta think where stuff would make sense at.

quartz kindle
#

well, discord.py intentionally doesnt support them lmao

#

you need third party extensions for dpy

spark flint
#

i use a third party module

neat ingot
#

interaction.options.getString('property') is how you do it in js, idk py tho 😦

spark flint
#

discord-py-slash-command

royal portal
#

do i have to enable port 22 in the sshd_config file for sftp?!?!1

wheat mesa
#

as usual the forge discord was no help

#

because I'm not allowed to ask about 1.8.9

lyric mountain
#

there's no 1.8.9 in ba sing se

royal portal
#

mh?!?!1

quartz kindle
#

whats wrong with 1.8.9?

royal portal
#

tim help!!1

proven escarp
royal portal
#

but it works without it angeryBOYE

quartz kindle
#

sftp is literally ftp over ssh

#

it uses the same ssh connection that you are already using

spark flint
#

here too @oak cliff

#

oh

#

is gone

royal portal
#

didnt enable it

spark flint
quartz kindle
#

because ssh ports can be changed

spark flint
#

strict

neat ingot
#

SEND_MESSAGES and VIEW_CHANNEL permissions seem a fair restriction for using slash commands i think, or have i overlooked one?

spark flint
#

some servers are too strict

lyric mountain
royal portal
lyric mountain
#

22 is unsecure iirc

royal portal
#

but even if its like that, it will still default to that?!?!1

royal portal
lyric mountain
#

idk, 22 is normal tcp

quartz kindle
#

22 is the default port, theres no need to change it. but one popular security trick is to change the ssh port to hide it from potential attackers

#

not really necessary in my opinion, especially if you use ssh keys and disable password logins

royal portal
#

i disabled ssh

#

not sure if the default is port 22

spark flint
#

sometimes 21

#

but 22 is usually the default port

#

i know because of how many vps's i've been through KEKW

royal portal
split hazel
#

I disabled ssh before I turned my bot on

#

wait but how will I turn my bot on without ssh

lyric mountain
#

that's the neat part

spark flint
#

surely keeping standard port is better

lyric mountain
#

by changing port you remove one clue from hackers

spark flint
#

like if i wanted ftp and someone said "oh yeah my port is port 69" i wouldn;t trust it

#

true

#

personally i would say keeping standard is better

lyric mountain
#

like, the first thing they'll try:

  • port 22
  • user: root
spark flint
#

true

#

i should change my username on my vps

#

its still root

#

but password is quite secure

lyric mountain
#

it's so easy to change to another user

spark flint
#

true

lyric mountain
#

the only bad thing is that you'll need to get used to sudo

#

but u can alwayls just sudo -i -u root

quartz kindle
#

just dont use password login

#

use an ssh key

spark flint
#

true

#

but i use cmd to do ssh

#

how would that work

quartz kindle
#

you add the key file with the -t option or something like that

#

idk i dont use cmd

royal portal
spark flint
#

oh

#

ok

#

i guess i use sftp then KEKW

royal portal
lyric mountain
#

switch to root

#

sudo -i -u <user>

#

there's a shorter cmd but I never remember it

royal portal
lyric mountain
#

now login to it KEKW

royal portal
lyric mountain
#

ohno putty

royal portal
#

whats wrong with it cryangeryBOYE

lyric mountain
#

cmd/powershell already have ssh

royal portal
#

but ssh disabled?!?!1

#

it closes if i enter the right password

lyric mountain
#

that's the thing

#

u can't login into something you islanded

quartz kindle
#

putty and openssh use different types of keys

royal portal
lyric mountain
#

you need to reach the island somehow

royal portal
#

wdym

lyric mountain
#

like, you need to have a way to login

royal portal
#

also wtf is this

lyric mountain
#

added to known hosts list

#

nothing to worry about

royal portal
#

in what?!?!1

#

where did it add that?!?!1

lyric mountain
#

C:\Users\<you>\.ssh\known_hosts

#

just the list of servers you willingly logged into

#

nothing to worry

#

I once saw a way to limit ssh to a single ip, then had to use a vpn to login

royal portal
lyric mountain
#

but idk, sometimes security has diminishing gains

royal portal
#

i use a site to access the vps

quartz kindle
#

usually your vps provider has a backdoor to login into it

#

on their admin panel

royal portal
#

how would i check that?!?!1

lyric mountain
#

rescue mode iirc

#

it loads a side system to allow you to "unlock" yourself

royal portal
#

one thing i want to know

#

is ssh disabled?!?!1

lyric mountain
#

for the rescue system? no

royal portal
#

without that

lyric mountain
#

probably

royal portal
boreal iron
#

Rescue system is a network boot with its own authorization level

#

They will show or send you the login credentials once you active it

royal portal
#

how do i know if its activated?!?!1

boreal iron
#

What service?

#

SSH?

lyric mountain
#

it's like running ubuntu on plug 'n play mode

#

you use then discard it

royal portal
boreal iron
#

Take a look if the service is running

royal portal
royal portal
lyric mountain
#

the rescue

#

it's a temporary access to the vps

boreal iron
#

It’s running by default then

#

Just stop the service and disable it

royal portal
#

whats the service name?!?!1

boreal iron
#

Or remove the whole package if you don’t need it

#

Probably sftp

#

Test it out

royal portal
#

how would i test it cryangeryBOYE

boreal iron
#

systemctl status sftp

royal portal
boreal iron
#

Hmm has a different name then I guess

quartz kindle
#

pretty sure sftp is not its own service

#

but a part of ssh itself

boreal iron
#

Oh well then disable it in the conf file

#

Yeah it’s a subsystem

#

nano /etc/ssh/sshd_config to edit its config

#

I mean you can also just setup the firewall properly and allow incoming connections for services you need only

#

Which would be recommended anyways

neat ingot
#

using discord js slash commands, is it possible to get the data a user types after the command? like, lets say i have a /admin action:send-message command, and i want to read all the junk the user types after the command, without adding another command option, is that possible?

boreal iron
#

Yeah auto complete is what you need

#

If that’s what you need

#

If you just wanna accept any input as argument for your option then choose string

#

Which has an unlimited length and accepts multi line inputs iirc

#

Auto complete however will send an event each key(s) the user types

#

(including the pressed key(s))

neat ingot
#

nah thats excessive, i just made my admin command have subcommands that can have the relevant options i need šŸ™‚

#

the commands only available in one server anyway so its only me that will ever use it lol

earnest phoenix
#
const emojis = interaction.guild.emojis.cache
 .map((e) => `${e} **-** \`:${e.name}:\``)
 .join(', ');```
How can I make it so it only shows like 15 emojis?
neat ingot
#

oh wait no its a collection im dumb af

empty willow
#

nah that would still work, since they're mapping the collection to an array, then joining it

#

inserting the .slice between the .map and .join should work

neat ingot
#

yea but i was trying to big brain it and return only 15 from the cache lmao

quaint wasp
#

hey

#

So.. I started using an API and it returns a data with results that is an array of objects

#

and.. this does not work

#
data.results.size.toString()```
neat ingot
#

what are you logged to console there, the data?

quaint wasp
#

yeah

quaint wasp
#

the results is an array of objects

neat ingot
#

so size, isnt an array thing, thats a collection thing

#

you want length

quaint wasp
#

o- thanks

#

it works šŸ‘

simple stump
#

Is it possible to have .setImage or .setThumbnail be a link? Specifically a gif. For some reason the embed shows up as loading for the image.

simple stump
#

.setImage returns the same thing. I can have the gif show up as an image/thumbnail if I'm getting the file directly, but via a link it doesn't work.

simple stump
neat ingot
#

yea, i did nothing special lol

simple stump
#

yep it was just imgur

#

thx

earnest phoenix
#

How can I delete all the global commands on the bot at once?

boreal iron
#

Updating them by sending an empty array may still work

#

But I’m not sure

#

client.application.commands.set([]);

earnest phoenix
#

I have really old Global commands loaded, and they won't delete using the simple one line delete command

boreal iron
#

Well fetch the commands and delete them in a loop then

earnest phoenix
#

Nope, they're all still there.

#
onst rest = new REST({ version: '9' }).setToken(token);
rest.get(Routes.applicationGuildCommands(clientId, guildId))
    .then(data => {
        const promises = [];
        for (const command of data) {
            const deleteUrl = `${Routes.applicationGuildCommands(clientId, guildId)}/${command.id}`;
            promises.push(rest.delete(deleteUrl));
        }
        return Promise.all(promises);
    });
#

Tried that, didn't work.

#

Said invalid form body

#

Well, now its that

boreal iron
#

See what I’ve said above

earnest phoenix
#

No it worked.

#

but now it says im not authorized.

quaint wasp
#

How do you change what a thing says in HTML with javascript functions?
I got this in my HTML file:


<body>
    <script src="js/scripts.js"></script>
    
    <p id="demo">ayo</p>

</body>
``` and this in my scripts:
```js
var axios = require("axios").default;

function logData(data) {
    let activeEvents = 0;
    let unactiveEvents = 0;

    data.results.forEach(data => {
        if(data.state == 'active') {
            activeEvents++
        } else if(!data.state == 'active') {
            unactiveEvents++
        }
    });
    let output = `there are ${activeEvents.toString()}/${data.results.length.toString()} active events!`
    return output
}

var options = {
    method: 'GET',
    url: 'https://##########/v1/events/',
  //  params: {'': ''},
    headers: {Authorization: 'Bearer #################'}
  };

axios.request(options).then(function (response) {
    let data = response.data
   // console.log(data);
   document.getElementById("demo").innerHTML = logData(data)
    console.log(logData(data))

}).catch(function (error) {
  console.error(error);
});```
#

it works when I run the file it self but when I do the document get element it just ignores it

#

it doesnt change the ayo

wheat mesa
#

Should work to do document.getElementById("id").innerText = whateverYouWantHere

quaint wasp
#

does it still work if its in a function?

wheat mesa
#

It should

quaint wasp
#

but here it doesnt for some reaosn..

wheat mesa
#

idk ĀÆ_(惄)_/ĀÆ

#

I haven’t done much web dev

quaint wasp
#

same..

earnest phoenix
#

Are slash commands just a one-line-thing?

quaint wasp
#

Probably...

earnest phoenix
#

not my ad btw

boreal iron
#

Not if it’s a string as option

earnest phoenix
#

oh

#

its required 🤣

#

It's optional, yet only one line.

boreal iron
#

And what’s the issue?

earnest phoenix
#

Wym?

#

It's gotta get that full ad in the desc: option

boreal iron
#

And what’s the question?

earnest phoenix
#

How can I get it to add that whole ad in the desc: option?

boreal iron
#

Start writing behind the parameter not in a new line

earnest phoenix
#

It has to have new lines tho

#

It's a ad.

#

Not a one line thing.

solemn latch
#

the way I would handle it, is by having setdescription send a dm to the user and have a message collector to get it.

earnest phoenix
#

Yeah

#

Makes sense

boreal iron
#

Start writing behind the parameter not in a new line

boreal iron
#

Dude please read what I wrote

#

Your answer makes no sense

#

It has to have new lines tho

earnest phoenix
#

Tf does "Start writing behind the parameter, not in a new line" mean...?

boreal iron
#

I didn’t say remove all new lines, I said START behind the parameter and not START with a new line

earnest phoenix
#

It has to he spaced out tho?

#

Like
here
here
here

#

It has to have those.

#

It can't just be one big thrown together paragraph

#

herhehrherhehrehrhehrehrhehrh ehrh herhehrh ehrhehr

#

Nah, that looks fugly

boreal iron
#

Did you actually read what I wrote?

earnest phoenix
#

Did I actually understand it? nope 🤣

boreal iron
#

I didn’t say remove all new lines […]

#

didn’t = did not

earnest phoenix
#

Idfk what this means

#

Start writing behind the parameter

#

Sorry, collectors are much more easier lol

boreal iron
#

Parameter = option

#

Your description is a slash command parameter (option in other words)

earnest phoenix
#

Why would I write behind the option?

#

infront of*

#

whatever

#

idk

boreal iron
#

DONT BEGIN WITH A NEW LINE - JUST DONT

earnest phoenix
#

Alr, im just gonna use a collector, bye now 🤣

boreal iron
#

Am I speaking Spanish?

spark flint
#

LMAO

earnest phoenix
#

I use simple terms

#

like

spark flint
#

Imagine trying to get help from someone if you aren’t gonna listen and cooperate?

earnest phoenix
#

I am trying

#

but I don't know how to write behind a param

#

how does it not begin with a new line

#

its a ad

#

tf?

spark flint
#

They’re trying to help you

earnest phoenix
#

so confusing

spark flint
#

Listen to them

earnest phoenix
#

Yeah, but Woo alr helped me.

spark flint
#

Don’t just jump to conclusions

earnest phoenix
#

All I said was I prefered to use collectors

boreal iron
earnest phoenix
spark flint
boreal iron
#

Start that first line of the ad behind your slash command option and do not start the first line with a new line

earnest phoenix
#

people are just gonna copy and paste their ads

#

there are multiple lines

#

Also

#

it is only set to get the desc: box

boreal iron
earnest phoenix
#

oml

boreal iron
#

The client will think you let the optional option emptY

earnest phoenix
#

Still making 0 sense tbh

boreal iron
#

It does

earnest phoenix
#

To you.

boreal iron
#

Just change the option to be required and you see what I mean

earnest phoenix
#

It just didn't do the new line

#

hm?

boreal iron
#

Dunno what you’re doing works fine for me

#

New lines works perfectly

#

As long as you don’t start with a new line right after your option

earnest phoenix
#

Your note getting it

#

:oml:

#

Wait

#

how did yours work

#

OMG

#

It didn't work fro e

#

egeigje

#

im done

boreal iron
earnest phoenix
#

not like a new line line

#

like

#

/setdescription desc: test
other line here
another here

boreal iron
#

It does even show the line break in the overview

earnest phoenix
#

but it only does desc: test and it reads the others as a "tab"

boreal iron
#

That works only for one option or if it’s your last option

earnest phoenix
#

whaaat

#

I only have one option

#

Its the lines im trying to show man

#

let desc = interaction.options.getString('desc')

#
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, Discord, MessageActionRow, MessageButton, MessageEmbed, MessageSelectMenu } = require('discord.js')
const db = require('quick.db')
module.exports = {
    data: new SlashCommandBuilder()
        .setName('setdescription')
        .setDescription('Sets the Servers Description!')
    .addStringOption(option => option.setName('desc')
    .setDescription(`Set the Server Description.`)),
    //.setRequired(true)),
        async execute(interaction, client) {
        await interaction.deferReply()

let desc = interaction.options.getString('desc')```
#

That's what it is

#

yet

#

No lines I can do

#

so like

boreal iron
#

Dunno what you’re doing wrong
Works like a charm for me

earnest phoenix
#

Thats the thing

boreal iron
#

Lemme test 3 lines

earnest phoenix
#

im not doing anything wrong

#
/setdescription desc: test
test```
#

it reads the 2nd line as a "TAB"

#

and ignores it

#

cause its not in the DESC box

boreal iron
earnest phoenix
#

Well its clearly not working for me

#

So im done

#

with it

#

done

#

bye

#

I have a headache whyGod

boreal iron
earnest phoenix
#

All that for nothin

boreal iron
#

At least I now know new lines being removed completely - not being parsed as white space

modest zealot
#

Yeah I don't think slash commands have support for spaces atm lol

boreal iron
#

Command names? No as well as options

earnest phoenix
#

I mean, aren't you guys using different clients

earnest phoenix
# boreal iron

Newlines should work on mobile client (or at least what I'm using, Android), though nicknames can't have them

boreal iron
#

I mentioned that the client may interpret the new lines, especially the first line if not placed directly behind the option differently - up to ignoring the option completely

earnest phoenix
#

That is,

Start that first line of the ad behind your slash command option and do not start the first line with a new line

#

Even before you told them to do it, they already did it

pale vessel
#

Just wait for the new slate framework and multiline input

earnest phoenix
#

Error : TypeError: channels is not iterable

for (const element of channels) {
let ch2 = client.channels.cache.get(element)
        await wait(4000)
await interaction.editReply({content: `Bump Sent to all Receiving Channels.`})

const emojis = interaction.guild.emojis.cache
 .map((e) => `${e} **-** \`:${e.name}:\``)
 .join(', ');
const owner =  await interaction.guild.fetchOwner();
const e = new MessageEmbed()
.setAuthor(interaction.guild.name+` Server Bumped`, interaction.user.displayAvatarURL({ dynamic:true }))
.setDescription(`${desc}\n\n> __${interaction.guild}'s Server Stats:__`)
.addField(`![admin](https://cdn.discordapp.com/emojis/917671312242135041.webp?size=128 "admin") - Members:`, `${interaction.guild.members.cache.size || '\`Could not Fetch Member Count.\`'}`, true)
.addField(`![yeah](https://cdn.discordapp.com/emojis/918283343940972564.webp?size=128 "yeah") - Emojis:`, `${emojis}`, true)
.addField(`![user](https://cdn.discordapp.com/emojis/917578952959225858.webp?size=128 "user") - Bumped By:`, `${interaction.user.tag}`, true)


 const row = new MessageActionRow().addComponents(
new MessageButton()
.setLabel(`| Join ${interaction.guild}`)
.setEmoji('919757103852290059')
.setStyle('LINK')
.setURL(invite),

new MessageButton()
.setLabel(`| Support Server`)
.setEmoji('919757103852290059')
.setStyle('LINK')
.setURL(''))

await ch2.send({ embeds: [e], components:[row] })


}```
#

Done.

#

ok ty

#

what is channels

#

where is it defined

#
let channels = db.fetch(`channels`)
let invite = db.fetch(`invite_${interaction.guild.id}`)```
#

that's a promise

#

not an object

#

hm?

#

channels is a array of channels

#

in a db

#

yeah but the db takes time to fetch the channel

#

so you have to use await db.fetch("channels");

#

Still the same thing

pale vessel
#

Check what channels is

earnest phoenix
earnest phoenix
earnest phoenix
earnest phoenix
#

Okay now I just got a new error

pale vessel
#

New error HYPERS

delicate shore
#

Hey guys

#

how to get path for svg?

earnest phoenix
#

wat

delicate shore
#

what

#

ok

#
                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" className="" viewBox="0 0 512 512">
                                    <path d="M188.8 255.93a67.2 67.2 0 1067.2-67.18 67.38 67.38 0 00-67.2 67.18z"/><path d="M476.75 217.79v.05a206.63 206.63 0 00-7-28.84h-.11a202.16 202.16 0 017.07 29 203.5 203.5 0 00-7.07-29h-155.4c19.05 17 31.36 40.17 31.36 67.05a86.55 86.55 0 01-12.31 44.73L231 478.45a2.44 2.44 0 010 .27v.28-.26a224 224 0 0025 1.26c6.84 0 13.61-.39 20.3-1a222.91 222.91 0 0029.78-4.74C405.68 451.52 480 362.4 480 255.94a225.25 225.25 0 00-3.25-38.15z"/><path d="M256 345.5c-33.6 0-61.6-17.91-77.29-44.79L76 123.05l-.14-.24A224 224 0 00207.4 474.55v-.05l77.69-134.6a84.13 84.13 0 01-29.09 5.6z"/><path d="M91.29 104.57l77.35 133.25A89.19 89.19 0 01256 166h205.17a246.51 246.51 0 00-25.78-43.94l.12.08A245.26 245.26 0 01461.17 166h.17a245.91 245.91 0 00-25.66-44 2.63 2.63 0 01-.35-.26 223.93 223.93 0 00-344.19-17.4l.14.24z"/>
                                </svg>
#

This is for Chrome Logo, I found this online

#

but lets say I have a custom SVG for which I want to get Path

#

how can I get that

cinder patio
#

why would you want to do that

small tangle
#

i get this error when embeding a image but when i refresh discord the image is displayed correctly, what could be the cause for that (im using java with jda)

#
try {
      final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      ImageIO.write(createImage(user), "png", bytes);

      final User dev = event.getJDA().getUserById(Env.get("DEV_ID"));

      final EmbedBuilder embed = new EmbedBuilder();
      embed.setTitle(user.getNickname())
                 .setDescription("_Have a llamazing day!_")
                 .addField("Work", checkCooldown(user.getWork()), true)
                 .addField("Sleep", checkCooldown(user.getSleep()), true)
                 .setThumbnail(event.getUser().getAvatarUrl())
                 .setFooter("Created by " + dev.getName(), dev.getAvatarUrl())
                 .setTimestamp(Instant.now())
                 .setImage("attachment://alpagotchi.png");

      event.replyEmbeds(embed.build())
                 .addFile(bytes.toByteArray(), "alpagotchi.png")
                 .queue();
} catch (IOException error) {
      LOGGER.error(error.getMessage());
}

so im using ByteArrayOutputStream to create the image and sending it as a bytearray to discord, but for some reasons it fails sometimes

#

im using the ByteArrayOutputStream because i want to keep the image in memory and dont want to save it on the local disk, could there be another way?

inner oak
#

Hlo

untold bone
#

Hi guys 2rekthello , is there any bot who count all unverified members as fake invites?

untold bone
#

I didn’t found anything, that’s why I’m asking…

earnest phoenix
#

there i even put the search link

untold bone
small tangle
#

huh he literally pointed you to a link where you find your desired type of bots

untold bone
#

My question is precise, I don’t see this function in these bots

earnest phoenix
#

my man just explained all of discord in one sentence

#

well you'll have to look for the bot yourself

#

top.gg can only give you a list of bots to see

untold bone
#

Very helpful community indeed

earnest phoenix
#

true

cinder patio
#

Holy shiet why is MDX so hard to use

#

Absolutely terrible developer experience

#

What MDX should do is transpile markdown to a react component. It tries to do too much

feral aspen
#

He left... robo_bruhKitty

wheat mesa
#

What

quartz kindle
#

What

feral aspen
#

What

austere scaffold
#

What

slender thistle
#

What the fuck?

feral aspen
#

Ayo, language.

#

I'm trying to make a button that update's the ping, did I do something wrong?

feral aspen
#

Although, how am I supposed to set the ping of the edit in the embed, you need to wait for it to be done.

quartz kindle
#

you're measuring how much time it takes to generate an embed object

#

which is 0ms

#

you have two options:

#

either measure the ping of all messages, and just send the latest one

#

or send a temp message/update to measure, then update again with the result

feral aspen
#

I'm trying to do this...

#

Although, I got confused at it.

#

I understood it at first, then I got confused when coding it.

quartz kindle
#
let before = Date.now();
await interaction.edit("calculating");
let time = Date.now() - before;
await interaction.edit(time);
#

Date.now() is the same thing as new Date().getTime()

#

but shorter

feral aspen
#

Let me try now.

eternal solar
#

#include <iostream> #include <cstdlib> using namespace std; int main() { int a; cout << "Pls Enter an Integer (from 0 to 9): "; cin>>a; switch (a) { case '0': cout << "Zero"; break; case '1': cout << "One"; break; case '2': cout << "Two"; break; case '3': cout << "Three"; break; case '4': cout << "Four"; break; case '5': cout << "Five"; break; case '6': cout << "Six"; break; case '7': cout << "Seven"; break; case '8': cout << "Eight"; break; case '9': cout << "Nine"; break; default: cout << "Invalid character"; } return 0; }

feral aspen
# quartz kindle ```js let before = Date.now(); await interaction.edit("calculating"); let time =...

Although the first part of it worked, it didn't for the other half.

Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
    at ButtonInteraction.update (C:\Users\HamoodiHajjiri\Desktop\Rewrite\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:202:46)
    at InteractionCollector.<anonymous> (C:\Users\HamoodiHajjiri\Desktop\Rewrite\src\slashcommands\utility\ping.js:90:60)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}

I can't use .update() again.

quartz kindle
#

but your switch cases are checking for chars?

#

case '6'

#

shouldnt it be case 6?

eternal solar
#

oh thx

radiant kraken
eternal solar
#

working šŸ’Æ

split hazel
#

uwu

wooden ember
#

can some one explain how on earth this happend

#

this is the code

#
function OK(message) {
    log(message)
    console.log(chalk.green("[ OK ]: ")+message)
}

bot.on("ready", () => {
    console.log(`${OK}${bot.user.tag} is online!`);
});
cinder patio
#

You aren't calling the function

#

you're turning it into a string

wooden ember
#

yeah but when i have it asconsole.log(OK) it did the same thing

#

wait

#

nvm

#

im dumb

earnest phoenix
#

thats dumb

wooden ember
#

yeha i just relised

earnest phoenix
#

thanks

wooden ember
#

i just remembered it worked when i tested it before and then this was me implamenting it into my bot

#

and i did it wrong

#
function OK(message) {
    log(message)
    console.log(chalk.green("[ OK ]: ")+message)
}

bot.on("ready", () => {
    OK(`${bot.user.tag} is online!`);
});
#

works now

earnest phoenix
#

lmfao

#

alr

cinder patio
wooden ember
#

I sometimes wonder how I miss these things

#

i made the thing my self and i forgot how to use it

slender thistle
#

I've done cryptography ciphers in Rust and I have no clue how they work

#

It's okay, you just forget about it after a while

earnest phoenix
#

I forget existence

feral aspen
#

Is there a way you could get bot.ws.ping but each is different value? (I'm doing this for my ping command when you refresh it via a button)

quartz kindle
#

which is every 45 seconds normally

#

also bot.ws.ping is the average ping of all shards

#

if you want the ping of a specific shard, its bot.ws.shards.get(shardid).ping (only if you're using internal sharding, aka shards:"auto")

feral aspen
quartz kindle
#

you can manually call the websocket ping function

feral aspen
#

Could you check the code? I think the way I did was also good but it would not update.

quartz kindle
#

i have not tested, but according to the docs this is how a manual websocket ping would work:

const socket = client.ws.shards.get(shard_id).connection // or client.ws.shards.first().connection if you only have one internal shard
const now = Date.now();
socket.once("pong", () => {
  const time = Date.now() - now;
  // do something with time;
});
socket.ping();
spark flint
#

alr so

#

i'm trying to now make a bot with discordjs

#

how the fuck do i add commands

#
@client.command()
async def command_name(ctx):
  #do shit```
proven escarp
#

moeq

marble juniper
#

discord.js does not come included with a command handler

covert gale
#

oh

marble juniper
#

you have to code it yourself

covert gale
#

make command handler

spark flint
#

how the fuck

proven escarp
#

true

marble juniper
#

its easy

covert gale
#

@spark flint want me to send a template?

marble juniper
#

btw

spark flint
marble juniper
#

here

covert gale
#

k

marble juniper
#

check out the guide

#

it has the code in there too

#

do you wanna do it with slash commands or over normal messages @spark flint

#

or both

#

idk

spark flint
#

normal messages

marble juniper
#

check out the v12 guide then

#

its for v12 and therefore not up to date

#

but the v13 guide only shows you how to use slash commands

#

so you have to use the v12 guide

#

but the code in it should still work

covert gale
#

bunny dms

spark flint
#

ok

proven escarp
#

woops

#

might have sent token

spark flint
#

loom sent token

#

for which bot lol

marble juniper
#

this is probably the code you need

proven escarp
marble juniper
#

lol

proven escarp
#

or nya

#

depends

spark flint
marble juniper
#

just make sure you have a commands folder

spark flint
#

so not one file lol

#

like i usualy do with python

marble juniper
#

yeah

#

that is gonna get really ugly if you do it in djs

#

its better if you split ur commands into multiple files

#

doing it all in a single file is very hard to maintain with djs

spark flint
#

ah

proven escarp
#

nya has over 50 files or something like that

spark flint
#

did i install v12

#

or 13

marble juniper
#

make sure you got the latest nodejs version

#

you need nodejs v16 or higher

#

for discord.js v13 to function

proven escarp
#

npm install discord.js@12.x.x

marble juniper
#

no

#

don't install discord.js 12

spark flint
#

ah i have node 14

marble juniper
#

lol

proven escarp
marble juniper
#

discord.js v13 is better

#

since you can customize caching with caching options

#

thus reducing memory usage

#

still high since its djs but its still an improvement compared to v12

covert gale
marble juniper
#

dpy dev just dropped dpy

#

lol

#

not gonna happen anytime soon with discord.js

covert gale
#

yea

#

djs has a whole crew behind it

spark flint
#
const { Client, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILD_MESSAGES] });

client.once('ready', () => {
    console.log('Ready!');
});

client.on('message', message => {
    if (!message.content.startsWith("f!") || message.author.bot) return;

    const args = message.content.slice(prefix.length).trim().split(/ +/);
    const command = args.shift().toLowerCase();

    if (command === 'ping') {
        message.channel.send('Pong.');
    } else if (command === 'beep') {
        message.channel.send('Boop.');
    }
    // ...
});

client.login("MY TOKEN");```
#

what did i do wrong

#

@covert gale angeryBOI

covert gale
#

uh

#

what error?

spark flint
#

none

#

just no response

covert gale
#

uh gimme sec

spark flint
covert gale
#

just use command handler

#

real one

#

with commands folder

spark flint
#

dude

#

idk how

covert gale
#

use my template.........

#

just add new commands simple

#

also to prevent crash in the config folder add new commands folder name and add emoji otherwise crash

quartz kindle
#

you didnt define prefix?

spark flint
#

got it working now

#

kek

quartz kindle
#

lel

marble juniper
#

Tim quick question (or anyone else who is there)

#
const siteTitle = title ?? content.title ?? 'Astro'
#

is this valid javascript

#

lol

#

are you allowed to chain the ?? together like this

lament rock
#

yes

#

tbh, idk why ?? exists when || exists

solemn latch
#

they have different purposes

#

0 || 1
will give 1
0 ?? 1
will give 0

earnest phoenix
#

it is like soft and hard (false) (undefined)

solemn latch
#

for most cases ?? is actually the correct usage, its just || was the only way to do it for so long that everyone still uses ||

cinder patio
#

The reason is semantics, let's say the user provides some option, and you want to assign it to a variable, or if they did not provide anything, set it to a default value:

const option = selectedOption || 256

But what if 0 is a valid option? Before you'd have to explicitly check if selectedOption is undefined or null

#

now you can use ??

lament rock
#

I know it strictly checks null, but more often than not, I find it literally useless unless dealing with numbers which is less often than I need to use logical OR

quartz kindle
#

same, i dont even bother using it for the cases it's made for either

solemn latch
#

I guess it kind of depends on your usage, but I use ?? maybe 5/6 times

quartz kindle
#

im not a big fan of writing bleeding edge code that only works on the latest versions

solemn latch
#

thats fair

#

thankfully no one uses my code šŸ˜‰

lament rock
#

Unless its ts you can transpile to older ECMA versions

cinder patio
#

transpilers tho

#

you can also transpile to older ECMA versions with ts

quartz kindle
#

thats exactly what transpilers will do, convert all your ??s to ternaries and shit

#

so i rather just write the end code myself lul

earnest phoenix
#
let a = 0 ?? 1;
let a = 0 !== null && 0 !== void 0 ? 0 : 1;
#

.g

quartz kindle
earnest phoenix
#

yes but ts compiler isn't so intelligent

sudden geyser
#
let a = 0 !== null ? 0 !== void ? 0 : 1 : 1;
quartz kindle
cinder patio
#

checking if the value is not null and undefined is mooost likely faster than using that method if that's your argument

spark flint
#

ok i need help again

#

getting Command raised an exception: Forbidden: 403 Forbidden (error code: 50001): Missing Access

#

but the bot has full admin

earnest phoenix
#

If i use express in a server with apache2 reverse proxy.Do i have to configure any settings for express.Since i use a ratelimiter pkg,which ratelimit global.

cinder patio
#

uuuuum what
TypeError: Cannot read property 'Symbol(type)' of undefined

const files = await fs.readdir("./cmds", { withFileTypes: true });
timber fractal
#

so i want my website link to preview in discord with the image that is on the site. how can i do that?

sudden geyser
#

I think you need to use og:image as metadata

#

I know they use parts of the open graph protocol

timber fractal
cinder patio
#

I feel like typescript should warn you in cases like these

cinder patio
#

took me a few mins to figure it out

timber fractal
earnest phoenix
#

Use SQLite

#

Json not a database

#

Json isnt a option :D

oblique mist
boreal iron
#

Actually not… SQLite is perfect for you needs and easily scalable if you have to move over to MariaDB (MySQL) later on

earnest phoenix
#

i like maria.db

timber fractal
oblique mist
#

How you make?

boreal iron
timber fractal
oblique mist
#

Pls make this

#

In red colour

boreal iron
#

@rose warren

earnest phoenix
#

@solemn latch

solemn latch
#

@oblique mist keep this server sfw please

boreal iron
#

There has been one mentioned already…

boreal iron
#

My gosh

oblique mist
#

Sir

boreal iron
#

If you wanna make it red then take a look into syntax highlighting by googling it

#

There’s no other reliable way to colorize your text

timber fractal
boreal iron
#

Is it a complete HTML code or only the head element?

#

Also Discord sometimes doesn’t wanna fetch images from unknown sources like private domains

#

Try a different image from a public source like Discord itself or Imgur for example

#

Also if that’s your domain then check the logs if Discord actually tries to get the image from your server

#

If so check the status code

timber fractal
boreal iron
#

Yeah it’s no valid HTML document then

#

And the domain isn’t a public one

#

(known)

#

But you first gotta fix Your html code

timber fractal
#

or known

#

and how can i make it public/known?

#

@boreal iron

proven lantern
#

do slash commands have some way to input datetime parameters

#

like a date picker or something

boreal iron
# timber fractal how isnt it public?

Please keep the order.
First fix your HTML code, try again if the image now shows up, if not choose a public known image hoster like Imgur and test it again

#

Also try to post the image URL in discord manually before using it in an embed
That worked for me in the past if images didn’t show up before

#

But anyways the code is your issue in the first place

spark flint
#
<meta name="twitter:card" content="summary_large_image"> <meta name="twitter:image" content="img url"> <meta name="twitter:image:src" content="img url"> <meta property="og:image" content="img url">```
#

that works for me

sterile lantern
#

How could I get the IDs of the rest of the people interested in the event?

#

And if I do make a request to the API, does the bot need to be in the server?

#

I am assuming it has to do with sending some sort of request, but not too sure abt it

boreal iron
spark flint
#

the image url works tho

#

wait

#

am stupid

#

the html looks valid hmm

boreal iron
#

It’s not

spark flint
#

oh no <!DOCTYPE html>

boreal iron
#

HTML doesn’t begin with head tags

spark flint
#

<html>
<head>
<title>crab.jpg</title>
<meta property="og:title" content="crab.jpg" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://cdn.luckiecrab.nl/crabimg.jpg" />
<meta property="og:image" content="http://cdn.luckiecrab.nl/crabimg.jpg" />
<meta property="og:description" content="CDN for luckiecrab.nl" />
<meta name="theme-color" content="#FF0000">

<meta name="twitter:card" content="summary_large_image">

</head>

</html>

#

thats their full code

boreal iron
spark flint
#

ik

#

i'm looking at their site

boreal iron
#

Hmm maybe… can’t view the source code on mobile

#

If that doesn’t work after posting the image manually in Discord then picking and trying a public image hoster is the next step

#

Also the links aren’t the same than in his screenshot

#

The protocol is different

spark flint
#

image posts

#

http://cdn.luckiecrab.nl/crabimg.jpg

spark flint
#

just the image doesn't embed

#

2 secs

spark flint
sterile lantern
#

oof

boreal iron
spark flint
#

both works

boreal iron
#

No

#

You will be redirected

#

3xx status codes may not be accepted

#

Who knows

spark flint
#

that worked

#

@timber fractal ^^

#
<html>
<head>
<title>crab.jpg</title>
<meta property="og:title" content="crab.jpg" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://cdn.luckiecrab.nl/crabimg.jpg" />
<meta name="twitter:card" content="summary_large_image"> <meta name="twitter:image" content="https://cdn.luckiecrab.nl/crabimg.jpg"> <meta name="twitter:image:src" content="https://cdn.luckiecrab.nl/crabimg.jpg"> <meta property="og:image" content="https://cdn.luckiecrab.nl/crabimg.jpg">
<meta property="og:description" content="CDN for luckiecrab.nl" />
<meta name="theme-color" content="#FF0000">

</head>

</html>```
boreal iron
#

Yeah it now includes the right URL

#

Without a redirection

solemn latch
#

oh speaking of image hosts, working on gif's from random images dancie_wiggle_cutie

spark flint
#

yep

sterile lantern
#

How would I send a request to this? I haven't done raw requests like this so I'm not too sure

lament rock
#

some libs have custom routers

sterile lantern
#

i was looking at d.js but it seems like they dont have this yet

lament rock
#

Djs' is a proxy like
client.api.guilds[guild_id]["scheduled-events"][guild_scheduled_event_id].users

#

otherwise, if you have a way to make an http request with a path, it'd be /api/v9/guilds/:guild_id/scheduled-events/:guild_scheduled_event_id/users

unless the method that's exposed prepends /api/v9

sterile lantern
#

yeah i dont have a way to make the http request Sadge

quartz kindle
#

when using the djs router, you need to call .get() at the end as well

#

you can also pass query params to the options object

sterile lantern
#

.get() returns Promise pending

quartz kindle
#

of course

#

its an api request

#

needs to be awaited like all others

sterile lantern
#

oh yeah

#

thanks

proven lantern
#

tim helped

#

he did the hard part

#

line 15

sterile lantern
#

how come it prints 203/380

#

there r 383 actually now, but in total thats how many ppl clicked the interested button but only 203 printed out

#

acc nvm found it

#

ah i realized

#

the query is set to default at 100

#

anyway to change that to 380? (nvM)

earnest phoenix
#

Can someone help me come up with a leveling system? I absolutely suck at math.

sudden geyser
#

set xp requirements for each level

#

and generate a random number between a range to determine how many points some user earns for something

#

e.g. sending a message

#

and bam now you have a leveling system

#

personally I think most/all of them suck

earnest phoenix
#

Mmmm

#

Setting an xp requirement is annoying for the kind of xp system I wanna make

sudden geyser
#

I'd rather see a points system like Points where you can assign and earn points through specific activities defined by the server and spend them on items

earnest phoenix
#

I don't want there to be a level cap

earnest phoenix
#

But I wanna make an infinite level system

sudden geyser
#

then you can just do the generation part

#

and have some algorithm for what level the user is at

#

like exponential levels most bots deploy

earnest phoenix
#

Mmmm

#

That's the tough part for me cause that requires a lot of math and I'm not good at math 😩

sudden geyser
#

hmm

earnest phoenix
# sudden geyser hmm

So when you mean exponential levels, do you mean like using an exponential growth formula?

sudden geyser
#

yes

earnest phoenix
#

so like

#

f(x) = a(1+r)^x

#

gotten from google btw

#

depends on what you wanna do and assuming position 0 in the array is a string then sure

#

alright then yea that should work

#

you could shorten that tho

#

actually

#

idk if it would work in practice

#

my thinking is you could probably do if(!args.includes(blah)) but now that I am thinking about it I don't think that will work since you wanna check for both

#

:p

#

so ignore me

#

mhm mhm

#

what about it

boreal iron
#

Omg

#

NOT OR NOT

spark flint
earnest phoenix
#

I do not understand exponential growth formula

#

😩

boreal iron
#

Just perform simple math then

quartz kindle
#

methmetiks

boreal iron
#

Like growing the xp by 50% for example

boreal iron
earnest phoenix
#

:c

#

Anyway

boreal iron
#

new xp = current xp * 1.5 to example

#

The easiest shit outta there

earnest phoenix
#

Won't growing the xp by percentages like that get too easy at some point

#

Also, I am trying to make an infinite level system so idk how exactly to determine when they actually level up

boreal iron
#

Than add the current xp to it

earnest phoenix
#

wdym

boreal iron
#

new xp = current xp * 1.5 + current xp

#

Dunno why you would like to over complicate such a simple thing

earnest phoenix
#

listen here

#

I suck at math and so my brain isn't as big as urs when it comes to calculations and coming up with calculations

boreal iron
#

Ok but the upper example is easy, isn’t it?

earnest phoenix
#

But how do I determine when they actually go up a level

#

that is just calculating new xp no?

boreal iron
earnest phoenix
#

They're probably saying to do not and instead

earnest phoenix
#

reeeeeeee

#

my monkey brain knows this is simple yet still doesnt understand

boreal iron
boreal iron
#

If you wanna store any information persistently you will need to deal with a database

quartz kindle
#

no?

earnest phoenix
#

I know how to store things

#

I dont know how to determine how to go from level 1 to level 2 when the levels are infinite so there is no xp requirement per level like klay was saying

quartz kindle
#

well, that works too, but literally all you had to do was use && instead of ||

quartz kindle
earnest phoenix
#

But with an infinite level system how do you know the required amount for the current level

#

say you start out at level 0

quartz kindle
#

you can come up with a formula that only uses the level and nothing else, like current level multiplied by some constant

earnest phoenix
#

how do you determine how much you need for level 1 and then 2 and 3 and so on

quartz kindle
#

there are a million different formulas for that kind of thing

earnest phoenix
#

Someone said exponential growth formula

#

but that makes no sense to me

quartz kindle
#

for a lot of people, exponential is too steep, but if you like it, just use that

earnest phoenix
#

šŸ¤”

#

So, can you give me an example of how this could work

#

I assume that the number in the exp method is the level right?

quartz kindle
#

do you reset exp on every level up?

earnest phoenix
#

and the result is the amount of xp you need for that level

quartz kindle
#

or is the xp cumulative?

earnest phoenix
#

I think the xp will be cumulative

quartz kindle
#

so then its easy

#

if(currentExp > Math.exp(currentLevel)) { levelUp() }

earnest phoenix
#

I see

#

so the result of Math.exp is the amount of xp for that level?

quartz kindle
#

yes

earnest phoenix
#

Makes sense

#

What do you think would be a good amount of xp to add to a user?

#

Essentially the idea is you get xp randomly when using one of the commands in the bot

#

but i don't wanna make it super easy to jump from level 0 to a higher level

quartz kindle
#

heres a few examples of different exp curves

quartz kindle
#

for example, lets say you are level 1

#

Math.exp(1) = 2.something

#

thats very low

#

literally 2 xp

#

if you want it to be like, 100 xp required

#

you can do Math.exp(1) * 50

#

so then instead of 2 xp, 100 xp will be required

#

then for level 3, instead of 5 xp, if will be 250

#

so just add a multiplier to get the desired range you want to work with

earnest phoenix
#

I think 50 is good

quartz kindle
#

just keep in mind that exponential growth leveling is usually used together with exponential reward increase

#

like, the higher level you are, the more exp you get

earnest phoenix
#

mmmm

#

yea

quartz kindle
#

fight higher level monsters etc

earnest phoenix
#

The idea behind is at certain level milestones you unlock something else

quartz kindle
#

because level 10 requires literally 10000x more exp than level 2

earnest phoenix
#

Ah right

quartz kindle
earnest phoenix
#

and if you do it by 50

#

yea

quartz kindle
#

135 xp for level 2

earnest phoenix
#

110k xp for level 10

quartz kindle
#

1 million xp for level 10

earnest phoenix
#

oh that is 1 million

#

I cant read

#

:p

quartz kindle
#

exactly

#

exponential has quite a steep curve

earnest phoenix
#

Yea

quartz kindle
#

so its not a very good system for messages for example, if messages always give the same amount of exp

earnest phoenix
#

My idea behind the infinite leveling system was at certain level milestones you unlock something new in the bot

#

but I am not even sure if that is a good idea anymore

quartz kindle
#

its not a bad idea

#

you just need to find an exp curve that suits your needs

earnest phoenix
#

Yea

#

I am just unsure anymore aha

#

Cause then I have to go in and code those milestones

#

which can be tedious since it is infinite

boreal iron
#

Just use the modulo to check if a level is a potential of 10 for example to dynamically create milestones every 10 levels

#

_arrr thx auto correct _

quartz kindle
#

if(currentLevel % 10 === 0) { 10 levels milestone reached }

#

if(currentLevel % 25 === 0) { 25 levels milestone reached }

boreal iron
#

I mean milestone names, icons etc. can be random

earnest phoenix
quartz kindle
#

also, here's a simple leveling formula with a more moderate growth curve
Math.sqrt(level) * level * 100

#

that's 100 xp for level 2

#

3000 exp for level 10

#

approximately

earnest phoenix
#

That is a lot better

#

That is the thing

#

I dont know exactly how much to give per command use

quartz kindle
#

random number between 1 and 5?

earnest phoenix
#

since I don't want to make it impossible to level up when they start getting higher levels

boreal iron
#

In your case i would calculate the xp by the content length

quartz kindle
#

think about how many messages you want people to need for them to level up at certain levels

#

if its approx 10 xp per message, then its 10 messages to level 2

#

28 messages to level 3

#

51 messages to level 4

#

etc

#

meaning, 18 messages from level 2 to level 3

earnest phoenix
#

Its not per message though

#

I want it to occur randomly when using the command.

#

every other command usage should give xp

quartz kindle
#

alright then if there is a 50% chance of getting 10 xp

earnest phoenix
#

/command - no xp
/command - get xp

quartz kindle
#

the user will need on avrage 20 commands for level 2

#

then 36 from 2 to 3

#

etc

earnest phoenix
#

There will be a cooldown for the command

quartz kindle
#

cooldown is not relevant for this

earnest phoenix
#

I mean yea, but if wass is worried about spamming to gain levels it won't matter.

#

there will be cooldowns

quartz kindle
#

just think about how many exp-worth instances of an action the user needs to do to achive x levels, and think if you like that amount

earnest phoenix
#

I like the 50% chance of 10xp

quartz kindle
#

if you think its too little or too much, adjust your formulas

earnest phoenix
#

How would that formula look? would it essentially be what you were doing with Math.sqrt?

quartz kindle
#

square root is kinda the opposite of exponential

earnest phoenix
#

true

quartz kindle
#

instead of the amount increasing with increasing base, it decreases instead

earnest phoenix
#

and also when the level gets to a certain point won't you need to raise the amount of xp gained from 10 - something

quartz kindle
#

so the difference from 1 to 2 is bigger than the difference from 2 to 3

earnest phoenix
quartz kindle
#

so i added another multiplier to correct for that

#

so it turns into a slight increase instead of decrease

earnest phoenix
#

mmmm

#

yea im not sure I fully understand still

#

ugh

quartz kindle
#

just write a loop that counts to 20

#

and make it log the xp for each number

#

and tweak it until you like the numbers

#

for example

#

i is the current level

earnest phoenix
#

ya

quartz kindle
#

tweak the numbers around it, and see how it affects the growth curve

earnest phoenix
#

so to get to level 20 you need 41k?

#

4k*

quartz kindle
#

in the above example yes

earnest phoenix
#

and what is the 50 again?

quartz kindle
#

another multiplier

#

to adjust how big you want your numbers to be

#

ie if you want exp to be 100,200,300 or 10000,20000,30000

earnest phoenix
#

I see

#

That makes a bit more sense

#

so I could do

if(currXp < (Math.sqrt(currLevel) * (currLevel+1) * 50)) {levelUp()}
quartz kindle
earnest phoenix
#

ah right

quartz kindle
#

yup

earnest phoenix
#

also what is the point of the +1

quartz kindle
#

another way to give you more control

earnest phoenix
#

Ah

quartz kindle
#

if you increase it to +2 or +3 it wll slightly increase the overall exp requirements

#

if you reduce it to -1 or -2 it will decrease it

earnest phoenix
#

with +3 5k is the req for 20

#

Makes sense

#

I like that

#

So I also wanna ask for advice on how to handle the milestone stuff

#

I noticed you guys say use modulo right?

#

so you can give them rewards every 10 levels

quartz kindle
#

for example, the difference between i+1 and i+2 is 50 exp at level 1, and 220 exp at level 20

quartz kindle