#development

1 messages · Page 916 of 1

white anvil
#

it automatically converts them to unicode on send

cinder patio
#

Discord probably replaces them with the raw unicode before it counts the characters

white anvil
#

so you can still have the same amount

brave blade
#

no it doesn't

earnest phoenix
#

internally all :emoji: get parsed to unicode, replacing all colon format emojis to their unicode counterparts

brave blade
#

I tried it

white anvil
#

it does

pale vessel
white anvil
#

but the emote limit is lower

#

than char limit

brave blade
#

well I don't know how they do it internally

pale vessel
#

@copper cradle

copper cradle
#

had to be spanish

#

smh

brave blade
#

but fact is, they rejected my bot messages when its character count was over 2000, with shortcodes

#

whatever

#

thanks

copper cradle
#

those dudes make the rest of the Spanish dev community get bad looks

reef girder
#

If you write a bot to throw on more than one server do you actually host all instances of that bot?

#

Or when people add it to their server you as the author host it yourself?

pale vessel
#

the first

reef girder
#

So I need to maintain state between servers?

#

Like if they set a setting

earnest phoenix
#

like server-specific setting? maybe like a prefix
@reef girder

copper cradle
#

you only need 1 instance of the bot

reef girder
#

yeah

#

Like a prefix or a response message

copper cradle
#

then you can use a database to store such data

earnest phoenix
#

so you use a database to store that

wicked pivot
#
const fs = require('fs')
const hour = JSON.parse(fs.readFileSync("./hour.json", "utf8"))
function write(){
  fs.writeFile("./hour.json", JSON.stringify(hour), (err) => {
      if (err) console.log(err)
  })
}
if(!hour[moment().format("DD/MM/YYYY")]){
    hour[moment().format("DD/MM/YYYY")] = {
      users : 0,
      bots: 0
    }
  }
  write()
  if(message.author.bot){
    let add = 1
    let Current = hour[moment().format("DD/MM/YYYY")].bots
    hour[moment().format("DD/MM/YYYY")].bots = Current + add
    write()
    return
  }
  let add = 1
  let Current = hour[moment().format("DD/MM/YYYY")].users
  hour[moment().format("DD/MM/YYYY")].users = Current + add
  write()```it does not write in the json
copper cradle
#

it's like asking if a new account gets create everytime I join a server

reef girder
#

and then use the guild ID to just grab wahtever info?

#

sighhh okay

copper cradle
#

bc it uses the old hour

#

the one that's at the top

earnest phoenix
#

I use keyv and a mongodb

copper cradle
#

add hour as a parameter and pass it to the function

earnest phoenix
#

keyv is really simple and to the point

reef girder
#

ill check it out thanks

#

🙂

earnest phoenix
#

what things should i consider when storing user input in a json file? is there a parse function to escape stuff like quotes etc?

cinder patio
#

you shouldn't do that

reef girder
#

If you want to do it you can though!

#

checkout decodeuricomponent

#

oh wait maybe thats the wrong thing sec

#

oh no thats right

#

but JSON.parse will get you most of the way there

tardy estuary
#

yeah json parse

earnest phoenix
#

so i am trying to do it if the guildid has 1 in the blacklist row they cant do any commands what have i done wrong

client.on('message', async msg => {
  if (msg.channel.type !== 'text' || !msg.content.startsWith(settings.prefix)) return;
  console.log(`[${msg.guild.name}] ${msg.author.tag} >> ${msg.content}`);
  const cmd = msg.content.toLowerCase().slice(settings.prefix.length).split(' ')[0];
  if (!commands[cmd]) return;
  con.query(`SELECT * FROM testing WHERE guildid = ${msg.guild.id}`, (err, result) => {
      if (err) return console.log(err);
      if (result[0] && result[0].blacklist == 1 || cmd !== 'help') {
          return msg.channel.send('This server is blacklisted so cannot use this command.');
      }
      else {
          commands[cmd](msg);
      }
  });
});```
reef girder
#

are you getting an error?

earnest phoenix
#

aren’t jsons prone to corruption

reef girder
#

or whats happening when you run that

#

@earnest phoenix yeah its not perfect but if they want to just move forward best to help people with their actual question instead of suggesting rewrites

earnest phoenix
#

will json parse fix stuff like quotes being stored properly etc

copper cradle
#

don't use json as a database

#

when you migrate your crap we talk ok

reef girder
#

Yeah :p

#

then thats the time to answer the other question haha

earnest phoenix
#

get a nice mongodb sandbox

#

i just migrated over from using .txt

tardy estuary
#

dont use json as a db because it isnt a real db and you are gonna run into issues trying to write to a single file simultaneously. unless you forcibly do everything synchronous, which also sucks

reef girder
#

?

tardy estuary
#

any errors @wicked pivot

wicked pivot
#

no :c

tardy estuary
#

im assuming write() isnt doing what you think its doing?

#

aka

#

you should be calling fs.write()

#

im assuming

#

oh nevermind i see you have it as a function

#

ignore me

hasty lotus
#
dbl.hasVoted(message.author.id).then(voted => {
    if (voted) {
      //command
    }
});``` Does anyone know why does this always run ? (even if the person didn't voted in the past 12 hours) This example is from https://discordbots.org/api/docs#jslib
#
const fs = require('fs')
const hour = JSON.parse(fs.readFileSync("./hour.json", "utf8"))
function write(){
  fs.writeFile("./hour.json", JSON.stringify(hour), (err) => {
      if (err) console.log(err)
  })
}
if(!hour[moment().format("DD/MM/YYYY")]){
    hour[moment().format("DD/MM/YYYY")] = {
      users : 0,
      bots: 0
    }
  }
  write()
  if(message.author.bot){
    let add = 1
    let Current = hour[moment().format("DD/MM/YYYY")].bots
    hour[moment().format("DD/MM/YYYY")].bots = Current + add
    write()
    return
  }
  let add = 1
  let Current = hour[moment().format("DD/MM/YYYY")].users
  hour[moment().format("DD/MM/YYYY")].users = Current + add
  write()```it does not write in the json

@wicked pivot do you use command handler ?

#

and do you host on glitch ?

wicked pivot
#

glitch

earnest phoenix
#

yikes

hasty lotus
#

glitch frequently has problems with file writing

earnest phoenix
#

yes it does

hasty lotus
#

try to host it on your computer

#

just to make a test

#

if it works then it means that the pblm if from glitch

#

if not idk

#

check the name of the file

earnest phoenix
#

pm2 and self host are great things

wicked pivot
#

I already used json before and I had no problem

hasty lotus
#

while your process is running

#

try cat

#

do cat hour.json

wicked pivot
#

I have to do what ?

hasty lotus
#

download your bot files

copper cradle
#

yeah

hasty lotus
#

on your computer

copper cradle
#

you won't be using json dbs on glitch

hasty lotus
#

and try to run it on your computer

copper cradle
#

and nowhere else

#

json is not supposed to be used as a database

#

just get a real database smh

wicked pivot
#

on my pc it works

hasty lotus
#

then it's from glitch

#

you will have to change your host sorry :/

wicked pivot
#

on my pc it works, what do you advise me like db on glitch? free

hasty lotus
#

idk

#

sqlite with quick.db is quite easy to setup

#

and use

copper cradle
#

ofc it's gonna work on your pc

reef girder
#

@earnest phoenix for keyv is there a way to set character encoding types?

#

I want to store emojis

copper cradle
#

you can't just dynamically write files like that on glitch

#

get a real host

vestal sequoia
#

Is it any way to get the Field title white?

copper cradle
#

or don't bother people with such problems

hasty lotus
#

Is it any way to get the Field title white?
@vestal sequoia no sorry

vestal sequoia
#

Ok, Thanks

earnest phoenix
#

@reef girder not sure, you might be able to store emotes

wicked pivot
#

@hasty lotus I already use quick.db in the same file

hasty lotus
#

but you can use .setDescription @vestal sequoia

vestal sequoia
#

Ok thanks 🙂

hasty lotus
#

@hasty lotus I already use quick.db in the same file
@wicked pivot idk then

#

:/

copper cradle
#

they want to get the field not set it

#

fetch the messagw

hasty lotus
#

yeah like make it white

#

but nope

#

field titles are gray

#

and they will stay gray

#

🤷‍♂️

copper cradle
#

the message returns an array of embeds if there are any the embed you want will be the first item

#

then you can get it's properties

vestal sequoia
#

In an Embed, AddField, What dose the inline do?

reef girder
#

make it all show in the same row

#

instead of on a new row

#

side by side vs new row

vestal sequoia
#

Ok, thanks

reef girder
#

np

tight plinth
#

I'm having issues with my djs v12 bot, music starts by being glitchy and then stabilize after ~20 seconds, how can I avoid that

#

ytdl gang

earnest phoenix
#

@tight plinth are running it locally

tight plinth
#

?

earnest phoenix
#

are you running it on your computer or in the clouds

tight plinth
#

vps

white anvil
#

is there any way to force a git fork to sync back to the current commit the base repo is on

#

or do u have to re-fork

earnest phoenix
#

anyone used remotemysql? what do i write in "host:" when i want to connect my nodejs code with the db?

#

phpmyadmin just says localhost

copper cradle
#

well

#

it says it all

#

localhost

earnest phoenix
#

but when i type that i get a connect refused

copper cradle
#

127.0.0.1

earnest phoenix
#

Error: connect ECONNREFUSED 127.0.0.1:3306

copper cradle
#

and you need the port

#

is that the correct port?

#

where is the database hosted at

earnest phoenix
#

not sure where i see the correct port

#

can i view the port num on phpmyadmin?

copper cradle
#

idk

#

never used phpmyadmin

earnest phoenix
#

not sure how to relate it to host

#

you mentioned port, but where do i input that?

#

just local:3306?

pale vessel
#

oh yikes

#

that's a free mysql hosting

copper cradle
#

ah

earnest phoenix
#

i guess default is 3306

pale vessel
#

because 3306 is the default port

copper cradle
#

that's the default port

pale vessel
#

yes

copper cradle
#

yea

#

lmao

pale vessel
#

you're prone to data leak

copper cradle
#

yeah

earnest phoenix
#

glad we agree, lol

pale vessel
#

if your database vanishes one day, you can't blame us

copper cradle
#

I won't use such sketchy hosts

earnest phoenix
#

i think there are some free myswl hosting through github student pack too

copper cradle
#

¯_(ツ)_/¯

#

idk I have my vps where I have my stuff

earnest phoenix
#

but are i really like how it instantly has your phpmyadmin setup too

copper cradle
#

to I'm fine

pale vessel
#

pma is good

earnest phoenix
copper cradle
#

oh well

earnest phoenix
#

what if i use json on the mysql db

copper cradle
#

are you kidding

pale vessel
#

doesn't sound like it

nocturne dagger
#

Hey so im trying to make a vote command that gives a user a role when the vote and it works to tell if you voted or not but it gives me this error

#
(node:3265) UnhandledPromiseRejectionWarning: TypeError: message.addRole is not a function
at dbl.getVotes.then.votes (/app/master/commands/vote.js:13:11)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:3265) 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:3265) [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.
#

This is my code

#
module.exports.run = async (Discord, client, message, args) => {
  const DBL = require("dblapi.js");
let voter = message.guild.roles.find(role => role.name === "voter");
  const dbl = new DBL(process.env.DBL_TOKEN,
    client
  );
let member = message.member
  dbl.getVotes().then(votes => {
    if (votes.find(vote => vote.id == message.author.id)) {
      message.channel.send("Thanks for the vote! :)");
      client.channels.get("708353671175602206").send(message.author + " has voted for Yobo")
  
  message.addRole(voter)

    

    } else {
      message.channel.send(
        "You have not voted yet go vote on our discordbots. \n\n**If you already voted it can take up to 5 minutes to update on to our bot.**"
      );
    }
  });
};

quartz kindle
#

you're trying to add a role to a message?

pale vessel
#

surely that'll work

nocturne dagger
#

oh

#

god

#

i changed it message.author

#

but it was member

#

so go with it as that

#

same error tho just member.addRole

pale vessel
#

are you on v12?

#

i guess not since client.channels.get()

nocturne dagger
#

no im not

#

i am old

pale vessel
#

are you sure it's the same error?

#

can you send it here, just in case

nocturne dagger
#

let me get that one

earnest phoenix
brazen vortex
#

My bot was returned today and it said it was declined because of my !image command which can send NSFW content and I need to add a search filter. How?

restive furnace
#

put safesearch

pale vessel
#

make it nsfw channel only

nocturne dagger
#

now it gives this ```

(node:3455) UnhandledPromiseRejectionWarning: TypeError: Supplied parameter was neither a Role nor a Snowflake.
at GuildMember.addRole (/rbd/pnpm-volume/7d63fd46-a383-46f0-afca-7da9eafb3707/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/structures/GuildMember.js:452:38)
at dbl.getVotes.then.votes (/app/master/commands/vote.js:13:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:3455) 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:3455) [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.

pale vessel
#

try addRole(voter.id)

#

although voter should've worked

nocturne dagger
#
(node:3513) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
at dbl.getVotes.then.votes (/app/master/commands/vote.js:13:24)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:3513) 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:3513) [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.
pale vessel
#

voter is null

brazen vortex
#

How do I put safe search?

pale vessel
#

role name is case sensitive, are you sure it's the correct spelling ted?

earnest phoenix
pale vessel
#

please don't bump messages

earnest phoenix
#

;v

nocturne dagger
#

Thanks it works now

#

it was capital t

#

im big dumb

pale vessel
#

remove .id from voter.id because why not

tight plinth
mental lodge
#

when my bot ques a song it just plays it emiedeatly, its really enoying anyone else have that problem

tight plinth
#

the bot connects to the vc and leaves it instantly with this error

pale vessel
#

yo

#

dispatcher doesn't exist

#

it's just connection.on()

tight plinth
#

im trying to figure out why

#

of

#

how am I supposed to guess

copper cradle
#

message.member.addRole

pale vessel
copper cradle
#

ffs

pale vessel
#

did you press escape

tight plinth
#

yes

copper cradle
#

dispatcher.on

earnest phoenix
#

help?

copper cradle
#

else it's returning not that

#

idk how to explain

pale vessel
#

i just-

#

ok

#

lumap read docs

copper cradle
#

ah shit

#

the papulince is back

tight plinth
#

so I guess

//djs v12
connection.dispatcher.end()
```--> ```js
//eris
connection.end()
```for the stop command?
#

I do

pale vessel
#

that idk

#

i never do that i did use that but forgot kek

tight plinth
#

oh

pale vessel
#

read docs smh

copper cradle
#

ffs

#

tfw ppl don't read the docs

#

reading the docs is the easiest shit ever

pale vessel
#

which is why i'm always angry

#

feel free to dm be regarding eris @tight plinth

mental lodge
#

I genuinly dont know how to make webhooks,

tight plinth
#

ok

#

I got it to work woohoo

pale vessel
#

pog

mental lodge
#

do you need webhooks?

pale vessel
#

no

mental lodge
#

mk ight

earnest phoenix
pale vessel
#

because data is not an array

#

or is it

#

yes it is

#

but you're using the v1 api, which is deprecated.

earnest phoenix
#

Just changing the url?

pale vessel
#

yes

earnest phoenix
#

Oh ty

sacred crystal
#

anyone here do scala?

tight plinth
mental lodge
#

lumap what language are you using

pale vessel
#

seems to be english

tight plinth
#

seems to be js

warm maple
#
0|index    |     at Module._compile (internal/modules/cjs/loader.js:1156:30)
0|index    |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
0|index    |     at Module.load (internal/modules/cjs/loader.js:1000:32)
0|index    |     at Function.Module._load (internal/modules/cjs/loader.js:899:14)
0|index    |     at Module.require (internal/modules/cjs/loader.js:1042:19)
0|index    |     at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
0|index    |     at require (internal/modules/cjs/helpers.js:77:18)
0|index    |     at CommandoClient.<anonymous> (/root/bot/index.js:79:3)
0|index    |     at CommandoClient.emit (events.js:310:20)
0|index    |     at CommandoMessage.run (/root/bot/node_modules/discord.js-commando/src/extensions/message.js:256:17)
0|index    |     at runMicrotasks (<anonymous>)
0|index    |     at processTicksAndRejections (internal/process/task_queues.js:97:5)```
#

this keeps popping up in the console

pale vessel
#

good job you managed to not show the error

warm maple
#

ugh

#

there's nothing else

#

than that

#

like NOTHING

#

just this

pale vessel
#

commando oof

warm maple
#

yh

pale vessel
#

idk how i can help but look at the stack trace

sudden geyser
#

You sure there's nothing.

#

There would at least be the type of error

warm maple
#

nope

#

thats all

#

nothing else

sudden geyser
#

Okay well I assume the error was logged at /root/bot/events/client/commandError.js:1:15. There's also stuff like /root/bot/index.js:79:3 and /root/bot/node_modules/discord.js-commando/src/extensions/message.js:256:17, so could you show the code in the index file at line 79?

fallow quiver
#
function randColor() {
    red = (Math.floor(Math.random() % 255) + 100).toString(16)
    green = (Math.floor(Math.random() % 255) + 100).toString(16)
    blue = (Math.floor(Math.random() % 255) + 100).toString(16)
    color = `#${red}${green}${blue}`
    console.log(`Made Color ${color}`)
    return color;
}

I made this random color function to generate a random color for my embeds, but it always generates the same color: #646464, does anyone know what is causing that?

quartz kindle
#

Math.random() % 255 is always a number between 0 and 1

#

flooring it makes it return always 0

fallow quiver
#

I guess I did the Math.random() wrong then, I guess my brain was thinking like the rand() function in C++

quartz kindle
#

in js, Math.random() returns a double between 0 and 1

quartz hill
#

Math.floor(Math.random()*255)

fallow quiver
#

Yeah, I guess my brain forgot which language I was using halfway through the thing and I thought JS worked like that

neat ingot
#
'#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6)

is a fun way to generate a color

#
const rand = Math.floor(Math.random()*16777215);
const color = '#'+rand.toString(16);

is another fun way 😛

viral spade
#

Is it a thing to create multiple bots with the same name to better being able to distribute workload?

modest maple
#

wut

#

you mean clustering?

viral spade
#

i mean ensure that when i add new servers/shards, the same guilds stay on the same shard/server

modest maple
#

you cant

#

thats not quite how it works

hollow saddle
#

@fallow quiver Which lib are you using because I know discord.js has a built in random function for embeds. .setColor('RANDOM')

fallow quiver
#

Bro

#

Seriously?

hollow saddle
#

Yeah lol

fallow quiver
#

Well I wasted a bunch of time

#

thanks

hollow saddle
#

Anytime

viral spade
#

Yes you can. if you make xxBot1,xxBot2, .. and log them in on different vps, then the same guilds will stay on the same servers

modest maple
#

Clustering is basically splitting the bot into separate subprocesses, where X amount of shard distributed over X amount of processes (Clusters)

What it is not is making seperate bots and doing that because thats not how it works

viral spade
#

Yes clustering you will ned too

#

of course, so you can have more than 2500 per vps

modest maple
#

no

#

nononononono

#

that is sharding

#

Clustering != sharding

#

they are two very different things

tardy estuary
#

@neat ingot did you steal my code to generate a random color for every message? 😄

#

also afaik theres no reason to convert from decimal to hex into an embed

hollow prawn
#

https://sourceb.in/f0ff80fc3b
I'm using this code, what it should do is:
set the placeholder's color, send a preview of how role color would look, then await reactions for yes/no (green tick/red x) and based on that it will accept the command, create the role with the desired color by the user and add it to the user, when cancelled it will edit the embed saying its cancelled and when on error, it will say time's up
what it does:
changes the placeholder's color, sends the embed message of the preview, adds the first reaction the green tick and almost at the same time as it adds the second reaction the red x it doesn't await for the message reactions by the user and it cancels the command out as if it reads its own reaction the red x and it cancels the command
I'm using relatively the same code for when the role already exists and it works without an issue

dusty onyx
#

i keep getting the error discord.errors.NotFound: 404 Not Found (error code : 10008): Unknown Message and i have 0 clue where it’s coming from 👀💧has anyone heard of a fix for this (python btw)

modest maple
#

yes

#

ignore it

earnest phoenix
#
(node:12) UnhandledPromiseRejectionWarning: Error: This video is not available.
at request (/home/container/node_modules/ytdl-core/lib/info.js:47:25)
at PassThrough.Miniget.stream.on (/home/container/node_modules/miniget/dist/index.js:196:32)
at emitNone (events.js:111:20)
at PassThrough.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)

This error shows up when I try to play a music video

modest maple
#

its basically saying the message is no longer cached so the bot cant see it when it tires to do somthing to it

dusty onyx
#

aight but it keeps spamming my bot with errors

earnest phoenix
#

anyone knows why?

viral spade
#

so i am only talking about different bots and sharding, not about clustering. I am talking about being able to split guilds to separate vps, never changing which server the guild is on. (After a bot has recahed a certain limit of servers, the next bot is created and the next say 100k servers can connect to this one, instead of the last).

modest maple
#

just silence it

dusty onyx
#

oh

#

oki

modest maple
#

@viral spade and i am telling you YOU CANNOT DO THAT

#

which is why i told you

#

you need to cluster

viral spade
#

with cluster i can do that?

modest maple
#

damn this is hard

#

i would suggest it would be a good idea learning how Sharding and Clustering works with deployment

#

because you have a rather large misconception on how it needs to work

viral spade
#

can you link me to an info about this clustering i need for discord?

neat ingot
#

huh ? no lol, i got those samples from github ages ago when i was looking for random colors, thought they were neat 😛

#

@tardy estuary

tardy estuary
#

haha im just messin

#

i said in here a few days ago that I don't see a good use case for the embed colors. it's too small of a sliver to provide a user a good understanding of what it means, so I decided to just make it random

viral spade
#

So i dont understand how i can use a cluster to ensure the same guilds stay on the same vps?

neat ingot
#

lmao

#

i use umm

#

the color of a persons name for embed colors

tardy estuary
#

yeah that might be about it. but i mean their name is already a color so it just seems redundant still (imo)

modest maple
#

@viral spade YOU CANT

tardy estuary
#

but using it for an error color or something is kinda.. not helpful imo

modest maple
#

Clustering is the method of splitting shards into seperate processes

neat ingot
modest maple
#

these processes can potentially be split across machines

neat ingot
#

yea, thats true lol

modest maple
#

but your bot is in 16k guilds its no where near the size to where multi machine scaling is needed

viral spade
#

i am rebuilding it now and i want the next version of it to being able to sustain 1.000.000 servers

#

ideally

#

or just be horzontally scalable

amber fractal
#

At that point, it must have already been horizontally scaled really

#

unless you like wasting resources

viral spade
#

yes so is there a way to scale horizontally in such a way, that each set of guilds has its dedicated vps and local database forever? When a new guild adds the bot, it gts assigned a vps and stays there forever?

quartz kindle
#

no

viral spade
#

aight, thanks

quartz kindle
#

unless you set it to like 500 shards, and never change lol

viral spade
#

wouldnt creating a single bot for each vps work, tim?

modest maple
#

no

#

DONT DO THAT

#

jesus dude

viral spade
#

i am asking in theroy

modest maple
#

split the shards into seperate proccesses

#

and no

#

diffrent bot

#

different account token everything

viral spade
#

dude i am thinking about a way to achieve this "yes so is there a way to scale horizontally in such a way, that each set of guilds has its dedicated vps and local database forever? When a new guild adds the bot, it gts assigned a vps and stays there forever?"

modest maple
#

people rlly need to learn how to scale shit earlier on smh

viral spade
#

and the same time you say i dont need to care about this yet with 16K

quartz kindle
#

you mean having separate bot accounts for each vps?

viral spade
#

ye

modest maple
#

no

#

you shouldnt even need seperate VPSs at 16k guilds

quartz kindle
#

i mean, in theory it could work, but that just sounds like even more work to maintain

amber fractal
#

you cant create a bot account programmatically though can you?

modest maple
#

its just avoiding learning how to properlly scale stuff

#

and no

#

not without getting banned

viral spade
#

you shouldnt even need seperate VPSs at 16k guilds
@modest maple

people rlly need to learn how to scale shit earlier on smh
@modest maple

#

i am doing this

modest maple
#

🤨 Learn about splitting shards up into seperate processes

#

read d.js docs on the sharder

viral spade
#

will it achieve this: "scale horizontally in such a way, that each set of guilds has its dedicated vps and local database forever" ?

modest maple
#

get that idea out of your fucking head

#

that is not how you should scale shit

#

that is not a robust system

#

that is not good

viral spade
#

id call that the perfect scaling, but as tim said, the solution with maintaining different bots sounds like more work

modest maple
#

no its not

#

because what happens if a guild gets sent to the wrong thing

#

what then

#

that vps has fuck all on that guild

#

Your system should be able to scale regardless of being on seperate machines

#

or on the same machine

#

you should start by just not having your bot run on 1 freaking process

viral spade
#

isnt the sharding manager creating 1 process per shard per default?

modest maple
#

NO

tardy estuary
#

theres no reason to be mad at someone for asking questions

modest maple
#

that would be a awful waste of reasources

#

it would help if you read up even a little bit into more depth on how sharding works

#

and why it exists fundamentally

tardy estuary
#

Linck01 is your bot really in 16k guilds already?

viral spade
#

y

tardy estuary
#

i mean, if someones bot was that successful I feel like they would already understand a majority of this

#

but perhaps not

modest maple
#

its not a new bot

quartz kindle
#

@viral spade honestly, if you want to go for database clustering, you should give up on mysql

#

mysql is simply not designed for that, mysql works best as a single-machine mega-database

modest maple
#

idek how the bot got so big considering some of his logic

viral spade
#

i just dont want to redo everything at 100K servers, preferably also not at 500K servers, but only "add new nodes to my cluster" you know^^

modest maple
#

thats litterally what clustering is

quartz kindle
#

with one database and proper caching on all shards, i doubt you will need horizontal scaling on the database side

modest maple
#

Discord makes it so freaking easy to split processes and multi machine bots

#

by that point you should probably just have a online host for the db and let them scale it for you

quartz kindle
knotty steeple
#

cassandra gud

amber fractal
#

or just use mongo shit's easy asf to scale and shard

modest maple
#

no point scaling the db if he cant scale the bot lmao

viral spade
#

the db is the only problem

quartz kindle
#

the thing is that his bot is highly reliant on the database

modest maple
#

should of ditched Mysql before hand then lol

#

or set up a cache db aswell as a buffer

knotty steeple
#

whats he trying to do

modest maple
#

hes at 16k guilds with zero knowledge of how sharding or clustering works

#

that is what is happening

viral spade
#

i mean the bot runs on different vps perfectly right now

knotty steeple
#

odd

viral spade
#

with an in memory local cache of every guild that is on that vps

modest maple
#

i cant, this is too much for me

quartz kindle
#

then get out :^)

viral spade
#

so what database you could recommend me for a stats bot like this?

neat ingot
#

mongodb/mongoose imo

viral spade
#

that works well for scaling and discord and everything

earnest phoenix
#

can i can use brake; in if() ??

#

or i have to use switch and case

sudden geyser
#

switch cases or loops or labels

#

what would you need it for

hollow prawn
#

heyo Tim doggowave

neat ingot
#

why do you need to break an if? just end the if block :/

earnest phoenix
#

i dont want when the code come in if() it will stop, and dont read code anymore

sudden geyser
#

What are you doing to exit it.

#

Using return?

pale vessel
#

it's not even brake

earnest phoenix
#

return;

#

so it will stop ??

knotty steeple
#

dont use return if u dont want it to stop

pale vessel
#

yes but not on forEach loop

earnest phoenix
#

wut

#

i want to stop

pale vessel
#

return won't work on forEach loop

sudden geyser
#

I mean there's else if and such

earnest phoenix
#

oh

amber fractal
#

you cant stop a forEach unless you error it

earnest phoenix
#

yes i only need stop on else if

pale vessel
#

if you intend on using a lot of else if, consider using switches

neat ingot
#

you can continue a foreach i beleive, never used it myself

pale vessel
#

what's the point of that

sudden geyser
#

noop

neat ingot
amber fractal
#

that doesnt work in forEach

earnest phoenix
#

shouldn't this work on mysql nodejs? connection.query("SELECT * FROM timezones").then(data =>{console.log(data)})

pale vessel
#

yeah

earnest phoenix
#

this is better then stackoverflow xD

neat ingot
#

ahh yea just for

#

my bad 😄

amber fractal
#

You cant stop a forEach loop

knotty steeple
#

tf does a continue do

amber fractal
#

not without erroring it

neat ingot
#
for (i = 0; i < 10; i++) {
  if (i === 3) { continue; }
  text += "The number is " + i + "<br>";
}```
pale vessel
#

yes it will work if you have a table called timezones @earnest phoenix

neat ingot
#

skip to next iteration

earnest phoenix
#

i do

pale vessel
#

okay

earnest phoenix
#

but it says it's not a function

hollow prawn
#

@earnest phoenix if you use promise mysql, it should work, if you use default mysql, that's on callback functions, also what it returns is an array

earnest phoenix
#

TypeError: connection.query(...).then is not a function

pale vessel
#

did you define connection

earnest phoenix
#

yes ofc

pale vessel
#

oh

#

i think it's the .then

earnest phoenix
#

let connection = mysql.createConnection({ host: process.env.host, user: process.env.user, password: process.env.pass });

amber fractal
#

it is that

knotty steeple
#

dont think the mysql module works like that

pale vessel
knotty steeple
#

u need a callback..?

amber fractal
#

query doesnt return a promise ^^

knotty steeple
#

u do

amber fractal
#

it takes a callback

pale vessel
#

yes

knotty steeple
#

ew lowercase env variables

earnest phoenix
#

so sql, (data => {}) instead of using a .then

pale vessel
#

yes

amber fractal
#

uh

knotty steeple
#

the first one is the error

pale vessel
#

but (error, results, fields) => {}

hollow prawn
#

no

knotty steeple
#

so no

earnest phoenix
#

did you say there was a version of sql that works with promises instead of callbacks?

knotty steeple
#

u wouldnt get real data

amber fractal
#

.then only works for promises

pale vessel
#

i answer yes to everything

knotty steeple
#

u need a callback function and the first argument is the error if there is any

pale vessel
#

yes mysql2/promise

knotty steeple
#

the second is ur actual data

pale vessel
#

const [rows] = await con.query(fuck)

knotty steeple
#

what does that do

pale vessel
#

same shit

hollow prawn
#

connection.query('database you deal with', (<error>, <rows>, <anything else you need>) => { code in here })
@earnest phoenix this is callback default mysql
if you install and set up promise-mysql, you can use .then

pale vessel
#

same as results

#

that's what i use

earnest phoenix
#

use promise-mysql or mysql2/promise?

pale vessel
#

mysql2/promise is better

knotty steeple
#

mysql2/promise is mysql2 with promises

hollow prawn
#

with what would mysql2/promise be better Thinking2

pale vessel
#

yes

knotty steeple
#

so its just the promise branch that has promises

pale vessel
#

cleaner syntax

hollow prawn
#

compared to promise-mysql

pale vessel
#

oh

#

idk

knotty steeple
#

promise-mysql is a different package

pale vessel
#

i just use whatever works

#

¯_(ツ)_/¯

earnest phoenix
#

is the connection code still the same

pale vessel
#

yes

hollow prawn
#

it is, yes, but it seems to work quite good for me

#

depends, for promise-mysql I had to change some things around

pale vessel
#

both good

#

use whatever you're comfortable with

earnest phoenix
#

does it deal with reconnecting itself?

pale vessel
#

it's not going to connect all the time

#

only when executing statements afaik

earnest phoenix
#

because the reconnecthandler i got from overflow is not working

hollow prawn
#

and make it like this:

(async () => {
  bot.db = await mysql.createConnection({
    host: 'ip',
    user: 'user',
    password: 'pass',
    port: 'port',
    database: 'db',
  });
  console.log('DB Coonected');
})();```
inside my `index.js` file, what I do is I bind the connection to `bot.db` and I have to await it, otherwise it can't do proper query
#

wdym reconnect handler

neat ingot
#

😄

hollow prawn
#

oh ggod, good spot imma fix that

earnest phoenix
#
function handleDisconnect(conn) {
  conn.on('error', function(err) {
    if (!err.fatal) {
      return;
    }

    if (err.code !== 'PROTOCOL_CONNECTION_LOST') {
      throw err;
    }

    console.log('Re-connecting lost connection: ' + err.stack);

    connection = mysql.createConnection(conn.config);
    handleDisconnect(connection);
    connection.connect();
    console.log("reconnected")
  });
}
hollow prawn
earnest phoenix
#

hmm so i can't just connect in the beginning inside bot.on("ready"... ?

hollow prawn
#

oh, when you do reconnects your "ready" event should be ran again

#

you can do the connection in there

#

I do mine outside of my on ready event

#

as I access it in other events as well

#

and I dont use reconnect handler as I have pm2 which so far works good enough for me

earnest phoenix
#

wait is this the lib i was supposed to download?

pale vessel
#

actually

#

it doesn't matter

#

you can even use the original mysql

earnest phoenix
#

i wanted to use promises though

pale vessel
#

you don't necessarily need promises

#

well in that case you can use mysql2

#

and require it as mysql2/promise

earnest phoenix
#

i can't find the npm page for mysql2/promise

#

only the page i linked

pale vessel
#

i sent it

earnest phoenix
#

oh wait

#

i see it now

pale vessel
earnest phoenix
#

i thought it had a separate page

heavy marsh
#

Using discord.js v12, Is there a way to check if a link is a working mp3 url?

winged remnant
#

Will the V11 still be usable after October?

heavy marsh
smoky spire
#

No @winged remnant

winged remnant
#

I have several versions ... @smoky spire

viral spade
#

Tim can you tell me what clustering db you would choose for my bot, and how/where you would host the cluster? Would you take a managed cluster or install in on your own machines? I just saw the mongodb cluster prices for amazon/google/azure on the mongodb website, and they terrify me a bit..

smoky spire
#

@winged remnant ?

winged remnant
#

Let the V11 be deleted.

atomic quarry
#

When the code is ran it just returns "what are you THINKING man ..."
if (
message.content.includes(r1) ||
message.content.includes(r2) ||
message.content.includes(r3)
) {
return message.channel.send("if this message shows up then it detects the correct input");
} else {
return message.channel.send(
"what are you THINKING man that's not a valid option from the list??"
);
}
})

astral yoke
#

hi so if I have this let prefix = config.prefix; how would I make it so you can set a custom prefix with mongodb i already connected it but i dont know what todo

fair oasis
#

hello can any bot developper sms me please and thanks

earnest phoenix
#

Just ask

heavy marsh
#

Is there a way to check if an link matches a following extensions
.png, .gif, .jpg - Basically all the image formates

atomic quarry
#

Is there an easier way to do the message.content.includes?

earnest phoenix
#

just check if it that link ends with these

heavy marsh
#

For all file formates?

#

Is there no other option to do it

earnest phoenix
#

its easy to filter through just the image ones

heavy marsh
#

I mean I am trying to do a stream command using discord.js. So I want to make sure no images linkes are there

#

for example stream blabl.png - Should give an error

quartz kindle
#

@viral spade honestly cant say, i've never used anything other than sql, but if you're up for a little experimenting, take a look at one of those newer ones, like yugabyte and cockroach db, otherwise mongo is known to be easily clusterable, but i would personally go for a vertically scaled remote rdbms and work on efficient caching and transactions, because thats what im most familiar with. if it gets very bad, you can always throw a redis cache in the middle. alternatively if you prefer a fully managed and automatic solution and dont mind paying for it, check out google cloud spanner

heavy marsh
earnest phoenix
#

again, just filter out the image types, thats the only way i know

#

if that link ends with .png, give an error

heavy marsh
#

There is alot of image types that is the reason

quartz kindle
#

what are you trying to do?

heavy marsh
#

A stream command

quartz kindle
#

make a request to it and check the response headers

#

its much easier and better to check if its a valid audio stream, than to check all other possibilities (theres literally thousands of other possibilities)

heavy marsh
#

What do you mean by response headers

quartz kindle
#

when you make an http request, for example using node-fetch or any other http library

#

you can access the response headers

heavy marsh
#

I am confessed 😐

quartz kindle
#

what are you using to play this link?

heavy marsh
#
connection.play(<args[0]>, { volume: 1 });    ```
#
let connection;
    
try {
connection = await VC.join();   
} catch (error) {
console.log(`Error On play.js : ${error}`);
message.channel.send(`![error](https://cdn.discordapp.com/emojis/678624265276358696.webp?size=128 "error") **Error occurred! Please retry the command again or contact support - https://discord.gg/xxx**`);
}
quartz kindle
#

doesnt it throw an error if you play an invalid link?

heavy marsh
#

nope

#

I tried playing a .png and no errors

quartz kindle
#

well then i'd make an http request to it

heavy marsh
#

I have no idea how to, that is why ...

quartz kindle
#

have you ever used a library like node-fetch, request, got, axios, snekfetch?

#

open dev tools in chrome

#

check network tab

heavy marsh
#

I have used request - But with a npm package

#

Ahh I use firfox

quartz kindle
#

then open firefox's dev tools

#

they should also have a network tab

heavy marsh
#

then open firefox's dev tools
Where will it be?

quartz kindle
#

so, you can use an npm package like request to check the content type of the url

heavy marsh
#

nvm found ir

#

it*

astral yoke
#

how would I get an sql server for quick.db

quartz kindle
#

for some reason firefox doesnt show the headers for that page lmao

#

thats why i dont use firefox, full of weird shit

astral yoke
#

chrome is where its at

heavy marsh
#

Nvm I use google crom 👀

#

chrome*

#

And I still cant find the tool

quartz kindle
#

open dev tools, go to network tab, reload the page, click on first connection that appears in the network tab, click headers

heavy marsh
#

OOh DAM

cinder patio
#

Thoughts on Dart? I just stared learning it today and it looks amazing

quartz kindle
#

its used for dart throwing

heavy marsh
#

But how to search a a link?

#

Do ou have to visite that page first?

quartz kindle
#

yes, thats why you have to use a library like request

heavy marsh
#

hmm ok

#

Is there a link to follow for a guild

quartz kindle
#

you can make a HEAD request instead of a GET request, to check only the headers, and not download any content

heavy marsh
#

And what should the header be?

quartz kindle
#

it should contain "Content-Type":"audio/mpeg"

#

or audio/ogg

heavy marsh
#

"audio/mpeg" || "audio/ogg"

#

Linke this

quartz kindle
#

there are a few more

smoky cedar
#
(node:12132) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
user_id: Value "@smoky cedar" is not snowflake.

Anyone knows something about this APIError?

heavy marsh
#

ooh 👀

quartz kindle
#

theres about 5 or 6 audio mime types, although not all types are used by streams

#

you would do something like this: ```js
let audiotypes = ["audio/aac","audio/mpeg","audio/opus",...]
let check = await request(url,{method:"HEAD"})
if(audiotypes.includes(check.headers["Content-Type"])) {
connection.play(url)
}

copper cradle
#

@smoky cedar remove the <@! >

earnest phoenix
#

look whos back back again

heavy marsh
#

@quartz kindle Thank you Tim for the help 🙂

earnest phoenix
#

oh tim i have something for you lol

heavy marsh
#

oofs RIP

earnest phoenix
#

why rip

#

he wont reply to me anyway he dont like me ahahahah

quartz kindle
#

if its something super basic, ill just tell you to go learn javascript

heavy marsh
#

he is yping

#

typing*

#

My spelling oofs

#

One more small question will you tube links be blocked by this? - @quartz kindle
#development message

#

YouTube, Sportify and etc ..

quartz kindle
#

if you give it a youtube link directly, it will not contain an audio type

#

because the audio is in a player on the page, its not a direct link

heavy marsh
#

ooh i see

hollow prawn
#

what do I have to do, to have always embedded images in rich embeds that I get from deleted messages?

heavy marsh
#

?

#

You mean message embeds?

hollow prawn
#
const mFiles = await message.attachments.map(a => a.proxyURL);
if (mFiles.length >= 1) {
        for (const a of mFiles) {
          if (a.toString().includes('.png') || a.toString().includes('.gif') || a.toString().includes('.jpg') || a.toString().includes('.jpeg') || a.toString().includes('.tiff') || a.toString().includes('.tif') || a.toString().includes('.bmp')) {
            const mDelete = new Discord.RichEmbed()
            .setAuthor(message.author.tag, message.author.displayAvatarURL)
            .setDescription(`**Message sent by **${message.author}** was deleted in **${message.channel}\n${message.content}`)
            .setColor('#c4150f')
            .setTimestamp()
            .setImage(a.toString())
            .setFooter(`Author ID: ${message.author.id} & Message ID: ${message.id}`);

            if (!logChannel) { return; } else if (logChannel) { return logChannel.send(mDelete); }
          } else {
            const mDelete = new Discord.RichEmbed()
            .setAuthor(message.author.tag, message.author.displayAvatarURL)
            .setDescription(`**Message sent by **${message.author}** was deleted in **${message.channel}\n${message.content}\n**File format not an image: **${a}`)
            .setColor('#c4150f')
            .setTimestamp()
            .setFooter(`Author ID: ${message.author.id} & Message ID: ${message.id}`);

            if (!logChannel) { return; } else if (logChannel) { return logChannel.send(mDelete); }
          }
        }
      }```
#

didn't expected it to be that big, but anyway for that code I get like 50/50 chance of the image to not be set in the rich embed

#

and it'll just log that a message was deleted

#

so I'm trying to see what do I have to do to have it constantly get the image's links and have them in the embeds

heavy marsh
#

@quartz kindle Just one more questions.
Is it possible to get the name of the stream to?

quartz kindle
#

no

heavy marsh
#

ooh ok

quartz kindle
#

streams are just data, nothing else

#

you'd need to get the name from somewhere else

heavy marsh
#

So it is possible?

quartz kindle
#

like a page about the stream, if it exists

heavy marsh
#

OOh I see

#

Thank you

quartz kindle
#

but thats only for that specific website, all websites are different

#

sometimes you can find some metadata in the header

heavy marsh
#

metadata - ?

quartz kindle
#

for example that stream has this

#

but those fields are not guaranteed to exist

heavy marsh
#

I see

#

but is it always icy-name ?

#

or diffrent?

quartz kindle
#

@hollow prawn if that's from a messageDelete event, i dont think thats possible, as discord deleted the images before your message arrives

#

@heavy marsh it will always depend on the website, broadcasting system used by the website, custom fields set by the owners, etc

heavy marsh
#

OOh ok

hollow prawn
#

it is from messageDelete event, it takes a bit of time until discord deletes the images

#

like 5-10 minutes

#

as I get the proxy URL

quartz kindle
#

well if it works only 50% of the time, clearly not

hollow prawn
#

it's weird, if I spam delete images it works 50/50 time

#

if I do it slower, it always works

cloud nacelle
#

how did u guys do that

hollow prawn
#

and if I do multiple images from phone, then delete them, I get more entries in the mapping

cloud nacelle
#

the colored text with the

#
hi`
hollow prawn
#

but only one gets recorded

#

you set the language

#

for the codeblocks lol

cloud nacelle
#

how to do the colored text

quartz kindle
#

then you're doing something wrong

#

are you using global variables accidentally?

cloud nacelle
#

prob

quartz kindle
#

console.log the urls to see if they are not being duplicated or messed up with

hollow prawn
#

yeah, but I can't figure out what, no global variable, already did, logs the URL links properly without an issue and returns them in an array even if its 1 link

#

that code is run inside an IF statement that checks if the bot has the permissions for sending messages and embedding links

#

and before that I check if there's a logging channel on the database or not

#

even if I use forEach same thing

quartz kindle
#

try console.logging(a) before sending

heavy marsh
#
const request = require('https')```
for this - [#development message](/guild/264445053596991498/channel/272764566411149314/)
hollow prawn
#

alright

quartz kindle
#

you can use the https module, but that module is more complicated to use

copper cradle
#

cOnSoLe.LoGgInG is NoT dEfInEd

#

that's gonna be their next msg

hollow prawn
#

no lmao

copper cradle
#

hmmm

heavy marsh
#

Then what request should I use

quartz kindle
#

if you want something easier, check out got

heavy marsh
#

got - ?

hollow prawn
#

yup, logging a properly without an issue

quartz kindle
#

got is the name of the package, check their npm page

earnest phoenix
#
let HighestAmountOfVotes = -1
let Winners = []
await ParticipantArray.forEach(async Participant => {
        let AllVotingDocsOfParticipant = await VotesSchema.countDocuments({Type: "Vote", UserName: Participant})
        if(HighestAmountOfVotes < AllVotingDocsOfParticipant){
            if(Winners.length == 0){
                HighestAmountOfVotes = AllVotingDocsOfParticipant
                Winners.push(Participant)
            }
            else{
                HighestAmountOfVotes = AllVotingDocsOfParticipant
                Winners = []
                Winners.push(Participant)
            }
        }
        else if(HighestAmountOfVotes == AllVotingDocsOfParticipant){
            Winners.push(Participant)
        }
    })
    let WinnersString = ""
    console.log(Winners) --- Logs an empty array

does anyone one know why it does not await the foreach before moving on?

hollow prawn
#

.forEach isn't fond of await

earnest phoenix
#

how can i fix that

#

or can i not

sterile minnow
#

Does anyone know how to give someone a Role?
i tried this:

            message.author.roles.add(role)
                                 ^

TypeError: Cannot read property 'add' of undefined
hollow prawn
#

using for ( X of Y ) { do magic }

earnest phoenix
#

@sterile minnow whats your version

hollow prawn
#

you're adding a role to a user not guild member

earnest phoenix
#

^

sterile minnow
#

djs 12

hollow prawn
#

users don't have roles

sterile minnow
#

you're adding a role to a user not guild member
@hollow prawn how do i fix it?

hollow prawn
#

by doing message.member

#

i think

earnest phoenix
#

@hollow prawn what would x and y be defined as

quartz kindle
#

@earnest phoenix forEach cannot be awaited

hollow prawn
#

X is your entries of Y array

mental lodge
#

I’m struggling to keep my bot up 24/7

sterile minnow
#

doess not work either

hollow prawn
#

lmao no

#

message.member

#

instead of message.author

#

the rest should be the same

sterile minnow
#

yeah but i have two users

mental lodge
#

Remove add and only add

sterile minnow
hollow prawn
#

wdym you have two users

sterile minnow
#

i have author and member

hollow prawn
#

and to who do you want to add the role?

sterile minnow
#

i want to give them both the role

hollow prawn
#

message.member will give you the author of the message in a member object
message.mentions.members.first() will give you separate member object that's the first mentioned one

quartz kindle
#

there are two different things in discord.js: User and Member
a User contains things like username, profile picture, etc
a Member contains things like nickname, roles, etc...
message.author is the User of who sent the message
message.member is the Member of who sent the message

hollow prawn
#

for it, you do member.roles.add(role)

#

as you have defined it as a member in your code

sterile minnow
#

okay i'll try

#

and how do i remove it?

#

only roles.remove?

hollow prawn
#

you can check the docs for removing, search for GuildMember in v12 and look for it if you're not sure for something
i haven't used v12 so idk for sure, but should be the same as .add

#

instead of .add it should be .remove and again with (<role>)

sterile minnow
#

okie

heavy marsh
#
let streamlink = args[0];

try {
let audiotypes = ["audio/aac","audio/mpeg","audio/opus"]
let check = await got(streamlink,{method:"HEAD"})
if(audiotypes.includes(check.headers["Content-Type"])) {

let connection;
    
try {
connection = await VC.join();   
} catch (error) {
console.log(`Error On play.js : ${error}`);
message.channel.send(`![error](https://cdn.discordapp.com/emojis/678624265276358696.webp?size=128 "error") **Error occurred! Please retry the command again or contact support - https://discord.gg/**`);
}```
quartz kindle
#

console.log(check)

#

also did you check if thats the correct syntax for got?

heavy marsh
quartz kindle
#

alright, console.log it

elder moss
#

How to link a discord to a Game and do like a verification thing?

#

discord bot

quartz kindle
#

@heavy marsh it appears the content-type is lower case

hollow prawn
#

I'm thinking maybe the issue comes from the "if" statement

heavy marsh
#

Let me re test

hollow prawn
#

is there a way I can reduce it without chaining multiple else if?

heavy marsh
earnest phoenix
#

@heavy marsh may I dm you?

heavy marsh
#

About what exactly?

earnest phoenix
#

That command actually 😂
I was wanting to do something similar for my bot but for some reason everytime i try it crashes

so i was gonna see if youd wanna trade your code so i can learn

heavy marsh
#

Tim already told how to do it

earnest phoenix
#

ah ty

white anvil
#

supply Discord iOS as an identify property to the gateway

#

not possible on most libs

earnest phoenix
#

Bruh why no android

white anvil
#

what lib

#

what lib

pale vessel
#

that's language

white anvil
#

js is a language not a library

earnest phoenix
#

THATS A LANGUAGE

white anvil
#

the library you use to communicate with discord

pale vessel
#

you ask me

white anvil
#

discord.js? eris?

pale vessel
#

yes

white anvil
#

I don’t think it’s possible with either of those actually

pale vessel
#

it is

white anvil
#

is it

pale vessel
#

you can supply ws options on both

white anvil
#

well idk the syntax

earnest phoenix
#

Just edit the source it will work

pale vessel
#

too much work

earnest phoenix
#

Basically you go to node_modules to discord.js

pale vessel
#

not recommended

white anvil
#

$identifyProperties: { $browser: 'Discord iOS' }

earnest phoenix
#

Well fork the github then smh

white anvil
#

lol the fact that you have to fork to do it means that it isn’t supported

#

..just saying

pale vessel
#

it's supported in djs

white anvil
#

you’ll probably run into problems in the future if you fork the lib

earnest phoenix
#

Nah theres a thing called maintaining

white anvil
#

yeah but you don’t get that maintenance if you run on a fork

earnest phoenix
#

You do bruh

#

You maintain it yourself or via a github bot mmLol

white anvil
#

or just run on base repo and don’t fork packages you use

earnest phoenix
#

Or dont be lazy and control your packages instead of letting them be controlled mmLol

white anvil
#

don’t know about you but trying to maintain forked packages is probably a pain

#

and a waste of time

#

it’s not lazy it’s just pointless, if you want something to be added you open an issue

earnest phoenix
#

Not really, its just a search for important bug fixes in commit history

#

:D

white anvil
#

or a pull request

earnest phoenix
#

Useless prs get denied anyways

white anvil
#

if you’re forking for a useless feature then wtf are you doing lol

earnest phoenix
#

Im forking because im not going to move to these managers lol

#

But the versions after managers has bug fixes

#

And no ones gonna accept PR stuff for an old version lmao

white anvil
#

eventually ur old version will just become obsolete

earnest phoenix
#

Not if you maintain it mmLol

pale vessel
#

pain in the ass

earnest phoenix
#

I have enough javascript knowledge and github knowledge to maintain it until november

white anvil
#

yea literally

quartz kindle
#

discord.js v11 community edition

white anvil
#

i wanna work on the code I wrote not some else’s lol

pale vessel
#

lmao

white anvil
#

which is what that maintenance is doing

earnest phoenix
#

I'd rather maintain for months by cloni g commits into my fork rather than update my entire bots core with all its other npm packages because these damn devs thought adding .cache to everything was a good idea

white anvil
#

scrolling though commit history to find patches I should make to my fork based on my assumption of how important it is doesnt sound like a good long term model

pale vessel
#

managers are good

quartz kindle
#

didnt eris start as a discord.js fork?

white anvil
#

probably lol

grizzled raven
earnest phoenix
#

@white anvil "how important" yeah no

grizzled raven
#

create a discord.js fork with optional caching

white anvil
#

you’re the one that said that you’d patch in ‘important’ bug fixes ¯_(ツ)_/¯

earnest phoenix
#

I just update everything which has bugs, which is basically every commit nowadays

quartz kindle
#

i mean, the only thing you have to do to keep v11 running is supporting intents and changing the domain name

earnest phoenix
#

Yes important as in guild.available never turning false causing a massive fake event spams is pretty important

smoky spire
#

@grizzled raven you don't have to use caching lol

earnest phoenix
#

@quartz kindle no i run v12.0.0-dev

#

Right before managers were introduced

quartz kindle
#

oh you're gonna fork v12 pre-caches?

earnest phoenix
#

No after-caches and import them without the cache changes

#

Lol

quartz kindle
#

lmao

#

i have a bot on that version

#

i need to update it but i dont feel like it

white anvil
#

what is all this shit about .cache anyway

grizzled raven
#

managers

#

it makes more sense

earnest phoenix
#

Im only gonna update when i get my bots 50k lined code in its core and npm packages fixed for this managers bullshit

white anvil
#

i don’t follow the bloatville that is djs

#

lol

#

did they just make collection have shit like limits and expiration

quartz kindle
#

it makes sense, and its good for the library, but v12 has been in development for years, so people started porting their bots to v12 while it was still in development, then they introduced the managers change and fucked over hundreds of developers who have been using the v12 version lmao

earnest phoenix
#

Yup

#

Thats where i started maintaining my own fork lmao

white anvil
#

yeah the lib I use has that, with a .cache property

smoky spire
#

You can manage ur memory urself jacher

earnest phoenix
#

I cba to look through like 100k lines of code to fix this shit

white anvil
#

but all the methods you get on Map also exist on the Collection class it has

quartz kindle
#

it was a big breaking change, which is normal because the lib was in development still, but everyone was using it as if it was stable because its been in dev for years

white anvil
#

which means you never need to reference the .cache property

#

don’t see why djs wouldn’t introduce that

earnest phoenix
#

Yeah but then still lmao

quartz kindle
#

you do, all the collection methods were moved to a .cache property

grizzled raven
#

did they just make collection have stuff like limits and expiration
@white anvil two different classes, LimitedCollection and Collection

earnest phoenix
#

Why didnt they add it like a year earlier

white anvil
#

they should exist on the base object not .cache wtf

#

that’s dumb

quartz kindle
#

they dont exist on base anymore in v12

white anvil
#

big brain devs

earnest phoenix
#

message.guild.members.cache.get

#

Like christ

smoky spire
#

It was easier to maintain the backend with managers

white anvil
#

yeah with the lib I uses you can just do .members.get

#

even though the actual cache itself is .cache

#

pretty neat

quartz kindle
#

the reasoning is that the cache property handles all sync operations, while the parent class handles all async operations and rest methods, in order not to have them mixed up in the same class

earnest phoenix
#

They shouldve done it in v11 tbh

grizzled raven
#

what difference would it make

white anvil
#

what rest methods even exist on those caches

grizzled raven
#

fetch

quartz kindle
#

rest methods dont exist on the cache

grizzled raven
#

on all managers

white anvil
#

well I mean

#

the collection then

#

the base object whatever

quartz kindle
#

.fetch for example

white anvil
#

oh

grizzled raven
#

and add on some managers

#

like roles.add(roleID)

earnest phoenix
white anvil
#

yeah i just don’t use that stuff

#

I have a rest client

#

that I use for basically all my rest operations

quartz kindle
#

you're using a custom lib?

white anvil
#

it’s not custom but it’s very obscure

#

and the rest client is standalone

earnest phoenix
#

Is there a way to refer .cache back to its collection but keeping .cache a thing

quartz kindle
#

thats basically what im gonna do as well lol

earnest phoenix
white anvil
#

it covers 100% of the api

#

it’s pretty neat

quartz kindle
#

whats its name?

white anvil
#

detritus

#

sec

quartz kindle
#

@earnest phoenix you can extend the classes and add getters

white anvil
earnest phoenix
#

Which classes though

white anvil
earnest phoenix
#

Like i want to update, but keep the normal methods, do i just get getters insode my fork or where

#

Since i dont want my npm packages to break bcz some depend on the old cache methods

white anvil
#

so you just want to have all the regular Map properties available in the base object

#

?

earnest phoenix
#

Yes

white anvil
#

uhh

#

lemme find the source for the collection my lib uses

#

that implements that

earnest phoenix
#

But im talking about having both tho

white anvil
#

yeah this has both

earnest phoenix
#

.cache for all discord.js shit that changed and the base ones for everything outside discord.js

white anvil
#

if I understand what u mean

earnest phoenix
#

Typescript god damnit

#

Idk why but i hate looking at it

white anvil
#

yup 😃

quartz kindle
#

same lmao

#

very interesting lib tho, i might steal some things from it

white anvil
#

the rest client is like 3000 lines

#

there are so many functions lol

earnest phoenix
#

Oh christ where do i even have to look at lmao

#

Like the functions or wut xd

white anvil
#

it has getter methods for stuff like get, has, set

earnest phoenix
#

I dont rlly get "getters" how are they defined

#

Like the functions or actual "get"

white anvil
#

they’re just properties that fetch a value dynamically from somewhere else

#

get thing() { return 'thing' }

#

MyClass.thing

earnest phoenix
#

Wait get on a clear/delete wouldnt work would it

white anvil
#

wdym

stiff canyon
#

Any Script Program?

earnest phoenix
#

Deleting via the base, "get" on delete wouldnt work?

#

I suppose managers introduced members.cache.delete while removing members.delete?

white anvil
#

probably?

#

you can implement your own .delete

earnest phoenix
#

Hmmm..

white anvil
#

via getter

earnest phoenix
#

Ill just compare the files that changed soon i guess

white anvil
#

or just function

#

doesn’t have to be getter

#

getter is just fancy function

earnest phoenix
#

With my knowledge (and a 9 for javascript in school) i should probably find out how to