#development

1 messages · Page 1669 of 1

stray sinew
#

Now thats CLEAn

subtle kiln
#

log-that-http package seams to work

modest maple
#

or if ya a pro verycool

earnest phoenix
#

@modest maple I'M SWEATING 😰

#

But bro how am I supposed to give my friends Minecraft servers that way ?!

bright gazelle
#

Yo! What's up ya'll?

earnest phoenix
bright gazelle
earnest phoenix
#

nope

rocky dagger
#

i have this type of command handler and i want to use await but for that you need to have an async somewhere and i just wondered where and how i need to implement the function```js
module.exports = {
name: 't',
description: '...',

execute(message, args) {

}
};

slender wagon
#
module.exports = {
  name: 't',
  description: '...',

  async execute(message, args) {

  }
};
#

i think

rocky dagger
#

i can try

umbral zealot
#

async execute ()

slender wagon
#

oop

#

my bad

rocky dagger
#

thanks

tired panther
#

How do I know, on the vote tracking, on the object req, which user voted for which bot?

vast garnet
#

I want to assign it to the category I created here. How do I do all the channels?

lost wadi
#

I need help!

    let clanes_buscados = await clanes.find()
    clanes_buscados.map(x => `${clanes_buscados.length} ${x.nombre} | ${x.tema} | ${x.codigo}`).join("\n")
    
    let paginas = []
    let cantidad = 2 
    while(clanes_buscados.length > 0) {
      paginas.push(clanes_buscados.splice(0, cantidad))
    }
    
    let embed = new Discord.MessageEmbed()
    .setDescription(`Clanes disponibles (Pagina ${args[0]} de ${paginas.length})\n\n${paginas[parseInt(args[0]) - 1].join("")}`)
   
    return message.channel.send(embed)

it comes out like this in the DB and not as I specify with the map

#

thats what I refer

umbral zealot
#

Sounds like you didn't save your file and restart your bot.

quartz kindle
#

jaja que loco

lost wadi
umbral zealot
#

ok then it probably means that one of these things isn't what you think it is. Have you tried logging the variables and values and seeing what they are? Because that's probably what I'd do.

#

Also glitch is not an appropriate place to host bots (develop them yes, hosting them 24/7, absolutely not).

lost wadi
#

I have no money to host, not everyone is rich

modest maple
#

KannaWhat It costs like

quartz kindle
#

you dont need to be rich

modest maple
#

$3 a month

quartz kindle
#

1 burger per month

umbral zealot
#

You do'nt need to be rich you just need to chose another free host like repl.it

#

Glitch.com bans accounts that use ping services to keep alive, so, it's not appropriate.

quartz kindle
#

btw is your code literally what you posted?

#

await clanes.find()

#

empty find function

modest maple
quartz kindle
#

using string.splice() which is not a function

lost wadi
quartz kindle
#
clanes_buscados.map(x => `${clanes_buscados.length} ${x.nombre} | ${x.tema} | ${x.codigo}`).join("\n")
``` what is this doing?
#

the result is not assigned anywhere

umbral zealot
#

oh yeah that's true, I missed that KEKW

quartz kindle
vast garnet
#

thanks bro

stray sinew
#

I need a bit of help on port forwarding my raspberry pi

thorn nexus
#

Help. how can one overlay png on gif using js? nothing works

quartz kindle
#

define "nothing works"

#

what have you tried?

earnest phoenix
#

does anybody know how to make links show a embed in html

thorn nexus
#
const GifEncoder = require("gifencoder");
const { createCanvas, loadImage } = require("canvas");
const Blob = require("cross-blob");
const gifExtract = require("gif-frames");
const { MessageAttachment } = require("discord.js");

    (async () => {

      let frames = await gifExtract({
        url: "giphy.gif",
        outputType: "png",
        frames: "all",
      }).then((frames1) => frames1.map((frame) => frame.getImage().data));

      console.log(frames);

      frames = await Promise.all(frames.map((frame) => loadImage(onBinaryMessage(frame)).then((image) => image)));

      const gifencoder = new GifEncoder(600, 300);

      gifencoder.setDelay(1000);
      gifencoder.setRepeat(0);
      gifencoder.setQuality(10);

      gifencoder.start();

      const ctx = createCanvas(600, 300).getContext("2d");

      for (const frame of frames) {
        gifencoder.addFrame(ctx);
        ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
      }

      gifencoder.finish();

      const attachment = new MessageAttachment(gifencoder.out.getData(), "profile.png");
      message.channel.send(attachment);

function onBinaryMessage(input) {
  const blob = new Blob([input], { type: "image/png" });
  URL.createObjectURL = function () {};
  const img = Image(600, 600);
  img.src = URL.createObjectURL(blob);
}```
#

that's all that happens

#

I originally tried to split the gif into frames and put it back together

deft jackal
#

What's the mission role?

umbral zealot
#

no idea, what's your code for that command?

deft jackal
#

Umm

umbral zealot
#

It's your bot, right? You're making this bot?

deft jackal
#

Yes

#

But

umbral zealot
#

how the hell would we know what your programmed into it?

deft jackal
#

No coding

umbral zealot
#

Even if you're not writing actual code, you still have... some logic into it, no?

#

whatever logic you have for that command in terms of roles, is what you need to figure out and fix

quartz kindle
#

where did URL come from, and why is it an empty function

#

basically making img.src become undefined

modest maple
quartz kindle
#

plus you dont need blobs at all

#

gif-frames can be configured to return canvas objects

stray sinew
#

I have a namecheap website how do I add a node.js file on there?

#

I would live to host my bot on the website

thorn nexus
thorn nexus
boreal iron
#

woop woop

modest maple
boreal iron
#

SQL queries

#

in other words database entries

modest maple
#

To a server type?

boreal iron
#

wut?

modest maple
#

To a Fat file or to a server type system

#

e.g. Sqlite or Postgres style

boreal iron
#

mariadb of course

modest maple
#

Are you sending those in bulk or one at a time?

boreal iron
#

as the screenshot shows 100k inserts each time

modest maple
#

So thats 100k inserts every 24s

#

correct?

vast garnet
#

How do I set the permissions of the channel I created automatically from the bot?

boreal iron
#

Time's increasing cause of the RAM limit, but ~ 22s atm

modest maple
#

100k inserts in 24s is reasonable ish

boreal iron
#

well usually takes 0,x s

#

just because the RAM is full

modest maple
#

reading it i thought it was doing 1 bil in 24s which i was gonna call BS on unless you have an entire DC at your call bloblul

boreal iron
#

limited to disk speed atm

#

it's that huge bc of it's indexing, reading takes a few ms only of course

boreal iron
#

That Discord function is called ANSWERING not push my post

livid carbon
modest maple
#

im surprised Maria can handle that much in a reasonable time if the rows are large

boreal iron
#

haha lol

#

u think 800 GB database size is much? it isn't

modest maple
#

Its not much no

#

But MySQL has a history for falling over itself with large tables with billions of rows bloblul I naturally assume due to MySQL being Maria's back bone it carries the same flaw

quartz kindle
#

doesnt maria advertise itself as being mysql without all the mysql issues?

boreal iron
#

MySQL is much better than people think

#

Yes it does

modest maple
#

Maria fixes alot of MySQL's issues

#

still carries a couple of the war marks though

boreal iron
#

The founder created MariaDB after god damn Oracle buyed MySQL and fucked it up

modest maple
#

Still no match for my main man Postgres bloblul

livid carbon
#

mariadb

#

lmao

#

sorry i'm a firestore user

modest maple
#

man thats a yikes

boreal iron
#

dealing for 14y now with these db engines

#

only a few issues so far, nothing I can complain about

quartz kindle
#

i've never used firestore myself, but the few people i've seen using it had lots of complaints

#

especially about slowness

modest maple
#

Its definitely a google product that google dont use

boreal iron
#

db optimization is an important point of course

umbral zealot
#

I remember trying ot use firestore and it was just a complex mess I didn't quite grasp

stray sinew
#

I have a namecheap website how do I add a node.js file on there? I would live to host my bot on the website

modest maple
#

its very slow unless you're literally ontop of the server's it's running on

#

its also very expensive

quartz kindle
#

you point the domain name to a host

modest maple
#

the bigger the DB, the more expensive it gets per row fetched / inserted etc...

umbral zealot
boreal iron
#

well tbh without a fine tuning db's at that size will always be slowly

modest maple
#

nah they offer hosting etc...

boreal iron
#

the hardware matters ofc, too

quartz kindle
#

if you want to host in your PI, then you need to point the domain to the PI's IP address

umbral zealot
#

probably not VPS hosting though

quartz kindle
#

in namecheap's DNS settings

modest maple
quartz kindle
#

did you buy only a domain name or also webhosting?

modest maple
#

all the way upto dedis

stray sinew
#

You can host on there

#

I got both

#

Web hosting as well

modest maple
quartz kindle
#

alright

#

then you can access your cpanel or similar

#

and also via ftp

#

but you need to check if they support node.js

#

many webhosting solutions dont support node

modest maple
#

Php strikes again

stray sinew
#

Ah thanks

quartz kindle
#

first step is to login to your cpanel

stray sinew
#

On it

modest maple
#

Idk what Datomic does but that thing is just mad

boreal iron
#

I'm missing the context, we're still talking about dbs?

modest maple
#

i am

stray sinew
#

One more question how do I make my raspberry pi project have its own web link so that I can have external people access it?

modest maple
#

they're on about hosting

stray sinew
#

When I start my project using pm2 it gives me a localhost://80sometbjng

boreal iron
#

I scale my databases myself by a load balancer sharing the load between two clusters

quartz kindle
#

you use your PI's IP address

boreal iron
#

But not the one I'm generating 4B entries for

stray sinew
#

Can anybody acccess it using my ip

tired panther
#

Does anyone has good mongodb experience/know-how?

stray sinew
#

Like if I use a vpm and try it would it work?

quartz kindle
#

if your PI's ip address is lets say 142.345.234.34 then you can put that IP in your browser and it should work

boreal iron
#

I'm managing my whole infrastructre myself anyways, starting by the DNS up to the virtualisation

quartz kindle
#

as long as you did port forward

stray sinew
#

How do I port forward it?

quartz kindle
#

in your router

#

check if it works first

tired panther
modest maple
quartz kindle
boreal iron
slim umbra
#

scylla gang 🤝

boreal iron
#

Keep that in mind

earnest phoenix
#

Is discord having API issues?

modest maple
#

its such an awesome DB its hard to use others 😅 Unless im heavily relational then i go with Postgres

earnest phoenix
#

My bot is taking a while to connect

#

My shards timeout

boreal iron
#

And yeah well keeping up with the latest hardware

#

Which is the reason why I am currently generating a new database

quartz kindle
#

is there an updated version of this?

modest maple
#

I mean ours is pretty simple in that regards, new machine, run setup.sh which just installs Docker, setup volumes run cluster

quartz kindle
#

xD

boreal iron
#

Because I'm moving all the VMs to a new dedicated server and a whole new virtualization method

modest maple
#

I think the best couple of Db's to come out of the recent spurge are probably Redis, KeyDB, and Cassandra

marble juniper
#

use docker if you don't lol

slim umbra
#

ur missing cockroachdb

#

it is super easily scaleable and easy to use

modest maple
#

Nah, Cockroach is okay

slim umbra
#

i mean for the scaleability it has to be up there

modest maple
#

But it can get really fucked with higher mem systems

slim umbra
#

and idk if u can consider keydb its own thing since it is a redis fork

twilit geode
#

on an attempt to create my own command handler because I couldnt find any for java (javacord), I seem to be stuck on running the file, like how would I go about running the file once I've figured out that that is one of my commands

import java.io.File;
import java.nio.file.FileSystems;

import org.javacord.api.DiscordApi;
import org.javacord.api.event.message.MessageCreateEvent;

public class CommandHandler {

    File folder = new File("JADIB/src/main/java/Commands/");

    public CommandHandler(MessageCreateEvent event, DiscordApi api) {
        // make the argument string[]
        String[] args = event.getMessageContent().substring(Util.prefix.length()).split(" ");

        if (isFileInFolder(folder, args[1])) {
            
        }

    }

    private Boolean isFileInFolder(File folder, String command) {
        // prevent running superclass
        if (command == "command")
            return false;

        for (File fileEntry : folder.listFiles()) {
            if (fileEntry.isDirectory()) {
                isFileInFolder(fileEntry, command);
            } else {
                if (fileEntry.getName().toLowerCase() == command) {
                    return true;
                }
                
            }
        }
        return false;
    }

}
slim umbra
#

yeah ive heard it can

modest maple
#

cuz that Garbage collector doing those interupts™️

slim umbra
#

hasnt happened to me yet atleast

restive furnace
#

imagine using GCed language, could not be me

vast garnet
#

It always creates a different category here. How can I prevent it?

quartz kindle
#

check if the category already exists before creating it

vast garnet
#

how so

quartz kindle
#

message.guild.channels.cache.find()

livid carbon
#

or rust

restive furnace
livid carbon
#

nice

#

on average how many times do you forget to allocate enough data

#

and cause a segmentation fault

restive furnace
#

two times a day

quartz kindle
#

yo @restive furnace remember the issue with tsl::sparse_map

restive furnace
#

yeah

quartz kindle
#

the author gave me a solution

livid carbon
restive furnace
restive furnace
#

oops wrong reply

#

i meant to tim's

quartz kindle
#
template <class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator<std::pair<Key, T>>>
using sparse_map = tsl::sparse_map<Key, T, Hash, KeyEqual, Allocator>;
#

this is exactly what we tried doing, creating an intermediate template

#

but i couldnt figure out the right way

modest maple
#

I never forget to allocate because i use rust verycool

restive furnace
#

oh that was semi-easy

#

well glad u got it working

quartz kindle
#

didnt do anything with it yet lmao

#

but yeah one less thing to worry about in the future

restive furnace
quartz kindle
#

im working on other stuff, like that binary encoder i told you about

restive furnace
#

oh cool, i hope it will be ✨ blazing fast binary encoder

quartz kindle
#

early testing is looking good

livid carbon
quartz kindle
#

faster and smaller than JSON.stringify()

restive furnace
livid carbon
#

not for bots tho because its a bit too low level

restive furnace
#

well i gtg cya

quartz kindle
#

cya

livid carbon
#

but anything terminal

quartz kindle
vast garnet
#

more?

nocturne dagger
#

Anyone know why this is being caused?

vast garnet
#
var guild = message.guild```
#

to the very beginning

nocturne dagger
#

Message isn't even defined yet.

#

I am trying to get the guild count of the bot,

umbral zealot
#

it's not client.cache.guilds

#

it's clients.guilds.cache

nocturne dagger
#

Thanks ill try that.

earnest phoenix
vast garnet
#

more?

earnest phoenix
#

what

#

more what

vast garnet
#

What will I write?

boreal iron
#

Well that’s up to you, nobody will code for you

#

There’s a difference between getting help and let others do your job

stray sinew
#

I have a github project that I would like to host on my webserver

#

How do I do this?

solemn quartz
#

Guys how to check if a user is banned by it's id?

earnest phoenix
#

Good evening,

I am currently using the canvas module but nowhere does it show the available fonts.
Would you know where to find them?
Thank you

boreal iron
#

Or fetchBan for a single fetch of course

quartz kindle
#

otherwise you need to use the registerFont function to make fonts available to it

#

there is no way to list available fonts

#

at least not yet, i believe it has been requested before, and there was some talk about it

earnest phoenix
#

Ok so i can use my properly tff font so?

quartz kindle
#

yes

earnest phoenix
#

ok and where i put the tff file please ? @quartz kindle

feral arch
#

Hi (: How could I have 2 environment like, the discord bot in a server, and a development environment where I apply constant changes and I want to only see that bot instead of the production bot?

quartz kindle
#

just load it with registerFont

earnest phoenix
#

Ok thx u

opaque acorn
#

/app/events/message.js:16
cmd.run(client, message, args);
^

TypeError: cmd.run is not a function

#

?

quartz kindle
quartz kindle
opaque acorn
#

a ok

feral arch
opaque acorn
#

i dont like command handler

quartz kindle
opaque acorn
#

how i do the avatar inside of embed command?

misty sigil
#

actually

#

i prefer having a different dev bot

#

if you get a ratelimit on your dev bot it doesnt affect the main one

opaque acorn
#

this is wrong?
let usuario = message.mentions.member.first() || message.member;

lament rock
#

If you get a rate limit on your dev bot, there's a BIG issue

#

unless you're developing a lib

misty sigil
#

BIG issues can happen in dev

feral arch
misty sigil
#

I prefer having an isolated environment

#

just better imo

lament rock
#

big issues can indeed happen, but that's usually when someone isn't thinking properly in terms of logic and makes a fucky wucky.

earnest phoenix
#

@quartz kindle thx uu ☺️☺️

opaque acorn
#

let usuario = message.mentions.member.first() || message.member;
^
TypeError: Cannot read property 'first' of undefined

now what?

earnest phoenix
#

message.mentions.users.first()

opaque acorn
#

really?

earnest phoenix
#

ye

opaque acorn
#

wait

earnest phoenix
#

if u want

#

but im sure 😉

opaque acorn
#

i hate my life

#

) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function

quartz kindle
#

whats your node.js version?

opaque acorn
#

10.23.0

quartz kindle
#

thats old

#

install at least v14

opaque acorn
#

ok

quartz kindle
#

latest is v15

earnest phoenix
#

wow v10 x)

opaque acorn
#

ty

#

it worked

#

im retarded

vast garnet
#

How do I automatically move a category to the top with the bot?

boreal iron
#

Take a look in here: https://discord.js.org/#/docs/main/stable/class/GuildChannel
Especially the property position

earnest phoenix
boreal iron
#

By checking if the channel type is category and reading its position you can sort them

vast garnet
#

I couldnt find it :/

boreal iron
#

I wouldn’t recommend 2012 any longer @midnight blaze

midnight blaze
#

hmm, just for testing

#

trying to connect my 2 vps

#

together

#

one is a DC

#

one is a vpn

boreal iron
#

Hmm sure why not

opaque acorn
#

hahaahahah someone explains to me why every time I put a command it appears twice?

boreal iron
#

Still wonder what the benefit should be

midnight blaze
#

what do you mean?

boreal iron
#

Of connecting them together to do what?

midnight blaze
#

to learn how to work with networks?

boreal iron
#

Oh well yeah sure testing is learning

midnight blaze
#

als

opaque acorn
midnight blaze
#

also

#

that vpn is useful

boreal iron
#

Yeah thought they may have a productive purpose

opaque acorn
#

and the terminal is not open

midnight blaze
#

they have for sure

boreal iron
#

It is indeed yeah

#

It’s still the most common used system for public agencies and companies

#

Probably not a bad idea to know and understand how it works

livid carbon
#

ayyyy

#

rythm using / commands

#

how does someone like us use them too?

summer torrent
#

slash commands

livid carbon
#

tahnks

#

is it abstracted yet

#

@summer torrent

summer torrent
#

it is in beta iirc

#

you can create it

#

what language

livid carbon
#

js

summer torrent
#

there is PR about slash commands in discord.js https://github.com/discordjs/discord.js/pull/5106
you can use this if you want https://slash-create.js.org/#/

/create

Creator and handler for Discord's slash commands

lost wadi
quartz kindle
#

did you read my answers?

umbral zealot
#

Just... gonna pretend we didn't actually have a conversation there after your question?

lost wadi
umbral zealot
#

read below your question which you replied to

#

like... the thread of people talking to you...

umbral zealot
#

yes, that was an extremely important question. Let's pick up from there!

lost wadi
#

Well, what do I do

umbral zealot
#

Do you not understand how variables work?

quartz kindle
#

do you understand what that line of code does?

umbral zealot
#

like, you're not assigning the return of the map() function to anything so it's... doing nothing

#

inb4 learnjs situation.

lost wadi
#

Do I remove the variable?

umbral zealot
#

yeah definitely a learnjs situation here

lost wadi
#

😔 😟

quartz kindle
#

sorry dude, when we help people, we expect them to at least understand their own code, otherwise its hard to help

#

because we want to help people learn, not do the work for them

lost wadi
#

I did this code alone, only I didn't like applying the map in this case.

quartz kindle
#

so then you should know a bit what your code is doing right?

#

you are not assigning result of that line to a variable

#

.map() creates a copy

#

it does not modify the original

#

so clanes_buscados is still the same before and after the map function

#

it is not affected

lost wadi
#

I hear everything's fine, the problem is that it gives me the information as it is in the DB

quartz kindle
#

yes

#

thats what i just said

lost wadi
#

Ok...

quartz kindle
#

.map() creates a copy
it does not modify the original
so clanes_buscados is still the same before and after the map function
it is not affected

lament ruin
#

@lost wadi the map function affects the whole array. imagine having this array arr = [{id:1; name:"a"},{id:2; name:"b"}] then doing arr = arr.map(x => x.id) would result in arr = [1,2]

#

i think

lament ruin
#

maybe the syntax is wrong, it's been a couple of weeks since i last touched that function

umbral zealot
#

the syntax isn't wrong the fact that he's not actually doing anything with the return of that function is wrong.

#

literally doing nothing with it

lament ruin
#

yup

umbral zealot
#

And if "assigning the return of a function to a variable" doesn't immediately and instantly tell someone what the solution is, they need to read this immediately...
#development message

lost wadi
#

So I'm mis-applying the map?

umbral zealot
#

you're not applying it at all

quartz kindle
#

you are applying it, but you are not using the result

#

you are using the original again

lament ruin
#

clanes_buscados = clanes_buscados.map(x => ${clanes_buscados.length} ${x.nombre} | ${x.tema} | ${x.codigo}).join("\n")

lost mauve
#

you gotta affect it to a variable

lament ruin
#

you have to send the result to the og array

umbral zealot
#

or a new variable

#

whichever

lament ruin
#

yeah

#

and then do the .join() function, right?

#

in a new line

umbral zealot
#

that can be just chained exactly as it is right now

#

literally the only problem is not using the return value... that's it....

#

there's probably nothing else wrong with this code.

lament ruin
#

ah, well. there you have it @lost wadi

quartz kindle
#

thats not the only issue with the code though

#

hes still using string.splice() later on

lost wadi
#

So should I apply the map before the while function?

quartz kindle
#

which will throw not a function

quartz kindle
#

do you understand what that means?

#
array = bla;
result = array.map(...)
#

you dont have a result

lament ruin
#

it can be the same variable or a new one

quartz kindle
#

tienes que poner el resultado de .map en una nueva variable

#

no estas ponendo el resultado in nengun lugar

boreal iron
#

Huh

lost wadi
#
let clanes_buscados = await clanes.find()
    let otros_clan = clanes_buscados.map(x => `${x.nombre} | ${x.tema} | ${x.codigo}`).join("\n")
   
quartz kindle
#

yes

lament ruin
#

sep, ahi lo tienes

lost mauve
#

you can also put it in the same one

lost wadi
#

Okay, but that's not an arrangement.

quartz kindle
#

that is the solution to this problem

#

now deal with the next one

lost wadi
#

Let's see I think...

lament ruin
#

that's probably the splice thing. i have no idea what are you trying to do there

lost wadi
#

Ready I got the map, there's only one detail left but I don't know how to fix it

quartz kindle
#

the entire while loop is problematic

#

whats your current code?

lost wadi
#

They come separated by commas

#
  let clanes_buscados = await clanes.find()
    let otros_clan = clanes_buscados.map(x => `${x.nombre} | ${x.tema} | ${x.codigo}`)
    console.log(otros_clan)
    
    let seleccion = parseInt(args[0])
    if(!seleccion) seleccion = 1
    
    let paginas = []
    let cantidad = 2 
    while(otros_clan.length > 0) {
      paginas.push(otros_clan.splice(0, cantidad))
    }
    
    let embed = new Discord.MessageEmbed()
    .setDescription(`Clanes disponibles (Pagina ${seleccion} de ${paginas.length})`)
    .addField("** **", `${paginas[seleccion - 1]}`)
    return message.channel.send(embed)
lament ruin
#

what are you trying to do there?

quartz kindle
#

you need the .join("\n")

#

you can put it in paginas[seleccion - 1]

lost wadi
#

I finally finished it, thank you very much

Me tarde mucho con esta pendejada ._.xd

lament ruin
#

@lost wadi Puedes reemplazar la funcion while esa por esto, si es que te sigue dando problemas

for(let i = 0; i <= maxPaginas; i++) paginas.push(otros_clan.splice(i * cantidad, cantidad))
if(otros_clan.length % cantidad > 0) paginas.push(otros_clan.splice(maxPaginas * cantidad, otros_clan.length - (maxPaginas * cantidad)))```
lost wadi
#

Gracias, lo tendre en cuenta

lament ruin
#

Igual esta todo mal eh

#

Pero es que no me gusta usar funciones while

#

Son muy lentas

lament ruin
quartz kindle
#

while isnt slow

lost wadi
#

Eso no lo entiendo muy bien

lament ruin
#

from what i've seen in some iterations tests, it is

#

for loops are 30-40% faster

#

doing the same thing

quartz kindle
#

nah

#

more like 1% faster

#

idk which tests you saw but they were likely wrong

#

there is a lot of testing and benchmarking out there done wrong

lament ruin
#

they were done in python, the results may change from language to language tho

quartz kindle
#

ah

#

i cant say anything about python

lost mauve
#

In python yeah, while is slower than for x in range

#

Way slower

quartz kindle
#

in js, for in and for of are much slower than while

lost mauve
#

That's because for x in range uses C optimized code

#

While while (ha) doesn't

lament ruin
#

i heard about that, yeah

lost wadi
#

to do something like that

Codigo | Clan     | Creador
#27723   Warriors   ZCrzas
#76237   The Lions  FortY
#48733   Gods       Augep

do I need a module?

quartz kindle
#

no

lost wadi
#

so?

lament ruin
#

that should be easy to do by using the addField() function for each attribute

#

right?

boreal iron
#

Well the code blocks are using monospaced fonts.
You’re just counting the chars of each word to get to know how much tabs (probably unicode tabs) u need.

lost mauve
#

Or use an embed

boreal iron
#

Looping through each line

lament ruin
#

he is already using an embed

boreal iron
#

That’s not what a wrote

#

Formatting grids inside a codeblock has nothing to do with embeds

lament ruin
#

yeah, but he could do that too

lost mauve
#

Actually that would look terrible on mobile

lost wadi
boreal iron
lost mauve
#

Embeds on mobile are a tragedy

lament ruin
#

Are they? I haven't experienced that

boreal iron
#

Anyways if you wanna create a grid inside a codeblock you will have to loop per line and word, count it’s chars and add tabs after the word based on the char length

#

That’s it

quartz kindle
#

you can use the built-in pad functions

boreal iron
quartz kindle
#

much complicate wow

lament ruin
boreal iron
#

Oh I can feel that sarcasm

lament ruin
#

lmao xD

lost mauve
#

Lmfao

quartz kindle
#

kinda looks cool tho

#

like a japanese website

boreal iron
#

Never ever heard of nowraping 👀

quartz kindle
#

media-query :^)

boreal iron
#

You’re here to make me feel bad?

quartz kindle
#

lmao

lament ruin
#

it looks cool on pc though

boreal iron
#

Wew getting a push notification while I’m looking at the message I got mentioned in

lost mauve
#

At least it's something

boreal iron
#

Discord mobile... no words needed

lost mauve
#

My bot page is just stinky markdown

lament ruin
#

show us

vast garnet
#

How do I automatically move the channel I created to the top?

lament ruin
#

👁️👄👁️

boreal iron
#

Told you already

quartz kindle
#

channels.create has a position option

vast garnet
#

here's the rest

lost mauve
quartz kindle
#

mine is 800 lines of md

#

lul

vast garnet
#

my is 200 300 lines

lost mauve
#

200300 lines or 200-300

quartz kindle
#

imagine 200k lines

vast garnet
#

200-300

#

😄

quartz kindle
#

would take 2min just to load the page

lost mauve
#

Is there actually a limit? freerealestate

vast garnet
#

channels.create has a position option
Can you explain this?

summer torrent
#
channels.create({ position: 2 })```
vast garnet
#

If I make this 0 does it move to the top,

lost mauve
#

yes

vast garnet
#

ok

#

here the error

lost mauve
#

Wait, if you want to move an already existing channel, I think you have to use channel.edit({position: 0})

#

Although I'm gonna add a disclaimer that I'm not a js dev so I don't know much about discord.js

vast garnet
#

Am I going to write at the end of the code

#

There is a mistake but can you see?

halcyon jungle
#

slash commands are difficult to me

lost mauve
# vast garnet

Uh no, which channel do you want to put at the top? destek ?

vast garnet
#

No, I will move the category to the top

#

DESTEKLER category

lost mauve
#

Oh, then after type: "category" just add position: 0

vast garnet
#

ok

#

didn't happen, it still opens to the bottom

lost mauve
#

Then I don't know, sorry

#

You'd have to ask to someone who knows discord.js better

lament ruin
#

you can use the .setPosition() function

vast garnet
#

how will i use?

lament ruin
#

category.setPosition(0)

vast garnet
#

ok

lost mauve
#

But it's weird that specifying it at creation doesn't work

vast garnet
#

oh ok thnks it happened

lament ruin
#

maybe some typo in the code or something idk

#

in theory it should work the same way

vast garnet
#

it forms the same category twice here, how do I prevent it? if you want, let me assign ss

#

look at the left

lament ruin
#

yeah, if you run the code twice it has no idea on what the category is from the previous run so it just creates it again

vast garnet
#

Here's how to prevent it again when you say -dstekaç put it in the same category

lament ruin
#

if you don't want that to happen you should look into saving those channel ids somewhere

#

like a cloud database

#

or a json

vast garnet
#

no I know it can be done with code but I don't know the code: D

lament ruin
#

well, you could also "find" the category by its name

vast garnet
#

how?

lament ruin
#

category = await guild.channels.cache.find(name)

#

i think thats it

#

iirc

#

then you could do

#

if (!category) {
(create the category)
}

vast garnet
#

Should I delete the let category?

lament ruin
vast garnet
#

ok

lament ruin
vast garnet
lament ruin
#

category = guild.channels.find(c => c.name == "name")

lament ruin
lost mauve
#

using awaits instead of chaining futures smh

vast garnet
#

this is not the fault

lament ruin
#

tell him marco

#

let category = guild.channels.find(c => c.name == "name")

if(....)

umbral zealot
lost mauve
#
let category = await guild.channels.cache.find(c => c.name === "name")
if (!category) {
  // create category
  category = ...
  category.setPosition(0)
}
umbral zealot
#

why...

lament ruin
#

probably some copypasting error

umbral zealot
#

doubtful

vast garnet
#

category = ... What am I going to write ?

umbral zealot
#

what you have now

#

you just need to remove the extra parentheses () you put around there for literally no reason

lost mauve
#

Do you need to triple equals with strings? Idak

lament ruin
umbral zealot
#

=== means exactly equal. 1 === "1" is false. 1 == "1" is true. You should never use == unless you know why you're using it.

#

And it's rare that you really need it.

vast garnet
#

yeah I tampered with myself a little and it happened

lament ruin
#

isn't that the same thing?

umbral zealot
#

so you think "1" and 1 are exactly the same?

lost mauve
umbral zealot
#

you don't understand the difference between a string and a number?

lament ruin
#

ah

#

wait what

lost mauve
lament ruin
#

ah, didnt saw you were comparing strings and numbers

#

i get it now

lost mauve
#

Weak typing ftw

lament ruin
#

im on my phone so i can't read shit

lament ruin
#

what kind of results are those. i would just expect it to crash or return a null/undefined

earnest phoenix
#

How to disable my bot Commands for public?
All Commands

vast garnet
#

The code for the number of bot on the server is not `$ {message.guild.clientCount} '

boreal iron
earnest phoenix
#

🧐

#

Not understood

boreal iron
#

return

earnest phoenix
#

Okay

#

But I have to do in all Commands

boreal iron
#

Nope

earnest phoenix
#

Can't form a single COMMAND

lament ruin
#

you can do that by checking if the member has a certain role

boreal iron
#

Just for the message event before loading your commands

earnest phoenix
#

Ok

boreal iron
#

client.on("message", (message) => {
if(message.guild.id != yourid) return;

// your commands here

earnest phoenix
#

Huh

#

It's in command handler lol

#

😑

boreal iron
#

And what’s the issue?
They been called in your message event

earnest phoenix
#

Okay👍

lament ruin
#

@earnest phoenix are you looking to lock the command behind a role or a guild?

boreal iron
#

Just for the message event before loading your commands

#

before

earnest phoenix
#

@lament ruin umm I need to run it for only 1 server not globally

#

For testing purposes

lament ruin
#

the do what fake is telling you

boreal iron
#

1 line, 1 statement, 1 return, finish

earnest phoenix
#

Okay

lament ruin
#

you could also create a new discord bot token and use that one in the testing server

#

that's what i usually do

lost mauve
latent heron
#

this is why js gets made fun of

lament ruin
#

you didn't know that one, huh

lost mauve
#

Whats that oldEyes

lament ruin
#

try adding an array to a string then divide it by a boolean

#

it gives you an async function

lost mauve
boreal iron
#

Wouldn’t wonder if JS actually do that

lost mauve
#

Js is more cursed than i thought

lament ruin
#

let i = await 1

earnest phoenix
#
 UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'BroadcastEval' of null

boreal iron
#

Well getting from any "real" program language to JS is like strict, complex coding to absolutely crazy coding (with unexpected behavior)

earnest phoenix
#

What to do of this

lyric mountain
#

What do I do when someone wants few API calls but also doesn't want to use caching?

earnest phoenix
#
 UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'BroadcastEval' of null
lost mauve
boreal iron
#

Well depending on your system more API calls shouldn’t be an issue?!

lost mauve
#

Although I can’t be trusted with it

lyric mountain
#

a dude is wanting me to improve this:

for (Guild guild : handler.getGuilds()) {
   try {
      e = guild.retrieveEmoteById(id).complete();
      break;
   } catch (ErrorResponseException ignore) {}
}
#

to make it not iterate over guilds looking where the emote belongs to

boreal iron
#

TS?

lyric mountain
#

java, but that's just a detail

#

like

boreal iron
#

Aw dunno about both KEKW

lyric mountain
#

when running 0 cache mode, how the hell would I get an emote without finding it first? KEKW

boreal iron
#

Well I’m gonna tell you something

lost mauve
#

I feel Java slander coming

boreal iron
#

My bot as well as my web app is calling the Steam API each request to fetch the latest account informations
As well as a lot of different socket connections to get informations from websites following a specific protocol
I was caching all these data at first for 24h just to improve the response time and to lower the API calls
Once a beautiful day I was fetching on account incl. all other infos
By accident later that day I did fetch this guy again bc his ID was still in my clipboard and notice damn, somethings is wrong
Turned off the cache for fun a noticed his ban status has changed and people requesting my API wouldn’t notice

#

Just disabled all the caching shit, threw anything away and stick to a slightly higher response time

lost mauve
#

I mean there’s also rate limits

boreal iron
#

But improved the clients and processes to actually being able to split up requests on multiple processes to increase the response time again

#

A lot more work but at the end the better result

lyric mountain
#

I know but like, I don't know how to explain that caches solely exist to reduce api calls

#

not that emote cache is that big in JDA anyway

boreal iron
#

For sure yeah

#

That maybe important for Discord bots being in 1000 of servers

#

Not what I was talking about

lyric mountain
#

can't think of a better solution honestly, all the info the lib receives is the emote ID

boreal iron
#

APIs should be able to handle a huge amount of calls and scale up with the amount of requests

lyric mountain
#

I mean, what I might do is allow setting "repo" guilds for emote lookup

boreal iron
#

Even Discord API

lyric mountain
#

imagine not having a big request quota for the major selling point of your business KEKW

boreal iron
#

I actually think you’re talking about trains and I about cars okeh

lyric mountain
#

discord is 90% emotes

boreal iron
#

But yeah I know what you mean

#

That’s what matters KEKW

gritty anvil
#

hey you guys making a new bot?

boreal iron
#

I mean I’m rate limiting my APIs too but I’m actually being prepared for a greater load and higher limits

#

That’s what I wanted to say, anyone should be

ancient halo
#

Guys how a create a welcome comand for my bot??

blissful coral
#

@marble juniper 24h turn around time go brrrr

boreal iron
#

Watch some docs and guidelines how to get started.

cinder tusk
#

Bruh

blissful coral
#

Team is aware

earnest phoenix
#

Umm

old cliff
#

not BroadcastEval

earnest phoenix
#

Okay

#

hi i have a doubt

old cliff
#

Don't ask to ask

thin echo
#

I need help making a raid protection command for my bot, it is python.

#

or just raid protection

old cliff
#

ok

thin echo
#

It is python

earnest phoenix
#

like random memes on reddit is there a package for jokes?

old cliff
#

yes

earnest phoenix
old cliff
#

randomJokes

earnest phoenix
#

k

#

ty

sinful thistle
#

There was a lot of errors in my bot jesus

old cliff
#

should be

graceful quarry
#

anyone wanna help with a server emoji_32

restive furnace
earnest phoenix
#

need help dk why it happens this is my first time hosting

pale vessel
#

Lmao they put arc.io for their users

pure lion
tired panther
#
const webhook = require("./module/plugin/webhook.js");
``` how can I save variables in something like webhook.cache ?
earnest phoenix
#

umm how do i make subcommands in discord.js

cinder patio
#

what have you tried so far?

earnest phoenix
#

getting first argument

#

and checking if it is equal to word

solemn quartz
#
if (message.content.toLowerCase().startsWith(config.prefix + "unban")) {
  NHIP.setDescription("You must have the `Ban Members` permission to use this command!") //cambio descrizione dell embed dei permessi mancanti con i ban
  NHIP2.setDescription("I need the `Ban Members` permission to execute this command!") //cambio descrizione dell embed dei permessi mancanti del bot con i ban
  const unbannedID = args[0]
  if(!unbannedID) {
    return message.channel.send('You must specify who you want to unban!')
  }
  let unbanDm = new Discord.MessageEmbed()
  .setColor(colore)
  .setTitle('You got unbanned! :D')
  .setDescription(`Unbanned from: ${message.author.username} \n Unbanned in: ${guild.name}`)
  let unbanE = new Discord.MessageEmbed()
  .setColor(colore)
  .setTitle('User Unbanned!')
  .setDescription(`I succesfully unbanned ${unbannedID.username}`)
  try {
    guild.members.unban(unbannedID)
  } catch (e) {
    message.channel.send('Error: Could not unban the user, correct usage: ?Unban <UserID>')
  }

}```
#

So

#

This is my unban command, and i think it works, but i need the bot to send an embed in the channel and to the unbanned if the id is valid

cinder patio
#

you create the embeds but don't send them

solemn quartz
#

ik

#

and i need them to send if the user id is valid

#

And how are you always on?

dapper ocean
#

My bot’s prefix is ‘/‘. There are some slash commands in my server from other bots. The problem is I can’t type /help, because of that. Any solutions?

cinder patio
#

change your prefix

earnest phoenix
#

^^

dapper ocean
#

Nah, I can, but... it will be a bad way to go

#

I have always used “/“ as a prefix

#

Without a possibility to change it

cinder patio
#

Then you gotta live with it

dapper ocean
#

All it’s users are used to “/“

cinder patio
#

switch to slash commands

dapper ocean
#

:/

dapper ocean
#

Not js

cinder patio
#

that doesn't matter

dapper ocean
#

It does

#

Slash commands don’t work that well in discord.py

dusky sundial
#

You can't change the behaviour of other bots, so you'll need to change your own

earnest phoenix
#

yup

dapper ocean
#

That’s trash :/

earnest phoenix
#

slash commands ™️

cinder patio
#

You could make it so servers can change the default prefix

earnest phoenix
#

good idea

dapper ocean
earnest phoenix
#

but i dont think you can do that

cinder patio
#

Then you'll have to live with it

#

there's nothing else you can do

dapper ocean
#

:(

#

Guess I have to change a prefix then

#

What are good prefix examples?

#

Like I need a one letter prefix

#

Except for “!”, “/“, “?” etc

cinder patio
#

why one letter

dapper ocean
earnest phoenix
#

mine is four letter

#

and its pretty easy to remember

dapper ocean
#

Who needs myepicbot! as a prefix

dapper ocean
earnest phoenix
#

no bots will respond to prefix

cinder patio
#

All one letter prefixes are common and the chance of other bots using them is very high

#

so that doesn't solve your problem

dapper ocean
#

For me

cinder patio
#

Then use !

dapper ocean
cinder patio
#

bruh

dapper ocean
#

It’s not as common as / for example

cinder patio
#

/ is definitely the most common one

dapper ocean
#

I need an uncommon, easy to find on keyboard (on mobile too), one letter prefix

cinder patio
#

\

dapper ocean
dapper ocean
earnest phoenix
#

yup

dapper ocean
#

It’s not hard.. it’s just...

earnest phoenix
#

--?

cinder patio
dapper ocean
#

You have to click multiple buttons to access \

dapper ocean
cinder patio
#

You have to press multiple keys for almost all of them

earnest phoenix
#

your bots name?

dapper ocean
#

Actually not

#

It’s the same

#

Have to press multiple buttons to access >

dapper ocean
cinder patio
#

You have to press multiple keys for literally all of them except /

#

] maybe

#

or [

#

'

dapper ocean
cinder patio
#

what that's one button press

dapper ocean
cinder patio
#

allow all quotes

dapper ocean
#

It can be ‘ ’ ` “

earnest phoenix
#

just use k

dapper ocean
cinder patio
#

then it doesn't look like you're interacting with a bot

cinder patio
#

k! or \k

earnest phoenix
#

¯_(ツ)_/¯

dapper ocean
earnest phoenix
#

who cares if you look like not interacting with bot

cinder patio
#

k porn

dapper ocean
earnest phoenix
#

well nvm

cinder patio
#

It's that the letter k is slang

#

for ok

dapper ocean
#

//help

#

Hm

#

Let it be // then

cinder patio
#

but that's 2 characters

dapper ocean
#

I think it’s the only way to go...

#

Like it’s fast to press

#

It’s the same letter

#

Just you have to press it twice

#
  • it’s easy and quick to type on desktop and mobile keyboards
#
  • it’s more unique than / or !
#

Where are top.gg common prefixes listed. I can’t find the message with this info

feral aspen
#

I have my bot wanted to add a role, but if it fails, I usually return it, example:

try {
  addrole()
} catch (err) {
  return;
};

// If it fails to add the role and I don't want it to return but instead continue with the code, should I catch it as false?
#

.catch(err => false);

earnest phoenix
#

Yea, you can just

const add = await addRole(...).catch(() => null);

if (!add) // do something if it fails to add role

...```
cinder patio
#

or if (!(await addRole(...).catch(() => null))) ...

onyx karma
#

I wouldn't one line that

cinder patio
#

why

#

I would

crystal wigeon
#

anyone know lavalink?

pale vessel
crystal wigeon
#

someone help :c

#

so if (client.shard.ids.includes(0)) { // something }
what ever is in this condition should work for all shards right?

#

lavalink seems to be connecting to only 1 shard

cinder patio
#

No

#

only the first shard

#

Or, more like, only in the client which controls the first shard

onyx karma
pale vessel
#

no

swift cloak
#

hi

#

so

#

does anyone here know simple-youtube-api well?

cinder patio
#

why?

tired panther
cinder patio
#

What's webhook?

tired panther
#

ignore it

#

webhook.cache = new Map() ? is this okay?

cinder patio
#

Depends on what webook is... that's why I asked you

#

if it's an object then yes

#

if it's a primitive value then no

tired panther
#

the functions are in a class

cinder patio
#

Then why don't do webhook.cache in the constructor?

tired panther
#

like createWebhook, deleteWebhook

cinder patio
#

this.cache = new Map()

tired panther
cinder patio
#

yes?? Classes have constructors

#

or as a static property

tired panther
cinder patio
#

static cache = new Map()

tired panther
#

lemme try

tired panther
#

the map is empty

#

also tried with this.cache.set

cinder patio
#

how do you access it?

#

it has to be this.cache.set

opal plank
#

can you even modify a map thats static?

#

like an array, it should change its size in memory

#

so it wouldnt be static anymore

crystal wigeon
tired panther
cinder patio
#

Static not in that sense

crystal wigeon
#

cache.set(guildId, somevalue)

tired panther
crystal wigeon
#

xD

tired panther
#
this.cache.set(guildid , newguild)
``` did this
#

but the map does not have a key on fetch

crystal wigeon
#

also, you're doing a fetchGuild?

#

shouldnt it be cache.get then?

tired panther
wraith locust
#

Oo

#

discord.js?

crystal wigeon
#

it should have a value

#

if you set it

opal plank
crystal wigeon
#

;-;

#

why you booli me

tired panther
wraith locust
opal plank
#

^^

crystal wigeon
opal plank
#

detritus gang

wraith locust
quartz kindle
#

there cannot be a single day whitout erwin talking about detritus

crystal wigeon
opal plank
quartz kindle
#

its a universal law

opal plank
#

look, i havent said detritus on the 24th

quartz kindle
#

how dare you be illegal

opal plank
boreal iron
quartz kindle
#

100 bucks per day

opal plank
#

oiliy got nothing on me with his fancy island

boreal iron
#

Just woke up thought to take a look in here and see Erwins ad

#

what else

opal plank
#

if you had woken up yesterday, you wouldnt have seen it

quartz kindle
#

yesterday was not a real day

quartz kindle
#

it was a dream

boreal iron
#

lmao Tim

opal plank
#

dont star it

#

don do it

boreal iron
#

Wut?

quartz kindle
#

reverse psychology

opal plank
#

its not MY message being starred

boreal iron
#

I don’t get that

opal plank
#

staph!

boreal iron
#

Starring like look at something?

quartz kindle
#

reacting with a star

#

to put it on starboard

tired panther
#

lol

boreal iron
#

Oh lmao can’t even see reacts

quartz kindle
#

wut

boreal iron
#

They been blocked in my network

tired panther
quartz kindle
#

Lol

#

wtf

boreal iron
#

Yeah just takes useless space

#

And I’m too old for that shit anyway you know, Tim?
Old ass...

opal plank
#

good, none of them were put on starboard

boreal iron
quartz kindle
#

it needs at least 4 stars to go to starboard

quartz kindle
#

3?

opal plank
#

ye

quartz kindle
#

alright then

#

ima loggin to my alt and star the shit out of you

opal plank
#

starring me is fine, just dont star people talking mad shit about me or my detritus ads

boreal iron
#

Oh that’s preparing to a possible ban evade

quartz kindle
#

xD

boreal iron
#

Let’s ban Tim!

quartz kindle
#

my alt is uvuvwevwevwe onyetenyevwe ugwemubwem ossas

boreal iron
#

Yeah lmao

opal plank
#

talk shit git shit

boreal iron
#

regarding Erwins daily ads, here's mine, Tim

tired panther
tired panther
boreal iron
#

personal ads

#

about things nobody cares

opal plank
boreal iron
#

ok ok

#

graph battle begins

opal plank
#

a single panel

tired panther
opal plank
#

fool!

#

thou shall not compete with myself

crimson vapor
#

@opal plank do you look at that every day to make your self feel better?

boreal iron
#

well can't screenshot the whole panel, too much secret stuff you know

crimson vapor
#

nice

boreal iron
#

maybe this one at least

tired panther
opal plank
#

fucking 5 minutes download terminal logs

boreal iron
#

Take a look at X and watch the timestamps lmao