#development

1 messages · Page 1232 of 1

earnest phoenix
#

ok ill try it out

near veldt
#

ok

#

i have a json file and i think other json files are configured in the same format

#

(reason being why i said "i think" a lot as if i dunno bcuz if i was wrong, i woudnt wanna look dumb 😂. humans make human mistakes)

earnest phoenix
#

lol its fine

near veldt
#

ight

#

did u get it fixed?

gentle talon
hazy sparrow
#
const cooldownAmount = (command.cooldown || 3) * 1000;

#

^ should the last bit of numbers be in miliseconds?

bright musk
#

How to make bot plz tell plz

gentle talon
#

....

misty sigil
#

How to make bot plz tell plz
@bright musk code it

gentle talon
#

^

#

^ should the last bit of numbers be in miliseconds?
@hazy sparrow i think so

hazy sparrow
#

ty

#

@bright musk just code it

#

@hazy sparrow like i said learn how to code before trying to make a bot
@earnest phoenix dud i 100% understand the code written there but i have no idea where to put it

earnest phoenix
#

smh

rigid maple
#

When I get votes for my bot I want him to send a message

earnest phoenix
#

@earnest phoenix do you know how to program stuff

#

no im new to all this

#

well it would be a terrible idea to start developing bots rn

hazy sparrow
#

^

earnest phoenix
#

you need to be experienced as hell to make good bots

bright musk
#

Help to make a bot

steady anchor
#

can i check if a server is on top.gg?
and can I check who has voted on top.gg?

forest drift
#

Im trying to make it so when my bot clears messages it replies then deletes that reply 5sec later

message.channel.bulkDelete(argument2);
                        .then(async (deleted) => { 
                            newamountdel = `${deleted.size`;
    let response = await message.channel.send({embed: clearsuccess});
    reponse.delete({ timeout: 5000 }) 
    let response2 = await message.reply("ping");
    response2.delete({ timeout:500 })
    client.channels.cache.get('732708641039319101').send({embed: clearsuccesslog});
  })

Im currently getting the error
SyntaxError: Unexpected token '.' (refering to the '.'then(.....)
How would I go about fixing this?

cinder patio
#

You have to remove the semicolon

forest drift
#

which one?

#

oh wait nvm

#

lemme try that

#

ah ok thanks, now it works

earnest phoenix
#

guys i made my bot!! thanks a lot @earnest phoenix @near veldt

hazy sparrow
#

what is .toFixed() and how does it work? js btw

near veldt
#

anytime kid

forest drift
#

and now I'm getting a different error ;-;

#

is there something thats meant to come after a .then?

vale garden
#

hi

near veldt
#

@hazy sparrow from my understanding, .toFixed is made to turn a number into a fixed point notation. it's like rounding. for example,
var num = 5.56789;
var n = num.toFixed(2);
That would turn 5.56789 into 5.57 because the whole number or something to 5.56789 is 5.57

vale garden
#
case 'attack':
      if (talkedRecently.has(`a${message.guild.id}-${message.author.id}`)) {
            message.reply("Bro you need to rest, you can attack in 45 mins");

    } else {bot.commands.get('attack').execute(message, args);

        talkedRecently.add(`a${message.guild.id}-${message.author.id}`);

        setTimeout(() => {
          talkedRecently.delete(`a${message.guild.id}-${message.author.id}`);
        }, 86400000);
    }
      break;
#

i use this for my cooldown btw

#

and this is my command;s file

hazy sparrow
#

@hazy sparrow from my understanding, .toFixed is made to turn a number into a fixed point notation. it's like rounding. for example,
var num = 5.56789;
var n = num.toFixed(2);
That would turn 5.56789 into 5.7 because the whole number or something to 5.56789 is 5.57
@near veldt thank you so much!

near veldt
#

i meant 5.57 lol

#

but yw

vale garden
#
let guild = db.get(`guild_${message.guild.id}_${message.author.id}`)
    let inv = db.has(`inv_${message.guild.id}_${message.author.id}`, "hammer")
    let amount = Math.ceil(Math.random() * 600)
    let amount2 = Math.ceil(Math.random() * 11)

    if (guild === "Warrior") {      

      if (inv){

        if (amount2 === 5) {

        let embed = new Discord.MessageEmbed()
            .setColor("GREEN")
            .setTitle(`**Raid Loot**`)
            .setDescription(`You pillaged a nearby town with your hammer and looted \`${amount}\` coins.`)
            .setFooter("You can only use the command again in 2700 seconds or 45 Minutes")
            message.channel.send(embed)   

            message.reply("You also found a shiny coin, worth 200 regular coins!")
            db.add(`money_${message.guild.id}_${message.author.id}`, amount+200)


        }

        else {

          let embed = new Discord.MessageEmbed()
            .setColor("GREEN")
            .setTitle(`**Raid Loot**`)
            .setDescription(`You pillaged a nearby town with your hammer and looted \`${amount}\` coins.`)
            .setFooter("You can only use the command again in 2700 seconds or 45 Minutes")
            message.channel.send(embed)

            db.add(`money_${message.guild.id}_${message.author.id}`, amount)

        }

      }

      else {
        message.channel.send("Lol you aren't eligible to attack. You need to first buy a hammer from the shop for 50 coins, by doing `t!buy hammer`")
        talkedRecently.delete(`a${message.guild.id}-${message.author.id}`);
      }

    }

    else {
      message.reply("Only players under the `Warrior` guild can go on attack raids\nYou can change your guild however using `t!guild <guild_name>`")
      talkedRecently.delete(`a${message.guild.id}-${message.author.id}`);
}
near veldt
#

jeez

vale garden
#

lol

#

the thing is

near veldt
#

i dont use db

vale garden
#

i cant delete the timer from here

near veldt
#

i use mongoose

vale garden
#

db isnt the focus here

#

that doesnt matter

near veldt
#

oh, ok

vale garden
#

i just need to know if i can

near veldt
#

whats the matter then

vale garden
#

delete the timer from here

#

like see when i do t!attack

#

and like i didnt mention an arg

#

it tells me to do that

#

but due to the cooldown

#

i can only do it after 45 mins

forest drift
#

what would cause a "SyntaxError: Unexpected end of input"? I know it has something to do with the .then function I've just added as it was working before.

vale garden
#

so like i need to know if there is a way thru which i can disable the cooldown for that stuff

#

or delete the timer

#

which i tried doing but it didnt work

hazy sparrow
forest drift
#

-___-

near veldt
#

"}" isnt supposed to be there bow

hazy sparrow
#

yea i know, but wheres the extra }

forest drift
#

please tell me ur joking

#

i need to keep my sanity

near veldt
#

line 14

#

index

hazy sparrow
#

ok thanks

#

wait whart

#

ok nvm

#

ty

near veldt
#

yeah ,_,

vale garden
#

lol

forest drift
#
2020-09-11T07:44:06.998787+00:00 app[worker.1]: SyntaxError: Unexpected end of input
2020-09-11T07:44:06.998788+00:00 app[worker.1]:     at wrapSafe (internal/modules/cjs/loader.js:1053:16)
2020-09-11T07:44:06.998788+00:00 app[worker.1]:     at Module._compile (internal/modules/cjs/loader.js:1101:27)
2020-09-11T07:44:06.998796+00:00 app[worker.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-09-11T07:44:06.998796+00:00 app[worker.1]:     at Module.load (internal/modules/cjs/loader.js:985:32)
2020-09-11T07:44:06.998796+00:00 app[worker.1]:     at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-09-11T07:44:06.998796+00:00 app[worker.1]:     at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-09-11T07:44:06.998797+00:00 app[worker.1]:     at require (internal/modules/cjs/helpers.js:72:18)
2020-09-11T07:44:06.998797+00:00 app[worker.1]:     at Object.<anonymous> (/app/index.js:11:18)
2020-09-11T07:44:06.998797+00:00 app[worker.1]:     at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-09-11T07:44:06.998797+00:00 app[worker.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)

I'm guessing its something in my .then function but im not sure

vale garden
#

any help?

#

for my question

#

lol

near veldt
#

ok

earnest phoenix
#

what commands are for changing the bot's status??

near veldt
#

"SyntaxError: Unexpected end of input" It's a syntax error meaning that a character or string was incorrectly placed within a command or instruction so the code is unable to be executed

#

that requires a ready.js, Hype

forest drift
#

I've clicked every line, i cant find the issue

earnest phoenix
#

that requires a ready.js, Hype
@near veldt oh ok

forest drift
#
let argument2 = parseInt(argument) + 1;
                        message.channel.bulkDelete(argument2)
                        .then(async (deleted) => { 
                            newamountdel = `${deleted.size`;
    let response = await message.channel.send({embed: clearsuccess})
    reponse.delete({ timeout: 5000 }) 
    let response2 = await message.reply("ping");
    response2.delete({ timeout:500 })
    client.channels.cache.get('732708641039319101').send({embed: clearsuccesslog})
  });

Is there anything wrong with this code?

#

argument, newamountdel and the embeds are defined in the code before that

hazy sparrow
#

100% coded this myself before anyone complains that i have copypasted it from somewhere

const db = require("quick.db");

module.exports = {
    name: 'work',
    description: "flip a coin!",
    
    execute(message){
      const cooldown = new Set();
      const cooldownAmount = 3600000;
      const expirationTime = Date.now() + cooldownAmount
      const now = Date.now();
        
        
      if(now < expirationTime){
          const timeLeft = (expirationTime - now) / 1000;
          
          message.channel.send(`You have worked recently! Please wait ${timeLeft} seconds before you can work again!`);
      }  
      else 
            if(message.author.id == 542278740537769985) {
             const bal = new db.table(`${message.author.id}mybal`);
            if(message.author.id == 542278740537769985) {
            db.add(`${message.author.id}mybal`, 2000);
            message.channel.send(`You got **2000** bowbucks for working...`);
      }
            else {
          db.add(`${message.author.id}mybal`, 2);
          message.channel.send("you got **2** bowbucks for working");
          cooldown.add(message.author.id)
          setTimeout(() => cooldown.delete(message.author.id), cooldownAmount);
            }
          
      }
      }
    
     
        
    }
forest drift
#

oh wait a second, i found the issue

vale garden
#

lmao thats the same problem i have

#

@hazy sparrow

#

kinda

forest drift
#

bow pro thanks, ur code showed me my issue lol

vale garden
#

lol

near veldt
#

@forest drift "${deleted.size"

earnest phoenix
#

@hazy sparrow Fuckijg

#

Spoonfeeder

near veldt
#

i think ur missing a "}"

earnest phoenix
#

And guys

#

He copy it from somewhere

hazy sparrow
#

bow pro thanks, ur code showed me my issue lol
@forest drift welcome?

near veldt
#

the ending has the required });

forest drift
#

oh.... im blind... wait how does the rest of my code stay to format if... im so cinfused rn

hazy sparrow
#

wow did i just fix someone elses problem with my problem

forest drift
#

He copy it from somewhere
@earnest phoenix i think he was using an advanced technical term called joking -___-

earnest phoenix
#

No, he isnt.

hazy sparrow
#

help me pls ;-;

forest drift
#

does anyone else also plead when they launch their code that its gonna work?

earnest phoenix
#

Gotta say, bow pro, please dont lie about coding

hazy sparrow
#

wdym

#

wdym @earnest phoenix

near veldt
#

bows code looks pretty basic, star

#

bow coulda coded it himself

earnest phoenix
#

No

hazy sparrow
#

but i refered to the d.js thing

earnest phoenix
#

He copy it from discord.js guide

near veldt
#

it doesnt look copied

forest drift
#
let response = await message.channel.send({embed: clearsuccess})
    reponse.delete({ timeout: 5000 }) 

Now I'm getting "response isnt defined" ;-;

#

wait i cant spell

#

and im blind

hazy sparrow
#

lol

near veldt
#

f

#

reponse

hazy sparrow
#

He copy it from discord.js guide
@earnest phoenix I didn't copy it, I just reffered to it

#

reffered*

#

refered*

near veldt
#

refried

forest drift
#

^^^ according to copyright, as long as u state the source its legal

earnest phoenix
#

Refferenced

steady anchor
#

is there a limit by youtube video requests? (my bot send a message if someone upload a video)

earnest phoenix
#

@steady anchor yes

hazy sparrow
#

also @earnest phoenix my code and the d.js guide clearly has some difference

steady anchor
#

:(

earnest phoenix
#

Google api gave rate limit

#

Unless you buy upgrade i think

#

@hazy sparrow

name: 'work', description: "flip a coin!"
hazy sparrow
#

thats not the issue @earnest phoenix

earnest phoenix
#

but still it's weird

forest drift
#

if im using export modules, could i just add "client" to the export thingy on the send and recieve and itd work? or is this also gonna be annoying

hazy sparrow
#

but still its not the issue

earnest phoenix
#

@forest drift yes

forest drift
#

:D for once its less work

earnest phoenix
#

@pale vessel can i use CSS gradients in canvas?

#

exports.{name}

near veldt
#

u mean module.exports.client ?

earnest phoenix
#

require('path/to/file').{name}

#

terrible way

#

you'll still need to put .name at the end

#

when he stores all commands in individual files anyways

near veldt
#

lol

hazy sparrow
#

now can someone help me :/

earnest phoenix
#

yeah

near veldt
#

yeah

pale vessel
#

yes you can

earnest phoenix
#

yes you can
@pale vessel how

near veldt
#

damn

earnest phoenix
near veldt
#

gave yo ass the docs

earnest phoenix
#

lol

pale vessel
near veldt
#

lol

forest drift
#

module exports are annoying but way better than putting everything in 1 file... wish id known that a month ago...

near veldt
#

indeed, module.exports are annoying

pale vessel
#

why is it annoying

earnest phoenix
#

module exports are annoying but way better than putting everything in 1 file... wish id known that a month ago...
@forest drift you'd still need module.exports if you storw everything in one file

#

indeed, module.exports are annoying
@near veldt fuck no every single npm package NEEDS module.exports to have the code available to other modules that require() it

near veldt
#

ok boomer

earnest phoenix
#

what the fuck

hazy sparrow
#

lmaoo

earnest phoenix
#

ok boomer
ok whitename mmLol

forest drift
#

@forest drift you'd still need module.exports if you storw everything in one file
@earnest phoenix u do ;-; welp i was clearly coding wrong then

earnest phoenix
#

uhh no

#

i meant store all commands in one seperate file

#

not the same index.js

hazy sparrow
#

k imma ask my "question" again

#
const db = require("quick.db");

module.exports = {
    name: 'work',
    description: "flip a coin!",
    
    execute(message){
      const cooldown = new Set();
      const cooldownAmount = 3600000;
      const expirationTime = Date.now() + cooldownAmount
      const now = Date.now();
        
        
      if(now < expirationTime){
          const timeLeft = (expirationTime - now) / 1000;
          
          message.channel.send(`You have worked recently! Please wait ${timeLeft} seconds before you can work again!`);
      }  
      else 
            if(message.author.id == 542278740537769985) {
             const bal = new db.table(`${message.author.id}mybal`);
            if(message.author.id == 542278740537769985) {
            db.add(`${message.author.id}mybal`, 2000);
            message.channel.send(`You got **2000** bowbucks for working...`);
      }
            else {
          db.add(`${message.author.id}mybal`, 2);
          message.channel.send("you got **2** bowbucks for working");
          cooldown.add(message.author.id)
          setTimeout(() => cooldown.delete(message.author.id), cooldownAmount);
            }
          
      }
      }
    
     
        
    }
forest drift
#

oh yeah, i was storing everything in 1 file, had tried module.exports, that was 2 weeks after i had started, found in annoying af and didnt understand it, so just carried on and now im having to convert everything to module exports

hazy sparrow
#

oh wait i think i know how to fix it

near veldt
#

setTimeout

earnest phoenix
#

@hazy sparrow what even is the fucking problem

hazy sparrow
near veldt
#

i think bowy boi forget a setTimeout for his cooldown

earnest phoenix
#

@hazy sparrow yeah what is the problen

#

explain it

#

instead of pinging me with a screenshot

near veldt
#

i just explained for him, code

#

take a deeper look

#

3600 seconds

#

for each msg

#

it doesnt change

earnest phoenix
#

impossible to change it with setTimeout

near veldt
#

it doesnt count down

hazy sparrow
#

yes ans all messages are 10 seconds apart

earnest phoenix
#

node won't tell how much time is left before the timeout ends

#

just wait an hour

#

then try again

near veldt
#

bullshit

#

i've seen bots have that feature

hazy sparrow
#

its been 2 fking days since i used bow work

#

i think bowy boi forget a setTimeout for his cooldown
@near veldt didnt i set it in the bottom of the code?

nimble kiln
#

It's possible if you give the timer an argument

near veldt
#

im blind

hazy sparrow
#

should i use a .then?

earnest phoenix
#

bullshit
@near veldt do you fking know how to do that
you just told him to use setTimeout
you didn't tell him how exactly to return the amount of time left for the cooldown to end

#

i know how

#

but y'all are too toxic

hazy sparrow
#

how am i toxic

near veldt
#

nice assumption

earnest phoenix
#

@near veldt arrow_left arrow_left arrow_left

vague horizon
#

hey there uh may i ask what coding language yall use for ur bots?

near veldt
#

javascript

hazy sparrow
#

@vague horizon js

vague horizon
#

same lmao

hazy sparrow
#

not suprised

vague horizon
#

i see a lot of people who try to say they use javascript

#

but they use like bad websites

#

that dont even make u code

#

just buttons

#

and watermarks

hazy sparrow
#

lmao yea

vague horizon
#

and that stupid stuff

pale vessel
#

i use botghost

#

it's pretty solid

vague horizon
#

whats that

hazy sparrow
#

👀

vague horizon
#

non coding bot website?

hazy sparrow
#

yes

vague horizon
#

or something like that

#

oh k

hazy sparrow
#

yes

vague horizon
#

lmao

nimble kiln
#

var muteTimer = setTimeout(function, milliseconds, Date.now());
^If you give your timeout the current timestamp you can get time remaining with this:
timeRemaining: muteTimer._idleTimeout - (Date.now() - muteTimer._timerArgs[0])

Just throwing this in here now

vague horizon
#

btw

#

do any of u know

#

how to uh

#

do the authorization

#

also how do u get uh the bot dev role

nimble kiln
#

That's something for #topgg-api - But you define "authorization" (or the password) in your bot's options for DBL

hazy sparrow
#

DSL?

vague horizon
#

yes @hazy sparrow

#

that

#

its for dsl

hazy sparrow
vague horizon
#

i have no idea how it works

#

i did

#

noone answering

#

even in support

hazy sparrow
#

lol

vague horizon
#

i posted pic

#

but eh

hazy sparrow
#

look at what that green dude said

#

(sorry if i insulted anyon)

vague horizon
#

uh bot options

#

where do i go for dat .-.

hazy sparrow
#
const db = require("quick.db");

module.exports = {
    name: 'work',
    description: "flip a coin!",
    
    execute(message){
      const cooldown = new Set();
      const cooldownAmount = 3600000;
      const expirationTime = Date.now() + cooldownAmount
      const now = Date.now();
        
        
      if(now < expirationTime){
          const timeLeft = (expirationTime - now) / 1000;
          
          message.channel.send(`You have worked recently! Please wait ${timeLeft} seconds before you can work again!`);
      }  
      else {
            if(message.author.id == 542278740537769985) {
             const bal = new db.table(`${message.author.id}mybal`);
            if(message.author.id == 542278740537769985) {
            db.add(`${message.author.id}mybal`, 2000);
            message.channel.send(`You got **2000** bowbucks for working...`);
      }
           else { 
          db.add(`${message.author.id}mybal`, 2);
          message.channel.send("you got **2** bowbucks for working");
          cooldown.add(message.author.id)
          setTimeout(() => cooldown.delete(message.author.id), cooldownAmount);
            
           }   
      }
      }}
    
     
        
    }
``` it doesesnt let me work even though its been like 2 days since ive done bow work
cinder patio
#

The cooldown code should be in your message event listener

#

not in every command

#

Did you follow the tutorial?

pale vessel
#

you can also just put the cooldown outside the execute function

earnest phoenix
#

you're doing everything wrong @hazy sparrow

hazy sparrow
#

The cooldown code should be in your message event listener
@cinder patio i jist want it for this command

cinder patio
#

Still

#

You can do it like flazepineapple said, but it's not flexible that way

#

What if you want to have another command with cooldowns later on?

earnest phoenix
#

i just make a temporary cooldowns collection in mongodb and add and remove stuff to the collection and when my bot restarts i delete the collection else everyone will be stuck on infinite cooldown

torpid ember
#

hello

hazy sparrow
#

What if you want to have another command with cooldowns later on?
@cinder patio thats not the problem

cinder patio
#

I suggest actually reading the whole command handler tutorial instead of copying the code blindly. Then you'll be able to see where to put the code. It's okay to copy code from guides / the internet, but you have to understand it. If you don't know where to put it then you don't understand it.

hazy sparrow
#
  1. i understand the code
  2. i didn't just straight up copy it
  3. wont it work if i put it inside the command file?
#

also 4. i didnt copy the command handler from the guide

#

tim told me

cinder patio
#

It depends where you put it. If you did understand it, you would've been able to put it in the right place. Do you think putting the entire cooldown code in the command's execute function makes sense, considering the function is executed every time someone does the command?

hazy sparrow
#

holy i didnt think of that

cinder patio
#

The set you are creating gets created every time someone runs the command. You should put it outside of that function

hazy sparrow
#

kk

#

i didnt think of that

cinder patio
#

And maybe put cooldownAmount outside of it too, so you don't allocate memory for a number every time the command is ran

hazy sparrow
#

kk

#

the set one doesesnt wanna work

#

oh wait

#

im dumb

wanton anvil
#

can we add bots to dm groups??

#

??

#

ping me on reply

cinder patio
#

no

delicate shore
#

No

hybrid roost
#

hello, why my DSJS bot's presence don't changing?

bot.user.setPresence({
        status: "online",  //You can show online, idle....
        game: {
            name: "Using !help",  //The message shown
            type: "STREAMING" //PLAYING: WATCHING: LISTENING: STREAMING:
        }
    });
```\
nimble kiln
#

@hybrid roost Any errors?

earnest phoenix
#

activity not game

hybrid roost
#

No errors

#

(I am calling this in bot.on('ready')

#

oh, I understand. Now I'm using bot.user.setActivity() and it working!

feral aspen
#

Question

#

How does it mean by the following

infrastructure_third_party_accounts_description: Must be between 100 and 2000 in length.```
cinder sandal
#

how to make the execute() an async

#
const economy = require('../economy')

module.exports = {
    name: 'balance',
    description: 'shows ur balance',
    cooldown: 5,

    execute(message, args) {
       const target = message.mentions.users.first() || message.author
       const targetID = target.id

       const guildId = message.guild.id
       const userId = target.id

       const coins = await economy.getCoins(guildId, userId)

       message.channel.send(`${target.tag} has ${coins} Crystal(s)!`)
    },
};```
#

if it has an await in the command

still merlin
#

aysnc execute()

cinder sandal
#

async execute(message, args)?

still merlin
#

yes

cinder sandal
#

k thx

still merlin
#

np

outer perch
#

I am tired of dying here

#

someone pls send me a snippet to save prefixes in an object so I don't have to request the DB every time

#

I tried something that isn't working

earnest phoenix
#

@outer perch spoonfeed

outer perch
#

what

restive furnace
#
let databeis = new ConectionToDeitBeis("hello", "learn", "your", "self");

databeis.run("SELECT * FROM users WHERE id = "1234";");```
outer perch
#
const ref = db.collection('servidores').doc(message.guild.id);

    const prefixes = new Object();

    if (!prefixes[message.guild.id]) {
        ref.get().then(doc => {
            prefixes[message.guild.id] = doc.get('prefix');
        });
    }

    const prefix = prefixes[message.guild.id];
#

this sends me prefix = undefined

restive furnace
#

yeah, it's copy paste. spoonfeed.

outer perch
#

what is copy paste?

#

what u did or what I did

restive furnace
#

you lol

outer perch
#

I didn't copy paste from anybody

#

I did this myself

restive furnace
#

hmmmmmm

#

then why it's not working??

outer perch
#

I don't know

#

the only thing that makes sense is the ref.get there

#

the then function doesn't send the value outisde

faint zenith
#

can anyone help me with code of getting info of voters in our server channel

earnest phoenix
#

setting up mongodb
i gave myself a challenge that if i don't setup mongodb within 72 hours i will have to make a biggo giveaway

#

can anyone help me with code of getting info of voters in our server channel
@faint zenith you mean on DSL?

fluid basin
#

lol 72 hours

#

thats too lenient

#

make it 4 hours

earnest phoenix
#

12 already passed

#

and i have skool

fluid basin
#

LOL ok

faint zenith
#

@faint zenith you mean on DSL?
@earnest phoenix yes dsl and dbl both

#

i made a code but its not working idk why

#

😔

earnest phoenix
#

Get information about who voted the server in the past 12 hours?

faint zenith
#

yes

earnest phoenix
#

we can do that in DBL not sure about DSL the DSL API is still in beta

faint zenith
#

Get information about who voted the server in the past 12 hours?
server or bot

earnest phoenix
#

hits up docs

faint zenith
#

i hits up docs i setup everything but its not working there they said contact in dbl server

#

but noone is helping here

#

😔

earnest phoenix
#

but noone is helping here
@faint zenith i said i am checking the docs for info on how to get information on votes

faint zenith
#

ohk

#

will i send u my code ?

earnest phoenix
#

i foound it

faint zenith
#

ohhk

earnest phoenix
faint zenith
#

ohk

earnest phoenix
#

alright how do i hack R6 for bobux

slender thistle
#

Get information about who voted the server in the past 12 hours?
There's no API for DSL

#

so that's not possible

earnest phoenix
#

TIm

#

TIM

quartz kindle
#

@outer perch the data inside .then() is not available outside

earnest phoenix
#

is it possible to make IDE convert JS to TS

quartz kindle
#

you need to use async/await syntax instead of then

faint zenith
#

There's no API for DSL
but its possible for bots ? dbl

outer perch
#

@outer perch the data inside .then() is not available outside
@quartz kindle I did this another way

#

I can assign values from a then to a variable outside then right?

#
const ref = db.collection('servidores').doc(message.guild.id);

    const prefixes = new Object();

    if (!prefixes[message.guild.id]) {
        await ref.get().then(doc => { prefixes[message.guild.id] = doc.get('prefix'); });
    }

    const prefix = prefixes[message.guild.id];
quartz kindle
#

you can, but the outside code will not wait for it

outer perch
#

await

#

now it's getting the prefix I wanted, but it's going undefined right after

#

I'm just confused

quartz kindle
outer perch
#

AHA THAT WAY

quartz kindle
#

also, if you define prefixes inside the message event, it will be redefined/reset every time

outer perch
#

tfw you think you're somewhat of a dumbf*ck

#

also, if you define prefixes inside the message event, it will be redefined/reset every time
@quartz kindle I'd like to get around that

#

I thought the if statement would avoid that

#

like, if not in the object, retrieve from DB and put it in the obj

#

if it is, use from the obj

quartz kindle
#

yes but the object needs to already be created

outer perch
#

it is created

quartz kindle
#

you cant create it again on every single message

outer perch
#

I have client.on(message

#

true

cinder sandal
#
const target = message.mentions.users.first() || message.author
       const targetID = target.id

       const guildId = message.guild.id
       const userId = target.id

       const coins = await economy.getCoins(guildId, userId)

       const BalanceEmbed = new MessageEmbed()
       .setTitle(`${target.tag}'s Balance`)
       .setDescription(`Crystals: ${coins}\nTokens: 0`)
       .setTimestamp()

       message.channel.send(BalanceEmbed)```
outer perch
#

again I didn't noticed what I did

cinder sandal
#

it returns undefined (Crystals: undefined)

#

but it's defined

#

how do i fix it

outer perch
#

omg

#

put a Lint in there 🤣

#

missing semicolons make me go nuts

cinder sandal
#

where

outer perch
#

I know javascript lets you program

#

without semicolons

#

but a programmer always needs to have that habit

restive furnace
#

nope

quartz kindle
#

what is economy? how did you define economy?

cinder sandal
#

@quartz kindle const economy = require('../economy') economy/economy.js

quartz kindle
#

and what is economy.js?

cinder sandal
#

the code for getCoins and addCoins

quartz kindle
#

show it

outer perch
#
undefined
undefined
undefined
undefined
+
undefined
+
undefined
#
  • is the default prefix
#

why are the others getting undefined?

earnest phoenix
#

Yo

#

I am new here

outer perch
#

these are the prefix logs

earnest phoenix
#

@outer perch I know

cinder sandal
#

@quartz kindle

 const mongo = require('./mongo')
const profileSchema = require('./schemas/profile-schema')

const coinsCache = { 'guildId-userId': coins }

module.exports = (client) => {}

module.exports.addCoins = async (guildId, userId, coins) => {
    return await mongo().then(async (mongoose) => {
        try {
           console.log('Debug  Mode: running find one and update')
           
           const result = await profileSchema.findOneAndUpdate(
               {
                   guildId,
                   userId,

               },
               {
                   guildId,
                   userId,
                   $inc: {
                       coins,
                   },
               },
               {
                   upsert: true,
                   new: true,
               }
           )

           console.log('Debug Mode: RESULT:', result)

           coinsCache[`${guildId}-${userId}`] = result.coins

           return result.coins
            } finally {
                mongoose.connection.close()
            }
        })
    }

module.exports.getCoins = async (guildId, userId) => {
    const cachedValue = coinsCache[`${guildId}-${userId}`]
    if (cachedValue) {
        return cachedValue
    }
    return await mongo().then(async mongoose => {
        try {
           console.log('running findone()')

           const result = await profileSchema.findOne({
               guildId,
               userId
           })

           console.log('[DEBUG] Result:', result)

           let coins = 0
           if (result) {
               coins = result.coins
           } else {
               console.log('[DEBUG] Inserting docs')

               await new profileSchema({
                   guildId,
                   userId,
                   coins
               }).save()


               return coins
           }
        } finally {
            mongoose.connection.close()
        }
    })
}```
earnest phoenix
#

Iferg is better than bobby

quartz kindle
#

@cinder sandal what do the console.logs in there say?

cinder sandal
#

nothing

quartz kindle
#

you dont return coins if there is a result

cinder sandal
#

just the error that coins is not defined in economy.js

earnest phoenix
#

@cinder sandal hello

quartz kindle
#

because you did this lol const coinsCache = { 'guildId-userId': coins }

#

coins is undefined

earnest phoenix
#

@quartz kindle u noob

#

lol

quartz kindle
#

???

cinder sandal
#

so

earnest phoenix
#

how do i make it so Discord OAuth2 sends a HTTP POST request to the redirect URI instead of adding ?code= in the redirect URI

#

@quartz kindle u play cod?

quartz kindle
#

no, also wrong channel for that

earnest phoenix
#

@quartz kindle it’s boobys channel

#

@quartz kindle u noob
@earnest phoenix how could you say that bleach

cinder sandal
#

i should define it up0n it
and remove return coins?

quartz kindle
#

you dont need to make any schema for it

#

just do const coinsCache = {}

earnest phoenix
#

@slender thistle NSFW in the channel

slender thistle
#

@earnest phoenix Keep this channel on topic of programming. Non-English goes to #general-int

earnest phoenix
#

Why is it

#

Isn’t it gaming discord server?

slender thistle
#

No?

earnest phoenix
#

how do i make it so Discord OAuth2 sends a HTTP POST request to the redirect URI instead of adding ?code= in the redirect URI
special ping: @quartz kindle

#

I thought it’s of bobby plays

#

Isn’t it gaming discord server?
@earnest phoenix definetely no

thin turret
slender thistle
#

No, it's not. This is top.gg support server

cinder sandal
earnest phoenix
#

What do we do here??

#

Duhhhh

quartz kindle
#

@earnest phoenix i dont think you can

earnest phoenix
#

Can someone tell me

#

At least

slender thistle
#

Move to #general if you want to continue this conversation

earnest phoenix
#

@slender thistle nope

#

What do we do here

#

Tell me

slender thistle
earnest phoenix
#

Ok what will I do there

cinder sandal
#

ty

thin turret
#

gg

cinder sandal
#

i made an economy system in my bot now

slender thistle
#

Keep your off-topic conversation in the proper channel and avoid getting muted for misusing channels

earnest phoenix
#

why are people like this
oops i forgot we're humans

#

@earnest phoenix for eg > why are people like this

oops i forgot we're humans
@earnest phoenix

slender thistle
#

sigh

remote orbit
earnest phoenix
#

@earnest phoenix i dont think you can
@quartz kindle what about putting ?response_type=smth in the OAuth URL

#

@slender thistle please feel free to take

#

What si load cogs

faint prism
#

Not hard to move channels bro

restive furnace
#

ban speedrun?

earnest phoenix
#

Client..........???😂

#

i made an economy system in my bot now
@cinder sandal cool which database you use for storing stuff

cinder sandal
#

@cinder sandal cool which database you use for storing stuff
@earnest phoenix mongo

restive furnace
#

@remote orbit not really

earnest phoenix
#

I am going

#

Bye gotta go

faint prism
#

Tfw my mongodb connection has 6s latency :(

slender thistle
#

@remote orbit A simple list like ["utility", "fun"] and then a for-loop where you load f"Cogs.{cog}", where cog is each element of the list

earnest phoenix
#

@slender thistle mute?

#

Mainu pata nahi kidar jaana hai
@earnest phoenix #general-int me jaao agar hindi bolna hai kripya karke moderator ka baat sunlo bhai

thin turret
#

Man said n word okeh

earnest phoenix
#

no

#

he didn't

#

@earnest phoenix main tain Punjabi Bol Rahain hain

#

god

#

why can't you understand

cinder sandal
#

mongo is a good db
even more that good

faint prism
#

Good for big data

earnest phoenix
#

Registered
Thu, Jul 16, 2020 8:37 AM
of course these noobs that take a whole year to understand simple shit

#

@earnest phoenix who all??

#

alright now i am going off topic

#

mongo is a good db
even more that good
@cinder sandal atlas or local mongodb?

#

which one you use

#

i go for atlas

#

Same

#

my VPS ain't trustable

cinder sandal
#

@cinder sandal atlas or local mongodb?
@earnest phoenix atlas because i host on heroku

earnest phoenix
#

ATLAS

#

@earnest phoenix atlas because i host on heroku
@cinder sandal WHY HEROKU WHY WHY WHY WHY

eternal osprey
#

hey

earnest phoenix
#

hi

eternal osprey
#

is there any way to create your vps on your computer?

faint prism
#

Relatiomal dbs can be faster in some use cases than non-relational

earnest phoenix
#

Wanna play cod cod cod

#

I wanna play cod cod

#

@slender thistle pls mute

#

mute me for 5 minutes i might come off as toxic if this guy won't stop

blissful oxide
slender thistle
#

How about you leave this channel for on-topic discussions now after seeing me just mute someone for off-topic conversations in #development

earnest phoenix
#

||kthnxbai||

#

should i store OAuth2 access tokens on the user's computer on in my encrypted MongoDB database?

#

they both have their pros and cons

slender thistle
#

Now, on to relational DBs. Is MS Access worth a try in production? 🤔

faint prism
#

Ehhh

outer perch
#

@quartz kindle I fixed some things here and there inside the code, now everything is doing fine

faint prism
#

I personally don't like ms Access

earnest phoenix
faint prism
#

I'd rather draw out the diagrams, then implement them with SQL commands

slender thistle
#

Or would you consider it only as something to be used in a welcome-to-DB environment?

pale vessel
#

@slender thistle
@earnest phoenix bruh why here

earnest phoenix
#

he sweared in my DMs afterwards

#

and randomly called me multiple times

pale vessel
#

sorry for the ping

slender thistle
#

Block and carry on, also DM me for this

earnest phoenix
#

ok

#

does MongoDB have built-in encryption?

faint prism
#

Atlas does

earnest phoenix
#

k

#

wait is that the password for the user

faint prism
#

Lol

earnest phoenix
#

the key required to decrypt the files

#

i wanna store OAuth2 access tokens with encryption cuz storing it on user's PCs sucks

faint prism
#

Eh

slender thistle
#

Encrypt the access token reversed with base64 😂

faint prism
#

More of a config file use case

#

Encrypt the access token reversed with base64 😂
@slender thistle >security through obscurity

slender thistle
#

How bad is it, though?

faint prism
#

Because it isn't real security

#

I'd be pretty confident that some decryption scripts would include something like that

earnest phoenix
#

i'll just store it on Atlas

#

all i need is the user ID

#

and their email

faint prism
#

Base 64 is a pretty recognizable format

earnest phoenix
#

not worth hacking

faint prism
#

Even reversed

earnest phoenix
#

bearer tokens are enough to be stored in just memory

#

the user can just log back in if it's gone

#

what about storing it on the user machine

#

just store them in memory

#

but it'll eat the server RAM

#

...

#

no it wont

#

those are strings

#

it is a smol website through which people can manage stuff about the botum
express already takes 60% of CPU, no joke

#

yes but that is a string

cinder sandal
#

in economy commands i want an random amount of money to be given (1-5), id i put it to say how much you got, it would say like you got 5 coins but you get 4 or less or an onther random number

how do i prevent that?

earnest phoenix
#

if you're worried about a string eating your ram you might as well not use node in the first place

#

apache suck, it takes alots of ram

#

if you're worried about a string eating your ram you might as well not use node in the first place
@earnest phoenix alright moving to browser-based javascript

faint prism
#

but it'll eat the server RAM
@earnest phoenix depends on if the string length is massive or not.

earnest phoenix
#

uhhh yeah

#

snowflakes grow in size as more people start using discord and never delete their accounts before dying

#

simply hashing the token in memory protects the token from being sniffed from other processes reading the memory, which would be the only way to access something being stored in machine memory

#

simply hashing the token in memory protects the token from being sniffed from other processes reading the memory, which would be the only way to access something being stored in machine memory
@earnest phoenix if i hash the token how the fuck will i reverse it to get it back

cinder sandal
#

let random = Math.floor(Math.random() * 100 );

#

how do i return the exact result of it

faint prism
#

Hashing is one way

earnest phoenix
#

yeah but

#

you can reverse lookup

#

you dont even have to hash

#

hashes can't be reversed

#

just manipulate the original string to be shuffled so it can't be read from memory

faint prism
#

Sounds like obscurity

cinder sandal
#

and not just having a diffrent number
like message.channel.send('random: ${random} ${random2}')

earnest phoenix
#

yeah

#

@earnest phoenix we need our client secret to actually use OAuth tokens right? well then it won't be a problem if the token is leaked unless my client secret is also leaked

faint prism
#

Just encrypt it properly if you really care

#

Aes or something

cinder sandal
#

random2 would be diffrent from random

earnest phoenix
#

you have bigger concerns if you leak your client secret

#

which is unlikely

#

anyways

#

yeah

faint prism
#

The client secret is used to ask for tokens, yeah?

cinder sandal
#

i want the random2 be the result of random
how

earnest phoenix
#

storing bearer tokens in memory will not eat the memory, they are strings and bearer tokens expire after a week if you don't refresh regardless so just drop it from memory after a week

#

that's why i'll store the tokens in a temporary MongoDB collection that is deleted every 24 hours (which is what top.gg does)

#

k

#

but how will i store the tokens in memory anyways?
make an object where every property name is a user's IP address and the property value is the token?
or discord.js collection jazz?
or localstorage jazz?
or cache jazz?

faint prism
#

Just a dictionary object

#

Or some collection

earnest phoenix
#

array/map of the token and unix timestamp of entry

cinder sandal
#

i want the random2 be the result of random
how
@cinder sandal

earnest phoenix
#

in your backend

#

@cinder sandal explain your problem better man

slender thistle
#

how do i return the exact result of it
@cinder sandal What do you mean "exact"? Just remove the Math.floor? 🤔

earnest phoenix
#

how did u know js

#

shiv ?????????

slender thistle
#

Math.random() * 100 will return a float, and if that's not what you want, I don't know what else

#

Applying common sense and knowledge from Python, basic JS can be fairly comprehensive

earnest phoenix
#
Math.floor(Math.random() * 100)

Will be the code

eternal osprey
#

instead of getting a link

earnest phoenix
#

you can't

#

that many images

#

u can only display one image

eternal osprey
#

it iss one image

earnest phoenix
#

wtf

cinder sandal
#
const coins = Math.floor(Math.random() * 50);

        const guildId = message.guild.id
        const userId = message.author.id

        const NewCoins = await economy.addCoins(guildId, userId, coins)

        message.channel.send(`You walked on the streets and picked up ${coins} Crystal.`)
    },
};```
eternal osprey
#

they are all the same

slender thistle
#

You can't add images in any fields other than the image one. You could try to use emotes, which doesn't sound like what you want

earnest phoenix
#

uhh wut

cinder sandal
#

my code would add around 50 money in my balance

eternal osprey
#

owh okay

#

i will do that.

unique patio
#

So you guys are aware....

MAP is slow as hell; don't do it. PLEASE just don't!!!!
Your for-statement beats it ten-folds.

cinder sandal
#

0-50

earnest phoenix
#

fun fact
webhooks can use twitter embed's multi image support

faint prism
#

So you guys are aware....

MAP is slow as hell; don't do it. PLEASE just don't!!!!
Your for-statement beats it ten-folds.
@unique patio good luck convincing these guys here of that one lol

earnest phoenix
#

So you guys are aware....

MAP is slow as hell; don't do it. PLEASE just don't!!!!
Your for-statement beats it ten-folds.
@unique patio discord.js collections & our own methods of doing stuff intensify

unique patio
#

673940 OPS/s on for
206931OPS/s on MAP

cinder sandal
#

so how do i give the exact amount in the balance
and not like it says u got 50 but it give you 20

unique patio
#

Yeah I modified my discord.JS

earnest phoenix
#

@unique patio wtf is that

#

OPS

unique patio
#

Calculations

earnest phoenix
#

isn't a map just O(1)

faint prism
#

Operations per second

earnest phoenix
#

oh

#

@cinder sandal wtf that code is perfectly correct how the hell is there an error

unique patio
#

You can perform more operations in a for-loop in 10 seconds

#

than a map command

#

and go more complexed.

cinder sandal
#

@earnest phoenix it's not an error

earnest phoenix
#

how is a map so slow in node

eternal osprey
#

hey

unique patio
#

It just is...

eternal osprey
#
embed.setThumbnail(`${location.current.imageUrl}`)``` it is saying location is not defined
unique patio
#

Map can be fast in some scenarios but not always, it gets outweighed

earnest phoenix
#

c# dictionary lookups are O(1) being directly keyed by their hash

unique patio
#

with our default iterations

eternal osprey
#

while i am sure this is the actual variable

earnest phoenix
#

Cuz ur code is wrong @eternal osprey

#

@unique patio but still it is our own choice to do stuff

eternal osprey
#

and why so ace

cinder sandal
#

that it wouldn't give the exact amount that the message says to the balance
random amount between 5 and 0

earnest phoenix
#

GOOGLE

#

READ CONSOLE

#

smh

#

@eternal osprey is location defined AFTER that line of code

#

console.log()

eternal osprey
#

i have read console

earnest phoenix
#

show code

unique patio
#

Yup; but if you want to aim for practicality, and efficiency JSBench all code.

eternal osprey
#

yes it is

unique patio
#

You intend to use.

earnest phoenix
#

think about it @eternal osprey

#

yes it is
@eternal osprey you can't use a variable if it is defined AFTER the line that is asking for it

slender thistle
#

If you really care about performance, you might want to go strictly typed and compiled languages :p

eternal osprey
#
   }
      const title = "**Cities/countries ranked by: ** " +`**${skytext}**`;
      let embed = new Discord.MessageEmbed()
                              
                              .setTitle(title);
        locations_found.slice(0, 10).forEach(location =>
        {
          
        embed.addField(
          `${location.current.observationpoint}`, `${location.location.lat}`, `${location.location.long}`, true
           
          );
          
      });
      embed.setThumbnail(`${location.current.imageUrl}`)
      embed.setImage('https://media.giphy.com/media/CKsIi206Ntz4k/giphy.gif')
      
            .setColor('#FF0000')
            .setFooter("Command hosted for Pokehub`s community!");
            message.author.send("<@" + message.author.id + ">")
      message.author.send({embed});
    }
  }
});
cinder sandal
#
const coins = Math.floor(Math.random() * 50);

        const guildId = message.guild.id
        const userId = message.author.id

        const NewCoins = await economy.addCoins(guildId, userId, coins)

        message.channel.send(`You walked on the streets and picked up ${coins} Crystal.`)
    },
};```

@cinder sandal this would say like you found 1 - 50 coins but it gives you an diffrent amount

faint prism
#

If you really care about performance, you might want to go strictly typed and compiled languages :p
@slender thistle this

cinder sandal
#

what math.floor does

faint prism
#

Floors it

earnest phoenix
#

@eternal osprey location is literally not defined anywhere

cinder sandal
#

is it required for math.random

earnest phoenix
#

in ofrEach

slender thistle
eternal osprey
#

it is defined above

earnest phoenix
#

...you dont know what flooring is?

#

@earnest phoenix in ForEach

eternal osprey
#

it is defined ace

#

ffs

earnest phoenix
#

location => {}

#

what math.floor does
Floors it
@faint prism dogekek

unique patio
#

@slender thistle There's that, but the difference here was1/3

earnest phoenix
#

back to 4th grade you go

cinder sandal
#

one question: is math.floor required for math.random?

faint prism
#

Rounds down

unique patio
#

Imagine what a a lower-level language could do

earnest phoenix
#

@eternal osprey that's a callback function

faint prism
#

No

#

It acts on a double

slender thistle
#

It's not required, but do you want decimal numbers as user currency?

earnest phoenix
#

variables defined inside callback functions can't be used outside

faint prism
#

Which is something with a decimal

cinder sandal
#

how do i make a random number between 1 and 50 without math.floor

slender thistle
#

Imagine what a a lower-level language could do
@unique patio My brain hurts when it comes to memory pointers. I'm too used to Python's sugarcoating :p

earnest phoenix
#

how do i make a random number between 1 and 50 without math.floor
@cinder sandal it will but the number would have upto 10 decimal places

#

you floor it because Math.random() returns a decimal from 0 to 1 which you multiply based on what range you want

unique patio
#

lol 😛

cinder sandal
#

Math.random(1 * 50);

unique patio
#

I try to avoid python, for Js/C++/C# or Java

cinder sandal
#

should it be like that

unique patio
#

Used it a lot tho during early bot days

earnest phoenix
#

well 1x50 is 50

#

and no

#

random does not take args

slender thistle
#

3 years, still using it for my numerical methods assignments 😂

unique patio
#

lol

earnest phoenix
#

please stop being a help vampire and read what you're being told

#

I try to avoid python, for Js/C++/C# or Java
@unique patio how the hell would you use python inside those languages

unique patio
#

I like the python a lot, but it's not syntax appropriate for me

#

AT ALL

earnest phoenix
#

this

#

i gave up on python after 3 whole hours

#

I like the python a lot, but it's not syntax appropriate for me
@unique patio English is a giant meme boy

unique patio
#

^ yeah

#

but I don't count english

#

LOL

earnest phoenix
#

bracket style languages are my togo

unique patio
#

Yeah

#

Python indentation scares me...

faint prism
#

i gave up on python after 3 whole hours
@earnest phoenix I gave up when it told me not to mix spaces and tabs

unique patio
#

I can do it but that is ugly as hell

slender thistle
#

Time to make a bracket-styled Python interpreter in Python...

unique patio
#

sin.....

slender thistle
unique patio
#

Do it shivaco I'd probably use the language more

#

For me, I need to visually see errors GG with that

#

otherwise

slender thistle
#

I'll probably fail if I do it now but maybe someday™️

unique patio
#

Think someone has done it though with a linter.

slender thistle
#

I use PyCharm and it helps a lot

unique patio
#

An IDE?

slender thistle
#

Yup

earnest phoenix
unique patio
#

Never heard of it, I usually used one of them all in ones

#

visual studios, eclipse

#

you know.... lol

slender thistle
#

Though I sometimes mix it with Sublime + Anaconda + Kite

#

😂

unique patio
#

Sublime I like

#

Notepad editors are sick, with linters in them

slender thistle
#

Sometimes just running flake8 on my projects to spot stuff I can improve

unique patio
#

Light-weight and correcting on the go; or auto-formatting. That's all I need.

slender thistle
#

They really are

#

Imagine running a full-on IDE on 4 GB of RAM :p

unique patio
#

Yeah not happening^

#

That was my struggle early dev days on my pentium 4 dude

slender thistle
#

😂 especially with stuff running in background

cinder sandal
#

how do i generate a number between 1 and 5 or any other number
i forgot it

unique patio
#

I could only use relics like notepad

#

with CMD compilers/etc on hand.

slender thistle
unique patio
#

^

#

Rand

slender thistle
#

Heh, simple stuff gang

unique patio
#

Make a function for it

earnest phoenix
#

i use the node editor from the terminal
any questions

slender thistle
#

nano ftw

unique patio
#

Nah seems fitting

#

😄

cinder sandal
#

i use nano for git commits

unique patio
#

I only really chase the big-boy IDE's for project management when I got like 5-20+ files on the go for one project.

slender thistle
#

Same

unique patio
#

Helps pointing the fi nger to imports/requires better

earnest phoenix
#

How can I get the dominant color and color palettes from a url?
Which module or api should I use?

unique patio
#

Could you simplify on what you mean?

#

You want to take CSS attributes from another domain?

cinder sandal
#

my balance command shows Crystals: undefined
after i et some coins it returns the normal amount that i have.
how do i prevent the undefined to appear

earnest phoenix
#

bruh nobody gonna make ur bot for u

#

google it read docs

#

read console

#

console.log()

#

debug it by ur self

unique patio
#

Value needs setting ahead of time

#

Possibly starts out undefined and called in that state

#

then when it's set; you no longer see it. Simple issue, make sure you set correctly before first call.

#

or check if value is undefined to not return on state.

#

Yeah console.log (keep that on ctrl+s) for checking all your work/calcs.

cinder sandal
#
const economy = require('../economy');
const { MessageEmbed } = require('discord.js');

module.exports = {
    name: 'balance',
    description: 'shows ur balance',
    cooldown: 5,

    async execute(message, args) {
       const target = message.mentions.users.first() || message.author
       const targetID = target.id

       const guildId = message.guild.id
       const userId = target.id

       const coins = await economy.getCoins(guildId, userId)

       const BalanceEmbed = new MessageEmbed()
       .setTitle(`${target.tag}'s Balance`)
       .setDescription(`Crystals: ${coins}\nTokens: 0`)
       .setTimestamp()

       message.channel.send(BalanceEmbed)
    },
};```
#

any errors?

unique patio
#

Yeah many syntax

#

no end-lines.

earnest phoenix
cinder sandal
#

so

#

where i did an error

faint prism
#

What is this "economy"

earnest phoenix
#

ye

#

where did u get taht

faint prism
#

Better not be json

quartz kindle
#

did you fix the non-returned result i told you about? @cinder sandal

unique patio
#

So you ran an await

earnest phoenix
#

oh it is a module.exports ?

unique patio
#

You're in async vs sync....

#

You're going to return undefined cause the balance embed is not sent in promise

#

to the await

#

AKA wait for the coins to get value, and send it to

#

not send it before.

cinder sandal
#

if a user didn't get some coins after the bot restart

#

it returns undefined

quartz kindle
#

did you fix what i told you to fix?

unique patio
#

Then run an if-statement to check if coins is undefined

#

if so, return nothing

quartz kindle
#

in the code you showed before, you were not returning anything if the user had coins

cinder sandal
#

no didn't fix

unique patio
#

coins === undefined
DO NOTHING

#

So for you coins !== undefined
RUN CODE

quartz kindle
#

show your code again

#

economy.js

cinder sandal
#

don't want to fill the chat with code but ok

quartz kindle
#

use a bin

cinder sandal
#
 const mongo = require('./mongo')
const profileSchema = require('./schemas/profile-schema')

const coinsCache = {}

module.exports = (client) => {}

module.exports.addCoins = async (guildId, userId, coins) => {
    return await mongo().then(async (mongoose) => {
        try {
           console.log('Debug  Mode: running find one and update')
           
           const result = await profileSchema.findOneAndUpdate(
               {
                   guildId,
                   userId,

               },
               {
                   guildId,
                   userId,
                   $inc: {
                       coins,
                   },
               },
               {
                   upsert: true,
                   new: true,
               }
           )

           console.log('Debug Mode: RESULT:', result)

           coinsCache[`${guildId}-${userId}`] = result.coins

           return result.coins
            } finally {
                mongoose.connection.close()
            }
        })
    }

module.exports.getCoins = async (guildId, userId) => {
    const cachedValue = coinsCache[`${guildId}-${userId}`]
    if (cachedValue) {
        return cachedValue
    }
    return await mongo().then(async mongoose => {
        try {
           console.log('running findone()')

           const result = await profileSchema.findOne({
               guildId,
               userId
           })

           console.log('[DEBUG] Result:', result)

           let coins = 0
           if (result) {
               coins = result.coins
           } else {
               console.log('[DEBUG] Inserting docs')

               await new profileSchema({
                   guildId,
                   userId,
                   coins
               }).save()


               return coins
           }
        } finally {
            mongoose.connection.close()
        }
    })
}```
earnest phoenix
#

uh

quartz kindle
#

hastebin/pastebin/sourcebin

earnest phoenix
unique patio
#

:3

quartz kindle
#

see

earnest phoenix
#

huh

quartz kindle
unique patio
#

Yup^

quartz kindle
#

if result, coins = result.coins

#

but you dont return it

#

so it returns undefined

#

you only return coins if there is no result

earnest phoenix
#
const mongodbpass = process.env.MONGODBPASS;
const uri = `mongodb+srv://replit:${mongodbpass}@codeco-cluster.3pscq.mongodb.net/userData?retryWrites=true&w=majority`;
const MongoClient = require('mongodb').MongoClient;
const client = new MongoClient(uri,{useUnifiedTopology: true, useNewUrlParser: true});
client.connect(err => {
    if (err) throw err;
});

This throws the error: https://hastebin.com/uqifovemip.php
Why does this happen?

unique patio
#

Nailed @quartz kindle

cinder sandal
#

so i should remove return coins?

quartz kindle
#

no...

#

you should add it

unique patio
#

^

earnest phoenix
#

please don't be a help vampire
be a help cow

quartz kindle
#

to the first if as well

#

or just

#

move it outside the if

unique patio
#

You could below the if-statement do a return coins || result.coins

#

?

earnest phoenix
#
const mongodbpass = process.env.MONGODBPASS;
const uri = `mongodb+srv://replit:${mongodbpass}@codeco-cluster.3pscq.mongodb.net/userData?retryWrites=true&w=majority`;
const MongoClient = require('mongodb').MongoClient;
const client = new MongoClient(uri,{useUnifiedTopology: true, useNewUrlParser: true});
client.connect(err => {
    if (err) throw err;
});

This throws the error: https://hastebin.com/uqifovemip.php
Why does this happen?
special ping: @quartz kindle

unique patio
#

or with single |

quartz kindle
#
if(result) {
  coins = result.coins
} else {
  save coins
  coins = 0
}
return coins
unique patio
#

not double*

hot solstice
#

@hasty hedge

earnest phoenix
#

what

faint prism
earnest phoenix
#

the bot is muted anyways lol

cinder sandal
unique patio
#

I'd simplify that a bit, on the single return on any if they return true or with vals

quartz kindle
#

@earnest phoenix idk i dont use mongo

#

try googling the error: connection monitor closed

unique patio
#

conditional statements are fun

earnest phoenix
#
faint prism
#

Tim said the thing. Aww edit

cinder sandal
faint prism
#

Lgtm

earnest phoenix
quartz kindle
#

italian google

unique patio
#

It broke my PC^

#

It can only english

faint prism
#

Lol

cinder sandal
#

but it's the italian ver

earnest phoenix
#

nah

faint prism
#

No

earnest phoenix
#

:))

unique patio
#

Been here for like 5 mins, does that make me mod?

cinder sandal
unique patio
#

😛

cinder sandal
faint prism
#

google.it sounds cool
@cinder sandal it's really cool, especially when you realize it's all in Italian

earnest phoenix
#
cinder sandal
#

yes

languid dragon
#

no

faint prism
#

Oml

earnest phoenix
#

@earnest phoenix you'll get muted role if you ping devs for no reason

languid dragon
#

no

earnest phoenix
#

god stop

faint prism
#

Well bye

languid dragon
#

stop

cinder sandal
#

adding return coins to the if (result) fixed the Crystals: undefined

faint prism
#

@slender thistle

earnest phoenix
#

ban him

#

@weak parrot

#

@mint thicket

#

that's enough ig

faint prism
#

We gottem

earnest phoenix
#

yeah

slender thistle
#

There was an admin in the chat, why mention multiple mods, derp

earnest phoenix
#

now we're getting off topic

faint prism
#

It's hard to tell :c

#

Maybe you're just my favorite mod, shiv

eternal osprey
#
  const title = "**Cities/countries ranked by: ** " +`**${skytext}**`;
      let embed = new Discord.MessageEmbed()
      .setThumbnail(`${location.current.imageUrl}`)
                              .setTitle(title);
        locations_found.slice(0, 10).forEach(location =>
        {
        
        embed.addField(```
#

still undefinned location

#

can someone help me with suggestions on where to set the thumbnail so it stays defined.

thin turret
#

log location.current

#

And see what you get

eternal osprey
#

do i have to pastebin my code?

cinder patio
#

You can put it in the forEach

#

since there is only 1 thumbnail, putting it in the forEach will give you the thumbnail of the last location

#

Or you can get the first location and set the thimbnail to that

#

or you can just not add a thunbnail

drifting wedge
#

random int is a number between 2 vars

#

?

#

or is it one of the 2 vars?

slender thistle
#

random.randint?

drifting wedge
#

yea

#

my bad

slender thistle
#

between

drifting wedge
#

ok great

#

ty

slender thistle
#

I don't remember if it's inclusive or exclusive

drifting wedge
#

ehh its ok

#

i dont even know what that means

slender thistle
#

inclusive - randint(1, 10) can return 1 or 10
exclusive - randint(1, 10) cannot return 1 or 10

drifting wedge
#

o ok

#

well i need it to return those

#

well

#

not really

#

im ok

#

its fine regardless

slender thistle
#

Oh yeah it's inclusive

drifting wedge
#

even better

earnest phoenix
#

in CanvasGradient.addColorStop() can i pass a percentage instead of a decimal?

still merlin
#

I want to make a antiswear bot in discord.js but theres one issue, i need to do a trigger command, So none of the anti swear features can be used or deleted until someone with admin permissions type %trigger, and they can disable the anti swear again with %trigger command, Is there any guides or things i can use like a package to do this?

slender thistle
#

A global Map object where key is guild ID and value is a boolean

#

or even a damn array that includes guild IDs where antiswear is on

still merlin
#

alright ty

slender thistle
#

why not, code

drifting wedge
#

how can i combine 2 args?

slender thistle
#

Define "combine"

unique patio
#

Curious if any of you guys tried hosting off a phone before and noticed idling properties, but once kicked in, no issues?

drifting wedge
#

like so wihout quotes

#

have like a bunch of args be one

unique patio
#

Running several bots off my samsung and it works great till it goes idle for 20-30 mins 😐

slender thistle
#

Never tried hosting on a phone, personally. Seems like a pain in the ass to do to an extent GWahreeVampySmug

white drum
#

^

unique patio
#

Nah B! Super-easy

#

Well for android users*

unique patio
#

My hardware tho is giving issues tho, not ideal for it cause of its power-savers/etc.

vale garden
#

plz

white drum
#

Trust me if you don't got enough ram or good enough CPU it's gonna be horrible

earnest phoenix
#

@pale vessel can you use HEX colors in CanvasGradient.addColorStop()

unique patio
#

My projects are always low-ram usage/high calc; generally get away with an arm cpu

#

1-2GB ram

#

my bot only uses 30mb ram

earnest phoenix
#

gradient.addColorStop((1 / 7) * 2,"#4B0082");

drifting wedge
#

have like a bunch of args be one
@drifting wedge

vale garden
drifting wedge
#

?

#

like can anyone help

vale garden
#

lol

#

wat

earnest phoenix
#

@vale garden god stop being a help vampire

white drum
#

@unique patio as well, the more servers your bot is in the more ram it might use

vale garden
#

well

#

its kinda hard

#

this time

#

so

#

i mean the question i have

drifting wedge
#

how can i combine args without quotes

vale garden
#

why do you want to

#

do that

#

lol

unique patio
#

@white drum I haven't noticed that at all, stable ram usage varies on my active memory allocations per server

drifting wedge
#

cuz i do?

vale garden
#

bruh

#

why no quotes

white drum
#

@unique patio understandable

unique patio
#

So if I have 60 servers I allocate ahead the space for them, then it stays fixed entire time, no leaks

#

My issue mostly is my phone goes idle on me, it stays connected but it takes 2-3 seconds extra to get back into the game

#

and post again

white drum
#

I run my bot on my server pc

unique patio
#

I do testing that way and it's flawless

#

so t his is a dumb issue

#

lol

white drum
#

I leave my PC on all the time

unique patio
#

That'd work 😛

white drum
#

If you have issues with that, heroku is a decent free option to consider

weak rain
#
at Client.<anonymous> (/home/container/server.js:93:11)
(node:25) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)```
white drum
#

If you have issues with that, heroku is a decent free option to consider
@white drum

unique patio
#

I generally don't over-kill, so by that I'll run server bare-minimal why run top-end for a low-resource app

weak rain
#

it worked before btw

unique patio
#

So in my case, 2.5-5watts to power the bot 24/7

weak rain
#
    let channel = client.channels.cache.find((x) => (x.id === "709450453699526707"))    
   let data = await canva.welcome(member, { link: "https://cdn.discordapp.com/attachments/702477981570039939/739160066862612631/PicsArt_08-01-10.07.56.png" })
  
  let wembed = new discord.MessageEmbed()
  .attachFiles([{
    attachment: data,
    name: "hello.png"
  }])
  .setColor("RANDOM")
  .setImage("attachment://hello.png")
  .setThumbnail(member.user.avatarURL())
  .setDescription(`** Welcome <@${member.user.id}> To our Server** 
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**Make sure to**
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
** #🌆╎rules Read and Follow our Rules.**
** #🌃╎announcement Be upto date with our Server Updates.**
** #💭╎general-chat Make new friends in the chat and be active.**
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**We hope that u have fun in the server!**
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
**User Join Position - ${member.guild.memberCount}**
**User Joined Discord - ${member.user.createdAt}**`);
  channel.send(wembed)
});```
unique patio
#

vs 60-100w TDP 24/7?

#

maybe 200+ on load

earnest phoenix
#

@weak rain channel is undefined

white drum
#

^

earnest phoenix
#

there is no channel with that id

#

bruh

#

the arrow function is wrong

unique patio
#

true true

earnest phoenix
#

@weak rain it is () => {} not () => ()

#

god

#

these help vampires

unique patio
#

lol

white drum
#

Also it's ==
Not ===

#

It still works but

unique patio
#

no

#

it's true

#

You can use ===

#

it'll compare int/string