#development

1 messages · Page 828 of 1

naive mantle
#

so

#

var myArray = []; if (!myArray[0]) myFunction();

sacred knoll
#

The best way to get good performance in JavaScript is to find a exploit that allows you inject shellcode directly into V8.

naive mantle
#

wont that not run

#

because my array value is not 0

lyric mountain
#

The best way to get good performance in JavaScript is to find a exploit that allows you inject shellcode directly into V8.
@sacred knoll #memes-and-media

#

you're not being constructive in any way

#

not you pie

warm marsh
#

Pie are you on a PC or mobile?

naive mantle
#

pc

sacred knoll
#

Alright. I was just enjoying the lockdown.

pale vessel
#

you can test stuff on console

warm marsh
#

Try the browser, The console is the best way to learn.

naive mantle
#

ok

pale vessel
#

yez

naive mantle
#

like

#

control shift i console?

#

or

warm marsh
#

Yeah

naive mantle
#

ok

quartz kindle
#

it will work because an empty array can be checked for content

lyric mountain
#

but he's taking the value in index 0

#

which doesn't exists

pale vessel
#

time flies by fast, it's already 12:12am here

quartz kindle
#

yes, i mean the checking will work

#

the function will not

#

but the code will correctly check if the value exists and not run the function because the value doesnt exist

warm marsh
#

The function will call due to it being JS.

naive mantle
#

does an empty array automatically get assigned to 0

quartz kindle
#

no

naive mantle
#

i did

#

var myArray = [0];
if (!myArray[0]) console.log("happy")

#

and it said happy

quartz kindle
#

an empty array is an array without indexes. when you attempt to get a specific index from it, it will return undefined

pale vessel
#

0 would be the first element

#

in this case, there's none

lyric mountain
#

now there is

naive mantle
#
var myArray = [0];
if (!myArray[0]) console.log("happy")```
tight plinth
#

var myArray = [0]
thonkku

naive mantle
#

it logged happy

#

because yes

#

because myArray was defined as 0

pale vessel
#

it wouldn't log

tight plinth
#

var myArray[0] = 'something'

lyric mountain
#

because you set the array as containing one index that's 0

warm marsh
#

There isn't a requirement for having that 0 in there, Unless you were trying to see if a specific index had something.

naive mantle
#

it did

lyric mountain
#

it wouldn't log
@pale vessel it would

naive mantle
#

it did log

lyric mountain
#

because the first entry is 0

#

which converts to false

naive mantle
#
var myArray = [0];
if (!myArray[0]) console.log("happy")```
#

it worked

warm marsh
#

Shouldn't have.*

pale vessel
#

oh yeah there's !

tight plinth
#

yes

naive mantle
#

i have something i learned thats complicated

warm marsh
#

nvm

#

0 is falsy

naive mantle
#

let me do it

hidden spindle
#

Okay, im back with another question, to get all users from the server my bot is in, do i need a GuildManager or a Guild?

quartz kindle
#

!myArray[0] = !0 = 1 = true

sacred knoll
#

undefined & null & false & 0 all mean false in js

lyric mountain
#

Okay, im back with another question, to get all users from the server my bot is in, do i need a GuildManager or a Guild?
@hidden spindle guild

hidden spindle
#

Cool thanks!

lyric mountain
#

guildmanager is the "settings" menu in the server

hidden spindle
#

oooh

lyric mountain
#

undefined & null & false & 0 all mean false in js
@sacred knoll except they don't

pale vessel
#

depends on what you compare it with

sacred knoll
#

They call can be with type coercion

#

With the bool operators

lyric mountain
#

not the way you said it

#

if you use them as comparators then yes, they can be false

warm marsh
#

They are all considered falsy values but aren't equal to false.

lyric mountain
#

but themselves aren't false

naive mantle
#

here it is

#
var myArray = [1,0]
var choice = myArray[Math.floor(Math.random() * myArray.length)
console.log(choice)```
sacred knoll
#

I did not mean they are false. But they're falsy.

naive mantle
#

it randomises the values in the array

#

good for commands like coinflips

pale vessel
#

nice

lyric mountain
#
0 == false -> true
false == false -> true
null == false -> false
undefined == false -> false
sacred knoll
#

Yeah I mean with bool operators

#

Not comparsion

#

i.e !<thing>

tight plinth
#

undefined isnt true or false

#

its undefined

lyric mountain
#

undefined and null literally mean "no value"

sacred knoll
#

But !undefined is true

naive mantle
#

if you identify something as null does the value set to 0

lyric mountain
#

it's not

warm marsh
#

!undefined = true is correct.

sacred knoll
#

so is !null

naive mantle
#

like

#

if i said

#

var input = null
console.log(null)

#

it would log

#

0

#

right

sacred knoll
#

No

pale vessel
#

null

warm marsh
#

Should log null

naive mantle
#

it says this

#

When you evaluate a null variable, the null value behaves as 0 in numeric contexts and as false in boolean contexts. For example:

pale vessel
#

because null is null xd

naive mantle
#

wait

#

in numeric contexts

lyric mountain
#

because console.log converts everything inside it to string

naive mantle
#

so

#

if i did

#

var n = null
console.log(n * 3)

#

it would log 0

sacred knoll
#

It would output 0

#

I think

naive mantle
#

because in numeric contexts

#

null behaves as 0

#

right

warm marsh
#

Depends on context but yeah.

sacred knoll
#

I think so

hidden spindle
#

Aight, im trying to follow this page: https://discord.js.org/#/docs/main/stable/class/Guild
so far i have:

const guild = new Discord.Guild('wefit');
client.on('ready', () => {
  const { members } = guild;
  console.log('Guild', { guild });
  console.log('Guild Members', { members });  
});

But im getting members undefined

#

Where did i screw up?

naive mantle
#
var x = 5
if (true) {
var x = 5
}
console.log(x)```
#

it would like 5 because it's true

#

right

warm marsh
#

why setting x again?

sacred knoll
#

It would log 5 no matter what

warm marsh
#

But yeah, If works like if (statement is true) do else

hidden spindle
sacred knoll
#

imo var should not really be used due to broken scoping

pale vessel
#

speaking of if else, ternary operators are very useful in this context

naive mantle
#

var x = 5
if (true) {
var x = 4
console.log(x)
}

#

would that not log

#

because x does not equal 4

pale vessel
#

it'll be 4

#

you're reassigning x

hidden spindle
naive mantle
#

how do i make it so its not reassigning

hidden spindle
#

seems you are lacking basic understanding of javascript itself

#

the tutorial might help

#

helped me atleast

#

👍

naive mantle
#

im reading it

warm marsh
#

== or === is for comparison.

pale vessel
#

if (x == 4)

naive mantle
#

as im doing this

#

so

#

basicallyt

#
var x = 5
if (x == 4) {
console.log(x)
}``` will not run because x doesn't equal 4
warm marsh
#
let val = 10;
if (val >= 5) val = 15;

console.log(val); // val = 15;
#

Yes, Won't run due to x being 5 and not 4.

sacred knoll
#

== is kinda broken with type coercion in JS

naive mantle
#

ight

#

what

pale vessel
#

him with his coercion

sacred knoll
#

It'll try to covert types so they can be compared.

#

& that can make odd bugs

naive mantle
#

so use === isntead

sacred knoll
#

I'd say so

pale vessel
#

it's best to use === in most cases

sacred knoll
#

Just for the habit

warm marsh
#

Just make sure the datatypes are the same if you're trying to get your if statement to pass.

sacred knoll
#

It's nicer when the lang helps with that ^

hidden spindle
#

i think weak comparison is only useful for falsy values with != null

warm marsh
#

!== can still be done.

hidden spindle
#

!= will trigger for undefined, null and falsy

#

which is generally what you'll want

#

!== will not

warm marsh
#

Yes.

hidden spindle
#

Anyone has any idea about my guild member problems?

earnest phoenix
#

you can't create discord entities yourself

warm marsh
#

Did bots get their perms revoked for creating servers?

pale vessel
#

rip tls

lyric mountain
#

Did bots get their perms revoked for creating servers?
@warm marsh no

hidden spindle
#

Thanks

earnest phoenix
#

bots cannot create guilds if their guild count is above 10

lyric mountain
#

but if your bot is in 5 servers (iirc) then you cant create a new server

#

^ actually 10

warm marsh
#

Alright.

#

@hidden spindle Discord.Guild takes, client and an object of guild data.

#

So the reason you're not getting anything is either because you're trying to get the guild before bot is ready and/or it doesn't exist.

hidden spindle
#

Yea, i figured a way to do it

#

I had to destruct guild from client and find the guild i want through the cache

#

same as the channel

naive mantle
#

if you say

#
const MY_OBJECT = {'key': 'value'};```
#

then

hidden spindle
#

something like this

const wefit = guilds.cache.find(guild => guild.id === 'xx');
naive mantle
#

can you assign values

#

to the values

warm marsh
#

Yeah.

naive mantle
#

hot

warm marsh
#

Objects work slightly different. Just means you can't re-assign the datatype. You're stuck with it being an object.

naive mantle
#

if you say

warm marsh
#
const obj = {};
obj.x = 0 + Math.floor(Math.random() * 10);

// wont:
obj = true;
naive mantle
#
const MY_OBJECT = {'key': 'value'};
MY_OBJECT.key = {'yes': 'no'};
MY_OBJECT.key.yes = ("happy")```
#

you are assigning

#

a value

#

to the value

#

to the value

#

righrt

#

right

earnest phoenix
#

try it and see

naive mantle
#

ok

warm marsh
#

There isn't a need for parenthesis on the "happy".

naive mantle
#

i did

#
MY_OBJECT.key = {'yes': 'no'};
MY_OBJECT.key.yes = ("happy")
console.log(MY_OBJECT.key.yes)```
#

and it logged happy

#

so

#

you can

#

wait CAN YOU MAKE AN INFINITE LOOP OF ASSIGNING VALUES

warm marsh
#

Yes, You can but it's not needed.

#

Yes, More than likely crash your PC.

hidden spindle
#

No need to specify properties as string pie

naive mantle
#

lmao

#

ok

hidden spindle
#

you can do key: 'value'

warm marsh
#
const obj = {};

for (const i of new Array(100000)) {
  obj[i] = i;
}
naive mantle
#

since the contents of an array are not protected

#

you can add

#

contents

#

with

#

arrayname.push ("thing")

#

right

sudden geyser
#

yikes

naive mantle
#

im gtg

#

ill do code more laterr

prisma lion
#

what is Discord Bot List Acces Token

slender thistle
#

wot

quartz kindle
#

its a token to access the top.gg API

#

ie: to make your bot show how many servers its in, in the website

#

you get it in your bot's edit page

prisma lion
#

aha k

sudden geyser
#

Try using client.channels.cache.get

#

@earnest phoenix

timber cloak
#

does this look like a good feature

tight plinth
#

Not the place but yes

timber cloak
#

srry lol

shadow shale
#

Hey anyone know how to make a say command via typing in console? In python. Ping me witj answer

slender thistle
#

aioinput

shadow shale
#

?

copper cradle
#

he just told u

#

the name of a lib

#

now if someone says tha name of a lib

#

guess what u gotta do

#

fucking google ot

zenith terrace
#

docs

earnest phoenix
#

Hello guys do you now a command for a bot (v11) to delete a "-" in channel name ?

nova jolt
#

Hello

zenith terrace
#

No

earnest phoenix
#

@earnest phoenix patched lol u can't anymore sorry...

#

Nooooo

#

Bruh :/

earnest phoenix
#

Is there a discordjs thing I can use to detect when a role is added? I was going to use bot.on('roleAdd') but I couldn't find that, or any articles on it. It's only how to add permissions to a user.

quartz kindle
#

if you're talking about a role being added to a member, then you can only get it through fetching audit logs i believe

earnest phoenix
#

Noo

#

Ok

#

How would I do that with audit logs?

#

All I am seeing are events for message deletion, kicks, and bans, but no roles.

twilit rapids
#

Listen to the guildMemberUpdate event

earnest phoenix
#

^

#

you'll have to compare the user roles from before and after the event, which the event provides as arguments

finite bough
#

cry

#

while using mongoose db

#

on glitch what connection do i have to make

earnest phoenix
#

i don't know i don't use mongo

finite bough
#

ah oki

quartz hill
#

I have never changed my code. But when my bot has been opening for the past few days, it gives this error. It just doesn't connect. Or it gets connected after many attempts. Sometimes he gives this error when he gives a command. (discord.js ) server heroku But it does not connect when opening in the command window.

2020-03-16T08:32:54.414016+00:00 app[web.1]: Error: Something took too long to do.
2020-03-16T08:32:54.414051+00:00 app[web.1]:     at /app/node_modules/discord.js/src/client/ClientManager.js:40:57
2020-03-16T08:32:54.414052+00:00 app[web.1]:     at Timeout._onTimeout (/app/node_modules/discord.js/src/client/Client.js:436:7)
2020-03-16T08:32:54.414053+00:00 app[web.1]:     at listOnTimeout (internal/timers.js:549:17)
2020-03-16T08:32:54.414054+00:00 app[web.1]:     at processTimers (internal/timers.js:492:7)
quartz kindle
quartz hill
#

but havent shard bot

earnest phoenix
#

don't use glitch

#

nor heroku

quartz hill
#

heroku use no glitch

quartz kindle
#

i believe the issue is the same though.

earnest phoenix
#

discord is flagging ips from glitch and heroku

#

or, well, has been for the past few days

quartz kindle
#

its a guild packet that does not arrive, and discord.js refuses to mark itself as ready until all guilds are received

quartz hill
#

But the same happens on my computer.

earnest phoenix
#

hm yeah then it's the issue tim stated

quartz hill
#

"This seems to have to do with shards with unavalible guilds, which would explain leaving an undefined guild. These may have increased due to an increase in Discord users due to Covid-19"
this?

quartz kindle
#

if you do js client.on("raw", r => { if(r.t === "GUILD_CREATE") { console.log(r.d.name) } })

#

you will see all guilds being loaded when your bot connects

#

at some point it gets stuck on some guild

zenith terrace
#

Wee woo, its raw

quartz hill
#

yes 1 server stuck.

#

It remains stuck on the last server.

twilit rapids
#

Does this mean that bots with this issue are not able to boot until it's solved? zoomeyes

#

Or when the guild becomes available again^^

quartz kindle
#

something like that

#

if you keep restarting it, it eventually manages to receive it

#

its kinda random

twilit rapids
#

Good thing I moved away from Djs's sharding manager ages ago blob_sweat

modest maple
quartz hill
#

I guess there is no possibility to bypass the server to which it cannot connect.

#

😦

quartz kindle
#

there is

#

are you using v11 or v12?

quartz hill
#

11.6.2

quartz hill
#

Where exactly should I use this code.

quartz kindle
#

in your main file

#

anywhere

quartz hill
#

ohh thx so much

#

Does work at the Shard? @quartz kindle

quartz kindle
#

you said you are not using shards

quartz hill
#

I don't use Shard, but I wanted to ask.

#

yes not using shard

quartz kindle
#

i think it works yes

quartz hill
#

thank you very much again.

digital ibex
#

hi

twilit rapids
#

hi

earnest phoenix
#

ih

digital ibex
#

does anyone know why when i do text-decoration: none i still get a link underlined. css

#

hi

quartz kindle
#

check your selectors, might be wrong or being overwritten

copper cradle
#

yes

#

or add !important

#

at the end

digital ibex
#

i done that but it made no difference

#

and ok

#

the other things like actually work, but not the text decoration

#

so

copper cradle
#

lol

#

send your css

digital ibex
#

ok

#
button {
    text-decoration: none !important;
    padding: 10px;
    background-color: #fffffffa;
    border-radius: 5px;
}```
#

ik its basic

#

😳

copper cradle
#

like me

#

😳

earnest phoenix
#

you selected the button

#

not a link

copper cradle
#

yeah

digital ibex
#

oh

flint dawn
#

Is anyone else having shard's failing with "Shard X's Client took too long to become ready"?

quartz kindle
#

a lot of people apparently

copper cradle
#

yeah

#

well

#

at least those who host on glitch and heroku

digital ibex
#

how would i select the link?

#

juts

copper cradle
#

haven't seen any VPS dud having trouble

earnest phoenix
#

usually links are put in anchor tags

digital ibex
#

a:text-decoration: none!important

#

?

#

k. maybe not

earnest phoenix
#

so your selector would be ```cs
a {
//...
}

flint dawn
#

I'm hosting it myself and I'm having 2 shards refusing to work 😦

copper cradle
#

bruh

#

yes

quartz kindle
#

if you want to apply it globally to ALL <a> elements, do what cry said

#

with !important

copper cradle
#

@flint dawn well

#

don't self host it

twilit rapids
#

Not only related to glitch/heroku @copper cradle

copper cradle
#

like

#

aight

twilit rapids
#

Discord.js issue

copper cradle
#

ah

#

another reason why d.js big gay

quartz kindle
#

not sure if discord.js issue or discord api issue

twilit rapids
#

@flint dawn just keep retrying, should work at some point

copper cradle
#

blame it on discord

#

ez fix

digital ibex
#
a:button {
    text-decoration: none !important;
    padding: 10px;
    background-color: #fffffffa;
    border-radius: 5px;
}```
```css
button {
    text-decoration: none !important;
    padding: 10px;
    background-color: #fffffffa;
    border-radius: 5px;
}``` the first one shows:
#

the second one shows:

flint dawn
#

Aight I'll give it another couple of hours

copper cradle
#

just a

twilit rapids
#

@quartz kindle I'm using a different sharding manager and I don't have the issue

copper cradle
#

not a:button

#

that'll select every anchor tag

quartz kindle
#

the issue doesnt happen to everyone

digital ibex
quartz kindle
#

only a few random people

digital ibex
#

oh

flint dawn
#

Yeah everything was working fine but today it just doesn't want too

twilit rapids
#

It happened to me when I tried my second bot (Switched it back to the normal sharding manager)

digital ibex
#

how would i select the button link then

earnest phoenix
#

what's your html

digital ibex
#

me?

earnest phoenix
#

yes

digital ibex
#

ok

copper cradle
#

well

digital ibex
#

lemme get it

copper cradle
#

button a {}

earnest phoenix
#

i hope they're not doing what i'm thinking they're doing

copper cradle
#

I'm not entirely sure

#

what

digital ibex
#

button a

quartz kindle
#

it happened to me on my old bot, but not happening on the new bot, but the guy who posted the issue on github said he tested on all d.js versions and all have the issue lmao

digital ibex
#

😳

copper cradle
#

yes

#

now

#

send toe pics

digital ibex
#

how- ok

#

wha

copper cradle
#

dms

digital ibex
#

w-

flint dawn
#

Could it be over a certain amount of shards that it starts to happen or does it not matter?

digital ibex
#

i'll send toe pics after i get it normal

twilit rapids
#

How many shards do you have

quartz kindle
#

from what i've seen, the issue is that a single guild doesnt not arrive, and discord.js keeps waiting for it forever

flint dawn
#

8

quartz kindle
#

and refuses to enter ready state

earnest phoenix
#

if your html has an a tag inside of a button, then your selector is supposed to be button a

twilit rapids
#

seems like djs sharding manager issue

digital ibex
#

ok

quartz kindle
#

you can however force it to mark itself as ready

digital ibex
flint dawn
#

How would I go about trying that?

quartz kindle
#

not sure if that will break anything tho, especially concerning said guild

digital ibex
#

weird things joining it and on the end

quartz kindle
#

whats your djs version?

flint dawn
#

lemme check

#

11.5.0 😐

twilit rapids
#

Might wanna upgrade to v12 anyways

#

When you have the time

quartz kindle
earnest phoenix
#

are you using a WYSIWYG editor lol

digital ibex
#
<!DOCTYPE html>
<title>Lost</title>

<h1>Lost - A perfect Discord Bot</h1>

<noscript>You must enable JavaScript to access Lost's site.</noscript>
<ol>
    <head>
        <link rel="shortcut icon" type="image/x-icon" href="https://cdn.discordapp.com/avatars/650136984211292180/3dbcf8a2f49c193cd460eb441c7856a0.png?size=512" />
        <div>
        <button><a href="     ">Apply</a></button>
        <button><a href="      ">Invite Me!</a></button>
        <button><a href="      ">Support</a></button>
        <button><a href="       ">Contact</a></button>
        </div>
    </head>
</ol>
<link href="styles.css" rel="stylesheet" type="text/css">
<body>
    <div class="footer">Lost 2020 ©️</div> 
   
</body>

#

thats my html file

copper cradle
#

for some reason I thought that was xml and was like

#

ew xml

twilit rapids
#

Couldn't you just copy the link bruh

flint dawn
#

@quartz kindle cheers I'll try it now

copper cradle
#

lmao

digital ibex
#

so

#

u guys know bc i am kinda confused

slender thistle
#

in HTML, should I create a separate paragraph element per each newline

flint dawn
#

It said it took too long but I think it booted anyway

earnest phoenix
#

in HTML, should I create a separate paragraph element per each newline
no, it's named paragraph for a reason; use the br tag

slender thistle
earnest phoenix
#

r/cursedimages

ionic anchor
#

What is shard

digital ibex
#

cry, do u kno

earnest phoenix
#

What is shard
@ionic anchor a smaller part of a bot; sharding is used to split a big bot into a bunch of smaller connections through the gateway to reduce traffic and stress

#

know what?

ionic anchor
#

Oooh okay

#

Thanks

earnest phoenix
#

lost, your html is all wrong

#

head is not used like that

digital ibex
#

oh

#

oh

earnest phoenix
#

you don't need noscript since you aren't loading any javascript

digital ibex
#

i was going to add that after i got the basic things down

#

ok, ty

quartz kindle
#

you're applying the same css to both <a> and <button> and your css has padding, so both are being padded inside each other creating those distances

#

in any case using buttons inside <a>s and <a>s inside buttons is not recommended

#

either use a button with an action, or an <a> styled as a button

earnest phoenix
#

former is suggested more as it gets picked up by accessibility readers

digital ibex
#

ok

earnest phoenix
#

and it's able to tell the end user it's a button

quartz kindle
#

button inside a is not valid according to html5 spec tho

#

idk about a inside button

shy turret
#
app.post("/login", (req, res) => {
  console.log(res.body);
  let jsoncontent = JSON.parse(res.body);
  if (jsoncontent.username && jsoncontent.password) {
    res.send(`{\n"status": "success"\n"username": "${jsoncontent.username}",\n"password": "${jsoncontent.password}"\n}`);
  } else {
    res.send(`{\n"status": "error"\n}`);
  }
});
#

I'm trying to just get the data..

#
{
  "username": "hi",
  "password": "hi"
}
#

for some reason res.body is undefined

prime cliff
#

Imagine not checking if the request actually contains a body and your web servers fails 😔

valid frigate
#

iirc you don't have to parse the response body

quartz kindle
#

is you're using express, you need the body parser middleware

#

otherwise body will be undefined

valid frigate
#

ah yeah

shy turret
#

oh res

#

i wrote res not req

quartz kindle
#

ah true lol

shy turret
#

wow another error

#
{ username: 'hi', password: 'hi' }
SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
#

epic

#

did res.body become [object Object] 🤔

#

add that .toString(), becomes [object Object]

#

ovi

#

F THIS

#

i mean i fixed it

#

JSON.stringify

quartz kindle
#

if res.body is already json, then just use it as is lol

shy turret
#

it isnt though

#

JSON.stringify is needed

#

if this didnt work

quartz kindle
#

wat

shy turret
#

let jsoncontent = JSON.parse(JSON.stringify(req.body));

#

why though

#

i messed up the status , too..

#

well it works now finally.

quartz kindle
#

thats literally going full circle

#

let jsoncontent = req.body

shy turret
#

i tried that alr

#

didnt work

#

req.body is a string.

quartz kindle
#

that makes no sense

#

you cant stringify a string, it will just become a string with escaped quotes lol

shy turret
#

it would actually be like
JSON.stringify({a:10,b:20})

quartz kindle
#

then its not a string

copper cradle
#

Ok so, I'm having trouble with sqlite3 (the python module) I'm running this query

SELECT * FROM {ctx.guild.id} ORDER BY itemName LIMIT 10 OFFSET {10 * page}

But it's returning an empty list

#

This is literally a random error that started to occur literally from nowhere

#

unless I'm blind

#

and shivaco is offline

#

holy cow

#

who could help me

#

btw, it isn't erroring

#

and it shouldn return an empty list, bc there are more than 30 items in that table

scarlet bane
#

what's page

#

what value

#

@copper cradle

copper cradle
#

heyy

#

page is 2

scarlet bane
#

you sure there's more than 30 items

#

can you try with page=0

copper cradle
#

alright

frank dust
#

are you using aiosqlite?

#

if not, you should

#

the normal one is blocking

scarlet bane
#

that doesnt really solve his problem tho

frank dust
#

I am aware

#

I'm not too good with sql queries but I thought I'd give this tip if they aren't already using it

copper cradle
#

page set to 0 returns the first 10 items

#

@frank dust I'll look into it

scarlet bane
#

how many items are there actually in that table

copper cradle
#

lemme check

mystic violet
#

any idea why this wont work? js serverQueue.connection.play(`http://${this.node.host}:${this.node.port}/${track.videoId}.mp3`)

scarlet bane
#

whats the error

mystic violet
#
(node:17256) UnhandledPromiseRejectionWarning: TypeError: serverQueue.connection.play is not a function```
#
serverQueue.connection = await voiceChannel.join()```
scarlet bane
#

looks like your connection is failing

copper cradle
#

there are exactly 30 items

scarlet bane
#

can you run the same query without a limit/offset

#

SELECT * FROM {ctx.guild.id} ORDER BY itemName

copper cradle
#

ok

mystic violet
#

@scarlet bane do you think its v12 only?

scarlet bane
#

no clue

#

make sure you have perms to connect to the voice channel

mystic violet
#

Yeah it already joined

scarlet bane
#

hmph

mystic violet
#

Ill update to v12

scarlet bane
#

could honestly be a bunch of things, discord isnt very clean with failing calls

mystic violet
#

ill see if that works

copper cradle
#

huh

#

weird

#

it's working again

#

thx raid

scarlet bane
#

bruh

copper cradle
#

idk why

scarlet bane
#

wdym

copper cradle
#

cuz ya know

#

I was debugging

scarlet bane
#

is the query I posted working? or the one you posted

copper cradle
#

the one I posted

scarlet bane
#

bruh lol

#

wild

copper cradle
#

ikr

scarlet bane
#

retrace your steps, see what you changed

#

my theory is that page wasnt 2

copper cradle
#

page is an argument that gets passed to the command

#

and I was passing 2

scarlet bane
#

maybe you were passing a string or some stupid thing like that

copper cradle
#

I don't think so

scarlet bane
#

ending up with 10*"2" = "22....2"

copper cradle
#

I made sure to convert it into an int

#

ah yes

#

the good ol' '2222222222'

scarlet bane
#

indeed

#

either way, glad it's resolved 🙂

copper cradle
#

yeah

#

thanks for your time

scarlet bane
#

glad to help

mystic violet
#
RangeNotSatisfiableError: Range Not Satisfiable
    at SendStream.error (C:\Users\jnsho\node_modules\send\index.js:270:31)
    at SendStream.send (C:\Users\jnsho\node_modules\send\index.js:670:19)
    at onstat (C:\Users\jnsho\node_modules\send\index.js:729:10)
    at FSReqCallback.oncomplete (fs.js:172:5)```
copper cradle
#

send code

#

It says range not satisfiable

#

it means the server cannot serve the requested ranges

earnest phoenix
#

I'm using the code(inside the Embed):
.setImage(url=`${message.author.avatarURL()) And for the mentioned users: .setImage(url=`${message.mentions.users.first().avatarURL())

#

(discord.js btw)

summer torrent
#

avatarURL({size: 2048})

earnest phoenix
#

Oh ok... Thx

copper cradle
#

ok this is just plain stupid, it broke again 😩

tight mountain
#

ok so i tried installing discord.js using npm (npm install discord.js), and it did install (+ discord.js@12.0.2), but i think it is an older version. my bot keeps erroring out with TypeError: Discord.RichEmbed is not a constructor

dusky marsh
#

its MessageEmbed in v12

tight mountain
#

o

zenith terrace
#

Every time I hear v12 I want to just punch something for how stupid most things changed

wide ridge
#

is voting down?

red hollow
#

wdym

wide ridge
#

on top.gg it seems to be broken

red hollow
#

idk

#

dbl was down for a while

#

and it has under attack mode enabled now

hushed berry
#

Voting is down as well

#

waqit

red hollow
#

so its possible its broken

hushed berry
#

i mean searching not voting

wide ridge
#

I see

red hollow
#

ah i think voting has same issue then

pale vessel
#

yeah i can't vote either

shut kindle
#

guys i am trying to make a bot its says dbl.webhook.on('vote', vote => {
user = client.users.cache.get(vote.user)
client.channels.cache.get('685971547315240969').send(new Discord.MessageEmbed().setColor('RANDOM').setThumbnail(user.avatarURL({ format: 'png', dynamic: true, size: 2048 })).setDescription(Thanks you for voting <@${user.id}> (**${user.id}**)! As a reward, you get... Eternal respect from my dev))
});

#

not working can you help me

#

?

pale vessel
#

you can't just say "not working"

shut kindle
#

lol its not working

pale vessel
#

did it throw an error? did it do nothing?

#

be more specific

shut kindle
#

lol

#

its say its has an error LOL

copper cradle
#

then fucking send the error

hushed berry
shadow shale
#

Can anyone help me how to make a website dashboard fot bot?

summer torrent
#

google

earnest phoenix
#

learn front end and back end web dev

shut kindle
#

Guys can you help my bot

#

Join it if you can help me to slove the problem

#

Thanks you

pale vessel
#

do not do that

#

delete the message

#

DMs are find but not here because people can do malicious things

#

@shut kindle

quartz hill
#

I keep getting this error and cannot vote on my bot.

2020-03-19T06:38:27.551317+00:00 app[web.1]:     at IncomingMessage.<anonymous> (/app/node_modules/dblapi.js/src/index.js:118:25) ```
#

There is no change in the code. Bot was working yesterday.

pale vessel
#

that is normal

#

voting is disabled temporarily to fix some issues for the time being

quartz hill
#

ooh thx

tight plinth
#

with js, I have a string longer than X characters. how can I "split" it to obtain [X charachers text, the rest] ?

restive furnace
#

make array and then make a loop like this (not best way but i dont know better): var x = "hellohellohelloheloohelllohello"; x.split(""); var x1 = ""; for (var i = 0; i < 10 /* max charters per split */; i++) { x1 += x[i]; }

#

and then x1 should become "hellohello" @tight plinth

tight plinth
#

hm

#

pichu lyrics lhymne de nos campagnes

#

oof

#

wrong serv

lunar hill
#

hi

#

who also have problems with glitch?

gloomy apex
#

Yea failed to load

lunar hill
#

mm

#

when they fix..

#

all my projects disabled

#

and i cant load them

gloomy apex
#

Figured. Sent a mail to support. Awaiting response!

lunar hill
earnest phoenix
#

lol

#

oof

abstract glacier
#

WTF

gloomy apex
#

Its back up

cerulean pebble
#

can i use multiple heroku account to run a program

pale vessel
#

ask heroku

shut kindle
#

guys i fixed my bot

#

LOL

earnest phoenix
#

ok

tight plinth
#

@shut kindle finally (you made a new one or u use my bot's core?)

pale vessel
#

no way he made a new one

hoary elm
#

can anyone tell me how to set the bots game with Eris?

pale vessel
#

docs

hoary elm
#

yeah i got it

#

i was just about to say nvm

earnest phoenix
#
class Util {  
  static async getChannel (id) {
    
    let channel = client.channels.cache.get(id);
  //  if (!channel) return "Channel not found!";
    return channel;
  }
}
#

error

warm marsh
#

Where is this class located?

earnest phoenix
#

In util.js

warm marsh
#

Okay

#

client isn't in that file unless you made it a non static class and passed into the constructor.

earnest phoenix
warm marsh
#

You're exporting the client object not the live one.

earnest phoenix
#

yeah

warm marsh
#

Does it work in another file?

#

Client not util.

earnest phoenix
#

I haven't tested yet

#

I tested that with eval command

warm marsh
#

Make the util class a non static one or at least that method.

earnest phoenix
#

Well I just removed static and going to try it

warm marsh
#

Export the util class and then init it and pass client to constructor.

earnest phoenix
#

same error

warm marsh
#

// util.js

module.exports = class {
  constructor(client) {
    this.client = client;
  }

  getChannel(id) {
    let channel = this.client....
  }
}```
#

Then in your main file do

const util = require('path/to/util');
client.util = new util(client);```
#

Or how ever you want to store util to access later.

earnest phoenix
#

ok

#

thanks

quartz kindle
#

if you want to ping people, its always best to use <@userID>

late hill
#

try what tim said

#

<@userid> means "<@" + msg.author.id + ">"

gritty frost
#

hey, anyone know top.gg bot page css edit

hoary elm
#

so i have a bit of an issue

#
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
    at Function.Module._load (internal/modules/cjs/loader.js:591:27)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/rbd/pnpm-volume/488dad32-76a9-43f2-81ea-402b856ecc4b/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/util/Util.js:1:19)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)```
#

but its not on my end

#

this module is not in or used in my bot period

#

nvm it went away 🤔 updates?

finite bough
#
mongoose.connect("mongodb+srv://[username]:[password]@xxxx-xxx.mongodb.net/test?retryWrites=true&w=majority", { useNewUrlParser: true });
amber fractal
#

A dependency wasnt installed then. Idk what would depend on snekfetch tho

finite bough
#

is this the correct way to connect to a mongoose server?

hoary elm
#

A dependency wasnt installed then. Idk what would depend on snekfetch tho
@amber fractal according to the error its node_modules/discord.js/src/util/Util.js:1:19

#

...

#

That's not from my code.. i mean unless i own d.js and didn't know it 🤔 but seems to be fixed for now

#

appreciate it regardless but the error shows that its the d.js module itself that was erroring

sudden geyser
#

@hoary elm then installing Discord.js v11.5.1 (not npm install discord.js, that'll add v12) again and see if that fixes it.

hoary elm
#

@sudden geyser its fixed

#

it fixed itself

sudden geyser
#

hmm emilywhat

hoary elm
cerulean pebble
#

can i use multiple heroku account to run a program

hoary elm
#

to bypass limitations? @cerulean pebble

#

i mean why not, i know tons of people who just make a new Heroku account when the Free Dyno runs out!

lyric mountain
#

you can also just get a random credit card from google images and add it

#

even if it doesn't exists

#

heck even stock photos of credit cards are valid for heroku

hoary elm
#

^^

cerulean pebble
#

@lyric mountain i try but it fail

regal saddle
#
/*
    The following code goes into it's own file, and you run this file
    instead of your main bot file.
*/

const Discord = require('discord.js');
const Manager = new Discord.ShardingManager('./YOUR_BOT_FILE_NAME.js');
Manager.spawn(2); // This example will spawn 2 shards (5,000 guilds);``` does this still work?
cerulean pebble
#

@regal saddle

#

?

#

what do you want to do ?

regal saddle
#

ehm, sharding a bot?

cerulean pebble
#

your bot is big ?

regal saddle
#

nah, not that much, but i just wanna test it for later.

cerulean pebble
#

lol

#

it will not work

#

when your data is big enough

#

all shard will work

regal saddle
#

what do you mean?

#

it will work it my data is big enough, can you explain this?

lyric mountain
#

it means that your bot isn't big enough to be sharded

mossy vine
#

lmao

lyric mountain
#

so it can't be sharded

mossy vine
#

you dont need a guild count to shard

#

i can run 4 shards on 3 guilds

regal saddle
#

xD

lyric mountain
#

I just translated what he meant

mossy vine
#

ah yes, broadcasting the crap

regal saddle
#

:3

lyric mountain
#

anyway, were you supposed to pass a file to sharding manager?

regal saddle
#

i would put this in my main bot file where i start it and run it.

#

oh wait...

lyric mountain
earnest phoenix
#

Hye ! I have this error when i send n!help

at Function.normalizeFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:433:8)
at MessageEmbed.addFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:249:42)
at MessageEmbed.addField (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:240:17)
at Object.run (/home/container/commands/help.js:15:14)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:25) 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: 1)
(node:25) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
lyric mountain
#

fields.flat is not a function

#

on /home/container/commands/help.js, line 15, 14th word

#

it's written there

earnest phoenix
#

And how to solve this probleme ?

#

It's my cod ```const {
MessageEmbed
} = require('discord.js');

module.exports = {
name: 'help',
category: 'bot',
async run(client, message) {
var commands = client.commands;
var commandList = new MessageEmbed()
.setAuthor(message.author.username, await message.author.displayAvatarURL(), client.opt.url)
.setDescription(Voici la liste de mes commandes | prefix: ${client.opt.prefix})
.setThumbnail(await client.user.displayAvatarURL())
.setColor(client.opt.color)
.addField('Bot', '' + commands.filter(e => e.category === 'bot').map(c => c.name).join(', ', true) + '')
.addField('Music', '' + commands.filter(e => e.category === 'music').map(c => c.name).join(', ', true) + '')

    message.channel.send({
        embed: commandList
    }).catch(console.error);
}

}```

mossy vine
#

@lyric mountain isnt that error coming from d.js lol

earnest phoenix
#

it is

#

reinstall d.js

lyric mountain
#

yep

earnest phoenix
#

Just i reinstall discord.js ?

lyric mountain
#

are you using v12?

earnest phoenix
#

yes

lyric mountain
#

then just reinstall it normally

earnest phoenix
#

Just reinstall ? discord.js and it's good ?

#

that's not the method signature

#

look at the docs

#

you may only add one reaction in one method

slow elk
#

Anyone know that one translator community that allowed developers to add their project for translations? They can upload files, such as JSON or Java Properties. It started with a "Z", pretty sure. The Astolfo bot devs used it back when it was still a thing for it's translations

earnest phoenix
#

i just love this with js users - making up their own properties, methods and other shit that doesn't exist, and then thinking it's magically going to work just because js isn't typed

#

crowdin @slow elk ?

crimson vapor
#

lmao

slow elk
#

No, it started with a "Z"-

earnest phoenix
#

no idea, crowdin is the most commonly used platform for localisation management

slow elk
#

Hmmm-

#

Hold on

#

No, it was free to use

earnest phoenix
#

crowdin is free to projects that are opensource

heavy marsh
#

In Discord.js version 11.4.2 What the event to detect role added to & roles removed from a use.
Like for example member leave event is guildMemberRemove

earnest phoenix
#

guildMemberUpdate

heavy marsh
#

For bot the cases?

earnest phoenix
#

what

heavy marsh
#

both*

earnest phoenix
#

yes

heavy marsh
#

OOh oks thanks

earnest phoenix
#

you'll have to compare the member's roles before and after the event, which the event provides as the arguments

heavy marsh
#

oks thanks

mystic violet
#
var dispatcher = await node.play(track.videoId, message.guild, "over_internet")

        console.log(dispatcher)

        dispatcher.on('finish', () => {
            console.log("ended")
        })```

it says ```
(node:19016) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'on' of undefined```

The function is:

res = resolve

serverCache.player = await serverCache.connection.play(http://${this.node.host}:${this.node.port}/${videoId}.mp4)

        console.log(serverCache.connection.dispatcher)

        res(serverCache.player.dispatcher)```
#

sorry for the block of code

#

lmao

earnest phoenix
#

well... is node.play returning anything?

mystic violet
#

lemme check it should

earnest phoenix
#

if the method doesn't return anything then you don't have anything to assign to a variable

mystic violet
#

huh

#

it doesn't return anything

#

how do I check if a song is over then?

earnest phoenix
#

i don't know - i have no clue what you're using nor how you structured your code

hoary elm
#

What's a good reaction limit for a starboard (number of reactions before the bot will post the message)

earnest phoenix
#

whatever you feel like

#

for best results make it customisable

#

so people can adapt it to their guild

hoary elm
#

That's a good idea actually I have it using a database so should be pretty easy

mystic violet
#

I'm using d.js functions

#

Connection.play

heavy marsh
#
//Edit Role Adds & Role Removes
client.on("guildMemberUpdate", async(member) => {
let guild = await member.client.guilds.get(`611881570202025986`).fetchMember();

let MuteID = '624675605312569354';
let StaffID = '611882066912477185';

var staff = client.channels.get("689931831344365575");
var mute = client.channels.get("689931759848259699");

staff.setName(`Role Count: ${guild.roles.get(StaffID).members.size}`);
mute.setName(`Role Count: ${guild.roles.get(MuteID).members.size}`);
});

ERROR:

(node:12) UnhandledPromiseRejectionWarning: Error: Invalid id provided.
at Guild.fetchMember```
lyric mountain
#

context please

heavy marsh
#

In Discord.js version 11.4.2 What the event to detect role added to & roles removed from a use.
Like for example member leave event is guildMemberRemove

warm marsh
#

member.client?

#

Oh it exists.

mystic violet
#

but he already has "client" defined

#

idk why hes doing that

warm marsh
#

Also, The error tells you the issue.

heavy marsh
#

Should I not do it?

mystic violet
#

just change member.client to client

warm marsh
#

fetchMember has an invalid id. Thus uses fetchMember(id) not fetchMember();

mystic violet
#

I mean, it doesn't change anything

#

its just preference ig also what somehash said

heavy marsh
#
(node:12) UnhandledPromiseRejectionWarning: Error: Invalid id provided.
#

I provided the correct ids

lyric mountain
#

are you sure?

heavy marsh
#

yep

#

Let me recheck

lyric mountain
#

doesn't fetchMember() have a signature?

mystic violet
heavy marsh
#

Yes recheck and reloaded the bot but the same error

#

I am trying to get the number of members in the 2 roles on guildMemberUpdate - Discord.js Version 11.4.2

//Edit Role Adds & Role Removes
client.on("guildMemberUpdate", async(member) => {
let guild = await client.guilds.get(`611881570202025986`).fetchMember();

let MuteID = '624675605312569354';
let StaffID = '611882066912477185';

var staff = client.channels.get("689931831344365575");
var mute = client.channels.get("689931759848259699");

staff.setName(`Staff Count: ${guild.roles.get(StaffID).members.size}`);
mute.setName(`Mute Count: ${guild.roles.get(MuteID).members.size}`);
});

ERROR:

(node:12) UnhandledPromiseRejectionWarning: Error: Invalid id provided.
warm marsh
#

@heavy marsh

let guild = await client.guilds.get(`611881570202025986`).fetchMember();

// Should be
let guild = client.guilds.get(id);
heavy marsh
#

let guild 2 times?

warm marsh
#

No only the second one

heavy marsh
#

ahhh ok

#

nvm

warm marsh
#

replace the first.

lyric mountain
#

doesn't fetchMember() have a signature?
@heavy marsh ^

heavy marsh
#

What do you mean?

lyric mountain
#

someFunction(args)
^ signature

heavy marsh
#

ahhh

warm marsh
#

Those are called parameters ?

heavy marsh
#

But I looked it up and it was used like that

warm marsh
#

No fetchMembers() is used like that. fetchMember(id) takes a parameter.

lyric mountain
#

Those are called parameters ?
@warm marsh signature are the collection of parameters, parameter is a single argument passed to a function

heavy marsh
#

ya Thanks alot it works

mystic violet
#

is there any easier way of doing this? js serverCache.connection.dispatcher.streams.ffmpeg.on('end' ......)

lyric mountain
#

No fetchMembers() is used like that. fetchMember(id) takes a parameter.
@heavy marsh seems like you're missing a "s"

warm marsh
#

dispatcher.on?

mystic violet
#

that doesn't have an end event ;-;

warm marsh
#

RIP.

#

Language?

#

He's using it like that for the guild I think KuuHaKu?

heavy marsh
#
//Edit Role Adds & Role Removes
client.on("guildMemberUpdate", async(member) => {
let guild = client.guilds.get(`611881570202025986`);

let MuteID = '624675605312569354';
let StaffID = '611882066912477185';

var staff = client.channels.get("689931831344365575");
var mute = client.channels.get("689931759848259699");

staff.setName(`Staff Count: ${guild.roles.get(StaffID).members.size}`);
mute.setName(`Mute Count: ${guild.roles.get(MuteID).members.size}`);
});

This works now 🎉

ebon wyvern
#

how do I change the markdown color in my bots page? I know to change the whole body u need css, but idk about the markdown color, thanks in advance

lyric mountain
#

css

ebon wyvern
#

what's the markdown name

#

for the body its body

lyric mountain
#

no

#

don't just apply css to body

#

body is the whole page

#

.content h1, .content h2, .content h3, .content h4, .content code, .content strong
( headers ) ( code blocks) (bold characters)

ebon wyvern
#

ah

#

ok

#

ty

heavy marsh
#

What is the even to get ban added & Deleted?

warm marsh
#

guildBanAdd, guildBanDelete

#

?

heavy marsh
#

Thanks

warm marsh
lyric mountain
#

wait, what?

warm marsh
#

A list of all events are under client -> events.

#

@heavy marsh it's guildBanRemove

#

For deleted

#

KuuHaKu?

heavy marsh
#
client.on("guildBanAdd", async(ban) => {
let BanCount = await ban.guild.fetchBans()
var bans = client.channels.get("689973370238009392");

bans.setName(`Ban Count: ${BanCount.size}`);
});
#

Is this correct?

crimson vapor
#

I am not sure about the setName but yes

#

no its a function you are all good

#

I would add a reason to it so when you go to audit logs

heavy marsh
#

@crimson vapor Where to add the reason

#

In fetchBans("Get the count")

crimson vapor
#
bans.setName(`Ban Count: ${BanCount.size}`, 'There was another ban')```
heavy marsh
#

OOh ok thanks

#

Isn it when the vc channel name changes?

crimson vapor
#

yes

heavy marsh
#

Ahh ok

crimson vapor
#

so in the audit logs it would say why the name was changed

heavy marsh
#

yep thanks 🙂

mystic violet
#
why does request.body

return

<Buffer 68 74 74 70 3a 2f 2f 6c 6f 63 61 6c 68 6f 73 74 3a 36 39 2f 2d 4f 62 64 76 4d 6b 43 4b 77 73 2e 6d 70 34>

#

when its an object?

#

I mean string

#

whoops

#

lmao

#
if(req.headers.type == "over_internet") return res.send(`http://${req.headers.httppath}/${id}.mp4`)```
#

see

quartz kindle
#

set content type to utf8

mystic violet
#

how

#

in the res.send()?

crimson vapor
#

oh Tim, I was looking into your discord.js-light and it seems so smart the way it does things

quartz kindle
mystic violet
#

application/json im guessing?

quartz kindle
#

if its just a string, then use html or plain

#

this would also work

mystic violet
#

Ill try it

#

thanks 🙂

quartz kindle
#

any of these would also work

crimson vapor
#

Is spawning one shard the same as not using shards?

quartz kindle
#

pretty much yeah

crimson vapor
#

alright

mystic violet
#
res.set('Context-Type', 'text/plain')
                    if(req.headers.type == "over_internet") return res.send(`http://${req.headers.httppath}/${id}.mp4`)
                    if(req.headers.type == "server_only") return res.send(`${__dirname}/songs/${id}.mp4`)```
quartz kindle
#

i mean, a shard is a connection

mystic violet
#

still returns a buffer

quartz kindle
#

you always have at least one connection

crimson vapor
#

I assumed it would be just about the same

quartz kindle
#

Content

mystic violet
#

im so dumb

quartz kindle
#

fumb

mystic violet
#

lmao

#

still returns a buffer

#

wait

#

is it "Content" or "Content-Type"

quartz kindle
#

Content-Type

mystic violet
#

okay

#

so it should work

#

but it isn't :/

quartz kindle
#

are you loading it in the browser, or where?

mystic violet
#
var result = await request.post(`http://${this.node.host}:${this.node.port}/download`)
                .set('Authorization', this.node.password)
                .set('id', videoId)
                .set('type', type)
                .set('httppath', `${this.node.host}:${this.node.port}`)```
quartz kindle
#

using the request library?

mystic violet
#

using node-superfetch

slate oyster
#

--oof, sent early

quartz kindle
#

@mystic violet from what i understood, node-superfetch uses the same syntax as superagent, since it doesnt have any documentation

#

superagent documentation states that it doesnt process plain text responses automatically, you need to add it yourself

mystic violet
#

Im not too sure how to do that

#

I see theres examples

quartz kindle
#

i've never used superagent or superfetch so idk either

#

but if all else fails, you can always convert the buffer yourself

mystic violet
#

How could I do that with node?

#

.toString('utf8')?

quartz kindle
#

yeah

slate oyster
#

So last night I did some calculations and realized how valuable disk space is when I only have 100GB
The rewrite of my bot is using a mixture of JSON and filenames. This uses a lot of disk space.
I also realized that, even though usimg multiple files greatly reduces the impact of corruption, it comes with a large disk space cost.

After doing some calculations, I realized that I can store the basic user data for each user who sends a message whatsoever in as little as 22 bytes. This assumes that the user does not run any bot commands, I already know where each user's data is being stored, and I cache the names of keys elsewhere.

I am going to see if there is a way to write data directly to the disk, without buffering it in memory, in which case I can go back to single file. If so, I can store my data per user in a 32? byte block, where 28 bytes are dedicated to the data and 4 bytes are used to indicate a block, if applicable, where overflow data can be stored.
I'm also going to need a few blocks to indicate which blocks are available (I can indicate the availability of 28*8 other blocks within a block), as well as a few blocks with data usable to look up other data.
Additionally, I will want to be sure to write in a system to address another file of data if my current file gets too large.

I'm still working out some of the exact details

crimson vapor
#

how much information to you save to a JSON?

#

In sharding, how would you get information from all of the shards such as guild counts?

slate oyster
#

I'd have to check the storage again, but it's definitely inefficient
Guild counts are calculated at runtime via events.

#

Anyways
with JSON, single-file leads to corruption, while the size of multi-file is at the will of the hosting filesystem

crimson vapor
#

why dont you use a DB?

slate oyster
#

I dunno, I was thinking about looking into one, but, except for firebase, I think they would be alot stricter

#

If filesystems allowed me to put arbituary, unescaped filenames, and blocks were only 32 bytes, I would totally continue to use multi-file and wouldn't need this large, complex plan

#

For now, I'll work on the bot's features, and take care of storage later. Luckily, I segmented off my storage code into it's own package, so I don't have to deal with anything intertwined.

slate oyster
#

Actually, MongoDB might work
Lemme look at something

acoustic citrus
#

Some kid named @|| ☭ USSR ☭ ||#9380 just pretended to have my bot’s token and then tried to use eval to get the token, then asked right after for eval perms, then played dumb, if he joins your server beware lmao

pallid bluff
#

hello

pale vessel
#

nohello

mystic violet
#

He joined my server @acoustic citrus

#

lmao

#

he did the same thing

pale vessel
#

why do people do weird stuff

lyric mountain
#

lol I'd like to see him try with me

crimson vapor
#

How do you get the total ram usage over multiple shards?

modest maple
#

you hosting on multiple servers or somthing lmao

crimson vapor
#

no, is it just process.memoryUsage().heapUsed / 1024 / 1024?

restive furnace
#

yes

#

depends do u want bytes, megabytes or gigabytes shown.

crimson vapor
#

megabytes, hence the /1024/1024

restive furnace
#

okay, then it should except make it Math.floor(process.memoryUsage().heapUsed / 1024 / 1024)

#

and it shoukd work

open flicker
#

https://hasteb.in/ehuvoyut.coffeescript
How can I solve the problem?
an error appears when adding a bot to the server

I take the server ID and check it in the ban or not, and if it is in the bath house then the bot leaves the server

Sorry for my English)

crimson vapor
#

ok thank you

lyric mountain
#

bath house?

#

what's your native language?

open flicker
#

Russia

#

)

lyric mountain
#

ah

#

anyway, I'll consider that you meant guild

acoustic citrus
#

lmaoooo

slender thistle
#

Need help in translation here?

lyric mountain
#

yes

crimson vapor
#

Lmao im so dumb, I had it defining the ram, and I just forgot to add the ram value, I had it set to 11

slender thistle
#

Так в чём тут проблема? @open flicker

open flicker
#

ошибка в том что когда бота добавляют бота сервер то ошибка (я проверяю ID сервера на бан в базе данных) @slender thistle

slender thistle
#

Похоже, что guilds.get(data.ID) возвращает undefined

open flicker
#

хм

slender thistle
#

@lyric mountain What's the other thing for guilds.get(id)

crimson vapor
#

is he on 12 or 11 because its guilds.cache.get

slender thistle
#

У тебя какая версия discord.js?

open flicker
#

DiscordJS 11.6.2

crimson vapor
#

ok thats good

#

can you show more of your code?

#

you can paste it inside code blocks here

#

```js
<code here>
```

lyric mountain
crimson vapor
#

is that it?

open flicker
#

yes

crimson vapor
#

is banServer defined?

open flicker
#

??

crimson vapor
#

you could also change

catch {
  null;
}``` to
```js
catch (err) { 
  console.log(err)
}```
#

that would show more of the error I think

open flicker
#

ok

crimson vapor
#

what DB do you use?

open flicker
#

mongodb

crimson vapor
#

ok

#

yeah I think I know the error

open flicker
#
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'leave' of undefined
    at F:\Luni\guild\guildCreate.js:7:37
    at F:\Luni\node_modules\mongoose\lib\model.js:4830:16
    at F:\Luni\node_modules\mongoose\lib\query.js:4391:12
    at F:\Luni\node_modules\mongoose\lib\query.js:2869:28
    at processTicksAndRejections (internal/process/task_queues.js:76:11)
Emitted 'error' event on Function instance at:
    at F:\Luni\node_modules\mongoose\lib\model.js:4832:13
    at F:\Luni\node_modules\mongoose\lib\query.js:4391:12
    at F:\Luni\node_modules\mongoose\lib\query.js:2869:28
    at processTicksAndRejections (internal/process/task_queues.js:76:11)````
crimson vapor
#

ok yeah

#

you need to add more to the banServer.findOne()

#

I think

#

you need to match a guild ID I assume

slender thistle
#

Do you think it's Luni.guilds.get(data.ID).leave() erroring out

late hill
#

What you're doing doesn't make sense

crimson vapor
#

I do not

lyric mountain
#

he's basically making a server blacklist