#development

1 messages · Page 720 of 1

west spoke
#

Its creating a image

#

Ofc its gonna be slow

modest maple
#

^^^^^^^

distant plank
#

is there any alternative?

west spoke
#

not creating a image and just fetch the url's base64 data and then convert it into a image

distant plank
#

what?

modest maple
#

not making an image == faster

west spoke
#

Google "base64 to image lang"

distant plank
#

And how do I do that? I don't know much :C

west spoke
#

Fetch the url and turn the data into base64

#

google it if you dont know how

distant plank
#

ok

earnest phoenix
#

because those bots have a really strong server

west spoke
earnest phoenix
#

image generation, especially when using imagemagick, uses a lot of CPU power

#

it won't be optimal if you're selfhosting, multi-tasking on the same machine, using a free host or have a weak machine

modest maple
#

i mean

#

threadripper might be an exception

#

XD

fallow quiver
#

Ok, how would I make my bot send a message to a specific channel by ID

#

So only in that server, in that channel, will it send the message

earnest phoenix
#

i n

#

w h i c h

#

l i br a r y

distant plank
#

@fallow quiver

client.channels.get(channelid).send(message);
modest maple
#

what language tho

fallow quiver
#

Javascript

modest maple
#

ah

distant plank
#

JS in this example

modest maple
#

well then yh

fallow quiver
#

So I put the ID for (channelid)

#

I haven't done JS in a bit so thanks

distant plank
#

You're welcome

quartz kindle
#

@distant plank one way to make it faster is to rewrite that code to canvas, but good luck doing that

#

You can also try sharp

#

Supposedly its the fastest image manipulation library

#

Also, why is that code resizing an image 3 times?

#

Also check if the slowness is actually the image generation or if its the image downloading. If its the latter, get better internet

distant plank
#

@quartz kindle How can I achieve the same effect with sharp?

earnest phoenix
quartz kindle
#

@distant plank you'd have to read the sharp docs

#

I dont know what kind of effect youre looking for, but sharp should support almost everythng that gm has

runic dagger
#

So i've a question that i'm probably not asking in the right area, however, our bot {HSF}LadyShadow#7111 was removed from this server.
However this servers #logs has no report of it, yet she's still on DBL's website.
Any idea what's goin' on?
ID > 347872963636494337
Mention > @sly creek

slender thistle
runic dagger
mossy vine
#

DMs on "ok"

runic dagger
#

right, you can DM commands to shadow, but i don't understand why that's a reason to kick the bot?

slender thistle
#

It can be triggered without prefix

mossy vine
#

if you send "ok" in the server it dms you

#

and thats not allowed

runic dagger
#

?? it does?? I'll look into that asap, thanks!!

slender thistle
runic dagger
#

I'm not getting any response..
Would the test have been done here in the server or on another?

So that i can see what was happening at the time of error

slender thistle
#

It was randomly reproduced in #commands I believe

#

To attempt to reproduce it yourself is up to you :p

distant plank
#

@quartz kindle i didn't find anything :c.

runic dagger
#

alright ty, i'll look into it

#

owner prefix mixed with an alias, i'll throw in a check for it and make a re-submition to DBL
apologies for the weirdness.

distant plank
#

How can I get a "magik" effect with sharp?

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

floral zinc
#

I need help with java.. I want to send a webhook. I created a StringEntity with the Json body.
The description should be a tweet. The problem is, it doesn't accept the line breaks.. Has anyone here found a solution to this problem?

west spoke
#

@floral zinc use \n instead of a newline

floral zinc
#

I'm using that. When I type it in the Json string itself (I have to use \n) it works fine. But when I have the description as a variable and just replace the breaks with \n it results in sending a content like this:

Thisnisnantestn

Instead of:

This
Is
A
Test

west spoke
#

Try \n\n

#

It might require double newlines

#

Like reddit

hoary elm
#

Ummm I'm pretty sure it is \n\n 🤔 haven't used that in a while

floral zinc
#

I'll try tmr

sudden geyser
#

@floral zinc try doing \\n if it's from a json lemme try testing

undone rose
#

@distant plank Sharp?

#

You can imitate the magik affect using any image manipulator that allows for liquid rescaling

lament meteor
#

Rawr neko

distant plank
#

@undone rose Sharp doesn't have it?

west spoke
#

@sudden geyser that would be making the \n appear in the messagr

sudden geyser
#

yeah I realized that. At some time, I remember needing to use two slashes for something else

undone rose
#

I dont know, but thats how magik is done

#

Use a lib that interacts with image/graphicsmagick

#

That program can utilize liquid rescaling

vernal willow
#

@heavy void what are you hosting your bot on? Move here instead of #topgg-api
Whatever you're hosting on you can try restarting the running instance of your bot

heavy void
#

Heroku

#

I restarted it multiple times

#

But still sending 2 messages

earnest phoenix
#

Heroku isn't really ideal for discord bots, its more for websites

#

heroku isn't really ideal*

#

Heroku is good for what it's purpose was for

undone rose
#

HE is best host

frozen cedar
#

SparkedHost is what I use

valid frigate
#

all of these off brand vps moments

#

a lot of people go for vultr, galaxygate, digitalocean, ovh, etc

#

and you should move your bot off glitch asap

earnest phoenix
#

galaxygate is probably the best in that list for servers

#

Cheap, reliable, and good net speeds

valid frigate
#

yeah anything on that list, but not restricted there

#

imo the heiarchy is most vps servers > heroku > glitch

#

while you could ask someone to host your bot for you, that comes with the risk of providing your token n shit so dont do that

undone rose
#

https://qoilo.com/hosting I've been using them for months and they offer some super cheap hosting too. I haven't had a single issue with them yet tbh. I had a VPS (one of their mid-tier ones) for a while but then I got a dedi from them for super cheap. abt $36 a month for 64GB of RAM and dual quad core xeons. This host was the one that got me moved over from Vultr, and so far it's been the only host that's been able to make me ditch Vultr

valid frigate
#

first problem i see

#

$36/mo is too good to be true

cunning goblet
#

contabo is best

floral zinc
#

@sudden geyser yea I've tried that. And that does work if I put it in the Json directly. If I put it in a String and put that String in the Json it doesn't work. I dunno why

restive furnace
#

u need to make a code what knows in this whats \n means.

earnest phoenix
#

How to create a dynamic rebour in js ?

#

For an embed

undone rose
#

@valid frigate That's what I thought too

#

But I've had this dedi since March at this point and it's had zero issues

earnest phoenix
#

Hmmm...

undone rose
#

Only issue was me forgetting to setup a static IP

fallow spire
#

Is sending a Custom Dm from any User to an Other User with a Bot against The ToS?

hoary elm
#

@fallow spire not as far as i know there is a few bots such as Nadeko that allow (usually admin or bot owner) to send messages to a specified user

cunning goblet
#

no it isnt

#

in most cases

fallow spire
#

Because someone in my Server with his Bot a that Feature open for everyone

#

@hoary elm

hoary elm
#

well if it abuses API im sure would depend on how fast the messages are sent, as far as allowing the command to be used by everyone im not sure if there is rules to that

fallow spire
#

Ok

#

Cuz if the Person you want a Dm to send to, has blocked you, can you use that as a "bypass"

cunning goblet
#

it doesn't really care how much you spam (because you wont get api banned easily)

undone rose
#

You should not let users send messages with your bot because you are liable for whatever your bot sends

cunning goblet
#

almost every bot

#

has a say command

#

so this is basically a port to dms

patent prism
#

Is a bit intrusive but not against the tos

hoary elm
#

🤔

#

maybe there should be limitations to say commands

undone rose
#

But just like having an image search commands, while it in itself is not against tos, you should not do it, because it can break tos

hoary elm
#

mine are usually locked to owners/devs

cunning goblet
#

limitations

#

also

hoary elm
#

lol

cunning goblet
#

the bot devs wont care

#

popular bots are still doing fine

#

its been 3 years (or 4 kinda) since bots existed

undone rose
#

We used to deny bots here for most image search commands lol

#

Very few were able to pass

cunning goblet
#

i mean most popular bots have them

undone rose
#

We didnt really care much for say

#

But mostly image search

#

But the same idea as image search could be applied to say cmds

humble pendant
#

An image search?

undone rose
#

Commands that allow you to search for images

humble pendant
#

And?

undone rose
#

Since they are hard to do right, most bots that had them got declined for listing

humble pendant
#

Oh ok

hoary elm
#

im guessing that would be due to NSFW returns? @undone rose

humble pendant
#

Yeah probs

undone rose
#

Yeah you could do !imgsearch loli

humble pendant
#

😳

undone rose
#

Obv in a more nsfw manner

hoary elm
#

yeah

cunning goblet
#

yeah but that applies to alot of other bots here

undone rose
#

But that was grounds for denial and Discord staff had confirmed that ur liable for what your bot says

#

So we just declined for it

humble pendant
#

What did your bot say?

patent prism
#

Iirc you have to enable safesearch in non nsfw channels

earnest phoenix
#

Hello

#

Who can help me?

earnest phoenix
#

:/

twilit rapids
#

Just ask your question

earnest phoenix
#

How to make a dynamic timer (embed)?

lunar crystal
#

How make an intervall between different status of ur bot ?

hoary elm
#

@lunar crystal library?

fallow spire
#

How can i make an Command in Discord.js that cleans up the quick.db database?

hoary elm
#

@fallow spire if you dont have it reading from/writing to/editing a JSON file, it should clean it up on restart... Example my bot has a economy system set up that runs off of quick.db and if i dont store the users balances in a json file it refreshes their balance every restart

earnest phoenix
#

...

hoary elm
#

@earnest phoenix timer for what? And what library

earnest phoenix
#

discord.js

#

For a command

#

Example:

#

test 5

#

(seconds)

#

And the 5 seconds pass in the embed

#

in edit

hoary elm
#

Oh so you want like a countdown?

earnest phoenix
#

Yes

#

^^

hoary elm
#

Do you have the timeout defined already

earnest phoenix
#

No, I can't do it at all, so I ask.

#

var tps = args[0]

#

tps is the time for the countdown

mossy vine
#

setTimeout(callback, time)

earnest phoenix
#

I can't use it to make it dynamic in an embed

mossy vine
#

what do you mean by dynamic

earnest phoenix
#

2

mossy vine
#

updating an embed every second will get very close to api abuse

#

yeah

hoary elm
#

he wants it to edit the mebed displaying a different number

earnest phoenix
#

Etc...

hoary elm
#

for the countdown

#

but the countdown has to be defined by the users args input

earnest phoenix
#

Yes

mossy vine
#

thats quickly gonna get to the point of api abuse

hoary elm
#

yeah

#

i was just thinking that

late hill
#

Edit the message occasionally and update the remaining time

#

If your example of 5s is what it'll usually be

#

Just don't use it

hoary elm
#

a message every seconds seems like api abuse

late hill
#

Because I wouldn't update it faster than every 5s

earnest phoenix
#

Bruh...

late hill
#

even that would still be fast

earnest phoenix
#

3?

hoary elm
#

@earnest phoenix ``` let Timer = args[0];

if(!args[0]){
return message.channel.send(":x: " + "| Please Enter a time period followed by "s or m or h"");
}

if(args[0] <= 0){
return message.channel.send(":x: " + "| Please Enter a time period followed by "s or m or h"");
}

message.channel.send(":white_check_mark: " + "| Timer Started for: " + ${ms(ms(Timer), {long: true})})

setTimeout(function(){
message.channel.send(message.author.toString() + The Timer Has FINISHED!, it lasted: ${ms(ms(Timer), {long: true})})

}, ms(Timer));
}```

late hill
#

What are you using this for

hoary elm
#

you copuld use something liek this ^^

late hill
#

Is it that important that the user sees a very updated time

earnest phoenix
#

Okay ty

hoary elm
#

dont forget that ms requires ms

#

lol

#

const ms = require('ms');

earnest phoenix
#

Yes Wesley for just 3 second minim

#

Yes Toxic

late hill
#

You should also be aware that unless you've added some restriction

#

people can just spam the command

#

and you'll have tons of these running

hoary elm
#

add a command cooldown

#

easy fix

earnest phoenix
#

Yes

#

Ty

hoary elm
#

 if (talkedRecently.has(message.author.id)) {
            message.channel.send('Please wait 30 Seconds before using this command again');
    } else {
  let Timer = args[0];

  if(!args[0]){
    return message.channel.send(":x: " + "| Please Enter a time period followed by \"s or m or h\"");
  }

  if(args[0] <= 0){
    return message.channel.send(":x: " + "| Please Enter a time period followed by \"s or m or h\"");
  }

  message.channel.send(":white_check_mark: " + "| Timer Started for: " + `${ms(ms(Timer), {long: true})}`)

  setTimeout(function(){
    message.channel.send(message.author.toString() + ` The Timer Has FINISHED!, it lasted: ${ms(ms(Timer), {long: true})}`)

  }, ms(Timer));
}

talkedRecently.add(message.author.id);
        setTimeout(() => {
          // Removes the user from the set after a minute
          talkedRecently.delete(message.author.id);
        }, 30000);
    }```
#

@earnest phoenix with cooldown ^^

earnest phoenix
#

Ty ^^

late hill
#

You can specify a language for code blocks by adding it on the top line next to the 3 `

earnest phoenix
#

Oh okay why not :)

solemn harness
mossy vine
solemn harness
#

ok

#

erroe

#

error

mossy vine
#

cool

#

whats the error

solemn harness
#
(node:6864) UnhandledPromiseRejectionWarning: Error: Shard 0's process exited before its Client became ready.
    at Shard.<anonymous> (C:\Users\ZaidYt\Desktop\Discord Bot\node_modules\discord.js\src\sharding\Shard.js:88:39)
    at Object.onceWrapper (events.js:291:20)
    at Shard.emit (events.js:203:13)
    at Shard._handleExit (C:\Users\ZaidYt\Desktop\Discord Bot\node_modules\discord.js\src\sharding\Shard.js:272:10)
    at ChildProcess.emit (events.js:203:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
(node:6864) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function
without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)

mossy vine
#

there is another error above or below that causes this one

solemn harness
#

yes

#
.then(() => message.react('�'))
^^^
mossy vine
#

oh yeah

#

you have a semicolon there

solemn harness
#

ok

#

ok

#

done

#

Thank you

trim gull
#

I need a bot setup link

bright patio
#

Do you use JavaScript?

floral zinc
#

So I tried this.. I dont receive a webhook.. Probably because it doesnt accept the format or something.. I really dont know what else to try

earnest phoenix
#

what

quartz kindle
#

what?

earnest phoenix
#

sometimes the ads load sometimes they don't

willow magnet
#

Nope

#

The votes @quartz kindle @earnest phoenix

quartz kindle
#

votes reset every month

willow magnet
#

But they appear when I refresh

quartz kindle
#

caching bugs

willow magnet
#

Oh

#

Sad

#

Thanka Tim!

quartz kindle
#

np

solemn harness
#

guys

#

did vote reset after every month

quartz kindle
#

yes

#

we just talked about it lol

solemn harness
#

lol

#

ty

#

what else we can do with dblapi

earnest phoenix
#

go to the api docs and explore

hazy sparrow
earnest phoenix
#

what do you not get about it

hazy sparrow
#

how to initialize a folder with NPM?

earnest phoenix
#

read

#

it tells you exactly what to run

marsh frost
#

?

solemn harness
#

man

marsh frost
#

What did you @ me for?

solemn harness
#

which api you use ?

marsh frost
#

JDA

#

well I have used JDA for RepCord and DiscordJS for TeamTrees

solemn harness
#

is it possible in java to show how many trees are grown

#

discordjs

#

i just add your bot

grim aspen
#

api?

solemn harness
#

it cool

marsh frost
#

lol yeah I've already done it with the team trees bot

solemn harness
#

cool

marsh frost
solemn harness
#

ik

#

i see it

#

i want to use this in my bot

earnest phoenix
#

quite literally scrape the website

marsh frost
#

Yeah that's all we did

solemn harness
#

oh

marsh frost
#
  numberOfTrees = format({})(parseInt(html("#totalTrees").attr("data-count")));```
#

using Cheerio

solemn harness
#

hmm

little hamlet
#

@solemn harness ^

hazy sparrow
#

when I type npm init -y its saying 'npm' is not recognized as an internal or external command, opertable program or batch file any help?

mossy vine
#

npm is not installed

earnest phoenix
little hamlet
#

or that^

earnest phoenix
#

i mean all it is is litterally scraping the site

#

pretty simple to do manually

#

but that was first result on npm

little hamlet
#

ye, he even made a npm package to

quartz kindle
#

@hazy sparrow after you install node.js you need to restart your computer

hazy sparrow
#

oh

#

thanks

hazy sparrow
#

is NPM and node.js the same?

#

kk

#

ty

#

how do you install npm (asking cuz I cant fing in google. when i search they give how to download node.js)

earnest phoenix
#

npm comes with nodejs

hazy sparrow
#

oh

hazy sparrow
#

damn whatever i do im stuck in the hpm init -y thingy

earnest phoenix
quartz kindle
#

and of course, the "npm package manager" as well

hazy sparrow
#

ah, rip

#

ok now im stuck at Getting your bot running for a stupid reason :why is the background white while mine is black?

#

do i have to open a editor?

#

oh

#

got it

solemn harness
#

yea

hazy sparrow
#

did the code, the bot is not online

#

im losing patience to create a bot now

mossy vine
#

did you actually run the code

hazy sparrow
#

ye

grim aspen
#

did you put in a token to log in with your bot?

hazy sparrow
#

ye

grim aspen
#

is there anything showing in the console?

hazy sparrow
#

wait no

#

i dint put any token

#

where should i put it?

grim aspen
#

then there's your problem

#

where it logd in

hazy sparrow
#

ohm k

west spoke
earnest phoenix
#

@earnest phoenix how can i make widgets for my bot

#

it will be useful for a server stat and command list in the description

#

cause i know some about html

#

@earnest phoenix if you want to use widgets for your not page you must first of all take that simple example they give you in the edit page

#

Then you'll study how they connect bot components, then it'll be like decomposing an object

#

bot.avatar, bot.shardCount etc

#

i will come to that later after making a bot

leaden void
#

hey ! just a quick java question, how to check if the first argument is equals to an element of an enum class ?

pallid zinc
#

 let numberOfTrees = teamTrees.getTrees();

message.channel.send(numberOfTrees)```
#

Not giving any err but not even sending anything

leaden void
#

i code in JDA 😩

jade thistle
#

try putting a ";" at the end of the last line

leaden void
#

i made an enum class to list all of my commands, their usage and their explanation

#

and i want to check if the first arg of the command is an element of this enum class

pallid zinc
#

nothing happens with ";"

fallow spire
#

@jade thistle That don't solves the Problem...

valid frigate
#

semicolons do not matter

#

they're optional in js

#

also @leaden void what is the reason behind making your commands in an enum? it's better to put them in a List instance so you can iterate over them

leaden void
#

i just did this BAN ("Ban", "ban [user] [time (optional)] [reason]", "Bans user from the server."),

valid frigate
#

ah that

leaden void
#

the command's name, it's usage and it's explanation

#

in an enum class

valid frigate
#

and i assume you have a run() method override in your command classes?

late hill
#

I don't think there's a specific method to do that with enums but they do have a values() method that you can iterate to check for a match @leaden void

valid frigate
#

so the enum is just for description

leaden void
#

oh sure i will try is wesley

#

yup

valid frigate
#

ah ok

leaden void
#

just for descripting

valid frigate
#

well in that case do what he suggested then tell us if that works

leaden void
#

yup

quartz kindle
#

@pallid zinc did you read the package docs? all methods are async and return promises

pallid zinc
#

Thanks

leaden void
#

there's no available iterate method

#

if(args[1].equalsIgnoreCase(HelpList.values().toString())) {

#

this don't really sounds like it will work

valid frigate
#

huh

#

well to be fair i've never seen more than one value assigned to an enum key

leaden void
#

oof

valid frigate
#

to set up commands, you could make a base command class and extend other commands off of that class

#

although it's in kotlin it's not too different from java

leaden void
#

hmmm

#

k i think i'll just check if the args is equals to a value name

valid frigate
#

yeah id advise only using 1 value per enum key

leaden void
#

hmm

late hill
#

you can just use a for

leaden void
#

looks bad to make a class for every value

late hill
#
for (EnumValue value : Enum.values()) {

}```
leaden void
#

i always do enum classes with a lot of values

#

what am i supposed to do with that ?

late hill
#

Well

valid frigate
#

that iterates over every value in the enum

late hill
#

You wanted to check if one of them matches a given argument?

leaden void
#

ohhhhh

#

thanks alot

late hill
#

Basically put the code you've put up above in there

#

and use the value instead of Helplist.values()

#

I don't think toString() will work btw

leaden void
#

yup

late hill
#

Unless you've added a toString()

leaden void
#
for (HelpList value : HelpList.values()) {
                    if(args[1].equalsIgnoreCase(value.getCmdName())) {
                        //My code
                    }
                }
late hill
leaden void
#

Thanks a lot !

#

i'll just add a getCmdByName() method to be sure this will work

blissful scaffold
#

@leaden void instead of putting all my commands in an enum i just have them all in a package and on startup I loop over all the classes in there to see if they extend the main command class and just create a constructor and instance from that class

#
Class<?> superClass = CommandParent.class;
List<Class<?>> classes = ClassFinder.find(PACKAGE_NAME);
for (Class<?> c : classes) {
    if (c.equals(superClass) || !superClass.isAssignableFrom(c)) {
        continue;
    }
    try {
        Constructor<?> ctor = c.getConstructor();
        CommandParent o = (CommandParent) ctor.newInstance();
        register(o, o.getCommandName());
    } catch (Exception e) {
        // handle the error
    }
}
#

The ClassFinder is a class that I wrote, I won't help you with that 😛

valid frigate
#

or just

#

yknow

#

make an array of commands

blissful scaffold
#

you would still need to edit that array/enum every time you add a new command

#

im lazy

#

and i always forget to edit the enum/array that lists all the commands

valid frigate
#

don't get into class loading unless you know how to do it yet

blissful scaffold
#

good point

pallid zinc
#

Tim thanks it work perfectly

valid frigate
#

also once you have the time, learn kotlin it's hot 😩

leaden void
valid frigate
#

good

leaden void
#

Thank you guys for helping me ^^

earnest phoenix
fallow spire
#

idk formate or sth

blissful scaffold
earnest phoenix
#

it's the object that's returned to you

#

not the one you send

blissful scaffold
#

hmm yeah, i just noticed it has the url of the data

west spoke
#

@earnest phoenix data is the data of the file (eg image/png, etc.)

earnest phoenix
#

data is the data of the file (eg image/png, etc.)
no it's not

#

i don't know why that's even implemented

#

might be a derp, it shouldn't be in the constructor

#

basically it just patches over the object's data

west spoke
#

Ah

#

I thought it was the metadata

#

That's how it is for s3

earnest phoenix
#

everything about the image/attachment is in the buffer

quartz kindle
#

@earnest phoenix define "years to load"

earnest phoenix
west spoke
#

Oh, ok

earnest phoenix
#

well above, it was 13 seconds in one of them

quartz kindle
#

why are you making it 3000x1000 in the first place?

west spoke
#

@earnest phoenix the maximum file size has to be less than or equal to 8mb

earnest phoenix
#

because the person who made the rank card design for me in Photoshop sent me it as 3000 x 1000

quartz kindle
#

whats your "creating attachement" code?

earnest phoenix
#
const attachment = new MessageAttachment(canvas.toBuffer(), "rank.png");
west spoke
#

You can resize it down

quartz kindle
#

im sure you are aware resizing images is a thing, right?

west spoke
#

to about 1000*350

earnest phoenix
#

i didnt think it would be an issue PepeYikes

west spoke
#

more or less

quartz kindle
#

whats the background image format and size?

earnest phoenix
#

it takes a custom background, but the default is 3000 x 1000 also i believe, lemme double check

quartz kindle
#

size in kb/mb

earnest phoenix
#

ohhh

quartz kindle
#

assuming you're loading it from disk

#

is it jpg or png?

earnest phoenix
#

its a PNG, and im loading it using the proxyURL on discord (I used to load from disk but thought maybe using a proxy URL would be more efficient for speeds)

#

669KB

quartz kindle
#

so you uploaded it to discord and download from it every time?

earnest phoenix
#

no, i have the proxy URL of it saved in a database

west spoke
#

You don't need to download it again

earnest phoenix
#

wait no i dont

west spoke
#

just save the output image

quartz kindle
#

thats downloading it again

earnest phoenix
#
if (!card) card = {
    guild: message.guild.id,
    user: member.id,
    primary: "#44c0fc",
    secondary: "#ffffff",
    accent: "#44c0fc",
    background: "https://cdn.discordapp.com/attachments/632404176155967498/639499306012901386/defaultBackground.png",
    opacity: 0.75
} as RankCard;
quartz kindle
#

you cant use an image with canvas without downloading it

west spoke
#

that's why PIL is good lol

earnest phoenix
#

oh so I was better off loading from the disk?

quartz kindle
#

from a performance perspective, disk will always be faster than network

#

and memory will always be faster than disk

#

so you should load from disk, and cache in memory whatever can be reused

#

then, for a full background, jpg is better (if you dont need pixel perfect quality)

undone rose
#

Thays why PIL is good

quartz kindle
#

png is better for transparency

#

so use png for icons and objects with transparent parts, and jpg for full color backgrounds

#

then, use an image compressor

#

there are plenty of good algorithms out there that can compress images without any meaningful quality loss

#

for example pngquant (for pngs)

#

and of course, dont make images bigger than what you need them to be

#

keep their resolution realistic

earnest phoenix
#

alright so basically

  • Resize the overall image
  • Load images from the disk
  • Cache the default background
  • Use pngquant for compressing
quartz kindle
#

basically yes

earnest phoenix
#

alright i'll give it a go, ty

quartz kindle
#

doing those will probably give you a performance boost of over 50%

ashen urchin
#

Looking for a bot that can reply with information that is typed in from a database, it need search function, any info on a bot DM me.

undone rose
#

Everybody here will either tell you that doesnt exist or to look on the site lol

ashen urchin
#

Thanks

fallow spire
#

How would i do an commandusage command?

earnest phoenix
#

what

fallow spire
#

srly?

loud salmon
#

your sentence makes no sense

vernal willow
#

@fallow spire You mean see how many times a command has been used or?

fallow spire
#

Yes exactly

vernal willow
#

what language

fallow spire
#

js

#

oh

#

could i save it in an db?

valid frigate
#

after your command's run function has finished, that's where you would update command usage

earnest phoenix
#

im shit at maths, can somebody give me the equation please lol:

so for my XP bar,
675 pixels = 100%

my old equation: (xp * 100 / (level * 35)) * 20.2

basically the 20.2 needs changing to something to make it correct

#

nvm i got it

earnest phoenix
#
 1: node::Abort() [node]
 2: 0x8ccf9c [node]
 3: v8::Utils::ReportApiFailure(char const*, char const*) [node]
 4: Require(v8::Local<v8::Object>, char const*) [/rbd/pnpm-volume/13671c08-f1fc-4577-8b52-c3bbb55876b8/node_modules/.registry.npmjs.org/better-sqlite3/5.4.2/node_modules/better-sqlite3/build/better_sqlite3.node]
 5: Integer::Init(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Object>) [/rbd/pnpm-volume/13671c08-f1fc-4577-8b52-c3bbb55876b8/node_modules/.registry.npmjs.org/better-sqlite3/5.4.2/node_modules/better-sqlite3/build/better_sqlite3.node]
 6: RegisterModule(v8::Local<v8::Object>, v8::Local<v8::Object>) [/rbd/pnpm-volume/13671c08-f1fc-4577-8b52-c3bbb55876b8/node_modules/.registry.npmjs.org/better-sqlite3/5.4.2/node_modules/better-sqlite3/build/better_sqlite3.node]
 7: 0x8ce97d [node]
 8: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
 9: 0xb0d72c [node]
10: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
11: 0x2869c8d042fd
/opt/watcher/app-types/node/start.sh: line 51: 13050 Aborted                 (core dumped) node index.js```
#

What is this?

#

@quartz kindle what would you recommend for caching the images? sized it down now and its already loading alot faster

#

Can you help me with the error, please?

amber fractal
#

@earnest phoenix what node version do you have

earnest phoenix
#

Is the node-fetch portion?

amber fractal
#

What?

earnest phoenix
#

anyone know a js lib that helps you fetch the full url, that url shorteners redirects you to ?

quartz kindle
#

@earnest phoenix you can use anything, even an array/object/map

earnest phoenix
#

what would I store in a Map? just the file path?

quartz kindle
#

no, the loaded image

#

either its buffer, or a canvas with it in it

amber fractal
earnest phoenix
#

hmm

#

weird, it works on stuff like bitly, but not the specific service im working on

#

how many ways are there to shorten urls and redirect em

quartz kindle
#

the problem is not the redirection, is when the redirection is "premium"

#

like when they make you do something to make the link continue, like watch an ad, or fill a survey

earnest phoenix
#

can i send the link, i'm trying to expand

#

?

#

im fairly certain what you're mentioning isn't a problem, it's a pretty basic service

#

(this specific url shortener site)

hoary elm
#

uu.expand('url here')
  .then(url => {
    if (url) console.log('Original url is: ${url}');
    // no shortening service or an unknown one is used
    else console.log('This url can\'t be expanded');
  })
  .catch(err => console.log(err));```
#

@earnest phoenix I used to use this ^^ in one of my old node.js bots

#

Not sure if it still works though

earnest phoenix
#

hmm, i used an online url analytics tool

#

something about the url telling the site is moved and then changing the location

hoary elm
#

Hmm

earnest phoenix
#

don't just wanna screenshot the http header incase it contain ip or something

hoary elm
#

What is the reason for wanting to expand this

#

Like you think it's a grabber or?

earnest phoenix
#

grabber ?

hoary elm
#

IP grabber

#

You can use fake links to grab IPs

earnest phoenix
#

no, it's just somewhat popular here in Denmark

hoary elm
#

Oh

earnest phoenix
#

and i couldn't get it to expand unlike other url shortener services

#

not sure if it uses a different approach or something

surreal sage
#

How can i get mt server's guild id?

hoary elm
#

@surreal sage in the bot or?

surreal sage
#

oh nvm

#

i see

hoary elm
#

Lol

surreal sage
hoary elm
#

@earnest phoenix well the expander I used says it's just a Google link

#

Then it will show as a server you can edit

surreal sage
#

ik

earnest phoenix
#

what expander are you using ?

#

because your example code is returning " this url can't be expanded" on my side

hoary elm
#

Hmm

lofty hamlet
#

Hi

#

It's possible to detect when user join channel where the bot is and detect if channel content 1 user (Does not include the bot)

earnest phoenix
#

a voice channel?

lofty hamlet
#

Voice channel yeah

earnest phoenix
#

of course it is

lofty hamlet
#

?

#

Oh ok and how ?

earnest phoenix
#

in which library

lofty hamlet
#

discord.js

earnest phoenix
#

first check if the new member's voice channel property is defined

#

if it is, it means they joined in the channel

hoary elm
#

Umm

earnest phoenix
#

then you can grab the voice channel members property and filter out your bot

#

and simply count how many users there are

lofty hamlet
#

Mmmmh

hoary elm
#
  let newUserChannel = newMember.voiceChannel
  let oldUserChannel = oldMember.voiceChannel


  if(oldUserChannel === undefined && newUserChannel !== undefined) {

     // User Joins a voice channel

  } else if(newUserChannel === undefined){

    // User leaves a voice channel

  }
})```
earnest phoenix
#

stop spoonfeeding

hoary elm
#

Not really spoonfeeding as it's incomplete

#

And not guaranteed to work

lofty hamlet
#

Mmmh

earnest phoenix
#

spoonfeeding does not directly mean to give fully working code

hoary elm
#

Oh

#

My bad then

#

It's like literally incomplete doesn't log or nothing so I figured it was alright

lofty hamlet
#

And with this how i can know how much user is in the channel ?

hoary elm
#

like cry said you would have to grab or fetch the voice channel members filter out your bot and count how many users there are

#

This may help 🤷🏻‍♂️

lofty hamlet
#

Ok but now mmmh, i can detect if the bot is in the channel that i join ?

earnest phoenix
#

has on members property

hoary elm
#

For that I'm sure you could use guild.members.filter

#

Oh

earnest phoenix
#

filter is for... well filtering

#

use has(id) for checking if x is in the collection

hoary elm
#

😁

lofty hamlet
#

Mmmh

#

@earnest phoenix how ?

#

Don't understand srry

earnest phoenix
#

good, you have google

lofty hamlet
#

?

earnest phoenix
#

voiceChannel#members is a collection

#

you can use Collection#has to find out if a certain member is in that collection

#

that's basically a summary of what he/she just said

lofty hamlet
#
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel

    if (oldUserChannel === undefined && newUserChannel !== undefined) {
        const voiceChannels = newMember.guild.channels.filter(c => c.type === 'voice');
        let count = 0;

        for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;

        console.log(count);
        if (count == "2") {

        }
    } else if (newUserChannel === undefined) {
        console.log("Disconnected")
    }
})```
#

Now i have this

earnest phoenix
#

ok?

lofty hamlet
#

With this i want detect if the bot is in channel

earnest phoenix
#

ok so do what was just said

#

i'm not going to spoon feed you the code

lofty hamlet
#

I did not see

#

But i have not understand

#

Mmmh

earnest phoenix
#

maybe learn a little more js then

lofty hamlet
#

I'm not english ^^'

#

It's just this

earnest phoenix
#

why do you code in english then?

#

that's what i never get

lofty hamlet
#

Because english is a famous language

earnest phoenix
#

oh true, so you want to learn it?

#

and an easy way of learning some of the words is by coding?

lofty hamlet
#

Learn what ?

earnest phoenix
#

English

smoky spire
#

Trintous I want you to name a universally recognized coding language that isn't in English

earnest phoenix
lofty hamlet
#

😂

#

No worry

#
      guild: [Guild],
      user: [User],
      joinedTimestamp: 1572135410299,
      _roles: [Array],
      serverDeaf: false,
      serverMute: false,
      selfMute: false,
      selfDeaf: false,
      voiceSessionID: 'a862195d8c3cbcb9645e5de7b5d316e2',
      voiceChannelID: '630407881753362442',
      speaking: false,
      nickname: '▒ ▒▒▒ ▒',
      lastMessageID: null,
      lastMessage: null,
      deleted: false
    }```
#

My collection :d

#

@earnest phoenix now ? :d

#

I do test if channel of the bot is the channel of user ?

earnest phoenix
#

use has(id) for checking if x is in the collection
you can use Collection#has to find out if a certain member is in that collection

lofty hamlet
#

Mmmh

#

newMember.voiceChannel.has(WHATID) ?

#

What id ?

#

Wow

earnest phoenix
#

your bot's ID as a string

lofty hamlet
#

if (newMember.has("601546541466910722")) { console.log.log("YEAH") }

#

TypeError: newMember.has is not a function

#

@earnest phoenix

smoky spire
#

newMember.roles.has

lofty hamlet
#

?

#

No wtf

quartz kindle
#

console.log.log() ?

smoky spire
#

Oh you want to see if the bot is in the same voice channel as a user?

lofty hamlet
#

O fail

smoky spire
#

newMember.voiceChannel.members.has

lofty hamlet
#

if (newUserChannel.has("601546541466910722")) { console.log("YEAH") }

#
client.on('voiceStateUpdate', (oldMember, newMember) => {
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel

    if (newUserChannel.has("601546541466910722")) {
        console.log("YEAH")
    }


    if (oldUserChannel === undefined && newUserChannel !== undefined) {
        const voiceChannels = newMember.guild.channels.filter(c => c.type === 'voice');
        let count = 0;

        for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;

        console.log(count);
        if (count == "2") {

        }
    } else if (newUserChannel === undefined) {
        console.log("Disconnected")
    }
})```
#

@smoky spire no

smoky spire
#

What are you trying to do

lofty hamlet
#

Read message ...

smoky spire
earnest phoenix
#

read a voice channel message

#

???

lofty hamlet
#

No wtf 😂

#

@earnest phoenix you know what i want

smoky spire
#

I do test if channel of the bot is the channel of user ?
This is what you said earlier

lofty hamlet
#

So you say this and does not work

earnest phoenix
#

Lmao

#
  1. i didn't say that
lofty hamlet
#

if (newUserChannel.has("601546541466910722")) { console.log("YEAH") }

#

newUserChannel.has

earnest phoenix
#
  1. do you even know what your doing
lofty hamlet
#

You say this ...

earnest phoenix
#

a channel is not a collection what

#

Ok buddy

lofty hamlet
#

newUserChannel is my collection

earnest phoenix
#

no it's a voicechannel

lofty hamlet
#

I want if i join a channel when is my bot and the channel when is my bot content x users, i do x

earnest phoenix
#

let newUserChannel = newMember.voiceChannel

#

literally from your code

lofty hamlet
#

And for this i have this

earnest phoenix
#

and i have a feeling that you don't know what a collection is

lofty hamlet
#
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel

    if (newUserChannel.include("601546541466910722")) {
        console.log(newUserChannel)
    }


    if (oldUserChannel === undefined && newUserChannel !== undefined) {
        const voiceChannels = newMember.guild.channels.filter(c => c.type === 'voice');
        let count = 0;

        for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;

        console.log(count);
        if (count == "2") {

        }
    } else if (newUserChannel === undefined) {
        console.log("Disconnected")
    }
})```
earnest phoenix
#

or barely js at all

lofty hamlet
#

I say what i want ...

#

I want if i join a channel when is my bot and the channel when is my bot content x users, i do x

earnest phoenix
#

ok code it yourself

#

i'm not entitled to help you

copper cradle
#

^

earnest phoenix
#

Hey who are here?

copper cradle
#

wdym

earnest phoenix
#
let overwrites = category.permOverwrites.map(permOver => {
                        return {
                            id: backupserv.references.roles.get(permOver.id).new.id,
                            allow: new Permissions(permOver.allow),
                            deny: new Permissions(permOver.deny),
                        };
                    });```

I'm trying to make a bot of backups(Xenon in js lol)
But I can't restore permissions on categories
```js
"categories":[{"idOld":"637697437871505426","name":"textuels1","position":0,"permOverwrites":[{"id":"637697434180517888"}]```
#

Error: RangeError: Invalid permission string or number.

#

I use discord.js@11.5.1

candid hill
#

I submitted my bot recently to be approved, but didn't read the permissions = 0 part of the faq until afterwards. If a bot is relying on having permission to read text chat messages, could that cause it to fail to take arguments from a command?

loud salmon
#

if the bot alerts the command runner that it is missing permissions then we add the permissions @candid hill

candid hill
#

Ah. I just learned about catch, so I probably missed some promises. Is your testing process automated?

loud salmon
#

nope lol

#

userbots aren't allowed and bots shouldnt respond to other bots

candid hill
#

Yeah, that would do it. Ah, so the crash likely wasn't from your testing then.

earnest phoenix
#

Who can help me?

#

anyone know how i would access something equivalent to this through node.js, maybe using the 'request' module?

quartz kindle
#

pretty sure any http lib can do that

#

i wouldnt recommend request as its quite bloated

earnest phoenix
#

for now my main concern is how user friendly the lib is :p

#

but could you maybe guide me towards the right sources? or some search terms i could use?

mossy vine
#

so you just want to send an http request, and log all the response data?

earnest phoenix
#

well, currently i'm mostly interested in the location url

#

something like response.location, dunno

#

but pretty much yeah

mossy vine
#

isnt location a response header?

earnest phoenix
#

uhm, not sure

mossy vine
#

i think it is

earnest phoenix
#

so

#

i console.log(res.headers);?

#

Test 🤷

mossy vine
#

depends on the library you are using

earnest phoenix
#

request atm

mossy vine
#

yeah it seems to be working

earnest phoenix
#

i think it works, but i don't get the location

#

url

mossy vine
#

because the server doesnt give you a location header

#

The HTTP Location header field is returned in responses from an HTTP server under two circumstances:

To ask a web browser to load a different web page (URL redirection). In this circumstance, the Location header should be sent with an HTTP status code of 3xx. It is passed as...

earnest phoenix
#

but it does when i put the same url

#

into the online tool

mossy vine
#

oh weird im getting the location header with curl too

earnest phoenix
#

wait, so it's just me ?

mossy vine
#

seems to be request being weird

earnest phoenix
#

so you were using a lib called 'curl' ?

mossy vine
earnest phoenix
#

oh mb

mossy vine
#

its working with another http lib im trying rn

earnest phoenix
#

oh, what lib is that?

mossy vine
earnest phoenix
#

oh, it's discord bot oriented to?

mossy vine
#

its just a regular http client

earnest phoenix
#

so their documentation link dumps me here

#

not sure where to click

#

or is the documentation inside their discord server madThoonk

mossy vine
#

honestly, the documentation is trash. the dev is a really nice guy, so if you contact him, he will help you with it

earnest phoenix
#

i mean, something is better than nothing

#

can't even find it rn

mossy vine
#

should be on the wiki sidebar

earnest phoenix
#

ah thanks

#

in that case i want it set to true right?

mossy vine
#

chaining is method chaining

#

wumpfetch().bla().bla().bla().send()

earnest phoenix
#

oh ok, so something completely different

mossy vine
#

yeah

earnest phoenix
#

uh, so the example code is giving a bunch of errors already

mossy vine
#

lmao

#

yeah just spam his dms about thatp

earnest phoenix
#

idunno i feel bad just straight up dm'ing somebody

mossy vine
#

fine ill do it then

earnest phoenix
#

xD

mossy vine
#

@earnest phoenix send him the errors you got

earnest phoenix
#

just want me to dm him? @mossy vine

mossy vine
#

yeah

earnest phoenix
#

we got it working c:

distant plank
#

What is the best image editing module that liquid-resize has

#

?

quartz kindle
#

what you're looking for is called "seam carving" or simply "content-aware scaling"

#

its not something that can easily be done with js

warm marsh
#

Is the Discord.rb library still a thing?

cunning goblet
#

yeah

warm marsh
#

Alright.

snow urchin
#

(node:18953) UnhandledPromiseRejectionWarning: TypeError: u.hasRole is not a function

#
  let total = message.guild.roles.get('622722028121620500').members.map(m => message.guild.members.get(m.user.id));
  total.forEach(u => {
    if (u.hasRole(ppresenters)) {
      presenters.push(u.id)
    }
. . .
earnest phoenix
#

why not just make the members collection an array

#

rather than mapping it and then trying to get each one from the guild again

#

and is GuildMember#hasRole() even a method?

#

wait what version of d.js are you using

sudden geyser
#

@earnest phoenix in fact that might be useless

#

both mapping and converting to an array

#

forEach is already in Map

earnest phoenix
#

that's why i asked why is he mapping it

#

but you could convert the collection to an array of guild members to use forEach()

sudden geyser
#

yes, but there's no need to do that as forEach is inherited with map.

By the way, hasRole is not a property in stable or master. Take a look at the Collection/GuildMemberRolesStore class.

earnest phoenix
#

oh ok 👍

#

not sure if he was on a older version of d.js where/if that property existed

amber fractal
#

you already have the members

#

oh I didnt read what lite said

undone rose
#

@distant plank just use the gm module

#

With imagemagick

valid frigate
#

so in kotlin should i be checking a List instance for no objects by .size, .isNull(), or isNullOrEmpty()?

#

to be fair

west raptor
#

Probably isNullOrEmpty

#

Seems the most logical to me

#

Then again I dont use jvm much so

valid frigate
#

id think so too, maybe there is some overhead with using it but idk

west raptor
#

Yeah

hazy sparrow
#

At the installing discord.js step, i hit npm init -y, it created no new files, is that ok?

balmy lantern
#

hey whats up with the server button on the bots? mine hasnt updated in quite a while

pallid zinc
#

Does discord don't support .svg image

#

It don't support

balmy lantern
#

poof

hoary elm
#

```request.post(https://discordbots.org/api/bots/${client.user.id}/stats)

.set('Authorization', 'dblTokenHere')

.send({ server_count: client.guilds.size })

.end();```

#

I'm not gonna give you my full code for it but that's the basics

#

After the end you can either do a console.log or a message.channel.send

balmy lantern
#

Ok ya ya

hoary elm
#

@balmy lantern if you need more help you are free to DM or ping me I just don't want to get in trouble for spoon feeding

valid frigate
#

what is the primary difference between fold and sort methods on a List instance in kotlin?

#

from what i see so far it's that fold has an initializer while sort does not

cunning goblet
#

axios > node-fetch > request

earnest phoenix
#

I have the right to make a clone order for server owners?

sudden geyser
#

phin > node-fetch > axios

#

no request because that ain't maintained

glad leaf
#

i cant find the error here, is there a hotkey that finds it or something?

glad leaf
#

nvm

earnest phoenix
#

How can I see 3 days after the current time

#

const math = require('math-expression-evaluator')
var s = (new Date(Date.now()) + '0000-00-03');
let c= math.eval(s)
message.channel.send(c)

#

Error
[object Object]

west raptor
#

why are you evaling it in the first place

#

(new Date(Date.now()) + '0000-00-03') has already given s a value

earnest phoenix
#

const math = require('math-expression-evaluator')
math.eval(new Date(Date.now()) + '+ 0000-00-03');

#

?

quartz kindle
#

you cant do math like that

#

a date object will be converted to a string if you do that

earnest phoenix
#

Well, how can I add 3 days to the current time?

quartz kindle
#

the "0000-00-03" string will simply be appended to the end of the converted time string

#

the Date object can only do math operations based on timestamps

#

so you need to add 3 days in miliseconds to the original date

#

or use a library that is built for date and time operations like that

#

but the easiest way is to simply do new Date(Date.now() + 3daysinmiliseconds)

earnest phoenix
#

thanks

quartz kindle
#

1 second is 1000ms, 1 minute is 60s, 1 hour is 60m, one day is 24h
3 days = 1000 * 60 * 60 * 24 * 3

earnest phoenix
#

👌

humble pendant
#

whats the best node.js package for a music bot?

earnest phoenix
#

ytdl ?

#

not sure myself i don't use music stuff

humble pendant
#

alright lol

#

ill try it

earnest phoenix
#

it was made by the main developer of d.js

humble pendant
#

ah ok

earnest phoenix
#

I'm waiting that like 1 week for my bot to be approval and no one test it yet how much time should I wait

west spoke
#

how is this related to bot development

quartz kindle
#

it can take a while, depending on how many bots are in queue and how much time mods have to work on them

#

sometimes it takes 2-3 days, other times it takes a week or even more

loud salmon
west spoke
#

Great explanationGWnonRaphi

loud salmon
#

and got the same answer

west spoke
#

yep

azure nymph
#

I am trying to make a command which can be executed by typing any strings in an array. The only issue, it doesn't work for some reason and I can't find out why

quartz kindle
#

why are you wrapping an event listener in a function?

#

thats like, so wrong

earnest phoenix
#

^

azure nymph
#

it's just cleaner

#

in my opinion

#

because I can just list the commands like

#

requestOrbImage(); (a command)

#

or

#

exampleCommand();

late hill
#

So

#

You're also adding a new listener for each command

copper cradle
#

that's so wrong

#

use a command handler

#

smh

earnest phoenix
#

That's not cleaner

#

That's a problem

azure nymph
#

can you just attempt to answer my question

earnest phoenix
#

We did

#

Probably

late hill
#

^No

#

The issue you're having is that you're using Array.slice() while probably not knowing what it actually does

#

It returns an array

azure nymph
#

yes, I figured that out

late hill
#

yes

#

your cmd won't ever equal an array

azure nymph
#

beforehand I used [0,1,2] and it didn't work

#

so I posted a question on stackoverflow

#

some man suggested slice

late hill
#

..

azure nymph
#

it didn't work

#

and I came here

late hill
#

Have you thought of looking up like

#

official documentation

azure nymph
#

yes

late hill
#

👀

azure nymph
#

I couldn't find anything

late hill
earnest phoenix
#

lol

azure nymph
#

oh that page

#

I tried a lot of things on there

#

it didn't work

late hill
azure nymph
#

how is that supposed to help me

late hill
#

Read what the includes() method does

earnest phoenix
#

What

late hill
#

or simply guess by looking at it's name

earnest phoenix
#

People cant help if you aren't willing to learn

#

But yeah includes

#

Is a good method

#

To do things

quartz kindle
#

you really should stop using functions like that, but be my guest.
and yes, the answer to executing the same command from multiple keywords is using array.includes()

azure nymph
#

how should I use functions

quartz kindle
#

the event listener is the base, the source or all commands

#

there should only be one event listener, listening to all messages, and then analyzing each message, and firing a relevant function

azure nymph
#

there is only one event listener

#

because I only want one command

quartz kindle
#

so the listener should execute functions, not the function execute listeners

#

because listeners are permanent, they will keep running forever

#

if you execute a function which creates a listener, the listener will not stop when the function finishes

earnest phoenix
#

If you want it to be clean, you can use a command handler

quartz kindle
#

and when you need that function again, it will create a new listener again

#

and then you will slowly be filling up your memory with endless listeners

#

multiplying your ram and cpu usage, until your bot crashes

earnest phoenix
#

That's a 😳

#

You can still call function inside of the listener though

azure nymph
#

So, how would I use .Includes() to be anything in an entire array?

quartz kindle
#
let array = [1,2,3,4,5];
array.includes(3) // true
array.includes(7) // false```
azure nymph
#

that's only one thing in an array

#

unless I want to put tons of array.includes()

late hill
#

No

#

It goes through the entire array

quartz kindle
#

thats what you asked, unless you want to check if one of multiple items exist in an array

late hill
#

The parameter you pass to it is whatever you're checking

azure nymph
#

for example, if I used that in an if statement like (if array.includes(2) ) { execute message }

#

that would be a single thing

#

that would execute it

late hill
#

I think you're not understanding things because tim used numbers

#

the number you enter isn't an index

#

or an item in the array

azure nymph
#

ohhh

#

right

late hill
quartz kindle
#
let array = ["keyword1","keyword2"];
array.includes("keyword1") // true
array.includes("keyword3") // false```
west spoke
#

it's if "hi" is in " hi how are you"

azure nymph
#

but how would you do something like products.includes("apples" or "pears"){ fjsiekhesafessg}

quartz kindle
#

so you want to check if one of multiple items exist in an array

#

thats a different thing

#

for that you need to use a combination of array.some() and array.includes()

#

array.some() takes a function to test each item in the array

#

and it returns true if one of the tests passes

azure nymph
#

and would I just do

#

return true

#

in that case

#

so everything passes

quartz kindle
#

that will make it always return true, so no

#
let array = ["one","two","three"];
let itemsToCheck = ["one","five"];
itemsToCheck.some(item => array.includes(item)) // true because one of the itemsToCheck exists in array
fallow spire
#

how would i put my token in .env?

spare goblet
#

@fallow spire where are you hosting your bot in?

fallow spire
#

glitch.com but heroku soon. thats why im asking for that

spare goblet
#

heroku doesnt support .env iirc they use config vars

#

but nto sure

fallow spire
#

hm cuz in Tutorial it said use .env

spare goblet
#

anyway glitch.com uses a shell file, so it would look something like this

token=yourtokenhere

#

and you can refer to it in another file by process.env.token

fallow spire
#

for heroku: do i dont Still need a Botconfig File for token?

#

@spare goblet

spare goblet
#

i dont know

#

i dont use heroku

#

iirc you use config vars tho

fallow spire
#

so no Botconfig File?

copper cradle
#

@fallow spire you can use a bot config file

#

what's the point of putting anything inside an environment variable if the project is private anyway

distant plank
#

i need help

#

I created a small command for levels in my bot

#

and I want to know how I could use a command to see the ones with the highest level

#

use keyv with mysql as a database

#

This is my code when someone sends a msg

#

well

#

it is very long

#
if (message.author.bot) return;
    let messagenumber = await keyv.get("messagenumber" + message.author.id);
    let messagelevel = await keyv.get("messagelevel" + message.author.id);
    let messagedif = await keyv.get("messagedif" + message.author.id);
    if (!messagenumber) {
      messagenumber = 0;
    }
    if (!messagedif) {
      await keyv.set("messagedif" + message.author.id, 15);
    }
    if (!messagelevel) {
      await keyv.set("messagelevel" + message.author.id, 0);
    }

    let nmessagenumber = messagenumber + 1;
    await keyv.set("messagenumber" + message.author.id, nmessagenumber);

    if (nmessagenumber >= messagedif) {
      
      var nmessagedif = messagedif * 2;
      var nlevel = messagelevel + 1;
      var role;
      var obtainrole;
const embed = new Discord.RichEmbed()
        .setAuthor(
          `Felicidades ${message.author.username}!`,
          message.author.avatarURL
        )
        .setTitle(`Subiste al nivel ${nlevel}!`)
        .setDescription(obtainrole)
        .setThumbnail(message.author.avatarURL)
        .setColor("GREEN");
      message.channel.send(embed);

      await keyv.set("messagedif" + message.author.id, nmessagedif);
      await keyv.set("messagelevel" + message.author.id, nlevel);
 }
#

try to trim it

earnest phoenix
#

heroku support env @fallow spire

distant plank
#

if they see any error, it is because I cut it badly :v

spare goblet
#

@earnest phoenix wrong tag

#

tag the person who uses heroku pls

distant plank
#

i use heroku :v

quartz kindle
#

@distant plank you need to load all entries and then sort them

distant plank
#

how

quartz kindle
#

from keyv's documentation, they use a Map as the default storage for the in-memory side

#

so it should be compatible with all js Map methods

trail reef
#

hi, so

#

Yknow how they're now the custom status feature

#

when will that be a thing in the regular discord API?

#

or is it already there?

quartz kindle
#

if there is, it should be part of presences, so check that

distant plank
#

@quartz kindle Can you give me a little idea or example?

trail reef
#

@quartz kindle ^

#

idk

#

like get rid of the "playing" or "streaming" prefix

#

google yields no good answers

mossy vine
#

you cant

trail reef
#

hhhh

quartz kindle