#development

1 messages · Page 938 of 1

earnest phoenix
#

your missing 1 ending parenthesis

#

from fs.writeFile

#

your code editor is supposed to tell you this

rain jacinth
#

that's atom..

earnest phoenix
#

oh

rain jacinth
#

So did i do it right or wrong?

tight plinth
#

Use visual studio code, it tells you if there is a error

#

And (most of the time) how to fix it

hoary elm
#

@rain jacinth I want to say that's for the channel line

amber fractal
#

you never closed your (

tight plinth
#

You still forgot a) after JSON.stringify(...)

hoary elm
#

^

rain jacinth
#

better?

tight plinth
#

No

#

It should be JSON.stringify(code))

#

Oh nvm

#

Should be good

#

Try again

rain jacinth
#

i did and it still won't switch to the log i want it to..

tight plinth
#

?

#

Also, why using json as database?

rain jacinth
#

i'm trying to do a custom log channel

#

because i can

tight plinth
#

Use quick.db

#

It's way better

rain jacinth
#

got no idea what that is

tight plinth
lean sonnet
#

i have problem

#

suggest*

#

I want my bot to react when I react

nocturne grove
#

Hey. What's the reason message.author.locale is undefined? I saw the ? in the docs but why is it not always there?

earnest phoenix
#

One message removed from a suspended account.

rain jacinth
#

There's a problem in one of your commands maybe

#

Idk check the command you were recently working on

earnest phoenix
#

how to solve: Define name

#

One message removed from a suspended account.

#

One message removed from a suspended account.

fallow steppe
earnest phoenix
#

One message removed from a suspended account.

#

@fallow steppe wrong formatting

#

show us da code

fallow steppe
#

One sec

earnest phoenix
#

One message removed from a suspended account.

gilded ether
#

i would rather use ${}

fallow steppe
#

I can't ss everything because I'm on mobile. One moment

earnest phoenix
#

pasting the code also works, just remove private stuff GWowoHehe

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

I have a problem, suddenly my bot stopped working and now is not starting anymore, any idea why ?

fallow steppe
#

I can't because I cant select anything in glitch

earnest phoenix
#

One message removed from a suspended account.

fallow steppe
#

Ill try, a sec

earnest phoenix
#

One message removed from a suspended account.

fallow steppe
#

exports.run = (client, message, args) => {
  let days = Math.floor(client.uptime / 86400000);
      let hours = Math.floor(client.uptime / 3600000) % 24;
      let minutes = Math.floor(client.uptime / 60000) % 60;
      let seconds = Math.floor(client.uptime / 1000) % 60;
       
 let  arr = [1, 2, 3, 4, 5, 6, 9, 7, 8, 9, 10];
arr.reverse();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
  message.channel.send({embed:{
    title:`Test Bot's stats`,
    color:0xFFA07A,
    fields:[
      {
        name:'Uptime',
        value:`${days} days ${hours} hours ${minutes} minutes ${seconds} seconds`
      },
      {
        name:'General stats',
        value:`-Guilds: ${client.guilds.cache.size}
-Members count: ${client.users.cache.size}
-Memory usage:' + 'Math.round(used * 100) / 100' + 'MB'
      },
      {
        name:'Bot owner and developer',
        value:'Sandra#3781'
      }
      
    ]
    
  }})
  
  
}```
#

Had to copy it cause can't screenshot

#

@earnest phoenix ^

sterile mesa
#

.setFooter(client.user.displayAvatarURL())
Can someone help me?
I tried to add avatar image but it gives url

earnest phoenix
#

well as far as i can understand js, it think this is formatted wrong

const Discord = require("discord.js");

exports.run = (client, message, args) => {
 let days = Math.floor(client.uptime / 86400000);
     let hours = Math.floor(client.uptime / 3600000) % 24;
     let minutes = Math.floor(client.uptime / 60000) % 60;
     let seconds = Math.floor(client.uptime / 1000) % 60;
      
let  arr = [1, 2, 3, 4, 5, 6, 9, 7, 8, 9, 10];
arr.reverse();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
 message.channel.send({embed:{
   title:`Test Bot's stats`,
   color:0xFFA07A,
   fields:[
     {
       name:'Uptime',
       value:`${days} days ${hours} hours ${minutes} minutes ${seconds} seconds`
     },
     {
       name:'General stats',
       value:`-Guilds: ${client.guilds.cache.size}
-Members count: ${client.users.cache.size}
-Memory usage:' + 'Math.round(used * 100) / 100' + 'MB'
     },
     {
       name:'Bot owner and developer',
       value:'Sandra#3781'
     }
     
   ]
   
 }})
 
 
}```
quartz kindle
#

you're making them strings

sterile mesa
#

Help me to convert the url to image

earnest phoenix
#

^

#

you need to have a name

#

then pass the avatar url

#

along with the name

wary valve
#

what is a avatarurL? OwO

quartz kindle
#

@fallow steppe there are two ways of mixing strings and variables, one is concatenating, the other is templating

// concatenating
"my string" + Math.round(number) + "another string"

// templating
`my string ${Math.round(number)} another string`
``` notice the difference in quoting
fallow steppe
#

I see

earnest phoenix
#

My bot doesn't start anymore, any idea why ?

fallow steppe
#

So I'd have to use quotes instead of inverted comma?

quartz kindle
#

if you want to use concatenation, you can use whichever you want, but you have to stop the string, use the plus signs, then start another string

fallow steppe
#

I see

#

Alright thanks

quartz kindle
#

if you use templating, you dont need the plus signs, instead you use ${} around it. templating can only be done with backsticks/inverted comma

earnest phoenix
#

My bot suddenly stopped working, it actually doesn't start, any idea why? I didn't change anything about it except for some embeds

quartz kindle
#

without any code or error, its impossible to know why

earnest phoenix
#

errors?

#

No errors

#

in console i got nothing

#

All clear

#

then you don't handle your errors properly

#

it worked 5 minutes ago

quartz kindle
#

are you using glitch?

earnest phoenix
#

i don't even got the bot.ready message

#

Yes

quartz kindle
#

add a client.on("debug",console.log)

earnest phoenix
#

anywhere?

quartz kindle
#

anywhere

#

in your main file

#

just not inside another event lol

earnest phoenix
#

i got something in the console

quartz kindle
#

what is it

earnest phoenix
#
Provided token: Njg3OTk2OTYxMjk4NTc5NDk0.XsbDwA.***************************
Preparing to connect to the gateway...
[WS => Manager] Fetched Gateway Information
    URL: wss://gateway.discord.gg
    Recommended Shards: 1
[WS => Manager] Session Limit Information
    Total: 1000
    Remaining: 0
[WS => Manager] Spawning shards: 0
[WS => Manager] Exceeded identify threshold. Will attempt a connection in 7027324ms
quartz kindle
#

you reached your daily session limit

earnest phoenix
#

wtf are you doing to cross the 1k IDENTIFY limit

#

How do you await DM messages discordjsv11

quartz kindle
#

your bot will work again in approx 2 hours

#

which is when the limit will reset

earnest phoenix
#

isn't it 4

#

3*

quartz kindle
#

well i did time / 1000 / 60 / 60 and got 1.9

earnest phoenix
#

did you do it in UTC though

quartz kindle
#

wat

earnest phoenix
#

oh wait

quartz kindle
#

xD

earnest phoenix
#

i thought the timestamp in "will attempt connection" was something d.js was doing, not what discord returned

#

my b

quartz kindle
#

@earnest phoenix you should be able to use channel.awaitMessages the same way you do in guilds

earnest phoenix
#

Hey

#

For some reason when I try to post my sever on the website it doesnt allow me. Can someone help?

#

@quartz kindle i reached the limit maybe because my friend spammed with some bots ( old accounts tokens ) commands on my bot?

hardy vector
#

is a 1gb SSD vps good enough for a bot

earnest phoenix
#

Thats technically not a vps, its just something like glitch

white anvil
#

256mb is nothing for a discord bot

#

most bots in more than like 50 guilds will use more than this

#

unless you optimize

earnest phoenix
#

theres still a bunch of actual vps providers with decent vps servers under 10$

gilded ether
#

Digital Ocean is a good choice

fleet sphinx
#

OVH ( Best anti ddos ) Scaleway ( One Provider ) best support

earnest phoenix
#

private-hosting is the one i use, but theres several others

#

contabo and oneprovider are also good ones

white anvil
#

ovh has disadantage that their ips are banned from a lot of services

#

but if ur just hosting discord bot this isnt an issue

modest maple
#

Scaleway's support is hot shit

#

On several occasions we've had vm instances freeze and them take 6 hours just to say "we dont know"

fleet sphinx
#

If you want a smaller server Kimsufi ( OVH server ) & SoYouStart ( OVH too )

modest maple
#

then take another 4 hours to say "Nothing we can do other than hope"

fleet sphinx
#

On several occasions we've had vm instances freeze and them take 6 hours just to say "we dont know"
@modest maple Yep scaleway very bad, but Online its ok

modest maple
#

OneProvider is alright but yh scaleway is just

#

the big shit

#

Contabo is probably the best support ive seen so far

astral yoke
#

question

#

if i have this

#
            guild: message.guild,
            textChannel: message.channel,
            voiceChannel
        });```
#

how come it errors

#

at

#

(node:563) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'players' of undefined

#

this is the code its my play command

sudden geyser
#

is bot.music a property?

astral yoke
#

I believe so

#
at Object.run (/app/src/commands/music/play.js:20:34)```
#

I think I know why

earnest phoenix
#

whenever im doing my styleing for my bot page I cant change the content box, when i change the longdescription it only changes the borders and when i change the div content nothing happens

opaque seal
#

How can I make my bot send a message each day at a certain time of the day?

nocturne grove
#

Hey. What's the reason message.author.locale is undefined? I saw the ? in the docs but why is it not always there?

earnest phoenix
astral yoke
#

now i have this error

#
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 2333 }```
#

I don't understand it

earnest phoenix
#

glitch?

astral yoke
#

yes

earnest phoenix
#

The Connection is being refusedf

nocturne grove
#

Ohh thank you @earnest phoenix

astral yoke
#

How do I fix it?

earnest phoenix
#

I dont use glitch so give me a minute

#

Try remixing project

#

@astral yoke are you trying to connect to a local host?

astral yoke
#

Yes.

earnest phoenix
#

and where exactly is that happening

#

thats why

#

it wont work

#

aka for what are you connecting to localhost?

astral yoke
#
      { "host": "localhost", "port": 2333, "password": "Stringer1212" }
    ]```
earnest phoenix
astral yoke
#

damit

#

i leaked my password

#

welp changing that

#

lmao

#

goodluck with that pw

earnest phoenix
#

GWhurpyShrug nobody cares anyway lol

#

^

#

as long as we dont have your host

#
  • its a local host so we cant unless you ip foward
astral yoke
#

So in that support thing

#

it says to get the ip of the database

#

but im not using it for a database

#

im using it to play music?

earnest phoenix
#

its the same base issue

#

you need to connect to glitch not a local host\

astral yoke
#

so I need to find glitch ip or what?

earnest phoenix
#

something along those lines

astral yoke
#

url: 'ws://localhost:3000/',

#

So I need to attempt to change that to glitch?

earnest phoenix
#

you also need the IP i beleive

#

test it yourself

#

i dont use glitch so i dont know

astral yoke
#

@earnest phoenix ^?

#

welp

#

now i have this error

#
    at ClientRequest.req.on (/rbd/pnpm-volume/8026e4ea-29c1-4714-8479-5e7241f9946b/node_modules/erela.js/node_modules/ws/lib/websocket.js:579:7)
    at ClientRequest.emit (events.js:189:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
    at Socket.socketOnData (_http_client.js:442:20)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:94:17)```
earnest phoenix
#

wait for someone who actually uses glitch

#

ye

mossy vine
#

error: success

#

okay then

earnest phoenix
#

when even the server doesn't expect it working

astral yoke
#

actually ima go to my friend

#

ik he uses glitch with a music bot

#

ty

earnest phoenix
#

i can do ```js
client.login(["SecretToken1", "SecretToken2"])

#

well :v

mossy vine
#

@earnest phoenix what are you trying to do

earnest phoenix
#

2 bots in 1 proyect

sudden geyser
#

Why

astral yoke
#

thats useless

mossy vine
#

create 2 client objects

earnest phoenix
#

but why would you want 2 bots in one?

#

like

const client ....
const bot ....```
@mossy vine?
mossy vine
#

yes

wheat jolt
#

yes

earnest phoenix
#

ok

#

still, ytho

#

thanks

astral yoke
#

ok so anyone who hosts on glitch able to help

#

ping me 🙂

honest perch
#

what would message.guild.channels.forEach be equivalent to in v12

earnest phoenix
#

message.guild.channels.cache.forEach

honest perch
stable nimbus
#

Question, how would I have my bot detect the server name and use it in an embed?

earnest phoenix
#

library?

stable nimbus
#

JavaScript in V12.2.0

honest perch
#

afaik

stable nimbus
#

Okay?

earnest phoenix
stable nimbus
#

Thank you hope.

stoic arrow
#

How to make shards if I use discord.py and already have bot maked on cogs?

#

I want to test shards on my raspberry pi before something more powerful

astral yoke
#

i have this in my bot config

   { "host": "localhost", "port": 8080, "password": "yeeeyeepasswordtotallyit" }
 ]```
but with glitch
you cant use local host so what do I change it to/make it work with
stoic arrow
#

I would have to have a comprehensive guide because I don't know where to start at all

dense finch
#

salutt

#

Oh shit

lyric mountain
#

wrong channel lads

dense finch
#

Bon bye

indigo flax
#

anything wrong with this?

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
green vale
#

How can I catch an error from a const variable that awaits something? (Node)

rocky solstice
#

You can use try.

green vale
#

Can I do that with a const variable?

#

Or just any variable*

rocky solstice
#

Declaring the variable inside try.

#

And.

#

Yes, I guess.

green vale
#

Wait--so if I declare the variable inside try, can I use it outside of the try statement?

sterile mesa
#

Nani for richembed ( acutally its v12 idk if its v11 )

green vale
#

v11 is okay, I use v12

sterile mesa
#

So many people still using v11

#

:0

faint token
#

is it hard to make a setprefix with mongodb?

sterile mesa
#

No

faint token
#

ok

sterile mesa
faint token
#

ok thank

sterile mesa
#

Just copy mongodb tutorial on yt and modify it

unique nimbus
#

What

#

No

#

Don't copy a mongodb tutorial if you don't understand what it does

#

Literally

sterile mesa
#

Yes its the easiest way

#

mongodb money database tutorial

unique nimbus
#

Which teaches you fucking nothing

sterile mesa
#

into prefix

unique nimbus
#

Literally learn how they do it

#

what shit does

#

legit

#

not copy paste

sterile mesa
#

They dont even add source file

#

or source code

#

just follow

#

;;=;;

unique nimbus
#

You don't take the fucking source code and call it yours

#

bruh

#

Legit

#

that is not coding

sterile mesa
#

who said its mine

unique nimbus
#

Why are you stating to copy shit from YouTube then when its common sense

#

that it nearly teaches you NIL

sterile mesa
#

Because no one teach me irl

faint token
#

can u send a discord.js for mongodb

unique nimbus
#

Get fucking websites which tells you WHAT IT DOES

#

AND HOW IT DOES IT

sterile mesa
#

oh its python then ill head out

unique nimbus
faint token
#

ok thank

sterile mesa
#

im pretty sure i downloaded mongodb

unique nimbus
#

Don't copy paste it, read what it does and how it does it

sterile mesa
#

The guy said just copy this from mongodb source and paste it here and make other things

#

He dont even say if i must include err in mongoose.connect

faint token
#

i dont copy

sterile mesa
#

I just follow

unique nimbus
#

Following what they do and not understanding is useless

sterile mesa
unique nimbus
#

Again

#

You don't learn anything from modifying

sterile mesa
#

Following what they do and not understanding is useless

unique nimbus
#

yes

sterile mesa
unique nimbus
#

Literally

#

It is useless

#

if you take someones code

#

and not understand it

magic jackal
#

Yikes awkwardflushed

sterile mesa
#

I dont even understand what's he talking about just follow his money database tutorial and modify some

unique nimbus
#

MATE

#

YOU NEED TO UNDERSTAND

#

WHAT IT DOES

#

YOU ARE NOT CODING OTHERWISE LMAO

magic jackal
#

lol

dusty onyx
#

in discord.py, how would you get the voice channel without an initial user sent message? usually i have voice = message.author.voice but it doesn’t work as i wish to play audio in the middle of a game, when only the bot has been sending messages. any ideas bc i’m stumped haha

magic jackal
#

@unique nimbus Imagine this, git clone <repo> && npm run KEKW

unique nimbus
#

yes

sterile mesa
#

I just need some good translator

#

app

unique nimbus
#

wdym translator app

sterile mesa
#

Im bad at English

gilded ether
#

google translate dude

magic jackal
#

What are you trying to do anyways? This is Mongo. You're looking for a key that probably doesn't exist, so that's going to crash unless you catch it and insert the missing key

sterile mesa
#

It sucks give false one - google translate

unique nimbus
#

bruh

faint token
#

wat would u do if everyone just copy everyone repo

#

and dont put work into their own

magic jackal
#

@faint token Makes me want to go closed source.

unique nimbus
#

Watch them fail

#

If they take code

#

and not understand it

#

They will fail

#

and I will laugh

#

c:

faint token
#

yes

sterile mesa
#

just find the solution

magic jackal
#

just find the solution

#

hahahaha

faint token
#

Closed Source = Good

gilded ether
#

some people who are bot developers usually don’t develop their own shit 🤡

dusty onyx
#

i feel like yall should calm down a bit 😳

sterile mesa
#

I did copy from closed source

gilded ether
#

bro

sterile mesa
astral yoke
#

dont fucking talk to me

faint token
#

ok i would calm down

#

i am done here

magic jackal
#

same

dusty onyx
#

if they wanna copy code n understand nothing then that’s ultimately their problem

sterile mesa
#

I dont copy all i made some by seeing those djs page

twilit rapids
#

Can you all calm down, thank you.

sterile mesa
#

because transforming v11 to v12

faint token
#

me calm

sterile mesa
#

Im calmpogey

valid frigate
#

v12 is unstable but i feel like if u learn v12 right now you will have a much better time in the future

magic jackal
#

Good news boys, sharding is working now and ready for my framework :)

valid frigate
#

ok gl

sterile mesa
#

i use v12 and yt videos mostly are v11

valid frigate
#

???

dusty onyx
#

imma go ahead and repost my question now sksj

magic jackal
#

v12 is fairly new as well

valid frigate
#

v12 has been around for a looooong time

sterile mesa
#

i need to try to fix it all by using ?docs command on djs discord serv

magic jackal
#

Sorry I meant the brand new update

valid frigate
#

oh is it stable now

#

finally

quartz kindle
#

been stable for a few months lol

valid frigate
#

yo pog

sterile mesa
#

;;;---;;;

dusty onyx
#

in discord.py, how would you get the voice channel without an initial user sent message? usually i have voice = message.author.voice but it doesn’t work as i wish to play audio in the middle of a game, when only the bot has been sending messages. any ideas bc i’m stumped haha

modest maple
#

guild VoiceState

#

well actually

#

get the guild's voice client

digital ibex
#

hi

#

why does let e = require('ms'); e(message.member.createdAt) respond with 47 years?

pale vessel
#

¯\_(ツ)_/¯

sudden geyser
#

createdAt is a timestamp (in Discord.js it's a date, but in Eris it's a string) from the start of 1970.

junior prawn
#

hi

quartz kindle
#

and "ms" returns the amount of time the input represents

digital ibex
#

so uh

#

what can i do to format it?

quartz kindle
#

what do you want to format it as?

digital ibex
#

do i need to convert it into a unmber, then do e(..)

#

something like

quartz kindle
#

you want to know how long ago the member was created?

digital ibex
#

yeah

#

and it responds with years (if years), days (if days) and hours & minutes

quartz kindle
#

member.createdTimestamp = timestamp of when the member was created
Date.now() = current timestamp
Date.now() - member.createdTimestamp = difference between now and the creation date, aka how long ago it was

digital ibex
#

oh

#
let e = require('ms'); e(Date.now() - member.createdAt)
#

?

quartz kindle
#

better to use createdTimestamp in this case, since it returns the timestamp as a number, while createdAt returns it as a Date object

digital ibex
#

createdAt returns a timestamp

#

in eris

quartz kindle
#

ah ok

#

then yes

digital ibex
#

oki, thanks

pale vessel
#

ah you're officiallylost

astral yoke
#

what does this error mean

#

Oops! Error: Client network socket disconnected before secure TLS connection was established

pale vessel
#

bro no star

astral yoke
#

why not

turbid bough
#

it means you .close() before you get a tls connection

astral yoke
#

I know im retarded for this

#

and Ik it isnt how it really works

#

but how can I make this work

#
const config = require("../../../botconfig.json"); 

module.exports = {
    config: {
        name: "givepremium",
    },
    run: async (bot, message, args) => {
if (ownerid.includes(message.author.id)) {
  let premium = bot.db.set(`premium_${message.guild.id}`)
  message.reply("set this server with premium! Congrats! :)")
}
    }
}```
#

you guessed it

#

No value specified

earnest phoenix
#

my bot now has e🅱️ic spam command that requires manage roles

turbid bough
#

um, im not gonna diss much, but
why does your comment say //get ownerid from botconfig file
when requiring from ../../loaders/reader
and right under that comment you are using
const config = require("../../../botconfig.json");

astral yoke
#

because i use the same format of the tops for all my owner commands

vapid rune
earnest phoenix
#

i think so, not sure tho

vapid rune
#

ok, just to be safe i'll turn it on

earnest phoenix
#

Türkçe botlar ne sıklıkla onaylanıyor?

zenith orchid
#

@earnest phoenix, #general for questions.

fallow steppe
#

How do I extract a variable value? ( in js )

#

@ in response please

quartz kindle
#

@fallow steppe example?

fallow steppe
#

Example I have a variable that has your economy amount ( like gambling gives you 100 ), wht'd be the method to show this value and modify a variable value?

quartz kindle
#

you mean this? ```js
let a = 100;
console.log(a) // show 100 in console
message.channel.send(a) // send 100 as a message
a += 100 // add 100 to a, so it becomes 200
console.log(a) // show 200 in the console

fallow steppe
#

Not in console, just a variable within the bot itsself

#

Ex. My bot has a command called work and gives generated amount for ex 100, I'm not sure how do I modify a variable so it sums your balance with what's generated

steel drum
#

thats

#

what database are you using

#

/ how are you saving your data?

fallow steppe
#

Glitch

quartz kindle
#

variables can be modified in any way, for example a += 10 is the same as a = a + 10

steel drum
#

^

fallow steppe
#

I see

steel drum
#

you could do a= 123412312321312

#

then do a = 1

fallow steppe
#

What'd 'a' be though?

quartz kindle
#

the balance

fallow steppe
#

Ah

steel drum
#

you can name it anything

fallow steppe
#

Alright thanks

quartz kindle
#

if the user's balance is 100, and you do balance = balance + 50

steel drum
#

be mindful

quartz kindle
#

the balance becomes 150

steel drum
#

the values

#

will change when you reset the bot

quartz kindle
#

yes, all variables are in-memory only, they are destroyed when the bot's program exits or restarts

steel drum
#

^

#

hence why you should save them SOMEHOW

fallow steppe
#

Oof rip

steel drum
#

even if its txt / json files

fallow steppe
#

How so?

steel drum
#

thats better than nothing

#

there are a variety of ways

#

you could use mysql, mariadb, mongodb, postgresql, txt files, json files

#

its up to you to decide

fallow steppe
#

Yeah I use json files on the bot

steel drum
#

assuming you are using javascript

#

you could use the fs module to read and save json files

#

id advise against that however

fallow steppe
#

Alright

quartz kindle
#
thisIsMyVariable = 200; // value is 200
doSomeCommand() {
  thisIsMyVariable += 100; // value is now 300
}

// bot restarts
thisIsMyVariable = 200; // value is 200 again
doSomeCommand() {
  thisIsMyVariable += 100; // value is now 300
}



// with files
thisIsMyVariable = require("./somefile") // value is whatever it is in the file, for example 200
doSomeCommand() {
  thisIsMyVariable += 100; // value is now 300
  fs.writeFileSync("./somefile", thisIsMyVariable) // save 300 in the file
}

// bot restarts
thisIsMyVariable = require("./somefile") // value is still 300 because it was saved in a file
doSomeCommand() {
  thisIsMyVariable += 100; // value is now 400
  fs.writeFileSync("./somefile", thisIsMyVariable) // save 400 in the file
}
valid frigate
#

do bot clients need to enable presence intents to set their game status

#

been thinking about this one

#

if so that sucks tbf

gilded ether
#

hopefully not

zenith terrace
#

@jovial kayak I found this

JDABuilder.setActivity(Activity.playing("Thrones"))```
jovial kayak
#

THANK YOU SO MUCH

#

where did you find it?

zenith terrace
#

online lol

jovial kayak
#

What does this mean?

pale vessel
#

it's a bot

topaz fjord
#

hover over it

arctic juniper
#

I need a help can anyone help me?

white cloak
#

Hola, alguien que juegue fort y hable español el costa este?

winter basalt
#

@arctic juniper mention your problem dont ask2ask

willow sparrow
#

So I have a database for levels and want to know if there’s a way I can have my bot figure out who has the highest the second highest then 3rd highest level and then fetch their ID to put into mention form (<ID@>)

#

for a leaderboard

#

I currently have a database in a JSON file

earnest phoenix
#

please tell me why console.log(bot) makes my process lag

valid frigate
#

you what

#

you're logging your entire bot class probably that's why

#

and iirc it's massive

copper cradle
#

@white cloak este no es el canal para eso, ve a #memes-and-media y además este no es un servidor para fortnite, lee el nombre del server, ve a #memes-and-media para español

rain jacinth
pine bear
#

imagine being an idiot and not adding

{
  "install": {
    "include": [
      "^package\\.json$",
      "^\\.env$"
    ]
  },
  "restart": {
    "exclude": [
      "^public/",
      "^dist/"
    ],
    "include": [
      "\\.js$",
      "\\.json"
    ]
  },
  "throttle": 900000
}
``` when hosting a bot on glitch
#

I was that idiot 😂

rain jacinth
#

.

merry edge
#

TypeError: message.channel.sendmessage is not a function at Client.<anonymous> (C:\Users\ianab\Desktop\discord bot\index.js:18:29) at Client.emit (events.js:310:20) at MessageCreateAction.handle (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31) at WebSocketShard.onPacket (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22) at WebSocketShard.onMessage (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10) at WebSocket.onMessage (C:\Users\ianab\Desktop\discord bot\node_modules\ws\lib\event-target.js:125:16) at WebSocket.emit (events.js:310:20) at Receiver.receiverOnMessage (C:\Users\ianab\Desktop\discord bot\node_modules\ws\lib\websocket.js:800:20)

#

what does this mean

hoary elm
#

@merry edge I'm pretty sure it's sendMessage capital M and I'm also pretty sure that's Deprecated you can still use it but most common method now is just message.channel.send

merry edge
#

thanks

#

but i just fixed someone and now its saying one sec

hoary elm
#

Might be because you havent finished the if statement 🤔 other then that I'm honestly not to sure not really familiar with that command layout.

merry edge
#

ill try that

dusky marsh
#

yes its because you havent finished the if statement.

hoary elm
#

Yeah I thought so

merry edge
#

thank you both really means a lot

hoary elm
#

Np

pine bear
#

now it says invalid token? i know it read the token, but then it just says invalid? ;-;

hoary elm
#

@pine bear Refresh your bot token and re add it to the project usually helps if you are positive it's reading it/you added it properly 🤔

pine bear
#

it works while self hosting the code

hoary elm
#

Yeah glitch has done that to me a few times

#

But then if I refresh the token it's fine

pine bear
#

I'll try, thanks

#

nope, they need to update anidiotsguide lol

hoary elm
#

Oh lol outdated guide

#

Yeah that happens

rustic wing
pine bear
#

they had in in glitch beta!

hoary elm
#

Oof

pine bear
#

I'll fix it, if I found out how

#

;-;

earnest phoenix
#

db.set(...).then is not a function

if(!message.member.hasPermission("ADMINISTRATOR")) {
    const adm = new Discord.MessageMember()
    .setDescription(":no_entry_sign: **You don't have the required permission to do that!**")
    .setColor("#ff9900");
    
    message.channel.send(adm);
    
    return;  
  }
  
  if(!args.join(" ")) {
    const s = new Discord.MessageEmbed()
    .setDescription(":no_entry_sign: **You need to mention a role name!**")
    .setColor("#ff9900")
    .addField("Corect Usage:", "lt!arrole [roleName]");
    
    message.channel.send(s);
    
    return;
  }
  
  db.set(`autoRole_${message.guild.id}`, args.join(" ").trim()).then(i => {
    
    const succes = new Discord.MessageEmbed()
    .setDescription(`:white_check_mark: **The role has been set succesfully to ${i.text} !**`)
    .setColor("#ff9900");
    
    message.channel.send(succes);
    
  })
  

help ?

pale vessel
#

what database

earnest phoenix
#

quick.db

pale vessel
#

try omitting .then

#

it probably doesn't return a promise

earnest phoenix
#

I still can't figure it out

golden raven
#

My bot is having problem connecting to my mongodb database it shows the error EREFFUSED

#

Can anyone help me

#

And tell me how to fix it

honest perch
#

Have you whitelisted the ip it is hosted on

earnest phoenix
#

main file

bot.on("guildMemberAdd", (member) => { 
  
  const db = require("quick.db")
  
  let role = db.get(`autoRole_${member.guild.id}`)
    
    if(!role === 'none') return;
    else {
      
      try {
        
        member.roles.add(member.guild.roles.find('name', role))
        
      }catch (e) {
        
        console.log("A server tried to autorole an invalid role")
        
      }
    
  }
}

i got
````A server tried to autorole an invalid role``` in console everytime someone joins the server

pale vessel
#

have you tried logging the error

earnest phoenix
#

no

pale vessel
#

ok so are you going to do that now?

earnest phoenix
#

yes

#

everythig is fine

digital kiln
#
  let role = db.fetch(`autoRole_${member.guild.id}`);
  if (!role) return;
  member.addRole(role);
});```
#

@earnest phoenix maybe this should help.

earnest phoenix
steel drum
#

@earnest phoenix that means you're not using the async keyword before the function

earnest phoenix
#

i can't just get rid of await ?

digital kiln
#
  let role = db.fetch(`autoRole_${member.guild.id}`);
  if (!role) return;
  member.addRole(role);
});```
#

@earnest phoenix this?

earnest phoenix
#

Supplied roles is not an Role, Snowflake or Array or Collection of Roles or Snowflakes.

#

first time a got that error

#

have you ever heard of debugging

#

inspect your variables

#

see what their types and values are

balmy knoll
#
  try {
    await dbclient.connect();
    
    const result = await dbclient.db("musibeth").collection("prefixes").findOne({ guild: message.guild.id })
  
    if (result)
    {
      const prefix = result.prefix;
    } else {
      const prefix = default_prefix;
    }
    
  } catch (e) {
      console.error(e);
  } finally {
    await dbclient.close();
  }
  
  if (!message.content.startsWith(prefix)) return;

How can i fix this error: ReferenceError: prefix is not defined?

EDIT: I got also this in console: DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

pale vessel
#

do you know what const does?

#

pass useUnifiedTopology: true to the options

white anvil
#

you have defined prefix in the wrong place, it only exists within your if statement

#

you need to declare it within the scope of your event and set the value where you need it

balmy knoll
#

Where have i to add this useUnifiedTopology: true?

pale vessel
#

use let instead

#

if you read the error, you'll know why

balmy knoll
#

@pale vessel Yes i have just replace it with let

pale vessel
#

i guess you didn't read the error

sacred mural
#

Yall are gods at this stuff loki

#

Best developers in the world!

#

bye now

modest maple
#

🤔

grizzled raven
#

yeah thanks i am amazing

sacred mural
#

np!

#

but i wan't help with creating a discord bot.

#

@everyone @here in this development IS THE BEST BOT CREATORS IN THE WORLD!

pale vessel
#

bruh

#

you can't ping everyone or here

sacred mural
#

oh well still the best

grizzled raven
#

i bet im the youngest bot dev here

sacred mural
#

and i mean like every BOT DEVELOPER

#

you prolly are from you're profile picture

modest maple
#

like 80% of bot devs here dont even know the basics lol

willow sphinx
#

When making a bot, how do you keep the bot online because when i stop the program to run it on it goes offline ?

sacred mural
#

and you're not a noob

modest maple
#

@willow sphinx You must run the program to keep it running

#

that program runs 24/7

willow sphinx
#

Oh wow

#

So what if i want to exit off it

grizzled raven
#

you dont unplug a microwave to keep the food warming in the background

willow sphinx
#

Itll just shut down?

sacred mural
#

it'll*

modest maple
#

if you stop the program you stop the bot

willow sphinx
#

Oh wow

#

Okay,

#

So how do i get it to exit out of the program but still keep it running? (if thats possible)

modest maple
#

What r u using to host

grizzled raven
#

it'll and itll are practically the same, no-one is going to have a hard time reading their sentence without an apostrophe

willow sphinx
#

U host it?

#

You have to host something?

modest maple
#

wut

willow sphinx
#

I just started yesterday lol

modest maple
#

Somthing has to exist and be on 24/7 to run the code 24/7

willow sphinx
#

Ohh

#

So what should I use to host?

#

it*

coral stirrup
#

a vps

sacred mural
#

noice

willow sphinx
#

Ahh

balmy knoll
#

What is the cause of this problem: MongoError: no primary server available?

coral stirrup
#

i dont really work with mongodb but i guess the connection to the main database server does not exist?

#

correct me if im wrong

balmy knoll
#

It doesn't always give me this error, sometimes it can connect to the database...

coral stirrup
#

lemme google..

#
jolly zephyr
#

does anyone know a way of having javascript send the redirected link?

in my case I pull a url from reddit but its a gfycat url which in a browser would send you to the gifdeliverynetwork .com but the bot just sends the gfycat link which cannot embed the gif in question

sacred wraith
#

Hey guys, how exactly do you develop your bot once you've deployed it to production? Like if I run it locally, my bot suddenly replies twice (prod and dev).

jolly zephyr
#

are you on .js?

earnest phoenix
#

use different tokens for dev and prod

coral stirrup
#

dotenv is the solution

jolly zephyr
#

if you're using github here is the best method;

make a separate file for your token outside of your directory for all of the bot files and use ../config to fetch it

coral stirrup
#

this could upload the bots token, though.

earnest phoenix
#

.gitignore exists

jolly zephyr
#

oh yeah thats even better

coral stirrup
#

if you dont know how you can fix this simple issue, you may also not know about gitignore.

#

thats why its dotenv all the way.

jolly zephyr
#

does anyone have a solution for the redirect issue

earnest phoenix
#

see if there are any redirect instructions in the headers

earnest phoenix
#

bot.guild.channels.get("709875174324961383").createInvite

#

how i can fix this

#

oh

rain jacinth
balmy knoll
#

@coral stirrup I tried to follow the links you sent me, but I didn't quite understand how to solve the problem. I don't really understand why sometimes it works and sometimes it doesn't.

rain jacinth
#

Cam anyone help me?

#

Can

earnest phoenix
#

how to find a specific role in discord.js v12?

#

if i do ```js
let role = message.guild.roles.find('name', 'Muted');

#

i got errors

pale vessel
toxic quarry
#
if(message.content.startsWith(`${prefix}say`)) {
      const args = message.content.slice(prefix.length).split(' ')
        message.channel.send(args[1])
        message.delete()
  }

What is the problem? (say commmand)

earnest phoenix
#
let mReason = args.join(" ").slice(22)

at reason section in my embed it say all args from 0 to .... , why ?

pale vessel
#

@toxic quarry you ask me

#

what is the problem?

zenith terrace
#

So II tried looking about online to help see what there was but there was only a role permission update shown for this

bot.on("roleUpdate", async (oldRole, newRole) => {
 
});``` but is there a logs for hex color changes. I did newRole.color but it only showed numbers
I do know about oldRole.name and newRole.name but is there a oldRole
pale vessel
#

hexColor doesn't work?

earnest phoenix
#

or just like

zenith terrace
#

undefine

earnest phoenix
#

you can convert the num to hex lol

pale vessel
#

toString(16)

zenith terrace
#

I messed my message up in that lol

#

wait

#

hexColor

#

I'll try

pale vessel
#

color.toString(16) if that doesn't work

real helm
#

Why a map returns [object Object]

pale vessel
#

¯_(ツ)_/¯

real helm
#

I don't remember how fix it

#

XD

pale vessel
#

how did you initialize the map?

zenith terrace
#

ye hexColor works. Thanks flaz

pale vessel
#

np

real helm
#

state.players.map(m => m).join("\n")

#

like this

pale vessel
#

that's array#map

#

it's not the same as map lol

zenith terrace
#

ah ok

toxic quarry
#

Write only the first word the bot.
E.G: say test test
only write first test
(Soory my bad english)
@pale vessel

pale vessel
#

let me see

earnest phoenix
#

then just... join the args together?

#

throw out the command arg out of the array

#

and join it

#

boom

pale vessel
#

they did

earnest phoenix
#

they didn't

pale vessel
#

well you're not supposed to join the args if you want the first word

earnest phoenix
#

im pretty sure they want it to say the whole string not just the first arg

pale vessel
#

Write only the first word the bot.
E.G: say test test
only write first test
(Soory my bad english)
@pale vessel

#

pepehands

earnest phoenix
#

but they're already doing that

pale vessel
#

that's what i don't get lmao

#

maybe it's the whitespace

#

try .split(/\s+/) instead @toxic quarry

toxic quarry
#

Thank you

pale vessel
#

did it fix the problem?

toxic quarry
#

no 😕 the bot doesn't write anything

#

or dont

#

I do not speak English well

balmy knoll
#

@pale vessel

    at ReplSetState.pickServer (/rbd/pnpm-volume/c6dccffc-7036-44aa-92db-c340940f8112/node_modules/.registry.npmjs.org/mongodb/3.5.7/node_modules/mongodb/lib/core/topologies/replset_state.js:780:12)
    at Timeout._selectServer [as _onTimeout] (/rbd/pnpm-volume/c6dccffc-7036-44aa-92db-c340940f8112/node_modules/.registry.npmjs.org/mongodb/3.5.7/node_modules/mongodb/lib/core/topologies/replset.js:1142:43)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7) {
  name: 'MongoError',
  [Symbol(mongoErrorContextSymbol)]: {}
}```
I want integrate my bot in discord.js with a custom prefix feature, but when i try to connect the bot to a mongodb database, i got this error in console (sometimes all work properly). I had already reported a little over this problem, but they couldn't help me. Could you help me?
pale vessel
#

seems like an issue with mongo

balmy knoll
#

Yes the problem concerns the connection in mongo. But I don't understand since sometimes it connects and sometimes it doesn't.

pale vessel
#

try:

  • checking your credentials
  • whitelisting your server ip
  • have a proper connection string
balmy knoll
#

@pale vessel The credentials and the connection string are correct, because sometimes all work. So i don't know

pale vessel
#

can't really help you with this one, sorry. i have no experience with mongo

earnest phoenix
#

How to overrwrite al channels permission ?

pale vessel
#

read docs

earnest phoenix
#

i already did but i don't understand

still merlin
earnest phoenix
#

close the bracket

gritty frost
#

how to play mp3 file with bot [just upload and play]

#

help me pls

earnest phoenix
#

use ffmpeg to convert it to the standard format discord accepts and send it through the voice stream

#

(two channels, 48kHz sample rate)

gritty frost
#

hm ok I'll try it

quartz kindle
#

most likely your discord library will do all of that for you lol

gritty frost
#

discord.js and lavalink

quartz kindle
#

which lavalink library?

gritty frost
#

lavalink.js Version 2.10.0

red terrace
#

This is something that might help you out.

gritty frost
#

thanks

quartz kindle
#

lavalink.js has a .load method to add songs right? as far as i understand, it should support a path for a local file as well

gritty frost
#

hmm ok I'll check it

grand dirge
#

Merhaba

mossy vine
#

cmd is not defined

zenith terrace
#

cmd not defined

earnest phoenix
#

i told you already that we can't fix every single error you get

#

read the error and do research on it instead of not even attempting to read it, screenshotting it and sending it to us saying "solve it lol"

#

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined send message

#

error

#

-_-

#

have you tried reading the error

#

l someone english

#

-_-

#

you someone english?

coral stirrup
#

This is indeed alot of fun, go on

earnest phoenix
#

i know english a little @earnest phoenix

#

help -.-

#

doesn't prevent you from reading the error and doing research on it

#

but since you're lazy

#

whatever you're calling send on is undefined

#

member add send message channel

#

error

#

i don't speak caveman

#

🤨

coral stirrup
#

IM DYING

mossy vine
#

rude but true

warm marsh
#

Message isn't part of memberAdd...

#

Use the docs

earnest phoenix
#

@warm marsh send me a related article

hasty sparrow
#

Read the documentation

earnest phoenix
#

I have a lot of work please

coral stirrup
#

yeah we too

warm marsh
#

Ah rip

mossy vine
#
sudden geyser
#

It's not too hard to search "Discord.js" on a search engine like Google and use its dedicated search feature.

earnest phoenix
warm marsh
#

Omfg

#

Cry's on a mad one

earnest phoenix
#

they're being lazy and want someone else to fix it for them

coral stirrup
#

Im amused

warm marsh
#

The one pitfall of this server.

#

Anyone can join.

rain jacinth
#

if i want to add how much channels there is on my serverinfo cmd do i do .addField("Total Channel", message.guild.channel?

sudden geyser
rain jacinth
#

I don't understand that website

sudden geyser
#

How so?

#

There is an overview of all the properties, methods, and events for a class.

#

It's easier to navigate than other documentation sites.

earnest phoenix
#

if you don't understand how to click on hyperlinks based on what you need

#

you might need to reconsider what you're doing

coral stirrup
#

crys on a run today

mystic violet
#
const { Shoukaku } = require('shoukaku');

const ShoukakuOptions = { moveOnDisconnect: false, resumable: true, resumableTimeout: 30, reconnectTries: 2, restTimeout: 10000 };

module.exports = {
    async execute(Bot) {

        console.log("Creating PlayerManager")

        Bot.PlayerManager = new Shoukaku(Bot, Bot.musicNodes, ShoukakuOptions)

        console.log(Bot.PlayerManager)

        Bot.PlayerManager.on('ready', (name) => console.log(`Lavalink Node: ${name} is now connected`));
        Bot.PlayerManager.on('error', (name, error) => console.log(`Lavalink Node: ${name} emitted an error.`, error));
        Bot.PlayerManager.on('close', (name, code, reason) => console.log(`Lavalink Node: ${name} closed with code ${code}. Reason: ${reason || 'No reason'}`));
        Bot.PlayerManager.on('disconnected', (name, reason) => console.log(`Lavalink Node: ${name} disconnected. Reason: ${reason || 'No reason'}`));
        
    }
}``` This isn't my first time using shoukaku, but im getting this weird error where the ready event for it doesn't fire. any idea why?
nocturne grove
#

Hey. I need your advice. What would you prefer when you are making/using a help command?
A general help command where you have to react with emoji to get help about a category. Then you can return by reacting with ⬅️
A general help command which shows what categories the command has. You can get help about a category by doing <prefix>help <categoryname>, for example .help server settings

earnest phoenix
#

Last i'd say

#

from a user's perspective, to me all forms of paginators are annoying

#

just give me what i need plain and simple

#

bc the help command with reactions requires a reaction collecter which eats a lot of ram when used multiple times. Lets say some people want to break your bot and find a way to do so by spamming the help command. not good

#

put the categories in fields - field name is the category and field value is the list of commands in that category

#

^

#

if i want more information about some category or command, i'd expect for the bot to support help category or help command name

#

that's just me though, i don't know how other people feel about it

nocturne grove
#

well I got kind of what you're saying now

earnest phoenix
#

yeah

cosmic girder
#
if (msg.content.toLowerCase().startsWith(prefix + "help")) {
    const exampleEmbed = new Discord.MessageEmbed()
    .setTitle('Some title')
    .setDescription(`Testing`)
    

msg.channel.send(exampleEmbed);
  }
#

ok so it works but im getting a coming error msg in chat instead of in my cmd prompt / node prompt

earnest phoenix
#

unfortunately i broke my magic crystall ball and i cannot read minds anymore so you'll have to tell me what's the error

cosmic girder
#

lmao ur right i shouldve

#

and its not really a error, its a msg being sent in to the channel

#

i have a .catch(e) function on other cmds

#

but its now on its on help when i didnt put it.

#
.catch(e => {
        msg.channel.send("Please mention the users @");
        console.log(e);
      });
earnest phoenix
#

you probably have something outside of an if closure

cosmic girder
#

let me check

#

oh ok

#

there we go

#

ty

still merlin
#

in a embed to set the colour do you go 900093 or #900093

#

(its my colour thing i want to use)

cosmic girder
#

no ik

#

but is use displayhexcolor

#

so the role they have the color of tht role is the embed

#

if its blue the embed is blue

earnest phoenix
#

it depends on the library you use

#

officially, discord's api only accepts a decimal format of colors

cosmic girder
#

yuh

#

npm i discord.js --save

#

i remeber when i didnt know npm init was a thing

tight plinth
#

do I need to add a return before throw new Error(...) in js?

hasty sparrow
#

Nothing after a return statement is executed, so no

tight plinth
#

oh ok

#

I didnt remember

opaque seal
#

How can I send a custom emoji with a message?

summer torrent
opaque seal
#

fixed

earnest phoenix
#

What do you mean with goddamn mounting

#

@earnest phoenix elaborate please

limber flume
earnest phoenix
#

by using

#

somekind of timing thingy, idk GWowoHehe

limber flume
#

asyncio

#

but me dunno how to pass it in

earnest phoenix
slender thistle
limber flume
#

ok

#

thanks hope i guess

#

ill try it

#

to see what up

earnest phoenix
#

@earnest phoenix still waiting for your elaboration, what do you mean with mounting

limber flume
#

no its broken

#
"typing" is not defined
still merlin
#

in discord.js how do i like check how many guilds my bot is in and then respond with the number of guilds

#

(Without any names)

earnest phoenix
#

and then using .size to get the count

still merlin
#

so
.guilds.size

earnest phoenix
#

presumably yeah, try it and see

still merlin
#

alright tysm

nimble escarp
#

Anyone who could help a bit with React (TypeScript)?
I have an authentication using the Context API (& localStorage for persistence) but whenever I am authenticated (in localStorage) and reload the page, it just resets the authenticated to false.

export default (props: any) => {
    const prevAuth = window.localStorage.getItem("auth") || false;
    const prevAuthBody = window.localStorage.getItem("authBody") || null;

    const [authenticated, setAuthenticated] = useState(prevAuth);
    const [authBody, setAuthBody] = useState(prevAuthBody);

    useEffect(() => {
        window.localStorage.setItem("authenticated", `${authenticated}`);
        window.localStorage.setItem("authBody", authBody!);
    }, [authenticated, authBody]);

    const defaultContext = {
        authenticated,
        setAuthenticated,
        authBody,
        setAuthBody,
    };
    return (
        <RootContext.Provider value={defaultContext}>
            {props.children}
        </RootContext.Provider>
    );
};

The only time I change the authenticated is whenever I actually authenticate (this code)

const json = await response.json();
if (json.access_token) {
    context.setAuthenticated(true);
    context.setAuthBody(json.access_token);
    setToken(json.access_token);
} else setToken("invalid");
rain jacinth
earnest phoenix
#

One message removed from a suspended account.

#

stop being a help vampire

#

One message removed from a suspended account.

quartz kindle
#

@nimble escarp you're setting it as "authenticated" but getting it as "auth"?

still merlin
#

my code is

client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");
  switch (args[0]) {
    case "botinfo":
      let sicon = message.client.displayAvatarURL;
      let serverembed = new Discord.MessageEmbed()
        .setTitle("Bot Information!")
        .setColor("#f9f162")
        .setThumbnail(message.guild.iconURL())
        .addField("Bot Uptime:", client.uptime)
        .addField("Emojis:", message.guild.emojis)
        .addField("I was created at:", message.client.createdAt)
        .addField("I joined this server at:", message.client.joinedAt);
      return message.channel.send(serverembed);

      break;
  }
});
nimble escarp
#

Well, authenticated is the state variable from the react useState hook.

#

and auth is in localStorage

quartz kindle
#

well i dont see you doing setItem("auth") anywhere in that code

nimble escarp
#

It's there

useEffect(() => {
        window.localStorage.setItem("authenticated", `${authenticated}`);
        window.localStorage.setItem("authBody", authBody!);
    }, [authenticated, authBody]);
quartz kindle
#

where?

nimble escarp
#

literally posted it rn pepecry

#

the useEffect hook

quartz kindle
#

you're doing setItem("authenticated") but youre getting it as getItem("auth")

nimble escarp
#

ohhhhhhhhhhhhhhh

#

welp

#

Thanks MonjiroPray I get to be stupid once again pepeF

quartz kindle
#

@still merlin client.createdAt and client.joinedAt are not a thing

nimble escarp
#

@quartz kindle You're a godsend. Stupid mistake on my part, works fine now.
Thanks once again MonjiroPray

quartz kindle
#

👍

rain jacinth
#

My bot is having a problem where i change the prefix to something else but when i try the old one it still works like for example the prefix is . but : works aswell

#

how do i fix that?

earnest phoenix
#

well

#

code?

#

any error logs?

#

more input on your language/library?

nimble escarp
#

@earnest phoenix Pff, people these days can't even read minds, smh.

earnest phoenix
#

ikr

magic jackal
#

Hey guys in DiscordJS, how can I log the event name without making a hardcoded value? Does the client.on actually log the type of event itself or do I have to hardcode it?

#

I want to get the event from the client when each type is fired, so I dont have to make functions for each type of event

earnest phoenix
#

use reflection

magic jackal
#

?

#

Should I make an array and just make a list of events and then just use that?

earnest phoenix
#

nevermind i forgot node.js' eventemitter is some hacky shit and you can't use reflection on it

magic jackal
#

Like I could just use something like client.onAny()?

#

I'll test it

earnest phoenix
#

How i can get my vote value with dblapi.js

magic jackal
still merlin
#

is there something in discord.js that finds the author of a command's permissions and sends there permissions?

royal portal
#

anyone know how to convert a html site to json in discord.js?

#

or if its possible

lyric mountain
#

html to json? are you crazy?

cosmic girder
#

Html to json

#

?

narrow kettle
#

how do i print a list inside a list?
i tried to do
x[0][0]
but it seems to print the first letter of the first list

#

wait am i suppsoe to do x[0, 0]?

lyric mountain
#

how do i print a list inside a list?
i tried to do
x[0][0]
but it seems to print the first letter of the first list
@narrow kettle imagine it being like this:```
0: [0, 1, 2, 3],
1: [0, 1, 2, 3],
2: [0, 1, 2, 3],
3: [0, 1, 2, 3]

#

so [0][0] will get the first index of the first row

#

to print the whole arra (row) you just need to get [0]

narrow kettle
#

isnt it like this tho?

0: [0: [0, 1, 2, 3], 1: [0, 1, 2, 3], 2: [0, 1, 2, 3], 3: [0, 1, 2, 3]]
lyric mountain
#

no

#

that's a 3d array

#

in my example it was a 2d one

narrow kettle
#

wait a sec, ill send you the function that I used to make the string into a list

lyric mountain
#

note that I know little less than 1% of python

#

so I might not be able to read it

#

oh, nvm, though you were using python

narrow kettle
#

i am lmao

#

but the code shouldnt have anything hard in it

nocturne grove
#

How many times is a bot to change his status? I don't ask this for myself but I see a bot here that's updating like every 8 seconds or something

lyric mountain
#

How many times is a bot to change his status? I don't ask this for myself but I see a bot here that's updating like every 8 seconds or something
@nocturne grove 8 seconds is api abuse

narrow kettle
#
def open_file():
    f = open("Pink_Floyd_DB.txt", "r")
    text = f.read()
    f.close()
    x = text.split('#')
    for i in x:
        i = i.split('*')
    x.pop(0)
    return x[0][0]

the file is just full of songs and albums, the first split, splits the string into albums(Which works), and then the second splits should split the songs inside the albums(which i dont know if it works because i cant manage to print it)

nocturne grove
#

yeah already thought that

#

idk what to do with it now but just wanted to be sure 😂

lyric mountain
#

@narrow kettle so that's correct

#

it's a 2d matrix, which has albums as rows and songs as columns

neat ingot
#

wazzup nubcakes ❤️

pale vessel
#

html to json isn't a thing but xml to json is

lyric mountain
#

probably you're getting the album as a text

narrow kettle
#

ah

lyric mountain
#

the album*

#

so let's say the album is called yellow submarine

narrow kettle
#

how am i suppose to do that there is a list taht contains the albums which contains the songs then?

lyric mountain
#

getting [0] of that album would return y

narrow kettle
#

mhm

lyric mountain
#

you need to use objects

narrow kettle
#

wdym use objects

lyric mountain
#

artist A contains N albums, which contains N songs

#

I'll use json code as example

#
{
  "id": 0,
  "name": "Linkin Park",
  "albums": [
    {
      "id": 0,
      "name": "Hybrid Theory",
      "songs": ["a", "b", "c"]
    }
  ]
}
#

for example

#

so when you do artist.albums[0].songs you'll get all the songs of that artist

#

obviously for python you'll need to create a proper object (unless python works with json)

narrow kettle
#

ty :)

summer torrent
#

checkchannel is null. But when I try to check that, it gives false

lyric mountain
#

try doing checkchannel == null

#

or !checkchannel

earnest phoenix
lyric mountain
#

wrong parameter

summer torrent
#

same

lyric mountain
#

is it still giving false?

summer torrent
#

yes

earnest phoenix
#

@lyric mountain is there any relevant article I searched but couldn't find any material to fix

lyric mountain
#

well, with that two-line error I can't help much

#

all I can say is: check your parameters

summer torrent
#

oh

#

this is promise

lyric mountain
#

ah

summer torrent
#

resolved 👍

lyric mountain
#

another entry to DiscordIDE: What is it and why not to use book

summer torrent
#

@earnest phoenix can you show your code

earnest phoenix
#

@summer torrent

const db = require("quick.db");
module.exports = async member => {
    if(!member.guild) return;
      if (db.has(`autoROL${member.guild.id}`) === true) {
   var i = await db.fetch(`autoROL${member.guild.id}`)  
if(!i) return;
  var role = member.guild.roles.find(r => r.id === i);
   try {
    member.addRole(role)
  } catch (e) {
 console.log('Hmm..')
}
      }
}```
#

?

#

-.

#

What?

lyric mountain
#

that's poorly indented

earnest phoenix
#

oh sorry

#

@lyric mountain help me solve it when -.-

lyric mountain
#

when I finish trying to read it

cosmic girder
#
if (msg.content.toLowerCase().startsWith(prefix + "mute")) {
    var mem = msg.mentions.members.first();
    if (msg.guild.roles.find("name", "Muted")) {
      mem.addRole(msg.guild.roles.find("name", "Muted")).then(() => {
        msg.channel.send(mem.displayName + " has successfully been muted!");
      }).catch(e => {
        msg.channel.send("Please mention the users @");
        console.log(e);
      });

    }
  }
#

OOf

#

does anyone know the code to give role?

#

for discord.js

lyric mountain
#

@lyric mountain help me solve it when -.-
@earnest phoenix isn't addRole()'s arg a string?

summer torrent
earnest phoenix
#

@cosmic girder not working?

lyric mountain
#

like, addRole(ID)

cosmic girder
#

@earnest phoenix it works yes but doesnt give him the role

earnest phoenix
#

@lyric mountain no

lyric mountain
#

show the whole error

cosmic girder
#

addRole(ID) wont work because of the fact its gonna be in different servers

lyric mountain
#

ID is unique for each entity

cosmic girder
#

exactly

lyric mountain
#

no two roles have the same id, regardless of being in different servers

white anvil
#

@still merlin this question could not be more vague

cosmic girder
#

@lyric mountain exactly im trying to make it so they get muted so addRole(id) wont work

earnest phoenix
wide ridge
#

how do bots with many shards scale their bot? If their bot is added in thousands of servers every day, how could they scale automatically?

lyric mountain
#

dude

#

it's the addRole

earnest phoenix
#

-.- yes

lyric mountain
#

@lyric mountain exactly im trying to make it so they get muted so addRole(id) wont work
@cosmic girder addRole(id) will always work, unless you're trying to add a role to a member that's not in that server

#

@earnest phoenix use addRole(role.id)

sudden geyser
#

You can pass a role instance or the ID

earnest phoenix
#

well :D

sudden geyser
#

doesn't matter

#

You should check if the role was actually found

#

in the db fetch

lyric mountain
#

do a console.log(role)

cosmic girder
#

ok

sudden geyser
#

btw that try catch statement won't work since <Role>.addRole returns a promise.

pale vessel
#

it would

lyric mountain
#
if (msg.content.toLowerCase().startsWith(prefix + "mute")) {
    var mem = msg.mentions.members.first();
    if (msg.guild.roles.find("name", "Muted")) {
      mem.addRole(msg.guild.roles.find("name", "Muted")).then(() => {
        msg.channel.send(mem.displayName + " has successfully been muted!");
      }).catch(e => {
        msg.channel.send("Please mention the users @");
        console.log(e);
      });

    }
  }

@cosmic girder use this:```js
msg.guild.roles.find("name", "Muted")).then(r => {
mem.addRole(r);
msg.channel.send(mem.displayName + " has successfully been muted!");
}).catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});

still merlin
lyric mountain
#

see if it works

pale vessel
#

you don't need return

#

you already have break

lyric mountain
#

you can't return a value outside a function

sudden geyser
#

it would
from my experience it won't

#

you need to await it first

pale vessel
#

chances are you d-

#

yeah

#

you need the use await

#

just add one word

lyric mountain
#

or just use .catch()

#

since promises have built-in try-catches

earnest phoenix
#
["command"].forEach(handler => require(`./handlers/` + handler)(bot));

error
require(...) is not a function

sudden geyser
#

did you export a function in the file

earnest phoenix
#

no

still merlin
#

you don't need return
@pale vessel I removed it and got more errors

lyric mountain
#

what kind?

pale vessel
#

show

summer torrent
#

no
@earnest phoenix export it

cosmic girder
#

@lyric mountain

#

tht wouldnt work you have

#

msg.guild.roles.find("name", "Muted")).then(r => {
mem.addRole(r);
msg.channel.send(mem.displayName + " has successfully been muted!");
}).catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});

sudden geyser
#

Amazri I think you're missing a ) around setThumbnail