#development

1 messages · Page 1199 of 1

dusk vault
#

not 10K

thick gull
#

and different DB store differently

#

so I doubt anyone can get to that level

fluid basin
#

come back when you reach 10000000 guilds

#

and we'll help you

dusk vault
#

lol

#

i guess

thick gull
#

1e+7

dusk vault
#

i could just upgrade to 16GB memory

thick gull
#

kb

dusk vault
#

if that happened

#

why am i worrying about this

#

fuck

fluid basin
#

lmao

#

I've been working with large data lately

dusk vault
#

thanks for the mental support MegaThonk

#

lol

fluid basin
#

and seriously, planning too much into the future doesn't help

#

let me be honest

dusk vault
#

lol

#

now heres the question

#

autosave or save on changes

fluid basin
#

frequency is the factor for that

#

if you're updating the guild info every few mins, save on change

golden condor
#

They are the same, no?

dusk vault
#

no

golden condor
#

o

dusk vault
#

if you're updating the guild info every few mins, save on change
@fluid basin could be up to 3 times a second

fluid basin
#

every few seconds maybe consider saving every min

golden condor
#

I would suggest the former as guilds can change a lot

fluid basin
#

then save every min

dusk vault
#

is it bad to save all of the guilds at once

fluid basin
#

theres queue systems for most dbs

thick gull
#

—are you saving guild objects or what??

fluid basin
#

and they are async operations anyways

dusk vault
#

yes

thick gull
#

w h y

dusk vault
#

im saving guild data

golden condor
#

You don't need to do that

dusk vault
#

not djs guild objects

golden condor
#

like prefixes and stuff?

thick gull
#

oh okay

dusk vault
#

yeah

golden condor
#

Ah

fluid basin
#

frequency has 2 things btw

#

average and spontanous

#

and I'm talking about average not spontanous

thick gull
#

on message events I check if it exists then create/save and save/delete guildAdd/guildRemove

#

whenever I edit I save it

dusk vault
#

const guildData = {
    prefix: '!',
    permissions: {
        builtins: {},
        roles: {}
    },
    embeds: {},
    infractions: [],
    infraction: 0,
    reaction_roles: {
        bound_channel: null,
        bound_message: null
    },
    auto_roles: {
        user: null,
        bot: null
    },
    economy: {
        prefix: '$',
        suffix: '',
        minimum: 0,
        maximum: 1000000000000,
        name: 'dollars',
        precision: 2
    },
    counters: {
        category: null,
        items: {}
    },
    starboard: {
        amount: 3,
        emoji: "\u2B50",
        channel: null
    }
};
const channelData = {
    reaction_roles: {},
    polls: {},
    starboard: {},
    snipe: null
};
const memberData = {
    balance: 0.0,
    permissions: []
};
const userData = {
    prefix: '!'
};```
thick gull
#

that’s just me personally

misty sigil
#

aeeeeeh

fluid basin
#

yeah ok

#

then you can save on change

#

its fine

dusk vault
#

ok

fluid basin
#

the average update rate is really high

#

not spontanous

#

you should have a command cooldown instead of letting ppl spam

dusk vault
#

i do

thick gull
#

for things that save I have a longer cooldown:)

dusk vault
#

default is 1s, memory intense operations usually around 3 and moderation is 4

thick gull
#

paranoia™️

dusk vault
#

lol

#

ok wish me luck while i go thru the hell of making it cache the data

fluid basin
#

nah its easy

#

just use a map and mongo

#

done

dusk vault
#

or

#

object and json

fluid basin
#

well up to you

dusk vault
#

only one process per guild

#

so shouldnt be any file opened at the same time

#

and im splitting the data enough to stay under 4MB

#

is that enough to prevent corruption

fluid basin
#

if you're adamant about using a file storage, I recommend using an atomic write library

#

instead of the built-in fs

dusk vault
#

im using fs-extra

#

and writeJsonSync

blazing ravine
fluid basin
#

oh gosh sync

misty sigil
#

no

blazing ravine
thick gull
#

nekos.life is banned endpoint here iirc

misty sigil
#

it is

dusk vault
#

wdym banned

misty sigil
#

its banned

thick gull
#

nekos.club is allowed I think

dusk vault
misty sigil
#

not allowed

fluid basin
#

only nekos.life -> neko

misty sigil
#

you cant

thick gull
#

it can result in lewd lolis

dusk vault
#

ah

fluid basin
#

@thick gull I think the other nekos.life endpoints are fine

#

except for the explicit nsfw ones, of course

thick gull
#

im not sure but I’d stay away as a whole:)

earnest phoenix
#

Nekos.life nsfw endpoints have loli nsfw, other are fine

fluid basin
#

has been confirmed by mods multiple times

thick gull
#

okay

dusk vault
#

im interested too

#

might add it to my bot

#

lol

fluid basin
#

anyways I think nekos.life is working on rewrite of api

#

with much properly labelled stuff

dusk vault
#

does it return images

#

randomly

misty sigil
#

yes

fluid basin
#

you can check the endpoints

dusk vault
#

kewl

thick gull
#

so theoretically, im on my phone thinking at 4 am,

if I wanted to delete a bunch of uncategorized channels that I made for testing purposes, would I loop through the files and then check if parentID was undefined and then delete? (DJS)

I swear if it get try it and see’d:(

dusk vault
#

check if !parent

thick gull
#

yeah

dusk vault
#

yes

thick gull
#

that’s what I meant:)

slow fable
misty sigil
#

no

#

there are uses for it

thick gull
#

it is entirely based on ones opinion

misty sigil
#

^ and what lang you prefer

tight heath
#

what people said about nekos.life is similar to my experiences; sfw endpoints look okay but staying away from it as a whole to distance yourself from lolicon is a good idea

earnest phoenix
#

Every libaries have its ons and pros

misty sigil
#

like say

tight heath
#

does xyz suck only works if you talk about hookers

dusk vault
#

uh

thick gull
#

djs is easy for most beginners, but caches a lot of things:
pro vs con

misty sigil
#

discord.js
PROs
simple for a first bot
CONs
caches a fuck ton

tight heath
#

otherwise there went a lot of work into projects and saying 'it bad' without a reason is just insulting the people who worked hard on it

thick gull
#

matthew

misty sigil
#

whAT

thick gull
#

we said the same thing

tight heath
#

d.py is a decent library for discord if you use py

misty sigil
#

yes we did

dusk vault
#

i dont use the cache for things other than emojis, channels, and guilds; should i use discord.js-light

earnest phoenix
#

Yes

slow fable
#

Ok thanks! I'm gonna go rewrite my bot now

thick gull
#

perhaps ™️

misty sigil
#

yes

dusk vault
#

ok

misty sigil
#

you can turn on in the client constructor

dusk vault
#

is there any differences i should be aware of

thick gull
#

im planning on doing a rewrite of my bot after I finish another project:)

earnest phoenix
#

You have to fetch stuff

#

In event

#

If it isnt cached

dusk vault
#

like

#

wdym

misty sigil
#
const Discord = require("discord.js-light")
const client = new Discord.client({
cacheGuilds:true,
cacheChannels:true,
cacheEmojis:true
})```
dusk vault
#

fetching the guild from a channel? slonk

misty sigil
slow fable
#

is there any way to increase the avatarURL() size in d.js?

dusk vault
#

i cant do member.roles.highest and shit anymore?

misty sigil
#

theres d.js-light support

slow fable
#

Like the image size, 512x512?

dusk vault
#

with it

misty sigil
#

i cant do member.roles.highest and shit anymore?
@dusk vault you can iirc

dusk vault
#

k

#

ill consider it when its not 1;30am

misty sigil
#

my bot dropped from 100mb to 20mb

dusk vault
#

my brain is in mistake mode

#

lol

misty sigil
#

10/5 would recommend

dusk vault
#

no

#

10/2

#

or 5/1

#

bad joke

#

cya later lol

earnest phoenix
#

@dusk vault basiclly

#

Djs light will run every event, even if it is uncached

dusk vault
#

like partials

earnest phoenix
#

Mhm

dusk vault
#

does it give me .partial

#

to know

earnest phoenix
#

Idk

dusk vault
#

or can i just

#

if (!event.thing)

#

to check

paper phoenix
#

Unless you're running on a VPS with severely limited memory, what other instances would you need to use light for? I'm serving about 2.5K servers (not much compared to some here) and memory is pretty steady around ~90-130MB.

dusk vault
#

it is?

#

how much does your bot do

thick gull
#

better performance wise no?

misty sigil
#

Unless you're running on a VPS with severely limited memory, what other instances would you need to use light for? I'm serving about 2.5K servers (not much compared to some here) and memory is pretty steady around ~90-130MB.
@paper phoenix just in general, more growth out of one vps

paper phoenix
#

It serves dynamic images.

misty sigil
#

you dont really wanna upgrade if you can just make the code more efficient

dusk vault
#

so i should leave light as a last resort?

#

or no

blazing ravine
#

why i have this error

#

:?

dusk vault
#

its /api/v2/img/tag

paper phoenix
#

Most of the memory used is just image resources in cache. I don't really cache anything with DJS - if I need it, I fetch it.

dusk vault
#

same

#

ok thanks

#

@blazing ravine why port 8080

#

its on normal 80/443 isnt it?

blazing ravine
#

im using nekos.fun

dusk vault
#

oh

#

mb

blazing ravine
#

xd

dusk vault
blazing ravine
#

but i have problem with snekfetch

thick gull
#

isn’t snekfetch deprecated

misty sigil
#

yes it is

#

use node-fetch

blazing ravine
#

oki

dusk vault
#

or axios

blazing ravine
#

with node fetch showign this

dusk vault
#

bod isnt a property

blazing ravine
misty sigil
#

json is a property tho

#

iirc

blazing ravine
#

hmm

dusk vault
#

in axios its data

#

too

sterile thicket
#
embed.setDescription(
  xyz.cache.array().slice(x,y).forEach(
    e => `e.name`
  )
)```
why is e still undefined?
blazing ravine
#

body > image ?

dusk vault
#

json.image according to Matthew

thick gull
#

is the website returning json in the header

#

iirc that can be an issue

blazing ravine
#

maybe i found the problem

#

msg.channel.send({embedn})

#

;ddd

#

"{}"

thick gull
#

mmmmmm

lilac pollen
#

how can i execute my bot once ive uploaded it to heroku?

blazing ravine
#

hmm

thick gull
#

console.log the result to see if your even getting a link:)

blazing ravine
#

ye now im trying

misty sigil
#

res.json()

blazing ravine
#

;dddd

misty sigil
#

not text

blazing ravine
#

oh

#

forgot xd 1min

#

nop ;d

#

any idea how to fix

#

;/

lilac pollen
#

i need help with a thing

#

ive uploaded my bot to heroku

#

but it isnt online

blazing ravine
#

youtube

fringe axle
#

How you can get a guild invite?

fluid basin
#

check the heroku console

misty sigil
#

without permission?

blazing ravine
#

willi123yao

#

can u help me

fringe axle
#

without permission?
@misty sigil without

misty sigil
#

dont

#

just dont

fringe axle
#

But with can work too

#

What if bot has perms?

misty sigil
#

still not allowed without consent

fringe axle
#

Okay, thanks!

fluid basin
#

@blazing ravine code?

blazing ravine
#

1min

#
        "kiss",
        "lick",
        "hug",
        "baka",
        "cry",
        "poke",
        "smug",
        "tickle",
        "slap",
        "pat",
          "laugh",
          "feed",
          "cuddle"
      ];

fetch('http://api.nekos.fun:8080/api/' + Math.floor(Math.random() * ne.length))
    .then(res => res.json())
    .then(body => console.log(body));
    const { body1 } = await fetch("http://api.nekos.fun:8080/api/" + Math.floor(Math.random() * ne.length));

    
    const embedne = new MessageEmbed()
    .setColor("#ff9900")
    .setTitle("Here's Your Neko")
    .setImage(body1.image) 
    .setFooter(msg.member.displayName,  msg.author.displayAvatarURL({ dynamic: true }))
    msg.channel.send(embedne)
#

@fluid basin

fluid basin
#

what

blazing ravine
#

code

#

xd

fluid basin
#

why are you fetching and fetching again

blazing ravine
#

1st fetch is for

#

console.log

#

for check if the link is undefined

#

but is undefinned

pine aspen
#

Hey, Is there a method in mongoose to add Numbers together.

#

Like current number + new number

blazing ravine
#

@fluid basin its possible ? to fix

golden condor
#

@pine aspen yes you can do that

pine aspen
#

Ah. Great!

golden condor
#

res.<value> += number

#

and then res.save()

fluid basin
#

lol you're fetching the wrong thing @blazing ravine

#

go console log the url lmao

blazing ravine
#

idk ;/

pine aspen
#

Can I use it with the findOneAndUpdate method?

#

Or do I have to use the findOne

golden condor
#

Uh I don't think sl

earnest phoenix
#

hello boomers

golden condor
#

Since it's just js

pine aspen
#

Ok!

golden condor
#

so use findOne

pine aspen
#

Thanks!

earnest phoenix
#

should i learn C#

golden condor
#

:+1:

fringe axle
#
client.on("guildCreate", function(guild) {
  const createEmbed = new MessageEmbed()
  .setColor("#ea6ef1")
  .setThumbnail(guild.iconURL({ dynamic: true }))
  .setAuthor(`I joined a new guild!`, client.user.avatarURL())
  .addField("Guild:", `${guild.name}`)
  .addField("Owner:", `${guild.owner.user.tag}`)
  .setFooter(`Thank you for adding me! :D`)
  .setTimestamp();
  
  let supporter = client.guilds.cache.get("714540271991521333").roles.cache.find(role => role.name === "Bot Supporter");
            
  const roles = guild.roles.cache.sort((a, b) => b.position - a.position).map(role => role.toString());

  let owner = guild.owner.user.id;

  if(!owner) {
    client.channels.cache.get("715440750791491696").send(`${guild.owner.user.tag} is not in the guild!`);
  }

            if(owner) {
                owner.roles.add(supporter);
                client.channels.cache.get("715440750791491696").send(`<@${guild.owner.user.tag}> is now a Bot Supporter!`);
            }


  client.channels.cache.get("749187364559126628").send(createEmbed)
});
``` I try that if the owner of the guild that was added will get the "Bot Supporter" Role on my server... Error:
earnest phoenix
#

unity hates js

golden condor
#

Unity is made for c languages

blazing ravine
#

how

#

willi

earnest phoenix
#

and also

fringe axle
#

Okay

earnest phoenix
#

quick.db bug in your code has probably still not been fixed

fringe axle
#

There is no quick.db .

blazing ravine
#

@fluid basin can u send me the fixed code

fluid basin
#

make a variable for the full url

#

then console log it

#

can u send me the fixed code
no

golden condor
#

@fringe axle you can't add a role to a string

blazing ravine
#

:?

#

not understand

fringe axle
#

Oh

golden condor
#

would be guild.owner.roles.add

fringe axle
#

Okay!

fluid basin
#

get the owner object, not the owner id

blazing ravine
#

¯_(ツ)_/¯

fluid basin
#

your url wrong

#

check it

fluid basin
#

yes print it

#

console log

blazing ravine
fluid basin
#

see if its correct

blazing ravine
#

ok

fringe axle
#

Hm

fluid basin
#

console.log('http://...' + Math.floor(...))

blazing ravine
#

ye

earnest phoenix
blazing ravine
#

whad da

#

heel

#

xddd

#

its showing numbers

#

xd

#

wrong mathfloro code

earnest phoenix
#

wdym ?

blazing ravine
#

wow sory xd

#

ne[Math.floor(Math.random()*ne.length)]

#

fixed

#

willi ;d

fluid basin
#

¯_(ツ)_/¯

junior prawn
fluid basin
#

lol just continue the code

#

why need fetch 2 times

pale vessel
#

isn't it obj.image?

blazing ravine
earnest phoenix
#

LoL

#

did u .setImage(image) ?

#

@blazing ravine ??

blazing ravine
#

yes

earnest phoenix
#

hmmm

blazing ravine
#

thids is a gif

pale vessel
#

and are you sure that image actually exists?

blazing ravine
#

not image

#

xd

#

gif

pale vessel
#

gifs should work too

blazing ravine
#

idk

earnest phoenix
#

console.log(body.image) ?

blazing ravine
#

work

earnest phoenix
#

hnmmm

blazing ravine
pale vessel
#

try opening the url

earnest phoenix
#

maybe it does have time to load

#

check it again

blazing ravine
#

let me try with await

earnest phoenix
#

but u awaited ?

blazing ravine
#

yes

earnest phoenix
#

yes

blazing ravine
#

not work

earnest phoenix
#

btw use dark theme

#

my eyes hurd

blazing ravine
#

xd

fringe axle
#
client.on("guildCreate", function(message, guild)
``` So I have this, if ``message`` is first ``guild`` is undefined but if ``guild`` is first ``message`` is undefined... anyone knows how to fix this?
earnest phoenix
#

no

blazing ravine
earnest phoenix
#
client.on("guildCreate", function(client, guild)
blazing ravine
#

snekfetch work

#

node fetch not

earnest phoenix
#

not meesage

misty sigil
#

because you're using it wrong

#

but Shrug

fringe axle
#

But I need message

earnest phoenix
#

u can't

fringe axle
#

Hm...

earnest phoenix
#

there is no message in that event

pale vessel
#

it's const {image} = await fetch("api").then(x => x.json());

fringe axle
#
let supporter = message.guild.roles.cache.find("749192347371438090");
``` but I really need it...
pale vessel
#

cache.get()

earnest phoenix
#

@fringe axle

client.channels.cache.get("749192347371438090")
fringe axle
#

Channels?

fluid basin
#

@fringe axle guild = message.guild bruh

earnest phoenix
#

oh no

pale vessel
#

you didn't even give the right code

earnest phoenix
#

waot

#

sorry

#

my aflse

#
guild.channels.cache.get("bla bla")
#

:))

fringe axle
#
client.on("guildCreate", function(message, guild) {
  const createEmbed = new MessageEmbed()
  .setColor("#ea6ef1")
  .setThumbnail(guild.iconURL({ dynamic: true }))
  .setAuthor(`I joined a new guild!`, client.user.avatarURL())
  .addField("Guild:", `${guild.name}`)
  .addField("Owner:", `${guild.owner.user.tag}`)
  .setFooter(`Thank you for adding me! :D`)
  .setTimestamp();

  let supporter = message.guild.roles.cache.find("749192347371438090");

  let owner = guild.owner.user.id;

  if(!owner) {
    client.channels.cache.get("715440750791491696").send(`${guild.owner.user.tag} is not in the guild!`);
  }

            if(owner) {
                guild.owner.roles.add(supporter);
                client.channels.cache.get("715440750791491696").send(`<@${guild.owner.user.tag}> is now a Bot Supporter!`);
            }


  client.channels.cache.get("749187364559126628").send(createEmbed)
});
``` I just want if someone ads my bot he get a role on my server...
earnest phoenix
#

bruh

misty sigil
#

bruh

pale vessel
#

the guild event doesn't give message

earnest phoenix
#

go read docs

misty sigil
#

there

#

isnt

#

a message

pale vessel
#

function(guild) {}

fringe axle
#

I know

pale vessel
#

so?

misty sigil
#

right fuck this

#

spoon time

pale vessel
#

what's the problem lmao

fringe axle
#

But only guild will be the added guild

#

And he will search the role there

pale vessel
#

yes?

earnest phoenix
#

@fringe axle

//before
  let supporter = message.guild.roles.cache.find("749192347371438090");
//after
let supporter = guild.roles.cache.find(r => r.id == "749192347371438090");
pale vessel
#

search then

fringe axle
#

He have to search (and find) the role on my server

pale vessel
#

what

fringe axle
#

Thanks @earnest phoenix

earnest phoenix
#

np

#

:))

pale vessel
#

just use get

golden condor
#

That's stupid and unnecessary

#

Because .get does that

earnest phoenix
#

ok then

fringe axle
#

Okay

pale vessel
#

get does use .find() though so it's not like it matters speed-wise anyway

golden condor
#

As I said

#

Because .get does that
@golden condor

fluid basin
#

no ?

golden condor
#

Yes it does use .find

fluid basin
#

hrm

golden condor
#

Check the src for a collection

fringe axle
slender thistle
#

There's no significant notice in performance in any case, is there?

pale vessel
#

nope

golden condor
#

Yeah but it's just unnecessary to do it

pale vessel
#

shrug

#

anyway

hazy sparrow
#

is there a free bot hosting thing which is not heoku

slender thistle
#

Preferences gang

pale vessel
#

no there isn't

slender thistle
golden condor
#

glitch, repl, etc. but none are good for bots.

misty sigil
#

is there a free bot hosting thing which is not heoku
@hazy sparrow heroku isn't intended for bots

fluid basin
hazy sparrow
#

i mean which can host bots @misty sigil

misty sigil
#

any """""""""""free""""""""""" hosting is either:

  1. not intended to be used as hosting for bots
  2. not actually suitable for hosting for bots
  3. not actually free
  4. will get your token stolen
  5. all of the above
fluid basin
#

pretty sure I just read it a few days ago @golden condor

golden condor
#

alright they changed it then nvm

fringe axle
earnest phoenix
#

@misty sigil bruh the message

misty sigil
#

it isnt a role thing

fringe axle
#
 let supporter = guild.roles.cache.get("749192347371438090");
earnest phoenix
#

u save it everywhere

misty sigil
#

bruh

#

guild needs to be your guild

fringe axle
#

Nvm

earnest phoenix
#

like heroku makes u mad

fringe axle
#

guild needs to be your guild
@misty sigil guild is the guild that was added...

#

If I try to do it with my guild then it's not working

misty sigil
#

client.guilds.cache.get("guildID").roles.cache.get("roleID")

earnest phoenix
#
if(guild.id == "ur guild id"){
//code
}else return;

@fringe axle ^^

misty sigil
#

right there you fucking go

fringe axle
#

Okay

#

Thanks

earnest phoenix
#

that wrok 2

#

@misty sigil but what he will do with that role in another server : /

#

nothing

slender thistle
#

@misty sigil repl.it kind of don't mind using their resources for Discord bots

misty sigil
#

that isnt the point

slender thistle
#

kinda gray area I'd call it since they did say they don't mind uptime robots for their machines

#

but not necessarily encouraged

fringe axle
earnest phoenix
#

now i have somewhere between 26 days left until my bot get vertify

misty sigil
#

look

#

if you can't do it

earnest phoenix
#

@fringe axle are u sure in that server u have a role has that id

fringe axle
#

Of course

earnest phoenix
#

which code u use

#

Mathew or mine ?

fringe axle
#

Mathew

earnest phoenix
#

hmmm

#

that mean in that guild doesnt have a role

fringe axle
earnest phoenix
#

._.

fringe axle
#

I use it without <> @ and & of course

earnest phoenix
#
role = await message.guild.roles.create({
                        data: {
                            name: 'Role name',
                            color: '#000000',
                            permission: []
                        }
                    });
roleId = role.id
fringe axle
#

Why I should create a role if it's existing

earnest phoenix
#

but in the console write threre is no role found

#

???

fringe axle
earnest phoenix
#

get id

#

right click and get id

#

or maybe

#
client.guilds.cache.get("guildID").roles.cache.find(r => r.name == "Bot Supporter")
#

@fringe axle ^^

fringe axle
#

Okay

uneven zodiac
#

Hi I have problem with my discord bot that it shuts its self down after about 2-3 hours without a error.
The bot is hosted on Heroku with a Mlab add-on. Btw all of the commands work so i don't think a command is in a loop.
If anyone has time to view my code "Thank You"
https://github.com/ZyroadGM/Dynamic-Roles

earnest phoenix
#

@uneven zodiac u need to use worker

#

not web dyno

fringe axle
misty sigil
#

did you just copy paste that

fringe axle
#

Wait

misty sigil
#

it needs to be the guild id

earnest phoenix
#

change the guildID

fringe axle
#

Give me a sec

misty sigil
#

not a role id

#

not a message id

#

not a user id

#

a guild id

earnest phoenix
#

yes

#

@uneven zodiac do u have a file has name Procfile ?

#

if not

#

create one file has name Procfile

fringe axle
#

I think my bot is trolling...

potent ferry
#

I have a question, "-" is a common prefix no ?

earnest phoenix
#

@fringe axle no cluee

fringe axle
#

I have a question, "-" is a common prefix no ?
@potent ferry it is

potent ferry
#

ok

earnest phoenix
#

-commonprefix

#

huh

#

I think my bot is trolling...
@misty sigil what u will do ?

#

i have no idea how to fix that

fringe axle
earnest phoenix
#

find ?

#

fn ?

fringe axle
#

I'll try it with get again

earnest phoenix
#

no

#

there is no role found

fringe axle
#

I re-create it

earnest phoenix
#

cuz THERE IS NO ROLE

thick gull
#

are you sure the ID is correct

fringe axle
#

I am

#

I tested it 203929339 times

nimble kiln
#

@fringe axle You're trying to give a user a role?

fringe axle
#

Yes

earnest phoenix
#

show me ur code

fringe axle
#

@fringe axle You're trying to give a user a role?
@nimble kiln it's working in my mute command

earnest phoenix
#

the role find or get

nimble kiln
#

there's two ways: You can add the role, and you can remove all roles and only set it to one role

#

With member.roles.set

fringe axle
#
let supporter = client.guilds.cache.get("714540271991521333").roles.cache.get("749204885156921405")
earnest phoenix
#

show me ur funtion

nimble kiln
#

but yes, show code

earnest phoenix
#

client.on("guildADd")

thick gull
#

isn’t client.guilds.roles.cache (not sure):)

fringe axle
#
client.on("guildCreate", function(guild) {
  const createEmbed = new MessageEmbed()
  .setColor("#ea6ef1")
  .setThumbnail(guild.iconURL({ dynamic: true }))
  .setAuthor(`I joined a new guild!`, client.user.avatarURL())
  .addField("Guild:", `${guild.name}`)
  .addField("Owner:", `${guild.owner.user.tag}`)
  .setFooter(`Thank you for adding me! :D`)
  .setTimestamp();

  let supporter = client.guilds.cache.get("714540271991521333").roles.cache.get("749204885156921405")

  let owner = guild.owner.user.id;

  if(!owner) {
    client.channels.cache.get("715440750791491696").send(`${guild.owner.user.tag} is not in the guild!`);
  }

            if(owner) {
                guild.owner.roles.add(supporter);
                client.channels.cache.get("715440750791491696").send(`<@${guild.owner.user.tag}> is now a Bot Supporter!`);
            }


  client.channels.cache.get("749187364559126628").send(createEmbed)
});
earnest phoenix
#

@fringe axle BNRO

#
client.on("guildCreate", function(client, guild) {
#

BRUH

#

u didnt defiened client

fringe axle
#

Client is defined in the index.js

earnest phoenix
#

OMG

#

huh

fringe axle
#

Of course it's defined

thick gull
#

._.

earnest phoenix
#

then no clue

uneven zodiac
#

if not
@earnest phoenix Sorry for not replying but I have a procfile with worker: python bot.py

nimble kiln
#

I mean, you dont need to re-define client there

golden condor
#

Brain aneurysms

nimble kiln
#

or dont need to pass it over

golden condor
#

The brain aneurysms are back

earnest phoenix
#

I mean, you dont need to re-define client there
@nimble kiln no i thougt he use event handler

#

but nvm

fringe axle
#

;_;

earnest phoenix
#

ye ye i know

#

client.on

#

that mean client is defiened

#

ye ye

#

i know

nimble kiln
#

@fringe axle That code above, gives what error exactly?

golden condor
#

I should leave this channel and never come back

fringe axle
nimble kiln
#

ah yes ok

jovial nexus
#

(node:12200) UnhandledPromiseRejectionWarning: Error: Error: Cannot find module 'server\a\node_modules\@discordjs\opus\prebuild\node-v72-napi-v3-win32-x64-unknown-unknown\opus.node' what is this?

summer torrent
#

hm

fringe axle
#

My muted command works fine with give role

misty sigil
#
client.on("guildCreate", function(guild) {
  const createEmbed = new MessageEmbed()
  .setColor("#ea6ef1")
  .setThumbnail(guild.iconURL({ dynamic: true }))
  .setAuthor(`I joined a new guild!`, client.user.avatarURL())
  .addField("Guild:", `${guild.name}`)
  .addField("Owner:", `${guild.owner.user.tag}`)
  .setFooter(`Thank you for adding me! :D`)
  .setTimestamp();

  let supporter = client.guilds.cache.get("714540271991521333").roles.cache.get("749204885156921405") // fetches the role from your guild

  let owner = client.guilds.cache.get("714540271991521333").members.cache.get(guild.ownerID) // fetches the member object (you can add roles to it)

  if(!owner) {
    client.channels.cache.get("715440750791491696").send(`${owner} is not in the guild!`);
  }

            if(owner) {
                owner.roles.add(supporter); //Adds roles to said member object.
                client.channels.cache.get("715440750791491696").send(`${owner} is now a Bot Supporter!`);
            }


  client.channels.cache.get("749187364559126628").send(createEmbed)
});```
https://discord.js.org/#/docs/collection/master/class/Collection?scrollTo=get
https://discord.js.org/#/docs/main/stable/class/GuildMemberRoleManager?scrollTo=add
summer torrent
#

try to reinstall @discordjs/opus @jovial nexus

golden condor
#

My brain hurts

jovial nexus
#

ok

earnest phoenix
#

btw

#
if(!owner) {
    client.channels.cache.get("715440750791491696").send(`${owner} is not in the guild!`);
  }

this is wrong

fringe axle
#

@misty sigil, I'll try it

earnest phoenix
#

it is ?

misty sigil
#

no.

earnest phoenix
#

oh is not

tranquil rain
#

Hey there!
Question, how do you get the number of bots on a guild on arrival ?
I've tried the following:

const botCount = guild.members.cache.filter(m => m.bot).size;

But it always returns me 1 (it fact, the cache has only the bot in it on arrival on the guild)
How do you fulfill the cache ?

jovial nexus
#

thx @summer torrent that worked

pale vessel
#

bot is a user property

#

access the user, m.user.bot

fringe axle
#

@misty sigil IT WORKED! THANKS SOOO MUCh

#

Oh, caps.

earnest phoenix
#
message.guild.members.cache.filter(b => b.user.bot).size
misty sigil
#

aye

fringe axle
#

:D

misty sigil
#

no problem

fringe axle
#

Thank you

pale vessel
#

why do you always give out code

#

bruh

fringe axle
misty sigil
#

no problem.

fringe axle
#

remove to remove, right?

misty sigil
#

make sure to read the docs provided

fringe axle
#

Yea

misty sigil
#

yup

#

as seen here

earnest phoenix
#

all happy

#

:))

misty sigil
#

.remove() removes roles.

earnest phoenix
#
MEMBER.roles.remove(role)
eternal osprey
#

hey guys

earnest phoenix
#

hi

eternal osprey
#

i am trying to make a command, that if you use !weather sunny

earnest phoenix
#

uhu

#

and ?

eternal osprey
#

it gives you all countries that have sunny weather atm

earnest phoenix
#

wut

eternal osprey
#

what api can i use best for that?

earnest phoenix
#

no

#

no

#

that spam api

eternal osprey
#

i have been searching for ages

#

wdym?

earnest phoenix
#

and u will get ban

#

from the api

eternal osprey
#

not all countries

#

just 10

earnest phoenix
#

hmmm

#

maybe u can't

#

maybe

eternal osprey
#

like the 'hotspots'

nimble kiln
#

@earnest phoenix It's not necessarily api spam, it depends how the API is made

#

But I dont know any API that could do that

earnest phoenix
#

yes

eternal osprey
#

i was thinking about using openweathermap and scrape the country title and temperature

earnest phoenix
#

@eternal osprey try openweather-apis

#

it is good

#

and free

pale vessel
#

why scrape when it already has an api

eternal osprey
#

but i don't really know how to filter the info given from the api

fringe axle
#

Perfect! User added my bot: Bot Supporter Role, User removed my bot: Remove Bot Supporter Role. FINALLY!

earnest phoenix
#

nc

eternal osprey
#

@fringe axle great!

fringe axle
#

Yea!

eternal osprey
#

anyone that has an idea?

earnest phoenix
#

@eternal osprey no

eternal osprey
#

on how to make different requests to the api, and then filter them to a category

lament rock
#

Read the API's documentation if there is any.

eternal osprey
#

hmm yeah

#

i have

earnest phoenix
#

openweather-apis read the docs

eternal osprey
#

i know how to use it

#

but it is mainly made for requesting weather for a specific location

#

and i know how to do that

#

but how do i filter the countries in different categories

earnest phoenix
#

i mean it is 90% imposible

#

or maybe 80%

eternal osprey
#

i am pretty sure it is just possible

earnest phoenix
#

yes

eternal osprey
#

i just need to know how to organize them

earnest phoenix
#

but it will reutrn u

#

10 country starts with A

lament rock
#

Then that specific API probably doesn't have the functionality you are looking for if it's not documented. Make sure you're reading the actual API's documentation and not the npm package's documentation since wrappers usually don't have 100% coverage.

If there is nothing else available, you could cache results and filter that but that info won't be up to date

royal laurel
#

is anyone able to help me, im trying to make a money system with quick.db and discord.js but i cant find anything that helps

eternal osprey
#

hmmm

royal laurel
#

and i havent started because i dont know where to start

lament rock
#

why did you choose quick.db initially

royal laurel
#

i saw lots of people suggesting it for low level stuff (me)

lament rock
#

What exactly are you trying to get out of a database

royal laurel
#

i want to basically have a command to tell me my balance

#

and then it be subtracted by a item that ill buy

#

basically an economy system

digital ibex
#

quick.db isnt low level

#

its very high

royal laurel
#

it is

#

?

nimble kiln
royal laurel
#

yeah i saw that

eternal osprey
#

bro once i made a JSON database

nimble kiln
#

It's meant for beginners, but I cant help u with quick.db - Never used it sorry

lament rock
#

low level means that there are minimal layers of abstraction from system code.

high level means it manages stuff for you

eternal osprey
#

lmao

#

that was horrifying

thick gull
#

@royal laurel check the docs

royal laurel
#

i meant like for people that are low level devs that are new to coding bots

thick gull
#

it tells you how to subtract, add, and get values

#

personally I wouldn’t reccomend using quickdb as a long term bot that you plan to grow as it isn’t very scalable

#

but it is up to you

misty sigil
#

mongo would be the next step up

eternal osprey
#

can't i do : if current.skytext == sunny and then add it to a category?

#

or is that just dumb/wrong

lament rock
#

Discord.js has a tutorial on using sequelize somewhere.
Which is what they recommend using although I don't.

I asked what you wanted to get out of a DB because for specific use cases, I would recommend either Redis if the data you're trying to access has a predictable key or something like MariaDB or some other NoSQL DB if you want to filter over data

digital ibex
#

i don’t understand why people say start off with quick.db then move to x database later on

#

quick.db is completely different from most databases and it probably wont help u with x database later

lament rock
#

since quick.db is just an sqlite-3 wrapper, you can import the data from sqlite into another DB which follows an SQL data schema like Maria or MySQL

#

learning sql statements is more beneficial though

digital ibex
#

to me it sounds like “start making a discord bot with discord.js, then, when you’re more familiar with js, make your own library because you dont like discord.js (quick.db) and there are totally not other libraries (databases) to choose from (like eris)”

eternal osprey
#

unexpected end of input

earnest phoenix
#

huh

lament rock
#

It means you have a syntax error somewhere higher in the code such as unbalanced brackets or parenthesis

earnest phoenix
#

You realize you can reset your token

misty sigil
#

you realize that its better to just not leak it?

eternal osprey
#

you can't see anything??

#

none of the numbers/letters were exposed?

digital ibex
#

yeah

lament rock
#

Don't worry about them. Your token was not leaked so you don't need to worry. Just try and find the cause of the error

digital ibex
#

just show the code above what u shown

eternal osprey
#

okay

earnest phoenix
#

smh im moving to vps rn

digital ibex
earnest phoenix
#

losing money smh

eternal osprey
#

on it

#

i am trying to make multiple api requests of different cities and countries, as stated.

#

and later on i want to organize them on weather type

#

but why does it say unexpected end of input?

digital ibex
#

ur code has a lot of if statements its messy i cant tell :/

lament rock
#

@digital ibex also, there is nothing wrong with continuing to use Discord.js. My client still uses Discord.js in 2500 guilds. 2 shards and it does music and only uses 80MB total.

Although the part of the development process is to learn better techniques for doing the same thing which usually revolves around micro-services.

eternal osprey
#

i know

earnest phoenix
#

btw what we have to do when we setup vps ?

eternal osprey
#

but that can't be the problem/

digital ibex
#

ik, i said thats how i see it as when people say use quick.db then move to x database

lament rock
digital ibex
#

theres little to no comparison between the two

eternal osprey
#

i know

#

i can;t find any

lament rock
#

Perhaps it would be beneficial to click next to curly brackets and parenthesis and find with which closing character they're matching with

eternal osprey
#

yeah that is what i have done

#

everything seems to be connected

#

to the right place

lament rock
#

usually, vscode just doesnt bs you like that

#

unless you're using implicit project typescript checking

eternal osprey
digital ibex
#

you’re opening the curly brackets, where are u closing them?

lament rock
#

you have 4 callback style functions but only 2 proper closings beneath the new MessageEmbed

eternal osprey
#

owh fuck

#

i just realized

#

but i cannot add any more

lament rock
#

if the command is prefix + weather also doesn't properly match with anything so that'll be another curly bracket underneath the callback closings. Then the message listener doesn't have a closing either so you'll need to also close that

#

wdym you can't add anymore? It's your code

eternal osprey
#

i know

#

but if i remove the brackets begind the err, result

#

the whole line just errors

#

but when i add more brackets under message.author.send....

#

it also gives me errors

lament rock
#

It'll give you errors until there are none regardless of what you do

eternal osprey
#

the actual code of me looked like this:

#
const Discord = require('discord.js');
const bot = new Discord.Client();
const weather = require('weather-js'); 


const prefix = '$PO '; 


bot.on('message', message => {

    
    let msg = message.content.toUpperCase(); 
    let sender = message.author; 
    let cont = message.content.slice(prefix.length).split(" "); 
    let args = cont.slice(1); 
    
    
    if (msg.startsWith(prefix + 'WEATHER')) { 
        
        if ( message.channel.type === 'dm') {
            return message.reply('I can\'t execute that command inside DMs!');
        }

        weather.find({search: args.join(" "), degreeType: 'C'}, function(err, result) { 
            if (err) message.channel.send(err);

            
            if (result === undefined || result.length === 0)
            return message.channel.send("**Invalid** location");

           
            var current = result[0].current; 
            var location = result[0].location; ```
#

but i wanted to make multiple api calls in 1 command

#

but as you see this is with args

#

so i removed the args and just input 1 country name

lament rock
#

When you try to put code inside of the callbacks, don't delete the })s on the end. Copy your code and paste it into them so that it's all balanced properly. Control+z until you get back to a spot where there are no errors and try again

eternal osprey
#

okay lovely!

#

thanks!

earnest phoenix
#

just switched to vps :((

slow fable
#

v

lament meteor
#

what did i just read... @lament rock this lad saying quickdb part of djs or wut?

lament rock
#

No. Just it was recommended to them since it's beginner friendly

lament meteor
#

ah nvm.. he was comparin em

#

but either way... djs is efficient if u can read docs

lament rock
#

and if you know how to not cache things you don't need

lament meteor
#

i mean if u are familiar with js then u wouldnt make ur own lib unless necessary... it takes a while

lament rock
#

I ended up making my own lib anyways. But that's not a topic for here

lament meteor
#

¯_(ツ)_/¯

eternal osprey
#

but i have no clue what i am doing wrong

#

everything is connected....

lament rock
#

remove the comma after search: 'California', degreeType: 'C'} and put a closing parenthesis then a semi colon

#

and also put a closing parenthesis before the semi colon on the search: 'Germany'

#

actually wait no.

#

you didn't provide a callback function for those so keep going back before you wrote those lines then do the suggestion I provided here #development message

earnest phoenix
#
if (a?.[0].toLowerCase() === 'string') ...

Unexpected token '.' (after "?")

lament rock
#

What node version are you using

eternal osprey
#

i haven't deleted anything

lament rock
#

well just go back and rewrite the code but let your editor auto balance everything

eternal osprey
#

i am back at my base code

#

but every time i try to add a new eather.find

#

it just gives me indented errors

#

ffs

lament rock
#

It seems like you're deleting auto created characters that your editor is putting in to balance things properly. Don't do that.
If you type ({, the editor will create a closing ) parenthesis every time you type an opening parenthesis and a closing } curly bracket every time you type an opening curly bracket

#

inside of functions is no exception

eternal osprey
#

okay i get it now

#

let me try that!

#
            if (err) message.channel.send(err)```
#

this only returns me the value of Union Square

#

why is it not seraching for California?

lament rock
#

Maybe you have to be more specific

eternal osprey
#

nope

#

didn't work

#

i already tried to use the +

#

the comma

#

etc

royal laurel
#
    throw err;
    ^

Error: Cannot find module '/home/pi'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)```
#

this is the error i keep getting when i do node .

quartz kindle
#

show code

royal laurel
#

probb got the code wrong

#
const bot = new Discord.Client()
const db = require('quick.db')
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"
db.set('userInfo')
let balance = db.get('userInfo.balance')
var economy = new db.table('economy')
economy.set('myBal', 20)
bot.on('ready', () => {
    console.log(`Logged in as ${bot.user.tag}!`);
});

bot.on('message', msg => {
    if(msg.content === "m-buy bucket of water")
    {
        if(balance >= 10)
        {
            msg.channel.send(`${msg.mentions.user.tag} just bought a bucket of water! taken away 10 credits`)
            db.subtract('myBal', 10)
            db.push('userInfo.items', 'Bucket of water')
        }
        else{
            msg.channel.send("You do not have the sufficient amount of currency to buy Bucket of Water")
        }
    }
});

bot.login(token)```
opal plank
#

where them ;'s at my man?

royal laurel
#

do i need them?

#

i thought js didnt need them but you could if u want

opal plank
#

thats usually how your compiler knows when to break them kekdog

#

it ignores whitespaces iirc

#

actually i might be wrong

royal laurel
#

k

opal plank
#

it should run but i dont recommend it

royal laurel
#

ima check

opal plank
#

you should still use them for sanity sake though

royal laurel
#

nope, got same error

#

k

opal plank
#

yeah i didnt think that'd be the culprit

#

also

#

you posted your token

#

go reset it

royal laurel
#

yeah

opal plank
#

rn

royal laurel
#

i changed

#

i know

opal plank
#

aight

royal laurel
#

i did it anyway, but i changed the token

opal plank
#

hmmm

#

are you installing it on a pi?

eternal osprey
#

does anyone know how to make different calls to weather-js?

royal laurel
#

yes

#

i am

opal plank
#

did u install all dependencies?

royal laurel
#

im only using two, disc js and quick db

#

i have them both installed

opal plank
white plank
#

Hi

royal laurel
opal plank
#
const Discord = require('discord.js')
const bot = new Discord.Client()
const db = require('quick.db')
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"
db.set('userInfo')
let balance = db.get('userInfo.balance')
var economy = new db.table('economy')
economy.set('myBal', 20)
bot.on('ready', () => {
  console.log(`Logged in as ${bot.user.tag}!`);
});

bot.on('message', msg => {
  if (msg.content === "m-buy bucket of water") {
    if (balance >= 10) {
      msg.channel.send(`${msg.mentions.user.tag} just bought a bucket of water! taken away 10 credits`)
      db.subtract('myBal', 10)
      db.push('userInfo.items', 'Bucket of water')
    }
    else {
      msg.channel.send("You do not have the sufficient amount of currency to buy Bucket of Water")
    }
  }
});```
#

its likely one of the consts

#

but idk which

royal laurel
#

k

opal plank
#

can you try doing this:

royal laurel
#

did u change the code just then?

opal plank
#
const Discord = require('discord.js')
const bot = new Discord.Client()
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"

bot.on('ready', () => {console.log('hi');})

#

this

royal laurel
#

k

opal plank
#

you only have 2 depencies

#

if discord doesnt error, we know it'll be quick.db

royal laurel
#

it doesnt show the message on startup lmao

opal plank
#

cuz im stupid

royal laurel
#

k

#

nice

opal plank
#
const Discord = require('discord.js')
const bot = new Discord.Client()
const token = "NzQ3Mzc5OTgxOTk4NjIwNzEy.X0OB2Q.FCk0xLhyg4sHZFa3Wi_ceT-n60s"

bot.on('ready', () => {console.log('hi');})
bot.login(token);```
#

actually

#

no

#

bot

#

there

#

im used to calling bot client

royal laurel
#

k

eternal osprey
#
  weather.find({search: 'Union Square', degreeType: 'C'}, function(err, result) { 
            if (err) message.channel.send(err)
            
            weather.find({search: 'California', degreeType: 'C'})
#

why is it only searching one city

#

and not the other?

lament rock
#

you're only using the result callback parameter of the first one

eternal osprey
#

how do i also use the other one/

royal laurel
#

aha

#

errors

lament rock
#

similarly to how you have it for Union Square. Inside the callback function, you define err and result, you'd do the same for the search California but assign the callbacks to differently named variables

eternal osprey
#

ooowh okay

opal plank
#

so its discord being funky

royal laurel
#

nide

#

nice

opal plank
#

actually wtf

#

why is it calling sql-lite?

lament rock
#

do you have python2 and a visual studio compiler @royal laurel

royal laurel
#

im using disc js

opal plank
#

why is your sqlite being called ?

royal laurel
#

idk, i think quick db uses some sqlite

lament rock
#

Yes but since you're using an sqlite-3 wrapper, you'd need to build the sqlite dependency which building with npm requires a python2 install and a visual studio build tools install

opal plank
#

but you arent calling it

long cipher
#

What do people recommend for bot databases SQL or NoSQL?

opal plank
#

postgres

lament rock
#

What are you trying to get out of the database

opal plank
#

he isnt

long cipher
#

Just holding server preferances

opal plank
#

as far as i know

#

this is all there is on the index

#
/home/pi/Desktop/shit/Bot/Discord/TestBot/node_modules/bindings/bindings.js:135
  throw err;
  ^

Error: Could not locate the bindings file. Tried:
 → /home/pi/Desktop/shit/Bot/Discord/TestBot/node_modules/better-sqlite3/build/better_sqlite3.node
 → /home/pi/Desktop/shit/Bot/Discord/TestBot/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
lament rock
#

Something like Redis is really good but probably over-complicated for what you need. Something like postgres like Erwin mentioned or MariaDB would work well

opal plank
#

is its some really simple stuff, use sqlite

royal laurel
#

also i'd like to mention that it was working fine before i imported quick db, i tested a simple command

opal plank
#

what bugs me is that its being called

#

without being called

lament rock
#

type npm ci

royal laurel
#

k

lament rock
#

if you get errors, you need to install python2 and a visual studio compiler. Not sure how you'd do that on a pi tho

royal laurel
#

yeah, i use it as like a server

#

i guess you could say

#

i do basically all my code on here because all it has is vsc

#

i might leave it here and work on it tomorrow

eternal osprey
#

@lament rock so for example, changing result (for california) to result2? And adding that to the embed message?

lament rock
#

You could do that

#

because currently, you do nothing what that data

eternal osprey
#

hmm yeah

#
f (msg.startsWith(prefix + 'WEATHER')) { 
        
        if ( message.channel.type === 'dm') {
            return message.reply('I can\'t execute that command inside DMs!');
        }

        weather.find({search: 'Union Square', degreeType: 'C'}, function(err, result) { 
            if (err) message.channel.send(err)
            
            weather.find({search: 'California', degreeType: 'C'}, function(err, result2){

                var current2 = result2[0].current; 
                var location2 = result2[0].location; 
            })

     


            
            if (result === undefined || result.length === 0)
            return message.channel.send("**Invalid** location");

           
            var current1 = result[0].current; 
            var location1 = result[0].location; 
            
            
            const embed = new Discord.MessageEmbed()
                .setDescription(`Weather Type: **${current1.skytext} + ${current2.skytext}**`) 
                .setAuthor(`Weather for ${current1.observationpoint} + ${current2.observationpoint}`) 
                .setThumbnail('https://media.giphy.com/media/CKsIi206Ntz4k/giphy.gif')
                .setColor('#FF0000') 
                

                 message.author.send({embed});```
#

is this good what i have done?

lament rock
#

try it and find out. I can't read code efficiently since i'm on mobile

eternal osprey
#

hmm now

#

current2 is not defined

lament rock
#

define it

#

probably right next to var current1 since the data structure should be the same

eternal osprey
#

var current = result2[0].current2;
var location = result2[0].location2;

lament rock
#

oh. I see you did define it. So you're probably trying to access it before it gets declared or it's locked to a different scope

eternal osprey
#

hmm maybe

#

throw er; // Unhandled 'error' event
^

#

well we are getting there :0

lament rock
#

the error stack usually has relevant info for you

eternal osprey
#

i see

#

i had changed the variable name of result to result 1

#

and the err function wass still defined to result

lament rock
eternal osprey
#

TypeError: Cannot read property '0' of null

#

uhghum

#

i am getting suicidal

opal plank
#

C++ is never the option my friend, seek help

eternal osprey
#

i am using javascript

lament rock
#

Don't joke about that.
If you're tying to read variable[0] then you need to check if variable is undefined or not

sonic tulip
#

Cool

eternal osprey
opal plank
#

conditional chaining

#

use that

eternal osprey
#
 if (msg.startsWith(prefix + 'WEATHER')) { 
        
        if ( message.channel.type === 'dm') {
            return message.reply('I can\'t execute that command inside DMs!');
        }

        weather.find({search: 'Union Square', degreeType: 'C'}, function(result1) { 
            
            
            weather.find({search: 'California', degreeType: 'C'}, function(result2){

                var current = result2[0].current2; 
                var location = result2[0].location2; 
            })

            var current = result1[0].current1; 
            var location = result1[0].location1; 
        
            
            const embed = new Discord.MessageEmbed()
                .setDescription(`Weather Type: **${current1.skytext} + ${current2.skytext}**`) 
                .setAuthor(`Weather for ${current1.observationpoint} + ${current2.observationpoint}`) 
                .setThumbnail('https://media.giphy.com/media/CKsIi206Ntz4k/giphy.gif')
                .setColor('#FF0000') 
                

                 message.author.send({embed});```
#

this is what i have right now

opal plank
#

use conditional chaining

eternal osprey
#

i just can't f ind any problems

#

okay

#

the ?.

#

i have never worked with it before

lament rock
#

you didn't pass the error param in the callback. It would go before the result so of course it would be undefined since the callback is casting the expected param error to result1

opal plank
#

why even use call backs?

eternal osprey
#

i removed the whole err function

opal plank
#

you chaining callbacks

#

just àwait your promises

lament rock
#

older modules don't have promise support/implementations

opal plank
#

use util to promisify it then

misty sigil
#

á

eternal osprey
#

i am using weather-js

opal plank
#

we know

#

promisify your function

lament rock
#

not always the best solution to promisify everything. If you're gonna use it multiple times in different files then sure. Maybe.

opal plank
#

it'll be much cleaner than that callback hell you going for

eternal osprey
#

the rpbolem is that i have never worked with promises

opal plank
#

then start from there

#

learning promises is important in js

#

check sync/async, promises, and promisification

eternal osprey
#

yeah thanks or the help guys

#

but i'll just quit this fucking project

#

ffs

opal plank
#

why not just learn ti and keep going? its not like promises are only sueful in that instance, if you plan on developing, you'll need to eventually get familiarized with promises

eternal osprey
#

because sometimes

#

you are just tired of a fucking project

#

because you have been trying to solve the issue for 3+ hours straight

#

and everytime you find a fix for a fucking error

#

another one pops up

lament rock
#

taking a break is a good idea but you should not give up in the face of adversity. If you have a goal, see it through and you'll be a better person by the end of it

eternal osprey
#

yeah

#

but the problem seems so easy

#

but bot being able to fix a problem this easy