#development

1 messages ยท Page 1128 of 1

eternal flame
#

damnation in the pit awaits the var

#

ok

#

so

#

its working

#

but

#

the server value is still 0 even though its in 2 servers

toxic bane
#

@toxic bane https://lmgtfy.com/?q=meme+api
@nimble escarp thanks!!

#

hi

jolly wave
#

hi

quartz kindle
#

because you're defining it outside the ready event, as i told you before

nimble escarp
#

Could you just send it like a normal message next time so that other's questions don't get pushed up too fast? @eternal flame

eternal flame
#

im not picking up what youre saying here tim

#

ill just give you the code block that i think is giving me the issues

#

it is but

#

ok here

#

``let stats;
bot.on("ready", () => {
console.log('api boy is on')

stats = {
    "rainbow": 5,
    "unicorn": 3,
    "doom": -3,
    "gloom": -2,
    "poopoo": 2,
    "servers": servers

}

})``

jolly wave
#

yes

nimble escarp
#

Ask your code @earnest phoenix

eternal flame
#

^

#

also please dont flood with screenshots

quartz kindle
#

@eternal flame as i said, you're defining the variable servers before the bot is ready, so the servers will always be 0

eternal flame
#

how do i fix that

quartz kindle
#

isnt it obvious?

eternal flame
#

wait

#

im re******

earnest phoenix
#

@earnest phoenix return if author is a bot

nimble escarp
#

You are not checking if the sender is a bot

quartz kindle
#

@earnest phoenix make it ignore bots

nimble escarp
#

if (!message.content.startsWith(this.prefix) || message.author.bot) return;

This is what I use normally

earnest phoenix
#

Thanks for flooding btw

eternal flame
#

ok tim

#

so

#

it worked

#

but

#

it says 5 servers

#

and its in 2

#

wait let me check

#

imagine tho lol

#

ok brb

faint prism
#

So... I'm trying to figure out this issue I got. I think it corrupted my json db.
I suspect someone had a weird unicode username that didn't serialize well

quartz kindle
#

rip

#

no backups?

faint prism
#

It was recently wiped

eternal flame
#

ok so

faint prism
#

No backups yet lol

#

The data isn't super important yet anyways, but annoying

quartz kindle
#

either wipe it again or look at position 12248 for some unclosed string

eternal flame
#

im gonna wait for auger to finish cuz i dont wanna be a dick

quartz kindle
#

although it might be that the file was incorrectly truncated, so the problem might not be a broken string, but a whole chunk of data being cut off

twilit rapids
#

@dreamy elm did you start the server yet

dreamy elm
#

well timo it wont show nothing

twilit rapids
#

You have to run the jar file

#

And keep it running

dreamy elm
#

bc nginx is masking the ip to a port

faint prism
#

although it might be that the file was incorrectly truncated, so the problem might not be a broken string, but a whole chunk of data being cut off
@quartz kindle It overwrote the json file back to empty on that error because the file size dropped way down

#

I need to get my SQL db context working

#

So I can hurry up and mirate

quartz kindle
#

yeah do that

#

you need a lot of special considerations when working with json

dreamy elm
#

bc nginx is masking the ip to a port
@twilit rapids

eternal flame
#

ok so using graingers code that he gave me (props to him) i figured out that the 5 servers things WASNT an issue and that it was just me being a fucking idiot

#

so

#

how can i find

#

the number of members

#

like

#

total

#

how many members are in each server the bot is in

#

combined

faint prism
#

oh snap, I had a backup

quartz kindle
#

use a reduce function on the guild cache, do yo know how to use a reduce function?

faint prism
#

I'm exploring MongoDb. My DB class is essentially a List<UserRecord>
Is this what the DB should look like? I just threw my Json db at it

#

Or is there a way to make the _id the UserId, or primary key, or something like that

eternal flame
#

i do not tim

quartz kindle
#

you probably want each user record to have a unique id so it can be properly indexed

faint prism
#

Also, telling me to google is an acceptable reply lol

#

Yeah, the record's ID is <ulong> UserId

quartz kindle
#

are you using a collection?

faint prism
#

I'm exploring MongoDb. My DB class is essentially a List<UserRecord>
Is this what the DB should look like? I just threw my Json db at it
@quartz kindle

quartz kindle
#

i mean, if you did anything with mongodb collections

#

like db.someCollection.insert()

#

or how did you transfer from json to mongo

faint prism
#

Let me show you my user record repository class

#

That's essentially my JSON database

#

Nothing fancy

quartz kindle
#

yes but

#

you said you are exploring mongodb

faint prism
#

mhm

quartz kindle
#

did you actually write to mongodb yet?

faint prism
#

No, I imported via JSON file just to test it out. I'm assuming that doesn't make for the cleanest db.. ๐Ÿ˜›

quartz kindle
#

ah

#

i dont know what mongo does when importing json, but from the image you sent before, it doesnt look right

eternal flame
#

how do i check to see how many members are in all the servers my bot is in combined

faint prism
#

But, I think dropping the UserRecordsRepoitory would make it convert better.

eternal flame
#

and no i dont know how to use a reduce

#

that would be prob nice tho

amber fractal
#

That collection was not indexed

quartz kindle
#

i'd look into creating a collection in mongo db, then iterating over your json users and inserting each one into the collection, using the user id as the _id field

amber fractal
#

usually each document has its own _id for indexing

faint prism
#

That's what I figured

#

Bc rn it's a table with 1 object that's an array

quartz kindle
#

ye, it should be a collection with each user as a document

amber fractal
#

I believe getting by _id is much faster than by other properties

#

because it's guaranteed to be unique

quartz kindle
#

@eternal flame guilds have a .memberCount property

#

which gives you the total number of members it has

eternal flame
#

oh

#

wait so

quartz kindle
#

but to combine the memberCount of all guilds, the easiest way is to use a reduce function

eternal flame
#

can u give me an example code please

#

i dont know how to start it

#

oof

quartz kindle
#

a reduce function takes a list of items, for example an array, and does something with all of them until there is a single value left

#

for example ```js
array = [1,2,3,4,5];
result = array.reduce((previousValue,currentValue) => previousValue + currentValue, startingValue = 0)
result // 1 + 2 + 3 + 4 + 5 = 15

eternal flame
#

so basically

#

its a very complicated way of saying 1 + 2 + 3 + 4 + 5 equals 15

#

or so and so + so and so + so and so + so and so + so and so + so and so = dsjlghfekhdhfdgs

quartz kindle
#

exactly

eternal flame
#

ok so

quartz kindle
#

its a fast way to reduce any number of items into a single value based on whatever function you want

eternal flame
#

i have my bot set to log what servers its in and how many members each server has but it does not combine them

#

(thans grainger for the code)

#

ill show you

#

it console logs

#

"server is starting" is just a bug

quartz kindle
#

you know how to get the number of guilds, right?

ancient nova
#

does anyone wanna say their opinions on the website I made? I'm looking for feedback it's my third ever website

eternal flame
#

i have it set as the status

#

and yes it also displays it on the api

quartz kindle
#

so to get the number of guilds, you use client.guilds.cache.size

eternal flame
#

yep

quartz kindle
#

client.guilds.cache is an instance of a Map object, which is how discord.js stores guilds

eternal flame
#

dora the explorer intensifies

quartz kindle
#

but discord.js takes the default Maps and extends them with new functions

eternal flame
#

alr

quartz kindle
#

many of the array functions are added to them by discord.js

#

including a reduce function

#

so you can directly do client.guilds.cache.reduce()

eternal flame
#

shut up

#

rly?

#

thats a lot easier then i thought

#

so wait

#

how would i

#

wait

#

how would i have that display as a number

quartz kindle
#

so if you learn how reduce works in one, you can use it in the other exactly the same way

eternal flame
#

hm

#

how would i log this to the console

#

i just tried console.log(client.guilds.cache.reduce()) and that didnt work

#

(of)

#

ofc*

quartz kindle
#

reduce requires a function

#

just like find, filter, etc...

eternal flame
#

what would the function be

quartz kindle
#

remember the example i showed you above?

eternal flame
#

wait

#

hold on

#

would it be

#

i dont wanna fuck up and sound stupid

#

function

#

client.

#

hot or cold

quartz kindle
#

cold

eternal flame
#

fuck

#

uh

#

function

quartz kindle
#

do you know how to use .find and .filter and other array functions?

eternal flame
#

in my dreams maybe but thats the highest chance

faint prism
#

64-bit (8-byte) integers is what I need

quartz kindle
#

probably long

faint prism
#

wouldn't it being an unsigned long have an issue with that?

quartz kindle
#

which app is that?

faint prism
#

MongoDB Compass

eternal flame
#

ok so it does start with function right

faint prism
#

Long would make a ulong truncate. Unless it was a long long

quartz kindle
#

cant find anything in the compass docs

faint prism
#

me either :/

quartz kindle
#

decimal128 would probably be long long

faint prism
#

I'll look more into that db, but I don't need percision..

quartz kindle
#

so number would be uint32, and long would be uint64 i believe

#

but they have a separate int32

eternal flame
#

u guys sound like me trying to figure out the difference between 32 bit and 64 bit

quartz kindle
#

trying to figure out what exactly mongodb compass means with those names lol

eternal flame
#

so

#

the

#

reduce thing

#

it does start with function

#

right?

quartz kindle
#

anyway, you never used .find() or .filter()?

eternal flame
#

no

faint prism
#

Decimal128 supports 34 decimal digits of significand and an exponent range of โˆ’6143 to +6144

quartz kindle
#

you never used any array function?

eternal flame
#

nae

quartz kindle
#

what about forEach

faint prism
#

Do you know what an array is?

eternal flame
#

for my handlers yes

#

command handlers

#

also for the console log

#

commands

#

etc

quartz kindle
#

ok so, when you do something.forEach() inside the forEach you put a function

#

and the function is executed once for every item

#

this function is given the current item, for you to do something with it

#

for example

eternal flame
#

["command"].forEach((handler) => {
require(./handlers/${handler})(bot);
}); are my cmd handlers

quartz kindle
#

something.forEach(item => do something with item)

eternal flame
#

OHHH

#

oh

#

so

#

would the

#

the the the

#

the do something with item

#

be the reduce function

#

and the item

#

be the server count

#

or

quartz kindle
#

more or less

eternal flame
#

am i wrong

#

yay

quartz kindle
#

if you wanted to do .find or .filter, it would be the same thing: something.filter(currentItem => do something with current item) or something.find(currentItem => do soemthing with current item)

#

but with .reduce its a bit different

#

with forEach, find and filter, you function is given the current item, to do something with it, but with a reduce, the current item is given as the second parameter, not the first

#

the first parameter is an accumulator, which holds the total combined value so far

eternal flame
#

oh

quartz kindle
#

so a reduce would be like this

#

something.reduce((accumulator,currentItem) => do something with current item and accumulator)

eternal flame
#

what would it be with the needed things replaced with things to get member value

faint prism
#

ListOfThing.ForEach(aThing => aThing.thingsProperty = newValueForThing) // Replaces every things property

opaque eagle
#

what does he want to do

eternal flame
#

total member count of all servers

#

that the bot is in

quartz kindle
#

the accumulator has no initial value, it starts as being undefined, but, the reduce function gives you an option to set an initial value, as the second parameter

opaque eagle
#

yeah you can just use array.reduce

quartz kindle
#

so for example

#

we want the final value to be a number

#

so lets set the accumulator's initial value to 0

#

something.reduce((accumulator, currentItem) => do something, 0) <-- 0 is the initial value of the accumulator

eternal flame
#

so let me get started on this

#

kinda

#

if

#

i set the amount of servers its in as servers

#

would it be

#

["servers"].dbjsfgkjdsgfd.g(dfskjgkhfdhgdfsgf)

quartz kindle
#

no

eternal flame
#

hm

quartz kindle
#

your starting point is client.guilds.cache

#

remember?

eternal flame
#

oh

#

yeah

quartz kindle
#

anyway, the do something part, its basically, what to do with the current item, and the accumulator, and whatever the result is, the accumulator becomes that result

eternal flame
#

so the accumulator is what everything is added too

#

it piles up

quartz kindle
#

for example, if you put accumulator + currentItem in the do something part, then if accumulator is 0 and item is 5, then the accumulator becomes 5. so when the next item comes, let say the next item is 6, the next step will be 5 + 6, and the accumulator becomes 11, so the third item comes, lets say its 10, it will do 11 + 10, and the value will become 21

#

exactly

eternal flame
#

its like im learning math all over again lol

#

im just gonna call you mrs. baily now

#

jk

#

ok but

quartz kindle
#

so to do this with guilds

#

when you do client.guilds.cache.reduce((accumulator, item) => do something, 0)

#

the item, is a guild

#

not a number

#

but the guild contains a .memberCount property

#

which is what we want

#

so you simply do accumulator + item.memberCount

eternal flame
#

wait

#

so

#

client.guilds.cache.reduce((accumulator, membercount) => do something, 0)

#

oer

#

or*

#

wiat nop

#

wait no

#

servers would go there right?

#

client.guilds.cache.reduce((accumulator, servers) => do something, 0)

quartz kindle
#

it doesnt matter what you write there, its just a name

eternal flame
#

oh

quartz kindle
#

the item is always going to be a guild

eternal flame
#

OH

#

OH

#

ok

quartz kindle
#

because you're doing reduce on the guilds.cache

eternal flame
#

ok

#

so

#

client.guilds.cache.reduce((accumulator, servers) => do something, 0)

#

what would

#

go into the do something

quartz kindle
#

in the above case, servers would be 1 guild

#

the current guild being done something do

eternal flame
#

that

quartz kindle
#

and all guilds have a .memberCount property

eternal flame
#

so

#

wait

#

so we

#

go through each guild individually

#

get the member count

#

add that to the acc.

#

and then

quartz kindle
#

exactly

eternal flame
#

oh

#

would that just be

#

like

#

client.guilds.cache.size = servers

#

client.guilds.cache.reduce((accumulator, servers) => do something, 0)

quartz kindle
#

nope

eternal flame
#

ASJKGHGUFSDKHJKHFDDJSFF

quartz kindle
#

you dont need servers at all

eternal flame
#

wait

quartz kindle
#

whatever you write in there

eternal flame
#

what?

quartz kindle
#

its just a name

#

doesnt mean anything

eternal flame
#

ok

quartz kindle
#

you could write a instead of servers

#

doesnt matter

eternal flame
#

hm

#

ok so im gonna put servers in there for now

#

where do we determine the amount of guilds to go through

#

or does it

#

determine that auto.

quartz kindle
#

guilds.cache is a list of guilds

#

something like [guild1,guild2,guild3,etc...]

eternal flame
#

so it by default

#

caches

#

every guild?

quartz kindle
#

when you do .reduce on it, it does it to all of them

#

yes

eternal flame
#

oh

#

ok

#

so

#

client.guilds.cache.reduce((accumulator, servers) => do something, 0)

#

the accumulator

#

would be 0 right

quartz kindle
#

yes

eternal flame
#

client.guilds.cache.reduce((0, servers) => do something, 0)

#

?

quartz kindle
#

no

eternal flame
quartz kindle
#

the beginning of the function is where you define the names

#

it doesnt matter what you write

eternal flame
#

wait so

quartz kindle
#

could be (accumulator, item) => or (a,b) =>

eternal flame
#

is

quartz kindle
#

its just a placeholder name

eternal flame
#

oh

#

oh

#

oh

#

oh

#

okay

high summit
quartz kindle
#

what matters is how you use it inside the do something part

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => do something, 0)

#

we have this so far

#

client.guilds.cache.reduce((accumulator, servers) => a complicated way of saying add it all, right?, 0)

quartz kindle
#

more like, an easy way of saying add the current item to the accumulator

earnest phoenix
#

<What does that 0 at the end doing there>

quartz kindle
#

the initial value

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => current item?,0)

quartz kindle
#

in the above case, servers would be the current item

#

thats the name you gave it

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers, 0)

#

:O

quartz kindle
#

that will make the accumulator become the item

eternal flame
#

shit

quartz kindle
#

almost there

eternal flame
#

was the servers good wher eit was?

#

servers, 0

#

or is that the bad thing

quartz kindle
#

no, its correct

#

just add the accumulator there as well

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers, accumulator, 0)

quartz kindle
#

no

#

you want to add them up

#

how do you do addition?

eternal flame
#

omg

#

wait

#

client.guilds.cache.reduce((accumulator, servers) => servers + acc?, 0)

quartz kindle
#

yes

eternal flame
#

OH

#

im big brain

quartz kindle
#

but still theres something missing

eternal flame
quartz kindle
#

because the current item is a guild, not a number

#

they types dont match, they cant be added together

eternal flame
#

so

#

are we supposed to convert it to a number?

quartz kindle
#

you want to get the memberCount from it

earnest phoenix
#

No, guild has a memberCount

#

Just map them if you want

eternal flame
#

where would membercount go

quartz kindle
#

memberCount is a property of guild

#

if a = guild then memberCount would be a.memberCount

eternal flame
#

where would that goooo

#

client.guilds.cache.reduce((accumulator, servers) => servers + a.membercount?, 0)

quartz kindle
#

you named your guild servers not a

eternal flame
#

dshigbgdfjkhkjgdfl

#

client.guilds.cache.reduce((accumulator, servers) => servers + servers.membercount?, 0)

quartz kindle
#

now you removed the accumulator

eternal flame
#

h

earnest phoenix
#

Both are required

#

Both with the memberCount property

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers + a.servers.membercount?, 0)

earnest phoenix
#

Bruh

quartz kindle
#

that makes no sense

#

a doesnt exist

eternal flame
#

then

#

wait

#

would acc go in place of a?

#

or

#

wait

#

cgnb mkfgjsnbfsdg

quartz kindle
#

put the accumulator back

earnest phoenix
#

Bruh

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers + a.servers.membercount?, accumulator, 0)

earnest phoenix
#

No

#

Bruh

quartz kindle
#

lmao

eternal flame
#

hh

sudden geyser
#

this is painful and fun to watch

quartz kindle
#

you were almost there, now you're fucking it all up

eternal flame
#

TAKE A STEP BACK

earnest phoenix
#

Just do a fuck go back

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers + acc, 0)

quartz kindle
#

yes

earnest phoenix
#

And add memberCount property to both

amber fractal
#

not both

quartz kindle
#

not both

earnest phoenix
#

Nani

eternal flame
#

now is just the stage where you move something around till it works

amber fractal
#

accumulator will be a number

eternal flame
#

LOL

slender thistle
#

servers is the item itself, right?

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers + acc, something here, 0)

amber fractal
#

servers is one guild

slender thistle
#

Nope

quartz kindle
#

no commas

eternal flame
#

f

earnest phoenix
#

Hello everyone, tell me do you know how we can do to see the number of servers in which our bot is (mentioned me if you knew please)?

quartz kindle
#

leave the commas as they are

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers + acc, something here 0)

earnest phoenix
#

@earnest phoenix

<Client>.guilds.cache.size```
quartz kindle
#

leave the 0 as it is

eternal flame
#

so remove soemthing here

quartz kindle
#

what matters is whats between => and ,

#

everything else is correct

earnest phoenix
#

@earnest phoenix good ^^

eternal flame
#

oh

#

client.guilds.cache.reduce((accumulator, servers) sumthin => servers + acc, 0)

quartz kindle
#

no

earnest phoenix
#

Uhh

#

Bruh

eternal flame
#

f

quartz kindle
#

i said everything else is correct

earnest phoenix
#

Remove sumthin

eternal flame
#

take a step back, i must

#

client.guilds.cache.reduce((accumulator, servers) => servers + acc, 0)

#

is what i have

quartz kindle
#

yes

eternal flame
#

like i said

quartz kindle
#

that is correct, the only problem is that servers is a guild, and accumulator is a number

slender thistle
#

You'd need to edit the servers that's after =>

eternal flame
#

this is the stage where you move shit around until you get lucky and it works

sudden geyser
#

noop

quartz kindle
#

but because servers is a guild, it has a .memberCount property you can access

slender thistle
#

There's no need to move shit around

eternal flame
#

ok

#

so

#

do something]

#

that turns

#

servers into a number

#

or

#

no

quartz kindle
#

servers is a guild

#

all guilds have a .memberCount

eternal flame
quartz kindle
#

so how do you get the member count from a guild?

eternal flame
#

uh

#

wiat

#

wait

#

i got this

earnest phoenix
eternal flame
#

guild.memberCount

earnest phoenix
#

Yes

quartz kindle
#

exactly

slender thistle
#

Almost

eternal flame
#

SHIVACO I HATE YOU

slender thistle
#

Well, it's not literally guild

quartz kindle
#

now your guild is called servers because you gave it that name

#

so what do you have to do?

eternal flame
#

servers.memberCount

quartz kindle
#

bingo

eternal flame
#

jhk;fgdbajklo;fgdbajlkbf;dsfgdsjkl;

earnest phoenix
#

Yes

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers + acc, 0)

#

so

#

we take

#

servers.memberCount

#

and put it

#

where

quartz kindle
#

inside the => ,

eternal flame
#

replace servers with it or keep everything and just do servers.memberCount + etc + etc, 0

quartz kindle
#

replace servers with it

eternal flame
#

client.guilds.cache.reduce((accumulator, servers) => servers.memberCount + acc, 0)

earnest phoenix
#

Yes

quartz kindle
#

yes

#

now just name the accumulator properly

eternal flame
#

sweating

earnest phoenix
#

You can name it a

quartz kindle
#

Lol

earnest phoenix
#

Lmao

eternal flame
#

uh

#

okay

#

i feel like

#

i should think about what to name it

#

like its my newborn child

#

client.guilds.cache.reduce((steven, servers) => servers + acc, 0)

honest perch
#

Learning time with tim

quartz kindle
#

most people just name it (a,b)

#

i personally name it (a,t)

eternal flame
#

client.guilds.cache.reduce((hoarder, servers) => servers.memberCount + servers + hoarder, 0)

quartz kindle
#

why the extra servers

eternal flame
#

oh

earnest phoenix
#

You don't need the servers +

eternal flame
#

client.guilds.cache.reduce((hoarder, servers) => servers.memberCount + hoarder, 0)

earnest phoenix
#

Yes

quartz kindle
#

yes very good

eternal flame
#

๐Ÿ˜Ž

#

so

quartz kindle
#

now you can give all of that to a variable

eternal flame
#

so

quartz kindle
#

let totalMembers = all of that

eternal flame
#

var piece_of_shit_that_took_me_an_hour = client.guilds.cache.reduce((hoarder, servers) => servers.memberCount + hoarder, 0)

quartz kindle
#

yup

eternal flame
#

alr

earnest phoenix
#

Yes lol

quartz kindle
#

and it must be inside the ready event

#

otherwise the list of guilds is empty

earnest phoenix
#

Yea, lmao

slender thistle
#

I'll kindly yell at you for using snake case in JS

honest perch
#

Now tim

sudden geyser
#

What_About_This

honest perch
#

Teach me all of react in 10 seconds

quartz kindle
#

i cant beliebe i just spent an hour on this

eternal flame
slender thistle
#

Well you're permamuted now Tim

quartz kindle
#

missing a comma

eternal flame
#

ik

#

just making sure tbats right

quartz kindle
#

yes

slender thistle
#

you forgot a comma after- eh fuck phone

quartz kindle
#

except

#

your client

#

you named it bot

honest perch
#

Who doesnt do that

eternal flame
#

yes

#

anyways

quartz kindle
#

so you have to adapt

eternal flame
#

kets fuckin go

#

pog

quartz kindle
#

nice

earnest phoenix
honest perch
#

Tim

earnest phoenix
#

Whats the domain? @eternal flame

quartz kindle
#

@honest perch i dont know react >.>

eternal flame
#

localhost moment ๐Ÿ˜ณ

honest perch
#

How can we make sure Tim really isn't the creator of javascript

eternal flame
#

i still need to port the thingy

spare coyote
#

Who doesnt do that
@honest perch
i do i named my client, client

earnest phoenix
eternal flame
#

iim just working on getting it set up rn

quartz kindle
#

i name my client client as well

#

because... its the original name

eternal flame
#

iim making an api

quartz kindle
#

its like naming link link when playing zelda

#

you even get an extra heart for it

honest perch
#

I name it "thisisjustelectronbutdiscordversionsoramgobrrrr"

sonic lodge
#

wait really

faint prism
#

Weird. The website has Int64, but the Compass client doesn't

honest perch
#

Who uses 64

faint prism
#

People with ulongs

slender thistle
#

storing IDs as strings gang

faint prism
#

No way

quartz kindle
#

but isnt double supposed to be for decimals? doesnt make sense to use double for ints

faint prism
#

Yeah, idk

quartz kindle
#

i tried compass once and didnt like it

#

tbh i didnt like any of mongo

#

i prefer sqlite

faint prism
#

It seems less weird than MongoDB imo

#

Isn't NoSQL supposed to be better though?

honest perch
#

Depends on preference

slender thistle
#

I heard PostgreSQL is very efficient compared to the rest

#

but I like mongo because it's NoSQL and I just like fucking my JSONs up

quartz kindle
#

there are pros and const to both styles

#

nosql received a lot of hype but people are kinda finding out its not that great after all

#

the popularity of sql is going up again

slender thistle
#

catshrug I mean, I don't use NoSQL for its popularity really

#

And I kind of see why it's that way

gray finch
#

anyone know how to use style on top.gg ?

#

it seems that css is not working

#

i'm trying to use style on this part of the site

#

to change the white color to another

eternal flame
#

how does one port forward LOL

#

google isnt being nice

gray finch
#

you login to your router

eternal flame
#

i mean i got it successfully forwarded

#

but

#

its not

#

accessable

#

from anywhere else

#

aand idk what to do

#

its still a local boy

slender thistle
#

Firewall

gray finch
#

you need router id and password as far as i know

#

if you managed to set a port forward from your router pannel

solemn latch
#

Happy cake day shiv

gray finch
#

then you have to go to firewall and make sure that the specific program has allowed traffic trough your firewall

eternal flame
#

wait

#

so

#

i go off of att interne

#

an im using port 3000

#

for an api

#

is that

#

a good thing

gray finch
#

i think you can go with any port, if it's not used by something else

eternal flame
#

ok so

#

its still

#

its stuck on local still

#

uh

#

its not

#

public

#

im using a rasp pi and it wotn let me in

gray finch
#

check firewall settings

rustic nova
#

dont post it here though lmao

eternal flame
#

im noyt

#

LOL

#

ok so

#

like i said

#

im att wifi

#

whihc is

#

garbage

rustic nova
#

btw keep it one message

eternal flame
#

prob good idea

rustic nova
#

what model do you have?

eternal flame
#

fuck

#

lemme check

rustic nova
#

if you don't have access to your router's settings, then you're pretty much at a dead immediately

gray finch
#

how do you customize these things on top.gg ? anyone know ?

rustic nova
#

css

eternal flame
#

BGW210-700

rustic nova
#

<style> tags on your long description

eternal flame
#

i have access to the router stuff

rustic nova
gray finch
#

i did something like

<style type="text/css">
.class1 {
}
</style>
<body>
<p class=class1> test </p>
</body>

and it's not working

eternal flame
#

what protocol would i use

#

for an api

earnest phoenix
#

https

eternal flame
#

f

rustic nova
#

i did something like

<style type="text/css">
.class1 {
}
</style>
<body>
<p class=class1> test </p>
</body>

and it's not working
@gray finch use <style> only, not <style type="text/css">

earnest phoenix
#

that's not the issue either

#

that's invalid html

rustic nova
#

yeah

gray finch
#

ok , but how do i get buttons class name, to customize them

rustic nova
#

inspect element

eternal flame
#

@earnest phoenix

#

im talking about

#

protocol as in

gray finch
#

big brain

eternal flame
#

tcp/udp

rustic nova
#

big brain
@gray finch nah i'm fr, inspect element is the best way to go, it can give you all the class names for the buttons and stuff

earnest phoenix
#

https is tcp though

eternal flame
#

oh

#

im dujb

earnest phoenix
#

unda

rustic nova
#

this is one of the reasons why i don't host on windows

eternal flame
#

im dying in pain

#

istg

#

what would be better to host from?

rustic nova
#

vps

eternal flame
#

whats that

earnest phoenix
#

hg vps

eternal flame
#

i

#

what

#

which VPS

#

what VPS

rustic nova
#

any

eternal flame
#

how VPS

rustic nova
#

where vps

earnest phoenix
#

vps that has fast latency

eternal flame
#

i want to

#

host an api

#

i mean

#

it can already grab the data

#

but

#

meh

#

fuck it

earnest phoenix
#

i want to make it so if the user has the role already and you say !role it removes it instead of adding the role

#

this is my code:

@client.command(pass_context=True) @commands.has_permissions(administrator=True) async def role(ctx, user: discord.Member, role: discord.Role): if role in roles: await user.remove_roles(role) else: await user.add_roles(role) await ctx.send(f"{user.name} has been given {role.name}")

rustic nova
#

check if that user has the role, if it doesn't, add it

#

vise versa

earnest phoenix
#

yeah but instead of making a whole command on removing roles

#

i want to make it one command to remove and add roles

#

do you get me @rustic nova

slender thistle
#

if role in user.roles:
remove
else:
add

rustic nova
earnest phoenix
#

how i can unban in the event on_message? discordpy

slender thistle
#

unban whom

earnest phoenix
#

how do i make @command.cooldown convert to hours

#
        await client.unban(message.guild, client.get_user_info(722594354576883762))

#

i made a daily command

#

if used collects coins once a day

#

and basically ahs a day cooldown

slender thistle
#

Well

earnest phoenix
#

you should probably store long term cooldowns in a database in case the process dies for whatever reason

slender thistle
#

discord.Object(id=your_needed_ID_here) to avoid an unnecessary API request

#

and use message.guild.unban without passing the guild again as an argument

earnest phoenix
#

uhhh

earnest phoenix
#

@slender thistle Hey tell me how do we get the Bot Developer rank?

#

dont work @faint prism

#
AttributeError: 'Client' object has no attribute 'unban'
slender thistle
#

@earnest phoenix An approved bot on top.gg

faint prism
#

So client is going to be your discord client object variable

slender thistle
faint prism
#

Shiv probably knows more than me about this ^

slender thistle
#

Use message.guild.unban and pass it an instance of discord.Object

earnest phoenix
#

discord.Object(id=id_member)?

#

@slender thistle
ok and my bot gets tested when the shots?

slender thistle
#

id_member being ID of the member, yeah

earnest phoenix
#

thx

slender thistle
#

@earnest phoenix I'm not sure what you mean, but bot revies currently takes 3 weeks or more

earnest phoenix
#

3 weeks ๐Ÿ˜ฑ๐Ÿฅถ

full widget
#

wtf

slender thistle
#

What the fuck is that

faint prism
#

Did you type something instead of when you meant to make it a string?
What's a command in python? lol

slender thistle
#

how do you even get that

#

It's just python(3) some_file.py so idk how they got that

earnest phoenix
#

@slender thistle work

#

thx

slender thistle
#

magic of assumptions and there we go

earnest phoenix
#

is a stupid question but, how i can do a .then() in python?

eternal flame
#

someone teach me how to port forward

#

im dumb

slender thistle
#

Well

#

a = stuff()

do stuff with a

uneven estuary
#

Henloo, so I changed from hosting on glitch to locally hosting my bot but for some reason, even after installing all the packages required, im getting a MessageEmbed is not defined error when its a global variable in the file. I tried to use a different command that used embed and it worked. I'm using discord.js v12.
Here is where my code isnt working ( i removed the link bc well ouo )
and I would like to say that i didnt change anything in the code when i started hosting locally. It was working fine on glitch.
please @ me if someone answers thank you

sonic lodge
#

@fleet hornet is there an error

rustic nova
#

@uneven estuary what discord.js version?

uneven estuary
#

v12

eternal flame
#

someone teach me how to port forward
im dumb

#

tried that

rustic nova
eternal flame
#

doesnt work

rustic nova
#

Some things were changed about the MessageEmbed, correct me if i'm wrong

eternal flame
#

im making an api

#

and right now

#

its local host

#

i want it to be a public

#

att

earnest phoenix
#

you're asking to be ddos'd

eternal flame
#

BGW210-700

rustic nova
#

just use some kind of tunnel

eternal flame
#

idfk how

#

lol

earnest phoenix
#

don't expose a port on your home ip lol

#

people will either fry your router or dox you

sonic lodge
#

@fleet hornet does the embed send?

uneven estuary
#

Some things were changed about the MessageEmbed, correct me if i'm wrong
@rustic nova GWllentThinkPika im not sure but it was working fine on glitch

eternal flame
#

prob

rustic nova
#

better yet, don't even host locally, just get a vps

humble gyro
#

i have port 80 exposed uwu

rustic nova
#

ofc

#

@uneven estuary that's the only thing i remember back then, that RichEmbed was changed to MessageEmbed or smth

sonic lodge
#

i have a feeling something else other than your logging code is causing the restart

uneven estuary
#

that's the only thing i remember back then, that RichEmbed was changed to MessageEmbed or smth
@rustic nova yeah

eternal flame
#

is it okay for me to expose port 80

#

re

sonic lodge
#

would you mind showing the rest of your code

solemn latch
#

The font ahhh

earnest phoenix
#

why not just debug and see what is actually going on instead of guessing

#

if you're running with the debugger in vsc for example

#

that doesn't do much if you don't have breakpoints

#

log at points and try catch

#

/ or place a brakepoint

#

breakpoint*

#

how do i send hi marked text in discor dpy

#

what have you tried

#

i want to make it so the bot sends marked text

#

what have you tried

#

well

#

**

**

#

-_-

#

have you tried actually using the same syntax as you do as an user

#

yes

#

which is a logic step in every normal humans brain

#

like sending **hi**

#

yeaah

#

my bad

#

i'm stupid -_-

#

you are.

solemn latch
#

Wow, gottem

earnest phoenix
#

are you sure about that

#

or that you don't have multiple instances turned on

#

the message that was deleted wasn't in cache, so it has no properties at all. when you delete a message, all discord gives is the message id in the event, nothing else, the libs pull other relevant data from cache

#

hm

#

`@client.command(aliases=['with'])
@commands.cooldown(1, 5, commands.BucketType.user)
async def withdraw(ctx,amount = None):
await open_account(ctx.author)
if amount == None:
await ctx.send("please enter the amount!")
return

bal = await update_bank(ctx.author)
amount = int(amount)
if amount>bal[1]:
    await ctx.send("you don't have that much money!")
    return
if amount<0:
    await ctx.send("amount must be positive!")
    return
    
await update_bank(ctx.author, amount,)
await update_bank(ctx.author, -1*amount, "bank")

await ctx.send(f'you withdrew {amount} coin(s)!')`

how do i make it so if i say .withdraw all, it takes everything out of the wallet. instead of typing the numbers you have in your wallet

slender thistle
#

There's the option of doing if amount == "all":

snow urchin
#
        let votes = client.fetch("https://top.gg/api/bots/480421483575902208/votes", {headers: {Authorization: process.env.DBL}}).then(res => res.json())
          .then(json => {
            let voters = [... new Set(json.map(x => x.id))];
            return voters.map(x => {
              return {voter: x, count: json.filter(x => x.id == x).size}
            })
          }), numer = 0;

          message.channel.send(
            new client.Embed(message.guild.id)
              .setTitle(`${message.guild.name} - Votes Leaderboard`)
              .setDescription(
                votes.length >= 1
                  ? voters.map(top => `**${numer++}.** **${client.users.cache.get(top.voter).tag}** - **${top.count}** Vote${top.count == 1 ? "" : "s"}**`)
                  : "Nobody has voted yet!"
              )
          )

Why does this return the "Nobody has voted yet?"

#

wait im dumb

#

nvm

sudden geyser
#

yeah it returns a promise

dire obsidian
#

Stats should be a owner command or public command?

solemn latch
#

Depends what stats

dire obsidian
#

Ram, cpu, users, server count

snow urchin
#
        client.fetch("https://top.gg/api/bots/480421483575902208/votes", {headers: {Authorization: process.env.DBL}}).then(res => res.json())
          .then(json => {
            let voters = [...new Set(json.map(x => {return{voter: x.id, user: `${x.username}#${x.discriminator}`}}))], numer = 1
            let votes = voters.map(x => {
              return {voter: x.user, count: json.filter(y => y.id == x.voter).length}
            }).filter(x => x.count != 0).sort((a,b) => a.count - b.count).slice(0, 10).reverse()
            message.channel.send(
              new client.Embed(message.guild.id)
                .setTitle(`${message.guild.name} - Votes Leaderboard`)
                .setDescription(
                  votes.length >= 1
                    ? votes.map(top => `**${numer++}.** **${top.voter}** - **${top.count}** Vote${top.count == 1 ? "" : "s"}`)
                    : "Nobody has voted yet!"
                )
            )
          })
dire obsidian
#

maybe you dont make that..

#

just i say

#

maybe

snow urchin
sudden geyser
#

Why are you even making a raw string to then be parsed into an object with Object?

snow urchin
sudden geyser
#

nice

snow urchin
#

ya

#

well its sorta fixed

#

i am on it twice?

#

updated code block above

#

3 times actually

pale vessel
#

here's how i'd do it:```js
const formatted = {};

votes.map(voter => formatted[voter.id] ? formatted[voter.id]++ : formatted[voter.id] = 1);```

#

formatted would look like { "id": 10, "moreid": 4 }

#

so in the embed, you can use Object.entries(formatted) and map them however you like

snow urchin
pale vessel
#

nice

snow urchin
#

mhm

#

very helpful indeed

pale vessel
#

lol

#

mine returned {"590455379931037697":7,"373657230530052099":10}

snow urchin
#

yours is done differently then

pale vessel
#

the votes are from the same endpoint, hmm

karmic compass
#

does anyone know how to fetch data from a JSON file in javascipt? i know how to use requests in python but i don't know how to convert it into javascript (btw im using https://api.thecatapi.com/v1/images/search and want to fetch "url" when a user types in a command in discord)

#

oh where did that come from

#

uh

pale vessel
#

you'd want to parse the json response

#

can't help, sorry

#

there should be plenty of tutorials online

karmic compass
#

okay

#

after some short time spent on google i know how to do actually most of the things except for grabbing the JSON file from the website

pale vessel
#

ah, can't you use the request module?

#

get the response from the API and parse it as JSON

karmic compass
#

i know var jsonFile = "{"name":"hi"}"
var ojb = JSON.parse(jsonFile)

consoel.log(ojb.name)

pale vessel
#

that's javascript

karmic compass
#

yes

#

was it too confusing?

#

i meant to say i know how to do it in python but i want it in javascript

#

sorry if i came across as confusing

pale vessel
#

oh haha

karmic compass
#

lmao, i do that too much

pale vessel
#

do you use a package for requesting?

karmic compass
#

wdym,

pale vessel
#

e.g. axios and node-fetch

karmic compass
#

i haven't actually gotten into any of these,

#

i got as far as the other thing, i don't know what package/how to use it

pale vessel
#

you should get one of those packages to make things easier

karmic compass
#

alr ill install node-fetch

pale vessel
#

good choice, i use node-fetch too

surreal notch
#

I want help in my website i wanted that if someone press a button in my website then it should then my discord bot should send a particular message in my server that this person have pressed this button i cant understand how to attach website with bot.

karmic compass
#

npm install node-fetch?

#

hm

pale vessel
#

yes

#

an example in node-fetch would be const obj = await fetch("endpoint").then(x => x.json());

#

basically, it converts the response to a parsed object

pale vessel
#

you can access obj.url that way

karmic compass
#

how do i use node fetch? const fetch = require('node-fetch')

pale vessel
#

sure

karmic compass
#

sorry if i'm asking a lot of questions

pale vessel
#

nono

#

you're nice

karmic compass
#

aw thank you

solemn latch
#

The button should send a request to an api that has acess to your bot @surreal notch

pale vessel
#

yeah, that's the endpoint

solemn latch
#

Which can then send a message in a channel

karmic compass
#

then parse obj, and then we're good?

surreal notch
#

I m actually noob in backend

pale vessel
#

mhmm

karmic compass
#

woah

#

that was fast

pale vessel
#

node-fetch is cool

karmic compass
#

also btw

#

if i do function(message) {

#

will that work with await or do i have to require async?

pale vessel
#

you'd want to add the async keyword, so async function(message)

#

that way you can use await

karmic compass
#

okay

surreal notch
#

@solemn latch and how the button can send a request

pale vessel
#

there's always .then but it might make your code look wonky

surreal notch
#

i m trying this first time

harsh moon
#

What is the function for creating a role because createRole does not work

#

discord.js

pale vessel
#

<role manager>.create in v12

harsh moon
#

?

#

so how would I use that?

#

what is the role manager

pale vessel
#

role manager would be for example, message.guild.roles

harsh moon
#

ok

pale vessel
#

you should read docs though

harsh moon
#

but create was not working either

#

I tryed both commands

#

sorry functions

pale vessel
#

you might have messed up the structure

harsh moon
#

let me send it

solemn latch
harsh moon
pale vessel
#

ah, too lazy to send link

harsh moon
#

did I mess up?

pale vessel
#

what version are you on?

harsh moon
#

uhh idk

#

let me check

#

whats the command again>

karmic compass
#

so i got an error

pale vessel
#

Discord.version

#

can you show the code?

karmic compass
#

yes

harsh moon
#

cmd not found

pale vessel
#

oh, try npm ls discord.js

karmic compass
#
    if(message.content == 'y!cat') {
        const obj = await fetch("https://api.thecatapi.com/v1/images/search").then(x => x.json())
        const catURL = JSON.parse(obj)
        const catEmbed = new Discord.MessageEmbed()
         .setColor('0dff00')
         .setTitle('Meow!')
         .setImage(catURL.url)
        message.channel.send({embed:catEmbed})
    }
harsh moon
#

k

#

enpty

sonic lodge
#

you don't need to parse it agian, it's already json

pale vessel
#

you don't need to parse it again, response.json() does it for you

harsh moon
#

empty

sonic lodge
#

jinx

karmic compass
#

lmfao

#

kk

harsh moon
#

it said empty ๐Ÿ˜

pale vessel
#

xd

surreal notch
#

@solemn latch Thanks

solemn latch
#

Np

pale vessel
#

you can use console.log(require("discord.js").version)

harsh moon
#

ok found it

#

11.1.0

pale vessel
#

o you're still on v11

harsh moon
#

how do I update?

karmic compass
#

me: uncomfortalbe with the catapi
hypixel (minecraft server) api: like 10 pages long

#

okay okay so it's not giving me an error and sends the message

#

but

#

but

#

the image doesn't appear, would anyone have a guess to why?

surreal notch
harsh moon
#

updated

karmic compass
#

what essay is pangloss typing

midnight blaze
#

(message.author.presence.activities.map(msg => msg.name!=""))?message.author.presence.activities.map(msg => console.log(msg.name)) : console.log( 'Not playing.')
Hmm, it doesnt show what game I am playing. ๐Ÿค” Can someone help me?

#

not an essay

harsh moon
#

@pale vessel its still telling me its not a function

karmic compass
#

oh you already pinged him

#

was going to do it but ig hes offline

pale vessel
#

try debugging

#

console.log(obj)

karmic compass
#

oh apparently obj.url is undefined, i logged it to my console and it gave me "undefined"

#

yeah

#

imma see just obj

#

gotta wait for it to update

harsh moon
#

flazepe it still tells me its not a function and I updated

pale vessel
#

createRole is v11 code

harsh moon
#

yeah I did both

#

same err

karmic compass
pale vessel
#

it's an array

#

how would you access the first index of an array?

karmic compass
#

oh uh

pale vessel
#

say obj is an array

karmic compass
#

args[0]

#

bno

#

obj[0]?

pale vessel
#

yeah