#development

1 messages ยท Page 869 of 1

summer torrent
#

inside ()

#

fetchAuditLogs(->here<-)

earnest phoenix
#

hmm thx

high relic
#

I NEED HELP

#

Im a 16YO passionate coder

#

im making a bot

#

it works fine

#

but it cannot do more than 1 process at a time

#

that means it has to complete the task it's doing to process farther info

tight plinth
high relic
#

what can i use instead of time.sleep to give my bot a delay that wont block any commands?

modest maple
#

That command you did will straight up just not work properly

#

you need to have a better knowledge of asyncio if you want to make anything with while loops or doing somthing after X amount of time

high relic
#

doing it for fun actually this doesnt have to be that efficient. It'll be fine how it works now

#

just need it to do delay without blocking inputs

modest maple
#

what i ment by that was it will not work without that knowledge

high relic
#

its working actually ๐Ÿ˜—

#

please help brother

buoyant totem
#

I need some help if anyone is available. Kinda new to discord.js so Id really appreaciate it if you could help

tight plinth
#

ok

buoyant totem
#

Could you join a voicecall?

#

@tight plinth

tight plinth
#

nope

buoyant totem
#

Alright ill try to explain

#

So basically i've got an api that takes a screenshot of a website and then sends that screenshot in chat whenever someone types in that command

#

But I want to add a command that refreshes that screenshot. (takes a new screenshot of the website)

#
const request = require('request');
const fs = require('fs');

request({
    url: "https://api.apiflash.com/v1/urltoimage",
    encoding: "binary",
    fresh: "true",
    qs: {
        access_key: "",
        url: "https://wherethefuckisxur.com/"
    }
}, (error, response, body) => {
    if (error) {
        console.log(error);
    } else {
        fs.writeFile("screenshot.jpeg", body, "binary", error => {
            
        });
    }
});
#

Here's the code which takes the screenshot and sends it over

#

Im guessing I have to make it into a function to actually call it. But im unsure how to do that

tight plinth
#

a new screenshot of the website?

buoyant totem
#

Yes

#

a fresh one

tight plinth
#

wdym exactly

buoyant totem
#

So

#

It takes a screenshot. Im unsure at what times. seems to do it randomly atm

tight plinth
#

the most simple solution is to re execute the code

buoyant totem
#

But that doesnt seem to work

tight plinth
#

put the code in a function and execute it

buoyant totem
#

And how would I do that?

#

Im new to node.js.

#

So unsure about functions

tight plinth
#
function functionname () {
//code
}
functionname()
buoyant totem
#

Ah ok

#

Ty!

tight plinth
#

np

earnest phoenix
#
if(command === "rps")```
#

how can i give a command another name?

buoyant totem
#

So something like this?

#
const request = require('request');
const fs = require('fs');

function refresh (){
    request({
        url: "https://api.apiflash.com/v1/urltoimage",
        encoding: "binary",
        fresh: "true",
        qs: {
            access_key: "",
            url: "https://wherethefuckisxur.com/"
        }
    }, (error, response, body) => {
        if (error) {
            console.log(error);
        } else {
            fs.writeFile("screenshot.jpeg", body, "binary", error => {
                
            });
        }
    });
}
refresh()
summer torrent
#

|| means "or" in javascript

earnest phoenix
#

are you talking to me ?

summer torrent
#

yes

earnest phoenix
#

i tried that

#

if(command === "rps" || "name")

#

it will reply to everything that starts with the prefix

summer torrent
#
if (command === "rps" || command === "anothername") {
}```
earnest phoenix
#

oh

#

worked

#

thanks

buoyant totem
#

@tight plinth I get an error (cannot access 'request' before initialization)

summer torrent
#

return request({

tight plinth
#

^

buoyant totem
#

Ah ty

#

Ill try that

tight plinth
#

function needs to return something

buoyant totem
#

Ah ok

#

Still didnt work. gave me the same error

blazing portal
#

@blazing portal js if (message.author.id == '364836696149458944' || message.author.id == '390969718535618561') { console.log(`Blacklisted, Skipping...`) // or message.channel.send(`rot buddy`) // or message.channel.delete() // or message.author.ban(`noob`) return; }
@earnest phoenix why do you randomly ping me?

buoyant totem
#

Im trying to add it to a command so when I type !refresh it takes a new screenshot but it gave me the same error (cannot access 'request' before initialization)

#

I could send all of the code if that would help

spare goblet
#

it's a scoping issue, not related to return

buoyant totem
#

Are you talking to me?

spare goblet
#

Yes

buoyant totem
#

Ah

#

So how would I do it instead?

spare goblet
#

Did you initialise the variable request multiple times

#

seems like it's in a temporal dead zone

#

but idk

buoyant totem
#

I could send the code over if that would help

spare goblet
#

I guess

#

It doesn't look like the issue is within your codeblock tho

buoyant totem
#

too long jesus

languid dragon
#

put your require statements at the top of the document

#

always

buoyant totem
#
function refresh (){
    request({
        url: "https://api.apiflash.com/v1/urltoimage",
        encoding: "binary",
        qs: {
            access_key: "",
            url: "https://wherethefuckisxur.com/"
        }
    }, (error, response, body) => {
        if (error) {
            console.log(error);
        } else {
            fs.writeFile("screenshot.jpeg", body, "binary", error => {
                
            });
        }
    });
}
#

This is the function

#

And this is the command for it

languid dragon
#

well in the file you sent. your require statements were not at the top

#

put them at the top :)

buoyant totem
#
case 'refresh':
            console.log('refreshing');
            return refresh()
        break;
#

I did

#

They're on the top now

languid dragon
#

well, does it work now?

buoyant totem
#

No

languid dragon
#

what exactly is the error (please send the error)

buoyant totem
#

OOO

#

It works!

#

Tysm!

languid dragon
spare goblet
#

pinkpepe smhmyhead

buoyant totem
#

I really appreciate it

earnest phoenix
#

I would like to know if this module could help me to slow down my foreach

topaz fjord
#

why do you need to slow down your foreach

earnest phoenix
#

Because i need :)

#

I would just like to know if this would help

spare goblet
#

but why

cinder patio
#

I don't think it will

spare goblet
#

sounds like another

#

-xyproblem

gilded plankBOT
#

The XY problem is asking about your attempted solution rather than your actual problem. This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

User wants to do X.
User doesn't know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.
User doesn't know how to do Y either.
User asks for help with Y.
Others try to help user with Y, but are confused because Y seems like a strange problem to want to solve.
After much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn't even a suitable solution for X.

cinder patio
#

I mean, sure but your whole bot will stop executing while it's sleeping mmLol

#

it won't respond to commands

earnest phoenix
#

Kts xy problem exactly ๐Ÿ˜‚

#

Im doing a foreach

#

And i would like to not be that fast

#

LIKE ITS INSTANT

#

I would like to make a 30ms slow down

frail ocean
#

Is it me or is that embed really confusing to understand?

tight plinth
#

it is

topaz fjord
#

I've never said anyone complain about an operation being fast

elder vine
#

It is tho :P

topaz fjord
#

that's what people want

earnest phoenix
#

Its not about being fast

#

its about being too fast

tight plinth
#

confusing embeds = ppl trying to find logic = less questions mmlol

topaz fjord
#

there must be another solution than slowing down a for loop

#

cause that's just stupid

earnest phoenix
#

Nope because its related to discord api

#

I don't want to spam discord api

#

So i want to make a little delay between each actions

tight plinth
#

a foreach loop for what

earnest phoenix
#

For each server , guild size, change a channel name and a voice name

#

If it have too much servers, its not good

spare goblet
#

@earnest phoenix use a for loop

#

then delay it using a promise with a timeout that resolves in x seconds, creating a delay function.

#

rather than a foreach loop :^)

earnest phoenix
#

Im not that pro in nodejs ๐Ÿ˜‚

#

And less in discordJS ๐Ÿ˜‚

spare goblet
#

I'm not either, but what I provided to you is a possible solution to your issue

quartz kindle
#

forEach cannot be delayed, thats why its not good to use forEach with promises

#

you should use a for loop

spare goblet
#

^ basically what i said

earnest phoenix
#

Do you have a simple example please?

#

Or like

#

a website

#

to understand

spare goblet
#

for ( const thing of array ) {
// do something
}

earnest phoenix
#

mhmhmhmhmhmh

spare goblet
earnest phoenix
#

Alright

#

for ( const client of newclient.guilds.cache.get(args[1]) {

}

#

Looks right 4 u ?

quartz kindle
#

no

summer torrent
#

no

earnest phoenix
#

UH ๐Ÿ˜‚

#

Im so sad

spare goblet
#

.... .. w

#

what.

quartz kindle
#

lmao

spare goblet
#

you cannot run .forEach() on an object...

earnest phoenix
#

Of yeah true

quartz kindle
#

i mean, loops are like super basic javascript

earnest phoenix
#

Yeah but im not used to it

quartz kindle
#

you should know how to use them lol

earnest phoenix
#

I always used sleep like that

#

So not that good :/

spare goblet
#

Okay but idk what your problem or what you're trying to achieve again

quartz kindle
#

javascript doesnt have a built-in way to sleep, but you can create one with a promise

spare goblet
#

(is this another xy problem in an xy problem?)

earnest phoenix
#

For each guild > ACTION -> SLEEP 30ms

spare goblet
#

are you trying to mass send announcements in multiple guilds emote41uhm

quartz kindle
#

i understand what you want to do, but you cannot do that with a forEach, you have to use regular loops

earnest phoenix
#

Nope i said i was using this to change the server members count

#
if(collected.content == 0) return message.channel.send("The user didn't answer.")```
I want to do it so if the user didn't respond with "agree" or "decline" in 10 seconds it will send that
#

I said for each cuz idk how to call it

spare goblet
#

Well it should be an array

quartz kindle
spare goblet
#

(of guilds, in this case)

earnest phoenix
#

๐Ÿ˜‚ I fell so stupid..

quartz kindle
earnest phoenix
#

Alright im sure i won't understand XD shame on me

spare goblet
#

client.guilds.cache returns a collection which you can change into an array

#

I mean
you can try actually reading what is sent bunhuhu

earnest phoenix
#
if(collected.content == 0) return message.channel.send("The user didn't answer.")```
I want to do it so if the user didn't respond with "agree" or "decline" in 10 seconds it will send that

@earnest phoenix

spare goblet
#

theres an option in your message collector

#

called time or something iirc

quartz kindle
#

you can actually use a for of loop directly on collections

earnest phoenix
#

yeah

quartz kindle
#

they be smart

spare goblet
#

O really didn't know that POGGY

quartz kindle
#

for of iterates over their entries, so each item will be a [id,object]

#

for in doesnt work tho

earnest phoenix
#

client.guilds.cache returns a collection which you can change into an array
I mean
you can try actually reading what is sent :bunhuhu:

#

Bro that looks hard idk why ๐Ÿ˜‚

#

I never done that lmao

quartz kindle
#

how would you learn if you dont at least read a bit on how things work? lmao

earnest phoenix
#

Im reading ๐Ÿ˜‚

spare goblet
#

No point in coding something that you've already doneโ„ข๏ธ

earnest phoenix
#
if(collected.content !== "agree", "decline") return message.channel.send("The user didn't answer.")```
i want it to answer after 10 seconds
#

reading everything

summer torrent
#

@earnest phoenix show your awaitMessage function

earnest phoenix
#
const filter = m => m.author.id === user.id
    message.channel.send(`${user.username}, please use agree or decline.`)
    message.channel.awaitMessages(filter, {
     maxMatches: 1,
     time: 10000 ```
quartz kindle
#

@earnest phoenix you cant do something !== something,somethingElse

#

you have to do something !== something || something !== somethingElse

#

the || stands for OR

spare goblet
#

Make it so that when it's collected it runs collected.stop() if it's agree or decline

summer torrent
#

just add errors: ["time"] to your function

#

then catch error

spare goblet
#

O nvm ignore me pls

#

just realised you're using awaitMessages

quartz kindle
#

show your full code, you didnt post the last part of awaitMessages and what comes after it

earnest phoenix
#
if(collected.content !== "agree" || collected.content !== "decline") return message.channel.send("The user didn't answer.")```
#

when i reply (with anything) it will send

lusty quest
#

did someone here run a bot inside of a kubernetes? I dont really can get behind how to get different shards for every node

quartz kindle
#

nope, but probably using env vars

cinder patio
#

Itay, I bet collected is a collection, check if collected.size is truthy

quartz kindle
#

^ we need to see more code

#

where do you get collected from?

#

show the full code please

spare goblet
#

You defined message multiple times btw

earnest phoenix
#

i did ?

summer torrent
#
if (!["agree", "decline"].includes(collected.first().content)) {
//code
}```
spare goblet
#

or redefined, more like
might confuse you as you go down the code.

earnest phoenix
#

yeah your right

#

you're

#

lmao

#

i dont think you get me tho
i want to do that if the user doesn't respond with agree or decline within 10 seconds it will respond

spare goblet
quartz kindle
#

you probably also want to add the agree/decline to your filter

spare goblet
#

they want it to respond tho

#

If you filter it out, the bot won't respond to failed responses

quartz kindle
#

i mean filter everything else out

#

because you can respond with anything and it will pass the filter

spare goblet
#

right, but they want it to respond "The user didn't respond" if it wasn't agree or decline

earnest phoenix
#

i want it so the user can respond and nothing will happen, but if he doesnt respond with agree or decline within 10 seconds it will send

quartz kindle
#

but size wont be 0

#

if they respond with anything else

earnest phoenix
#

^

#

thats right

spare goblet
#

That's why they should do

#

(too lazy to retype sorry)

earnest phoenix
#

i tried using that but it didnt work

spare goblet
#

what did you try

earnest phoenix
#

if(!collected.size ||

followed by this chunk of code from nmw03
@spare goblet

spare goblet
#

I mean what did you try

#

I didn't type the entire thing, what did you actually type

earnest phoenix
#
if (!["agree", "decline"].includes(collected.first().content)) {
//code
}```
spare goblet
#

Okay no, you should be doing

quartz kindle
#

if you add it in the filter, wrong answers wont do anything, it will still wait 10 seconds for the right answer
if you add it in the collected.size check, any wrong answer will cancel the waiting and say that the user didnt respond
so basically depends which behavior you want

spare goblet
#

if(!collected.size || !["agree", "decline"].includes(collected.first().content)){
}

earnest phoenix
#

i want it so if he doesnt respond within 10 seconds, it will send the user didnt respond, if he does respond with agree or decline it will do its thing

quartz kindle
#

what if he does respond with something else?

spare goblet
#

^

earnest phoenix
#

it wont count, will wait

spare goblet
#

O

quartz kindle
#

then you have to add it to the filter

spare goblet
#

then just add it in your filter bahahaha

earnest phoenix
#

can i get an example ?

spare goblet
#

i misunderstandโ„ข๏ธ

earnest phoenix
#

lmao atleast you help

spare goblet
#

check if message content is agree / decline

quartz kindle
#

filter = m => m.author.id === user.id && ["accept","decline"].includes(m.content.toLowerCase())

earnest phoenix
#

i used that

#
 const filter = m => m.author.id === user.id && ["accept","decline"].includes(m.content)
    message.channel.send(`${user.username}, please use agree or decline.`)
    message.channel.awaitMessages(filter, {
     maxMatches: 1,
     time: 10000 
    }).then(collected => {
      if(collected.size == 0) return message.channel.send("The user didn't respond.")```
#

is this the right way ?

spare goblet
#

Bro

grizzled raven
#

friendzoned

spare goblet
#

Wait

#

If they didn't respond agree / decline in 10 seconds

#

do you want it to continue waiting?

earnest phoenix
#

no

#

it will respond

spare goblet
#

It will respond what

earnest phoenix
#

the user didnt respond

spare goblet
#

That was NOT what you said

quartz kindle
#

looks correct

spare goblet
earnest phoenix
#

it was

spare goblet
#

You said you will make it continue to wait

earnest phoenix
#

i think u got me wrong

spare goblet
#

Now you're saying that, if they didn't say agree / decline and say something else, it will say "user didn't respond"

quartz kindle
#

continue to wait until the end of those 10 seconds

earnest phoenix
#

If the user responded with anything which is not agree or decline, after the 10 seconds it will say "User didn't respond"
If the user responded with agree or decline within 10 seconds, it will continue

spare goblet
#

...SMH

grizzled raven
#

try it and see if you like it or not

spare goblet
#

Okay no

#

you don't use a filter then mochafacepalm

grizzled raven
#

no use the filter

spare goblet
#

No

#

They sia dthey want it to respond even if the person responds something irrelevant

#

See?

earnest phoenix
#

BRO

grizzled raven
#

user didnt respond should be equivalent to no collects

spare goblet
#

That is not true

#

because they are using awaitMessages

earnest phoenix
#

if he doesnt respond with agree or decline within 10 seconds it will send that he didnt respond
if he did respond with agree or decline it will continue

spare goblet
#

so it will still resolve an empty thing

earnest phoenix
#

thats what i meant

spare goblet
#

Okay but

#

what if they respond with what

#

what happens?

grizzled raven
#

it will filter it out

#

so then it would still be 0

spare goblet
#

IF

grizzled raven
#

therefor replying with user didnt respond

quartz kindle
#

it wont pass the filter, maxMatches wont match, time will continue waiting until the 10 seconds pass

#

after 10 seconds it resolves with an empty collection

spare goblet
#

๐Ÿค  okay I'm leaving this to Tim I'm out

#

I already explained multiple times ๐Ÿค 

grizzled raven
#

oh if thats what you

earnest phoenix
#

if he will respond with what, it will wait until the 10 seconds end

spare goblet
grizzled raven
#

maxMatches only collects that amount of matches

earnest phoenix
#

and if they didnt respond with agree or decline within 10 seconds it will respond

grizzled raven
#

max collects anything

#

so 1 maxMatch would mean one accept or decline

quartz kindle
#

yes, everything else gets ignored

#

so the only possible outcomes will be an empty collection, an accept or a decline

earnest phoenix
#

help what code js let commandfile = bot.commands.get(cmd.slice(prefix.length)); ERROR js TypeError: Cannot read property 'get' of undefined

spare goblet
#

bot.commands is not defined

earnest phoenix
#
module.exports = async (bot, message) => {
    const Discord = require("discord.js");
  
  
    var con = bot.con
      
      con.query(`SELECT * FROM servers WHERE sid = ('${message.guild.id}')`, (err, rows) => {
          if(err) throw err;
  
  
          if (rows.length === 0) {
            con.query(`INSERT INTO servers (sid, name, prefix) VALUES ('${message.guild.id}', '${message.guild.name}', '-')`);
            console.log("New Server ADDED \n Succesfully SAVED!!" )
          } else {
            var prefix = rows[0].prefix
    
            if (!message.content.startsWith(prefix)) return; 
          let messageArray = message.content.split(" ");
          let cmd = messageArray[0];
          let args = messageArray.slice(1);
          let commandfile = bot.commands.get(cmd.slice(prefix.length));
                  if(commandfile) commandfile.execute(bot, message, args, con);
              
          }
        });

//code
}```
#

WHY UNDIFEND

#

it has been good so far

golden condor
#

@earnest phoenix What is undefined

lyric mountain
#

bot.commands is not defined

#

3 messages above

golden condor
#

Where do you define it?

turbid bough
#

in async (bot, message) probably

golden condor
#

I mean bot.commands

#

Is it in your main file?

lyric mountain
#

yeah, iirc bot is the bot object itself

golden condor
#

So

#

Is it like this

lyric mountain
#

bot doesnt naturally have a commands attribute

golden condor
#

bot.commands = new Discord.Collection()

#

Yeah ik

earnest phoenix
#

o shit js bot.commdans = new Discord.Collection(); misspelled

golden condor
#

That will be it

lucid pasture
#

does anyone know how to make your bot not entirely respond to you but just say the message

golden condor
#

@lucid pasture in what context

lucid pasture
#

like it says for example @lucid pasture, Hello

golden condor
#

Yeah

#

message.reply

lucid pasture
#

kk

royal portal
#

can anyone help me with setActivity

#

it stops working after a day

#

there's no errors

#

im using pm2

#

discord.js

#

but then when I use my restart command

#

process.exit

#

it fires the ready event again

#

and it works

#

not sure why it only works for a day

quartz kindle
#

put your activity in the client options

tight plinth
#

please
stop
talking
like
that
plz

quartz kindle
#

otherwise it may be lost if it disconnects and reconnectes

royal portal
#

would i use client.on disconnect?

quartz kindle
#

no

nocturne dagger
#

@tight plinth I am sure they did it unintentionally but you don't need to repeat it to make a point.

tight plinth
#

still

royal portal
#

autoreconnect?

quartz kindle
#

@royal portal js new Client({ presence: { activity: { type: "bla", name: "bla" } } })

#

put it in your client options

#

instead of the ready event

royal portal
#

I dont have the options

quartz kindle
#

just add them

#

to your client

royal portal
#

where

quartz kindle
#

where i said

#

where you do new Client()

#

or new Discord.Client()

#

put that inside Client

royal portal
#

const client = new.Discord.Client(); ?

quartz kindle
#

...

#

show the code where you create your client

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client(new Client({ presence: { activity: { type: "bla", name: "bla" } } }));

new Client({
  presence: {
    activity: {
      type: "bla",
      name: "bla"
    }
  }
})

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
quartz kindle
#

this is your client

#

so add the options inside it

golden condor
#

@quartz kindle setStatus is so gay

#

is there any way to fix it

quartz kindle
#

no idea

royal portal
#

like this

#
const Discord = require('discord.js');
const client = new Discord.Client(new Client({ type: "bla", name: "bla" });

new Client({
  presence: {
    activity: {
      type: "bla",
      name: "bla"
    }
  }
})

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
quartz kindle
#

no

#

just the options

#

instead of Client() its Client({options here})

earnest phoenix
#
const client = new Discord.Client({
  presence: {
    activity: {
      type: "bla",
      name: "bla"
    }
  }
})
hybrid panther
#

I just released my bot a minute ago. How long does it take it to get verified on top.gg?

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client({presence: { activity: { type: "bla", name: "bla" }}});

new Client({
  presence: {
    activity: {
      type: "bla",
      name: "bla"
    }
  }
})

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
quartz kindle
#

@hybrid panther a few days, up to about 2 weeks

hybrid panther
#

Kk

royal portal
#

like that?

quartz kindle
#

no

#

dont remove presence and dont remove activity

#

and remove that extra new Client

#

you didnt close it correctly

#

and make it your Discord.Client

#

jesus

royal portal
#

so i type that in the ()

quartz kindle
#

yes, everything that is inside the ()

royal portal
#

do I need the 'new' part

quartz kindle
#

dude...

#

you already have the new part

#

you already have the Client part

tight plinth
#

quick question with djs : whats the fastest between js message.channel.send(new Discord.MessageEmbed() .setColor("YELLOW") .setTitle:("TEST"))
and js message.channel.send({embed: {color: 0xffff00, title: "TEST"}})

quartz kindle
#

you only need the OPTIONS

#

you only need the part inside the ()

tight plinth
#

in term of "loading"

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client({presence: { activity: { type: "bla", name: "bla" }}});

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
quartz kindle
#

yes, finally

#

now remove the other Client

#

and of course, change "bla" to your activity

royal portal
#

the type is playing listening and watching?

quartz kindle
#

yes

#

@tight plinth the second option is faster

tight plinth
#

ok

quartz kindle
#

by a few microseconds probably

golden condor
#

I am tryna move to mysql db and I'm not sure how to do queries and how to connect to it

#

Well I have a choice of any of these databases

royal portal
#

error

quartz kindle
#

the SQL language is mostly universal

golden condor
quartz kindle
#

the only thing that changes is which library you use, and how the library does the queries

royal portal
#

cannot access client before initialization

golden condor
#

What did you put as the status

royal portal
#

type watching

golden condor
#

The error is very self explanitory

#

You have used client inside the client object

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client({presence: { activity: { type: "WATCHING", name: `${client.guilds.cache.size`}}});

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
golden condor
#

If you wanna show server count or something

quartz kindle
#

that will not work

golden condor
#

On ready

#

type

quartz kindle
#

that can only be used inside the ready event like you had before

royal portal
#

oh

#

well the status stops working after a day

golden condor
#
client.user.setActivity({type: "WATHING",
name: `${client.guilds.cache.size}`})```
royal portal
#

and if i use restart cmd, it comes back

golden condor
#

Yes same here

#

and there is nothing you can do about it

royal portal
#

same for you?

golden condor
#

really

quartz kindle
#

then make an interval where it re-sets the status every 30 minutes

golden condor
#

I wasn't sure how to do that

royal portal
#

var activevar = ["with the &help command.", "with the developers console", "with some code", "with JavaScript"];
var activities = activevar[Math.floor(Math.random()*activevar.length)];
client.on('ready', () => {
client.user.setActivity(activities);
}

#

something like that

quartz kindle
#
client.on("ready", () => {
  client.user.setActivity(...)
  setInterval(() => {
    client.user.setActivity(...)
  }, 1800000)
})```
golden condor
#

yeah but that doesn't keep looping it

quartz kindle
#

it does

#

its an interval not a timeout

golden condor
#

ohhhh

royal portal
#

mine's not changing

#
client.on('ready', () => {
  client.user.setActivity(`test`, { type: 'WATCHING' });
  setInterval(() => {
    client.user.setActivity(`${client.guilds.cache.size} guilds| discord.js `, { type: 'WATCHING'});
  }, 1800000)
});
golden condor
#

I wish dnd would work

#
const client = new Discord.Client({ fetchAllMembers: false, 
  disableMentions: "all", 
  messageCacheMaxSize: 0,
presence: {status:"dnd"} });``` would this show dnd?
royal portal
#

@golden condor does the setInterval work

golden condor
#

yes

royal portal
#

how do you know

golden condor
#

Cos that is a js function

#

so it will definetly work

royal portal
#

would this work

#
client.on('ready', () => {
  client.user.setActivity(`${client.guilds.cache.size} guilds | discord.js`, { type: 'WATCHING' });
  setInterval(() => {
    client.user.setActivity(`${client.guilds.cache.size} guilds | discord.js`, { type: 'WATCHING'});
  }, 1800000)
});
#

and if i put console.log("Logged in") at top will it say that in console every 30 seconds?

elder vine
earnest phoenix
#

how can i reset a quick.db database to a specific servr ?

#

server

green kestrel
#

quick question with djs : whats the fastest between
@tight plinth the second one is shorter, so should be used as its faster to type as long as its still readable

finite bough
#

by deleting it

green kestrel
#

nobody likes to type out, or maintain boilerplate code

finite bough
#

and making a new one

earnest phoenix
#

ill try

tight plinth
#

Ok

earnest phoenix
#

wait um
is dbname.delete even a thing?

#

it doesnt seem to be

finite bough
#

if u do that

#

the whole db will be deleted no?

earnest phoenix
#

and then re-create it

#

but idk if dbname.delete is a real thing cause it doesnt seem to be in docs

finite bough
earnest phoenix
#

bruh

#

of course it wont tho

#

but idk if dbname.delete is a real thing cause it doesnt seem to be in docs

finite bough
#

programming is all about making errors and learning from them

#

if u say it wont work

#

quit programming

earnest phoenix
#

i know it wont work
and i tried it already

finite bough
#

damn deep words

#

xD

quartz kindle
#

so it will only run every 30 minutes

nocturne dagger
#

@finite bough lets keep memes & shitpost to off topic

earnest phoenix
#
  if(command === "reseteconomy") {
    await coins.delete(message.guild.id)
  }```
finite bough
pallid marsh
#

you can also do 1000 * 60 * 30 itll be maybe easier to understand

finite bough
#

@nocturne dagger sure if u can show me the meme thx

#

it is a function

royal portal
#

@quartz kindle so the part after setinterval will run every 30 mins?

quartz kindle
#

the part INSIDE setInterval

royal portal
#

ah ok

finite bough
#

@earnest phoenix can u show the error u get

earnest phoenix
#

im not getting any

quartz kindle
finite bough
#

and its not working?

earnest phoenix
#

no

finite bough
#

hmm

earnest phoenix
#
  if(command === "reseteconomy") {
    db.delete("coins", message.guild.id)
  }```
#

why wont this work

finite bough
#

no errors?

earnest phoenix
#

no errors

finite bough
#

glitch?

earnest phoenix
#

yes

finite bough
#

can u run the command and refresh in the terminal?

earnest phoenix
#

ok

finite bough
#

@quartz kindle quick db uses sql to store data right?

earnest phoenix
#

same thing

finite bough
#

can u try using the message guild id

#

like the number

earnest phoenix
#

same thing

finite bough
#

what did u define the quick db

#

like to add something

#

u do coints.add

#

or db.add

earnest phoenix
#

i tried both

finite bough
#

how about

#

db.delete(message.guild.id.coins)

#

or

earnest phoenix
#

i dont think so

finite bough
earnest phoenix
#

when i add i use coins.add

#

possible

#

ill try

finite bough
#

coints*

earnest phoenix
#

didnt work

finite bough
#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

#

ok lesson 1

#

i would rather use json db than using quick db

golden condor
#

Nah

#

Quick.db doesn't get corrupted

finite bough
#

it corrupts u

placid crown
#

@nocturne dagger is there any way for me to get a custom font onto my bot's page?

nocturne dagger
#

I am not the most skilled in that

#

I cannot answer try someone else.

placid crown
#

thanks for your help ๐Ÿ™‚

finite bough
#

@placid crown only some people can use css and other stuff to customize their bot page

placid crown
#

what do you mean by that @finite bough

finite bough
#

certified bots are among the example

placid crown
#

i am able to edit my page

#

i just don't know enough css to get a custom font on there

#

lol

finite bough
#

hmm

#

what do u need help with tho

#

like

placid crown
#

so i have this font

finite bough
#

fonts?

placid crown
#

in a .otf

#

and i want my bot's name on it's page to be in that font

#

i don't think it's a common font so I can't just put its name in the css

#

i have to give it the file too

finite bough
#

does the font have any name?

#

global name i mean

placid crown
#

Burbank

topaz fjord
#

quick.db

#

what a joke

finite bough
#
@font-face {
  font-family:'Burbank';
}
#

should do it

placid crown
#

really?

#

i'll try it

finite bough
#

i never really used css that much but thats what i found and what makes sense

placid crown
#

nah didn't work

#

i think it's because burbank isn't a well known font

#

so it's necessary to provide the otf file

topaz fjord
#

if it's a custom font you'll have to load it with the url

placid crown
#

thanks i'll try that ๐Ÿ˜„

topaz fjord
finite bough
#
@font-face {
  src: url('link');
}
#

something like that turtle?

placid crown
#

the thing is

#

i need a way to store the font in the url

topaz fjord
#

yes

placid crown
#

i'm confused on how to do that part

finite bough
#

use a vps

topaz fjord
#
@font-face {
    font-family: "Whatever";
    src: url("https://yeet.com/Whatever.ttf");
}
#

it can be a direct https/http

#

and then you just set that as a font for everything

placid crown
#

i'll check it out thanks

true ravine
#

Anyone know what kind of specs the big bots like mee6 and such need for hosting?

finite bough
#

their support servers would know more

topaz fjord
#

mm

true ravine
#

Tru

topaz fjord
#

lots of ram

#

high cpu

true ravine
#

Just curious

cerulean pebble
#

help

#

why NAH ( the users have been counted )

summer torrent
#

show your code

cerulean pebble
#

wait

#
const Discord = require("discord.js");
module.exports.run = async (bot, message, args, command) =>{
//let bicon = bot.user.displayAvatarURL;//
god = bot.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString('en') / bot.guilds.cache.size
god2 = bot.channels.cache.size / bot.guilds.cache.size
god3 = bot.guilds.cache.size / 2500 * 100
var days = Math.floor(bot.uptime / 86400000)
var hours = Math.floor((bot.uptime % 86400000) / 3600000)
var minutes = Math.floor(((bot.uptime % 86400000) % 3600000) / 60000)
var seconds = Math.floor((((bot.uptime % 86400000) % 360000) % 60000) / 1000)
let CPU = Number(Math.round((await new Promise(async r => {
let start = [process.hrtime(),process.cpuUsage()];
await new Promise(r => setTimeout(() => r(),100));
let elap = [process.hrtime(start[0]),process.cpuUsage(start[1])];
r(100.0 * ((elap[1].user / 1000) + (elap[1].system / 1000)) / (elap[0][0] * 1000 + elap[0][1] / 1000000));
}))+'e2')+'e-2')
let botembed = new Discord.MessageEmbed()
.setColor("#FFD700")
 //.setThumbnail(bicon)//
.addField('Bot information',`
Bot name:      \`\`${bot.user.username}\`\`
Bot create at: \`\`${bot.user.createdAt}\`\`
Bot creator: \`\`ใ€ŽShiro-chanใ€\`\`
Code line :\`\`1509\`\`
Total Commands enable : \`\`14/21\`\` 
Premium buy : \`\`2 (after new update)\`\`
Loli girl earning :\`\` 0 USD /count from new update beacause not complete request\`\` 
Top buy (show 3) : 
\`\`1.DemonX : 70 USD (Special pre)
2.Andrey-chan : 69.96 USD (Special pre)\`\` `)
.addField('Bot stats',`
Total:   \`\`${bot.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString('en')} Users |2mins count delay\`\`    
Total:   \`\`${bot.channels.cache.size} Channels\`\`
Total:   \`\`${bot.guilds.cache.size} Servers\`\`
Avg~:    \`\`${god2} Channels/Servers\`\`
Avg~:    \`\`${god} Users/Servers |5mins count delay\`\`       
`)```
#

@summer torrent

summer torrent
#

bot.guilds.cache.reduce((a, b) => a + b.memberCount, 0).toLocaleString('en') is a string

cerulean pebble
#

but i work by devide with channels

#

divide

summer torrent
#

because .size returning as number

cerulean pebble
#

@summer torrent so what i should do

quartz kindle
#

remove toLocaleString

cerulean pebble
#

@quartz kindle remove .toLocaleString('en') right

summer torrent
cerulean pebble
#

@summer torrent @quartz kindle tks

finite bough
#

glitch?

nocturne dagger
#

imagin only having half a gb of ram

quartz kindle
#

its enough ram if you know what you're doing :3

unique nimbus
#

People uses a Raspberry Pi

#

so if you know what you are doing

#

its fine

green kestrel
#

imagine having 64kb of ram and a 2mhz cpu?

cerulean pebble
#

@finite bough heroku

green kestrel
#

that was my first computer

#

๐Ÿ˜„

cerulean pebble
#

i do not have moneyyy

#

poor girll

#

@finite bough bot will auto reset

#

do not worry

finite bough
#

heroku and glitch had same specs

cerulean pebble
#

@nocturne dagger actually have 256 heap ram

quartz kindle
finite bough
cerulean pebble
#

@quartz kindle how

#

it impossible

warm marsh
#

Tim usee a custom lib?

#

Uses*

quartz kindle
#

a modified discord.js lib

finite bough
#
memory: 106.45
cerulean pebble
#

if my bot under 1000 guilds

#

106.45 seems possible

#

use shard = 2 will divide ram / 2 right ?

quartz kindle
#

if you use sharding, you will have two processes

royal portal
#

@quartz kindle for the setInterval, if I have something like ${client.guilds.cache.size} does that refresh it every 30 minutes

#
client.on('ready', () => {
  client.user.setActivity(`${client.guilds.cache.size} guilds | discord.js`, { type: 'WATCHING' });
  setInterval(() => {
    client.user.setActivity(`${client.guilds.cache.size} guilds | discord.js`, { type: 'WATCHING'});
  }, 1800000)
});
quartz kindle
#

so instead of 1 process with 200mb ram, you will have 2 processes with ~150mb ram each

cerulean pebble
#

@quartz kindle ree so 256 / 2

#

fuck

quartz kindle
#

if you use internal sharding in discord.js v12, then you will still have 1 process

cerulean pebble
#

oke

#

if 1 of 2 shard pass limit

#

2 shard will reset right

quartz kindle
#

with normal sharding, the shard would crash, and be restarted yes

#

@royal portal yes

royal portal
#

ah okay

#

thanks

cerulean pebble
#

@quartz kindle where is your bot

quartz kindle
#

wdym where?

#

hosting?

cerulean pebble
#

link

#

i will try to use your bot

#

also hosting

quartz kindle
cerulean pebble
#

reee need certifed from top .gg and discord

summer torrent
quartz kindle
#

i use galaxygate for hosting

cerulean pebble
#

@summer torrent i forget it

#

=)) poor and stupidd girl

#

you have 30 000 users + by me =))

#

tks for support me now i support you

quartz kindle
#

that just means more cpu usage lmao

cerulean pebble
#

@quartz kindle how to use chart command

#

my server is 3000

#

300

quartz kindle
#

check the help command

cerulean pebble
#

but my main server is =))

#

how to use new chard

#

i do not know how to use

quartz kindle
#

in the help command, click charting commands, then click new chart, then click examples

cerulean pebble
#

wow

#

i do not understand

quartz kindle
#

its an Astrology chart

cerulean pebble
#

ree

#

it's so hard for me

finite bough
#

tim 1 thing

#

why no one understands anything u say or do xD

quartz kindle
#

Lol

cerulean pebble
#

i still keep it

#

i will study more

quartz kindle
#

Astrology is the art of reading a person's life using the positions of the planets in the sky

cerulean pebble
#

reee

quartz kindle
#

its widely known as pseudoscience/divination, although those descriptions are not exactly accurate

cerulean pebble
#

this is good or bad

quartz kindle
finite bough
#
let channel = message.mention.channels.first() || message.guild.channels.get(args[0]) || message.guild.channels.find(c => c.name === args[0])
#

^??

quartz kindle
#

looks good

earnest phoenix
#

hehell

#

Why this donโ€™t good ?
if(Guild_Data.get(`${server}.lang`) === "fr") || if(!Guild_Data.get(`${server}.lang`)) {

#

hello im new

#

i just developed a swear filter

finite bough
#
events.js:173
      throw er; // Unhandled 'error' event
      ^
TypeError: Cannot read property 'channels' of undefined
at /app/commands/welcomechannel.js:28:37
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4837:16
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4837:16
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/helpers/promiseOrCallback.js:24:16
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4860:21
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/query.js:4370:11
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/kareem/2.3.1/node_modules/kareem/index.js:135:16
    at processTicksAndRejections (internal/process/task_queues.js:81:9)
Emitted 'error' event at:
earnest phoenix
#

@finite bough define channels

#

Why this donโ€™t good ?
if(Guild_Data.get(`${server}.lang`) === "fr") || if(!Guild_Data.get(`${server}.lang`)) {

amber fractal
#

do you have 2 if statements on the same line?

quartz kindle
#

@finite bough is it a DM?

amber fractal
#

that's not how js works

earnest phoenix
#

yes

#

uh ok

finite bough
#

nope

earnest phoenix
#

so

#

i remove if?

amber fractal
#

if(condition1 || condition 2)

prime cliff
#

You need to remove the second if

earnest phoenix
#

Ok

quartz kindle
#

@finite bough oh, message.mentions

#

you have message.mention

finite bough
#

why do i always make the smallest mistakes possible in history of discord

earnest phoenix
amber fractal
#

you didn't remove a )

earnest phoenix
#

is there a good chance a bot gets added?

amber fractal
#

you close the if then do a ||

earnest phoenix
#

same error

#

its like this

finite bough
#

@earnest phoenix depends upon ur bot

earnest phoenix
#

my bot bans you if you swear

#

and sends you a message

#

uh ok wait

amber fractal
#

show the line you have now

earnest phoenix
#

@finite bough if(//code||//code){//code}

finite bough
#

why did u send me that^?

earnest phoenix
#

oh

mossy vine
#

that would error but sure

amber fractal
#

it was meant for the other person

finite bough
#

and thats a bad function

#

coz many servers allow swearing

earnest phoenix
#

i thought somebody was learning to make an if statement

finite bough
#

so add a function to turn it off atleast

earnest phoenix
#

if oyu dont need a bot dont add it

#

lol

#

but many servers do

#

not

amber fractal
#
if(condition1 || condition || conditionx){

}```
that's if statement syntax (using `or` operators)
next mica
#

how would i do a randomized response for a command in discord.js 12

quartz kindle
#

put all responses in an array

#

then call array[Math.floor(Math.Random() * array.length)]

next mica
#

thanks

summer torrent
#

this is not related with your discord.js version ๐Ÿค”

next mica
#

?

quartz kindle
#

its just javascript

#

will be the same regardless of libraries and frameworks

turbid bough
#

does channel permission overwrites also show current permissions?

#

in code

quartz kindle
#

it should show only permissions that are specific to that channel

#

what you can see in channel permissions on discord

turbid bough
#

ah ok, nvm i cant use that

#

i need to check if a bot has permission in that channel or not

#

or maby i should have just checked if the bot has permission at all and

quartz kindle
#

you can use something like channel.permissionsFor

turbid bough
#

yeah, unfortunately that library does not have that

quartz kindle
#

which library?

turbid bough
quartz kindle
#

ah

turbid bough
#

but just checking role permissions should be enough i guess?

earnest phoenix
#

Im trying to find a way to get a user trought id in voicechat and remove the voicemute

#
 let channel = client.guilds.cache.get("688151170971336735").voiceChannel;
        for (let member of channel.cache.members) {
            if (!member.id == "425328259056664596") { return; }
            member[1].setMute(true)
        }
}
turbid bough
#

or is that the syntax of that language

quartz kindle
#

no, thats incorrect

#

that means NOT member.id EQUALS "xxx"

#

if it doesnt exist, it will turn it into true

#

so the end result is true/false == "xxx"

#

which will never work

earnest phoenix
#

I kinda found a way

quartz kindle
#

what you want is != or !== which means NOT EQUAL

earnest phoenix
#
 client.on('voiceStateUpdate', (oldState, newState) =>  {
if (newState.id = "425328259056664596") {
if (newstate.serverMute == true) {member[1].setMute(true) }
}

});```
#

How can i edit member[1].setMute to user id ?

quartz kindle
#

thats also wrong, youre using =

earnest phoenix
#

fixed

#

the ==

quartz kindle
#

what is member[1]?

earnest phoenix
#

Idk

#

i copied that

#

shall i do

#

client.on('voiceStateUpdate', (oldState, newState , member) => {

#

then just member.setMute(false)

quartz kindle
#

you should stop coding blindly and actually trying to understand what you're doing lol

#

what do you even want to do?

earnest phoenix
#

then unmute him

#

๐Ÿ˜‚

#

I have a coin system and i want the bot to use , for example: instead of 2000, it will be 2,000

quartz kindle
#

you can use .toLocaleString for that

earnest phoenix
#

how can i

turbid bough
#

2000.toLocaleString

quasi forge
#

I was trying to publish my package but I get the following error: -

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/disco-oauth
npm ERR! 404
npm ERR! 404 'disco-oauth@4.2.5' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

I get this error despite the fact that I'm the author and am logged in in the CLI.

turbid bough
quasi forge
quartz kindle
#

@earnest phoenix just use newState.setMute

earnest phoenix
#

Oww

quasi forge
#

Is the Github acquisition of npm the reason behind this issue? @turbid bough

turbid bough
#

no?

#

use that link under

quartz kindle
#

you're trying to publish a package you made?

earnest phoenix
#

ReferenceError: newstate is not defined

quasi forge
#

I am trying to publish some changes to a package I made long ago. @quartz kindle

quartz kindle
#

using npm publish?

quasi forge
#

yes

turbid bough
#

change your npm login registry?

quasi forge
#

hm?

quartz kindle
#

@earnest phoenix you have newState and newstate

turbid bough
#

npm login

quasi forge
#

I've done that

#

That's why the whoami shows my npm username

quartz kindle
#

did you bump the version numbers?

quasi forge
#

wdym by "bump"

quartz kindle
#

change the version numbers to reflect the update

quasi forge
#

yes

earnest phoenix
#

@quartz kindle what do you mean

quasi forge
#

@earnest phoenix lowercase and uppercase s

#

case sensitivity

turbid bough
#

i think he is trying to upload 4.2.5 so yeah its bumped

quartz kindle
#

im not sure, i've never used npm publish directly, i use np to publish mine

earnest phoenix
#
if(args[1] === "all") return coins.subtract(`${message.guild.id}.${pUser.id}`, parseInt(all)).then(message.channel.send(removedallcoinsembed))```
Tried to remove all coins from a user, coins are now stuck on 0
quasi forge
#

Wait what's np?

earnest phoenix
quartz kindle
earnest phoenix
#
if(args[1] === "all") return coins.subtract(`${message.guild.id}.${pUser.id}`, parseInt(all)).then(message.channel.send(removedallcoinsembed))```
Tried to remove all coins from a user, coins are now stuck on 0
turbid bough
#

you might have accidently changed to a github registry i guess

quasi forge
#

ooh

#

I haven't touched the package.json a single bit since the last time I published it @turbid bough

quartz kindle
quasi forge
#

except for the version bump

earnest phoenix
#

oh yeah my bad

indigo folio
#

in d.js, is there a way to check if a voice channel is joinable? for instance, either the voice channel is full or the bot doesn't have permission. i want some error message when someone tries to do that rather than it just being silent
i tried evaluating member.voice.channel but i can't seem to find anything

earnest phoenix
#
if(args[1] === "all") return coins.subtract(`${message.guild.id}.${pUser.id}`, parseInt(all)).then(message.channel.send(removedallcoinsembed))```
Tried to remove all coins from a user, coins are now stuck on 0
#
let all = coins.fetch(`${message.guild.id}.${pUser.id}`)```
quartz kindle
#

wdym stuck at 0

still roost
#

You might get more help from discord servers thats for bot developers

earnest phoenix
#

its now 0
wont change

quartz kindle
#

change by what

earnest phoenix
#
(node:25157) UnhandledPromiseRejectionWarning: TypeError: Target for .subtract(695319481609879582.336885192490745858, NaN) is not a number.
#

the coins

#

if i try to add

#

it wont work now

#

this is the error

quartz kindle
#

you tried to subtract NaN

earnest phoenix
#

but i used parseInt(all)

quartz kindle
#

parseInt(all) is not a number

#

that means all is not a valid number

#

what is all?

earnest phoenix
#
let all = coins.fetch(`${message.guild.id}.${pUser.id}`)```
quartz kindle
#

console.log(all)

ashen hull
#

Hey

quasi forge
#

I'll just use np myself. Thanks for the suggestion @quartz kindle

quartz kindle
#

yeah give it a try

earnest phoenix
#

Promise { <pending> }

#

how can i make it a number then/

quartz kindle
#

@indigo folio voicechannel.joinable

#

@earnest phoenix its a promise, then you need to await it

indigo folio
#

oh shit thanks

earnest phoenix
#

i tried using await

#
(node:25436) UnhandledPromiseRejectionWarning: TypeError: Target for .subtract(695319481609879582.336885192490745858, NaN) is not a number.
topaz fjord
#

how did you try using await

quartz kindle
#

console.log it

topaz fjord
#

send what you did

earnest phoenix
#
 let all = await coins.fetch(`${message.guild.id}.${pUser.id}`)```
#

its null

#

maybe because i have no coins ?

quartz kindle
#

if its null you did something wrong to it

#

or didnt initialize it as 0

earnest phoenix
#

yeah the db crashed after the mistake with all

#

i will redo it

#

working now

#

thanks Tim!

#

btw i tried using .toLocaleString but it says ```js
function toLocaleString() { [native code] }

#
let usercoins = await coins.fetch(`${message.guild.id}.${message.author.id}`).toLocaleString```
#

i used that

#

nvm i did it

#

Where in this i can find when a user is voice disconnected ?

lyric mountain
#

....what is that?

quartz kindle
#

connection and channelID

#

if they exist, the user is connected

#

if they dont exist, the user is disconected

earnest phoenix
#

is there a way to know if the user disconnected or got voice kicked

#

Same for move, moved or changed channel

quartz kindle
#

voiceStateUpdate

earnest phoenix
#

Its not refering like "usermove"

#

or things like that

quartz kindle
#

voiceStateUpdate gives you old state and new state

#

if oldState has a connection, but the newState doesnt have a connection

#

that means the user disconnected

summer torrent
#

you can fetch "usermove" from audit logs

earnest phoenix
#

you'd still have to use the event to know when to fetch it, which voids the use of audit logs in the first place lol

#

Alright so let's pretend i just compare oldState and newState, how can i move my user to oldState*, should i just get client and then move him ?

#

how can i make it so if a number is not a whole number it will return a message?

#

0.50 for example

elder vine
#

.isInteger()

earnest phoenix
#
    guild.fetchAuditLogs({type:20}).then(audit => {
        const executor = audit.entries.first().executor;
        let member = guild.members.get(executor.id)
        if (!config.whitelist && !config.bypass && !config.owner); {
            member.ban({reason:"Unathorized member kicked a user manually."})
        }
    })
    .catch((err) => {
        console.log(err);
    })
});```
elder vine
#

What's the error?

earnest phoenix
#

it does not ban person when they kick

#

1 sec

elder vine
#

You can pass member in the event tho

#

oh wait..

earnest phoenix
#

wym

elder vine
#

Is this discord.js?

earnest phoenix
#

mhm

elder vine
#

Do you have any errors?

quartz kindle
#

there is no guildKickAdd lol

earnest phoenix
#

MEMBER_KICK

quartz kindle
#

there is no MEMBER_KICK

elder vine
#

audit event yes...

earnest phoenix
elder vine
#

That's API docs

#

but yes, it's an discord api event

earnest phoenix
#

link me discord.js

#

rq

elder vine
earnest phoenix
#

doc

#

thanks

quartz kindle
elder vine
#

You might have to change it from stable depending on the version your are using.

quartz kindle
#

there is no kick event

finite bough
#

u have to get the kick from audit no?

earnest phoenix
#

How can i check if a number is a whole number?
I tried using .isInteger but it doesn't seem to be working?

quartz kindle
#

audit logs are not client events

finite bough
#

@earnest phoenix those are audit log events

earnest phoenix
#

yeah

#

1sec i am checkin

#

discord.js doc

finite bough
#

yes

quartz kindle
#

guild.fetchAuditLogs

elder vine
#

The number must be inside ()

#

Number.isInteger(0) //true
Number.isInteger(0.5) //false
Number.isInteger('123') //false

earnest phoenix
#

this weird lmao

finite bough
#

uses NaN

earnest phoenix
#

Alright so let's pretend i just compare oldState and newState, how can i move my user to oldState*, should i just get client and then move him ?

#

(repost)

finite bough
#

uh wdym

earnest phoenix
#

@elder vine i used it but now whatever number i use it will say its not a whole number?

finite bough
#

hmm

#

try using NaN

#

wait

earnest phoenix
#

no

#

nan is for letters

elder vine
#

isNaN is for letters yes

earnest phoenix
#

isnt it ?

#

oh yeah

elder vine
#

isInteger should work

earnest phoenix
#

i tried but it wont work

#

i used 1

#

so

finite bough
#

what are you trying

earnest phoenix
#

if a number is not whole, return message

finite bough
#

like if its 1 then nothing and if its like a then return?

elder vine
#

if (Number.isInteger(args[0])) return;

earnest phoenix
#

i tried that

#

if(Number.isInteger(parseInt(bet))) return message.channel.send("T")

#

bet is args[1] btw

elder vine
#

if (Number.isInteger(args[1])) return;

#

Try this then

earnest phoenix
#

ok

peak quail
#

when i log req.ip in express i get ::ffff:<xxx>.0.0.1
but when i look to my ip in a website like http://api.ipify.org/ it shows a other ip ๐Ÿค”

earnest phoenix
#

it still works

#
if(Number.isInteger(args[1])) return message.channel.send("T")```
#

i used 100.5

#

and it worked

elder vine
#

Can't you just use Math.floor()?

finite bough
#

hmm

elder vine
#

or Math.round()

finite bough
#

i would use typeof in most cases

earnest phoenix
#

idk im asking u ho

#

w

quartz kindle
#

wdym it still works

#

does it not say T?

earnest phoenix
#

no

quartz kindle
#

args[1] is a string, not a number

#

you need to convert it to a number first

earnest phoenix
#

oh