#development

1 messages · Page 811 of 1

finite bough
#

general

quartz kindle
#

oh the voice channel

finite bough
#

ye

#

can u see?

quartz kindle
#

nop

finite bough
#

wait r there perms for screen sharing?

quartz kindle
#

i mean, you can just post screenshots, no?

finite bough
#

well sure

earnest phoenix
#

Please do not use json for storing

finite bough
#

now u as it says its only the editor

quartz kindle
#

yes, its only the editor thats not updated

#

files that are altered on the backend (that is to say not in the editor - so either by your code or by using something like vim in your project’s console) don’t automatically get synced with the editor, so Glitch sees the right content if you use it in your code, but you won’t see it reflected in the editor unless you run the refresh command in your project’s console.

finite bough
#

it's under fsreadjson.... if(db.wmessageperm === "true"){

quartz kindle
#

do you have an eval command?

#

try doing eval fs.readFileSync()

finite bough
quartz kindle
#

welp idk then

finite bough
#

¯\_(ツ)_/¯

modest maple
#

Why you should use a db :∆

#

Welp idk how my phone has turned to the Greek alphabet but okii

amber fractal
#

@finite bough can you show me the code?

high linden
#

Ola

#

Piton

#

Del porte

#

Je

#

Dis
S

#

R

#

Is

#

K9z😭

modest maple
#

@coral trellis

high linden
#

Hola

quartz kindle
#

no spam

modest maple
#

No spam indeed

#

Bad

coral trellis
#

@high linden don't spam

high linden
#

Okay

finite bough
#

people spamming no spam

#

@amber fractal what code

amber fractal
#

Behind your welcome command

#

That sets it to true or false

finite bough
#
const Discord = require("discord.js");
const fs = require("fs-extra");

module.exports = {
  name: "welcome",
  description: "changes the welcome permission of the bot",
  usage: "welcome True/false",
  category: "mod",

  code(client, message, args) {
    if (!message.member.hasPermission('ADMINISTRATOR')) {
      return message.reply(`You cannot use that command!`);
    }
    
    
    
    
    
    
   fs.readJson(`./lol/${message.guild.id}.json`, (err, db) => {
  let wel = `${db.prefix}welcome`
  
  let answer = message.content.slice(wel.length + 1);
     if(!answer){
       return message.reply("invalid syntax, `welcome [true/false]`")
     }
     if(answer.toLowerCase() === "true" || answer.toLowerCase() === "false"){
       
     
  
  if (err) return console.error(err);
  db.wmessageperm = message.content.slice(wel.length + 1);
  fs.writeFile(`./lol/${message.guild.id}.json`, JSON.stringify(db, null, 2));
       message.channel.send("welcome permission changed successfully!")
}else 
  message.reply("invalid sytax, `welcone [true/false]`")
  });
               
}
}
#

wait

#

"welcone"

#

Lmmao

amber fractal
#

Yeah that's weird, it just isnt updating?

finite bough
#

nup

#

sometimes it does

#

but

#

rarely

fast zenith
#

Doesn't return any errors when it doesn't?

finite bough
#

that code works how am I suppose to get an error

#

I tried to add that in a file runned by local host

amber fractal
#

Because it doesnt update

finite bough
#

it works

fast zenith
#

Well if it's not executing correctly

amber fractal
#

Can you log what is returned when you JSON.stringify it after the update

#

I dont think it matters though

finite bough
#

^

#

I dont even use json dbs anymore

amber fractal
#

Because it'd still write

finite bough
#

I just wanted to show it to tim

amber fractal
#

Oh

vernal yoke
#
const GetGuild = message.guild;

    if(GetGuild)
    {
        GetGuild.emojis.create("url of emote", "name of the emote");
TypeError: GetGuild.emojis.create is not a function

what in the world of GWbruhSquidWoke

summer torrent
#

what is your djs version

vernal yoke
#

im on stable branch, 11.6.1

summer torrent
#

Guild#createEmoji()

vernal yoke
#

^ GWrjkSeemsKappa

#

thanks

#

big brain toime

solemn quartz
#

Can someone Help Me with this error?:

#

if(BotMember.voiceChannelID === ${message.author.voiceChannelID}) return message.reply('Non Siamo Nello Stesso Canale
Vocale!')
^

ReferenceError: Cannot access 'BotMember' before initialization

copper cradle
#

show the code

solemn quartz
#

Of that cmd?

copper cradle
#

yes

#

I mean

#

the error says it all

solemn quartz
#

case 'EsciCV':
if(!message.member.hasPermissions('MUTE_MEMBERS')) return message.reply('Non Hai il Permesso Di Usare Questo Comando!')
if(!message.member.voiceChannel) return message.reply('Devi Essere In Un Canale Vocale Per Usare Questo Comando!')
if(BotMember.voiceChannelID === ${message.author.voiceChannelID}) return message.reply('Non Siamo Nello Stesso Canale Vocale!')
BotMember.voiceChannel.leave()
break;

copper cradle
#

you're trying to access BotMember before initializing it

#

use code blocks

#

for the sake of god

solemn quartz
#

?

#

So how i fix this?

charred jetty
#

69bal

copper cradle
#

```js
paste your code here

fast zenith
#

^

copper cradle
#

copy that and send that

#

I'm not reading that code as you sent it

solemn quartz
#
        case 'EsciCV':
            if(!message.member.hasPermissions('MUTE_MEMBERS')) return message.reply('Non Hai il Permesso Di Usare Questo Comando!')
            if(!message.member.voiceChannel) return message.reply('Devi Essere In Un Canale Vocale Per Usare Questo Comando!')
            if(BotMember.voiceChannelID === `${message.author.voiceChannelID}`) return message.reply('Non Siamo Nello Stesso Canale Vocale!')
            BotMember.voiceChannel.leave()
            break;
#

I have a const for Bot member btw

fast zenith
#

Where is it defined? Can that code block access the const?

solemn quartz
#
const BotMember = message.guild.members.find(u => u.user.username === "Super Bot" )
#

Where is it defined? Can that code block access the const?
@fast zenith Nope

#

That works

#

ive tested it with JoinVC Cmd

fast zenith
#

is the bot called Super Bot?

solemn quartz
#

Yea

#

No questions

#

pls

#

I have a life

copper cradle
#

uuh

#

why are u doing that

fast zenith
#

^

solemn quartz
#

wat

fast zenith
#

Searching the Guild for the Bot user when you have it's instance?

solemn quartz
#

???????????????????????????????????????????

copper cradle
#

just use your instance of the bot

solemn quartz
#

const bot = new Discord.Client()

#

I just have this

#

No other

#

What

#

I ve seen what u said

#

Lol

#

@fast zenith

fast zenith
#

didn't mean to remove but like this.bot

earnest phoenix
#

also that doesn't guarantee it's going to return your bot

mossy vine
#

^

modest maple
#

why do u even need you bot object via searching?

solemn quartz
#

Why when i ask something in this server and i go a minute in aother tab i return here and there are 5 people responding

#

This happened yesterday too :p

fast zenith
#

Heaps of people willing to assist in solving your problem

solemn quartz
#

I know

#

But imagine your asking a thing and u just close your eyes for a second and then discord says you have 40 pings in the same server in the same chat

#

Im going afk a moment

#

bye

earnest phoenix
#

i have a question if i am using this msg.guild.channels.find(channel => channel.name === "logs") how do i send a msg to the logs channel

fast zenith
earnest phoenix
#

zoomeyes i so dumb

#

thx

#

yes i just remembered

#

XD

fast zenith
#

all g haha happens to everyone thisisfine

solemn quartz
#

i have a question if i am using this msg.guild.channels.find(channel => channel.name === "logs") how do i send a msg to the logs channel
@earnest phoenix btw u could make Channel -> ch

#

And this is the same

#

msg.guild.channels.find

#

am bakc boi

earnest phoenix
#

yah ik

solemn quartz
#

Lul

#

@copper cradle So how do i fix that bug?

#

I tried to fix it but it still doesnt work

rare tangle
#

Hi I just need a quick reply

#

is there a time limit on changing bot's status?

solemn quartz
#

I Dont think so

modest maple
#

yes

solemn quartz
#

really?

modest maple
#

5/20s

slate oyster
#

Once every four seconds approx

modest maple
#

^^

rare tangle
#

So I can change my bot's stat every 10 seconds safely?

modest maple
#

yes but idk why youd wanna

rare tangle
#

I'm getting online count from an api so

#

thanks for answering

slate oyster
#

Cache the count

#

And only update status if the count changes

fast zenith
#

^

finite bough
#

@earnest phoenix did u get ur answer?

earnest phoenix
#

hmmmm

finite bough
#

u can do

#

channel.send("ur stuff")
#

or find it using ids

earnest phoenix
#

i tried that before

#

but in didn't work

ionic anchor
#

How pay nitro to my bot ? 🙄

summer torrent
#

what

earnest phoenix
#

hmmm

fast zenith
#

uh

earnest phoenix
#

bots dont have nitro

#

u just put the :emot:

ionic anchor
#

So how some but can use custom emoji

earnest phoenix
#

you can already use custom emojis

#

without nitro

fast zenith
#

^

earnest phoenix
#

make sure the bot is in the server

ionic anchor
#

Animated

earnest phoenix
#

for the bot yser

#

user^^

#

same thing

#

and just us the :emote: in the codes

ionic anchor
#

Bot can use animated emote without nitro ?

earnest phoenix
#

i think so

#

try it lol

#

yep

#

if you dont know, just experiment

#

:P

fast zenith
#

Yea, The only thing you need to make sure is the invite link has the permission to Use External Emojis if your planning to use custom emotes

finite bough
#

@earnest phoenix did u get an error

ionic anchor
#

But i have see bot use custom emote in my server

finite bough
#

@ionic anchoryes bots can use custom emotes as well as animated emotes

fast zenith
#

You upload the emoji to yours as long as the bot has the use external emojis permission when invited to another server it will be able to use the emoji from yours

ionic anchor
#

Oh cool

earnest phoenix
#

nah its working

#

.send()

finite bough
#

yes

earnest phoenix
#

i cant find anything on discords web api for making an invite link,

the library im using (.net) also doesnt seem to have anything,

so before i go rummaging through the depths of sites, does anyone know if its possible to make an invite link through a bot user?

finite bough
#

@earnest phoenix do u mean invite of ur own bot?

earnest phoenix
#

no,

#

invite of guild

#

Server invite that is

#

sorry, shouldve specified^

#

okay so discord has a endpoint for this and document it well

#

lemme search it out

#

for making invites?

#

Yep

#

oh sweet okay, thank you

#

Ah, part of the channel class

#

that's why I couldn't find it then

#

thank you!

#

Yep, the invite has to be on a channel

finite bough
#

not exactly

finite bough
#

@earnest phoenix do ya use SQL?

earnest phoenix
#

no and also it has to be on a channel

#

there is no other way to create a invite

finite bough
#

client.getrank = sql.prepare("SELECT * FROM scores WHERE user = ? AND guild =? ORDER BY scores DESC")

earnest phoenix
#

oh wait

finite bough
#

how do u set the data in decending order

coral trellis
#

It should essentially sort them with that query

finite bough
#

@coral trellis I added the ASC

#

but it gives me an error

coral trellis
#

What's the error?

finite bough
#

cannot find columns "score ASC"

modest maple
#

you want the top 10?

blissful scaffold
#

what is the name of the column you want to order by?

#

is it score or scores?

finite bough
#

well yes

modest maple
#

you need to order via column

finite bough
#

scores

modest maple
#

so select <what ever> from <table>

blissful scaffold
#

cannot find columns "score ASC" this says score

finite bough
#

column name- wcores

modest maple
#

then order by

finite bough
#

oh mb

modest maple
#

colum DESC

finite bough
#

scores ACD

modest maple
#

order in DESC

#

take the first 10 results from fetchall

#

or fetch many

finite bough
#

I did that like

#

column name ASC

modest maple
#

if you want top 10 u need DESC

#

ascending means working up as u go down

#

do it would order like:

1
2
3
4
5
finite bough
#

ik

#

see the code I sent

modest maple
#

yh

#

you are doing Select all from table scores then trying to order it by the table

finite bough
#

actually ima try smthing

#

I will rename the columns

#

coz i think I named the column and the table the small thing

modest maple
#

according to ur Query you are trying to order by a table

#

which conflicts shit

#

so yh

#

change column name so it doesnt conflict

finite bough
#

yea

finite bough
#

@ハーリ-さん (CF8)#6621

#

@modest maple

#
    `SELECT * FROM scores WHERE guild =? ORDER BY points DESC`
  );```
#
  let ranking = client.getrank.get(message.guild.id)
  
  if(message.content.includes("$rank")){
    message.reply(`${ranking.level}`)
  }
})
#

ik the 2nd part is not right

modest maple
#

looks alright in terms of query

finite bough
#

like

modest maple
#

second part needs to fetch all or fetch many

finite bough
#

it sends "18"

#

wdym

modest maple
#

fetchall returns a list/ array

#

of all the values

#

you can then take the first 10 from that

finite bough
#

like

modest maple
#

or fetch many and tell it to get 10

finite bough
#

client.getrank.fetch all.get(...)

pseudo whale
#

So vote locking commands is considered voting abuse? Or just vote locking loads of commands?

mossy vine
#

no

grave jacinth
#

'' throw err;
^
Error: Cannot find module 'discord.js'''

mossy vine
#

install discord.js

grave jacinth
#

@mossy vine throw err;
^
Error: Cannot find module 'discord.js'

earnest phoenix
#

install discord.js

#

not that hard akkoshrug

grave jacinth
#

same error

#

how install?

earnest phoenix
#

how are you installing it

grave jacinth
#

on console

summer torrent
#

how can i get all data from my mongodb database

mossy vine
#

from a collection just .find()

summer torrent
#

i mean all data

mossy vine
#

ok so why do i not get messages with eris

smoky spire
#

eris suc

mossy vine
#
require('dotenv').config()

const Eris = require('eris')
const bot = new Eris(process.env.DISCORD_TOKEN)
/* commented cuz irrelevant
bot.on('ready', _ => {
    setTimeout(_ => console.log(`Yeeting as ${bot.user.username}#${bot.user.discriminator} in ${bot.guilds.size} servers`), 3000)
    bot.editStatus('idle', {name: '[object Object]'})
}) */

bot.on('message', msg => {
    console.log('e')
    //more irrelevant code, dont get anything in console
})

bot.connect()
#

yeah doesnt work on different bot acc either

#

just no messages

quartz kindle
#

well...

mossy vine
#

wait what

#

okay then

#

why did it literally work before

#

with the same code

#

im not even joking it was working

quartz kindle
#

lmao

mossy vine
#

here is actual proof that it was working earlier with the same bullshit code

#

at least now its working reliably, thank you lmao

copper cradle
#

r e s p e c t

finite bough
#

a had paid respect

mossy vine
#

ok are yall just making fun of my bot

pale vessel
#

is eris better?

#

(than your traditional djs)

quartz kindle
#

same shit mostly

mossy vine
#

well i sure hope memory usage wont climb to 1.5gb after a few days of uptime

pale vessel
#

was just about to try it

#

don't know if it would be worth the time

mossy vine
#

docs are shit

#

but its not too bad

pale vessel
#

and weeb devs

#

afaik dyno uses eris too right?

mossy vine
#

yes

earnest phoenix
#

What’s the eval to have your bot leave a server using the servers id

smoky spire
#

What lib

restive furnace
#

guild#leave method is on most libs, so try that.

earnest phoenix
#

Discord.js

balmy knoll
#

Hi, i have a problem in my bot. I want to show in the bot activity the number of servers that used the bot. I tried to use client.guilds.size, but the bot shows the undefined value. Do you have some solutions?

smoky spire
#

client.guilds.cache.size

balmy knoll
#

I try

#

@smoky spire Thanks

restive furnace
#

Tip for d.js stable users: if you get undefined on some client#object, then just try add client#object.cache always. notlikenoot

heavy marsh
#

Need a help on something. discord.js
So my bot is in 600+ servers.

when I try to get the server owner id it doesnt work [ Only In A Few Servers ].
How can I fix this issue?

balmy knoll
#

@restive furnace Thanks for the tips

summer torrent
#

@heavy marsh message.guild.ownerID

heavy marsh
#

@summer torrent thank you. Then how to get a owners pfp?

#

message.guild.owner.user.avatarURL

sterile minnow
summer torrent
#

get it from client

tight plinth
#
client.users.get(message.guild.ownerID).then(user => {user.avatarURL})
#

like this

heavy marsh
#

ook thanks you

#

thanks alot 🙂

#

client.users.get(message.guild.ownerID).avatarURL

#

this is also correct right?

smoky spire
#

Yes

tight plinth
earnest phoenix
safe nacelle
#

(node:3709) UnhandledPromiseRejectionWarning: TypeError: client.guilds.reduce is not a function

amber fractal
#

What is your d.js version

safe nacelle
#

new

amber fractal
#

Very helpful. Anyways, in the latest versions of d.js client.guilds returns a GuildManager to which to get the guild collection you need to access the property cache so try client.guilds.cache.reduce(...) dumb change but that's what happens

safe nacelle
#

@amber fractal

#

tnx

amber fractal
#

Yep

#

I would suggest checking the updated docs

#

A lot has changed since v11

earnest phoenix
#

someone give me some useful features that i can add

lyric mountain
#

hey guys, I need a little help with sending images in d.js

#

consider the following:
A - a json is returned from a fetch call, containing the response code and a Base64 image
B - the fetch is necessary for authentication

#

my question is: how do I convert from base64 and send the image?

amber fractal
#

d.js can send b64 resolvables cant it?

lyric mountain
#

how? @charred jetty is having some issues getting the image from my api and sending is via d.js

#

since I barely scratched d.js I'm a bit lost

#

also, the image is being returned correctly from the api (I've checked)

#

I've tried sending him the image itself as bytes, but idk how you can send it that way via djs either

amber fractal
#

It says you can send Buffer resolvables as message attachments

lyric mountain
#

we'll try, thx for the heads up

amber fractal
unique nimbus
#

check how many servers the bot is in and leave the newest?

zenith orchid
#

check how many servers the bot is in and leave the newest?
Yes, there is no other methods.

unique nimbus
#

is there something which logs when your bot joins a new guild

#

in python there was/is on_guild_join

smoky spire
#

which lib

zenith orchid
#

I think djs

smoky spire
#

guildCreate then

hoary elm
#

^^

zenith orchid
#

can actually read the document

earnest phoenix
#

that is so incorrect to the point it hurts

#

you'd want to leave your newest guilds or prioritize guilds with a low member count to leave

true ravine
#

I have a footer to my website, but I want it to stay at the bottom even when zoomed out so there's no white spaces

#

What property do I need?

solemn quartz
#

@true ravine So ur doing a website

#

do u use a website maker?

true ravine
#

I'm coding it all myself

solemn quartz
#

Ok

#

how did u make it

#

i mean

#

how to do the website itself

#

u code it, but where

#

how do u started it

true ravine
#

I'm using glitch at the moment so I can host it for free while I test it

#

I'll ditch glitch asap because it sucks and move the code to a real host + tld

solemn quartz
#

oki

#

I use a website maker but the URL is not cool

#

it adds ".jimdofree"

true ravine
#

If you want a proper URL, you have to pay

unique nimbus
#

^

solemn quartz
#

ik

true ravine
#

Tbh html and css is relatively easy if you have w3schools helping you out

#

No real benefit to using a website maker if you can do it properly

solemn quartz
#

But you need to pay

#

PAY

#

i dont wanna PAY

unique nimbus
#

you are expecting things to be free?

solemn quartz
#

i dont like paying

#

so yes

unique nimbus
#

welcome to life

true ravine
#

You don't have to pay to code

#

You just have to pay to host it

unique nimbus
#

and domain

solemn quartz
#

lol

true ravine
#

Yeah

#

Domains are pretty cheap if you get them bundled with hosting

#

The domain is often free

solemn quartz
#

im using a website maker and it is becoming pretty good

unique nimbus
#

wdym domains are normally free

#

oh wait

#

that one which they give you for no reason which doesn't look good

solemn quartz
#

?

true ravine
#

Nah companies like 1and1 give you a .com or .co.uk domain free with most hosting plans

unique nimbus
#

and they charge more for it upfront per month

true ravine
#

They're like £5/month

#

I'd take that personally

solemn quartz
#

but guys

#

im using a website maker

#

and it is FREE

true ravine
#

Don't

unique nimbus
#

^

solemn quartz
#

hosting too

#

its just the URL

#

nothing other

unique nimbus
#

Well you see no good company really wants to see free domains

#

with ad placement for the company who made it themselves

earnest phoenix
#

congrats your website is just as generic as every single portfolio and entrepreneur website ever

true ravine
#

That's true

#

If you follow a template, chances are there's a 100 other people who have used the same one

unique nimbus
#

yes

solemn quartz
#

im not using a template

#

lol

true ravine
#

Nice

unique nimbus
#

yes

#

wait Super you said you don't like paying for things but you got Nitro?

true ravine
#

Oof

solemn quartz
#

what about fortnite

#

i only spent 40$

unique nimbus
#

what

solemn quartz
#

sorry write worng

unique nimbus
#

and you can get a proper good game for 40$?

solemn quartz
#

wrong

#

3000$

unique nimbus
#

what

solemn quartz
#

fuck i cant spellnumbers

#

Shit i cant write today

true ravine
#

Interesting

solemn quartz
#

300$

#

ok

#

300

true ravine
#

Why would you do that then

solemn quartz
#

this is right

#

?

#

games are games

#

and are the skins i bought are permanent

true ravine
#

Cool

unique nimbus
#

until the game shuts down

solemn quartz
#

the premium things on websites arent perm

unique nimbus
#

well it is if you are paying for it

true ravine
#

Yeah but which one is more useful

solemn quartz
#

Skins

unique nimbus
#

no

solemn quartz
#

So i can make my friends hate me

true ravine
#

Mine already do

#

For free

#

Bam

solemn quartz
#

:p

#

ur not a gud friend

#

then

knotty fiber
#

hello, I'm working on a moderation bot for my server and I'm wondering if there's a reliable way to save files from deleted messages

mossy vine
#

what

knotty fiber
#

one of two links from the collection never works and the other is unreliable

solemn quartz
#

-owners @lyric hollow

gilded plankBOT
solemn quartz
#

-owners @shell echo

gilded plankBOT
unique nimbus
#

bruh

true ravine
#

You'll have to download the attachments as files and store them somewhere

unique nimbus
#

if it is just a message get the message contents

true ravine
#

He wants the attatchments tho

solemn quartz
#

-owners 159985870458322944

gilded plankBOT
#
Owners

@solid gale
@obtuse kelp

true ravine
#

I think

solemn quartz
#

YES

#

FINALLY I CAN SEE MEE6 OWNERS

#

FUCK YEAH

unique nimbus
#

Super

true ravine
unique nimbus
#

You can join their server for that

knotty fiber
#

it never works for files that aren't images it seems too

#

but downloading attachments is ugh

heavy marsh
#

I have a question on discord.js
guild.iconURL = Server Icon
How to change it so it also be like a gif if a server has a gif icon?

unique nimbus
#

Doesn't it already do that anyway?

solemn quartz
#

lol?

heavy marsh
#

not in my case

unique nimbus
#

hmm

solemn quartz
#

lolololol?

heavy marsh
#

it doesnt work for me

unique nimbus
#

hmm

solemn quartz
#

not lol?

#

developer lol?

heavy marsh
#

hmmm?

solemn quartz
#

hmlolmm?

earnest phoenix
#

@knotty fiber suggestion (not criticizing anything, it looks nice) - but maybe put the date in the footer

#

it looks better there 9 times out of 10

solemn quartz
#

guys

#

Can someone say me how to do things like this

unique nimbus
#

JS - Canvas
Python - PIL

solemn quartz
#

oki thank you

#

So i just search on google "Discord Avatar Canvas"?

knotty fiber
#

or sharp

solemn quartz
#

oki

knotty fiber
quartz kindle
#

for simple image compositing, sharp is the better option

#

canvas is best for drawing and programmatically generating an image

knotty fiber
#

although

#

to use a link

solemn quartz
#

thank you guys

#

@knotty fiber so i did "npm install sharp"

#

Now wat?

#

I dont know how to use it

knotty fiber
#

read the documentation

quartz kindle
#

scroll down to examples

solemn quartz
#

ty

#

I think im gonna see a yt tutorial too

vernal yoke
#

canvas is best for drawing and programmatically generating an image
@quartz kindle also jimp and graphics magik

#

and canvas contructor is a hacky easy way for canvas :p

quartz kindle
#

jimp is about 20x slower than others because its written in pure javascript

solemn quartz
#

ill problably use canvas constructor then

quartz kindle
#

canvas-constructor is just being lazy

#

lmao

solemn quartz
#

I am lazy

#

Ima download canvas constructor : )

vernal yoke
#

jimp is about 20x slower than others because its written in pure javascript
@quartz kindle idk for me is fast as fuck boi GWbruhSquidWoke

crimson vapor
#

alright I am still so confused, I am defining an object with a value as true, but its saying its undefined

#

and I have no spelling errors as I can tell

solemn quartz
#

lol?

vernal yoke
#

undefined javascript dev nightmare lmfao

near ether
#

what is a good way to target memory leaks?

solemn quartz
#

true :p

#

target memory leaks

near ether
#

i know i have one but i can't for the life of me figure out where it could be coming from

crimson vapor
#
        console.log(data);
        console.log(data.useEmbeds);```
quartz kindle
#

first make sure your leak is in fact your code, and not just your discord library's caching lol

crimson vapor
#

is the console log

near ether
#

do you happen to know which parts of djs have memory leaks?

#

i had no idea it did

quartz kindle
#

its not memory leaks, its just how the library handles caching

grizzled raven
#

when your program starts, maybe wait a minute or two, cache memory usage, then log in, wait a while, and cache again, see how it changes

quartz kindle
#

it caches EVERYTHING by default, to avoid hitting the discord api as much as possible, and to make it possible for you to access post-mortem data, such as deleted messages and such

grizzled raven
#

just a suggestion

near ether
#

gotcha ty for the explanation!

quartz kindle
#

how many guilds and users does your bot have?

near ether
#

let me check

vernal yoke
#

it's over 9000 GWpieHyperS

grizzled raven
#

also, when you say memory leak, how much ram do you have in the first place

near ether
#

dude

grizzled raven
#

or how much is it using

near ether
#

its actually over 9k

#

not kidding

#

lmao

grizzled raven
#

over 9k bytes

near ether
#

nah servers lol

vernal yoke
near ether
#

lmao

grizzled raven
#

oh lol

near ether
#

i have 8gbs of ram

grizzled raven
#

so then how much is it using

near ether
#

all of it

vernal yoke
#

2+2 equals 4 quick maffs GWmemetownTriHalf

grizzled raven
#

h

near ether
#

then it auto restarts

grizzled raven
#

tim you can take over

#

but

near ether
#

i think it has roughly 20k players

grizzled raven
#

music?

#

oh

#

nvm

#

nothingl

near ether
#

no its turn based combat with reactions/embeds

grizzled raven
#

first give me all your code, you know, so i can find the problem 😎

#

jkjk

near ether
#

lmaoo

quartz kindle
#

well, im just gonna say this, my bot is in 2300k servers, and using an unmodified discord.js with disabled events and disabled message caching, and basic cache sweeping, its memory usage reaches about 600mb

#

while with my modified discord.js framework, it only uses 60mb

vernal yoke
#

2300k GWbruhSquidWoke

crimson vapor
#

wow

quartz kindle
#

2300*

#

not k

#

lmao

grizzled raven
#

tim advertising his modified djs fw

vernal yoke
#

oh

crimson vapor
#

Tim what did you change?

quartz kindle
#

anyhow

grizzled raven
#

he basically remade it i think

#

like

quartz kindle
#

depending on what your bot needs, there is a LOT you can do

#

to reduce discord.js's memory usage

grizzled raven
#

without all the unecessary caching and stuff

quartz kindle
#

but its not that simple

#

and it might break some parts of your bot

#

or need workarounds

grizzled raven
#

h

vernal yoke
#

tim dont ban me

#

weird flex but ok GWspenderThinkChubby

grizzled raven
#

making a starboard bot i need to keep all my messages 😔

quartz kindle
#

im not intentionally advertising, im just using it as a real life example of what can be done

near ether
#

do the maxlisteners warnings actually matter? i stop every collector i create when im done with it

quartz kindle
#

they do matter

grizzled raven
#

nah im jk

#

its cool you did so anyway

vernal yoke
#

ikr tim im joking, semi drunk atm GWbruhSquidWoke

quartz kindle
#

when discord.js creates a collector, it internally sets the eventMaxListeners to +1 and then back when it ends

#

if youre getting maxlisteners warnings, it might be something outside of discord.js's control

#

but that by itself will not give you several gb or memory leaks

crimson vapor
#

Tim could you help me with an issue I have found?

near ether
#

hmm

#

i see

quartz kindle
#

@crimson vapor that usually happens when the data is not actually accessible yet, like in a promise or something

crimson vapor
#

but I can access some of it

#

and Its an await function

quartz kindle
#

can you show the code?

crimson vapor
#

yeah one sec

quartz kindle
#

@near ether the first thing you should do, is look into discord's intents and see if your bot can use them

#

intents are used to tell discord to only send you the packets that you actually need, instead of everything

#

but you need to check what kind of data your bot depends on

near ether
#

almost everything related to it uses reactions

crimson vapor
#

    const guildModel = require('../../models/guilds/Guilds'); //define the mongoDB model
    const _guilds = await guildModel.findOne({ guildId: message.guild.id }); //find the data with the ID of the guild
    if (!_guilds) return; //if no guilds, return

    console.log(_guilds.settings);
    console.log(_guilds.settings.useEmbeds);
    return;``` the console and the code used
quartz kindle
#

check the discord api on intents and study it carefully

#

another more immediate action you can take, is to enable regular sweeping

#

which version on discord.js are you on neelio?

crimson vapor
#

and this undefined is confusing because the main version of the bot uses the same exact code

near ether
#

the latest one

#

do you need a version number?

crimson vapor
#

he does because a lot changed in v12

quartz kindle
#

which mongo library are you using? mongoose?

crimson vapor
#

yes

near ether
#

djs v12.0.1, and i use the regular mongodb lib

quartz kindle
crimson vapor
#

I will read through this to see why it may be an error

#

its strange because I have not had this error before

quartz kindle
#

@near ether in v12 you can sweep caches like this: ```js
client.users.cache.sweep(user => someFilter) // remove users that pass the filter
client.users.cache.clear() // remove all users

// the above method works for all of these
client.channels // partially safe, channels will slowly recache themselves, but you need to manually fetch it if you want to send messages to uncached channels
client.guilds // dangerous, will break discord.js without workarounds
client.users // safe, users will recache themselves
guild.members // safe, members will recache themselves
guild.channels // safe, channels will recache themselves
guild.roles // potentially dangerous, will recache themselves but might break permissions
guild.presences // safe, will recache itself
guild.voiceStates // probably safe, never tested
channel.messages // safe, can be controlled in client settings

crimson vapor
#

wow you wrote that in discord?

quartz kindle
#

yes?

crimson vapor
#

well it is just a lot to type in a chat

near ether
#

ahh ok

#

thanks!!

#

i appreciate the effort, ill check out what i can do

quartz kindle
#

you can make a setInterval that sweeps every 30 min or so, and check your results

crimson vapor
#

oh wow thank you Tim

near ether
#

in addition to that i was reading up on memwatch, do you think that can help?

quartz kindle
#

not sure, never used it

near ether
#

alright

stoic gate
#

In Discord.js is there a way for a Bot to tell if a person using the command has blocked the bot?

quartz kindle
#

no

#

the only way is to try dming them and catch the error

copper cradle
#

what if they have their dms disabled

amber fractal
#

that's why you catch

copper cradle
#

ik

#

my point is

#

how r u gonna know if they blocked you

amber fractal
#

you arent.

copper cradle
#

that's my point

amber fractal
#

unless you react to a message of theirs and it errors

#

then you're blocked

copper cradle
#

ig that one makes sense

#

but what if the bot can't add reactions

amber fractal
#

I never said that was the solution

stoic gate
#

So ultimately there is no way to stop my bot from getting the DiscordApiError?

copper cradle
#

cuz there's no solution

#

@stoic gate send the err

amber fractal
#

Bots, like users, are unable to know if they were blocked by someone else. Unless you react to their message and it errors, but sometimes you can't react, so there is no guaranteed solution

stoic gate
#

The error is "DiscordApiError: Reaction Blocked". My bot reacts to a user who uses my command, but the user has me blocked. I have the error caught, I just wanted to know if there is anything I could do to pre-empt the error

#

Or if I'm just forced to always get DiscordAPIErrors

#

And catch them

copper cradle
#

well

#

that's what a catch is for

#

add .catch(_ => null); at the end of the line where you add the reaction

#

that way you'll ignore the err

#

or even better

#

make it send a message to the channel, that says something along the lines of

#

"YoU hAvE mE bLoCkEd"

sudden geyser
#

I believe there's an error code for when the bot's blocked, but I don't know if Discord uses it (for reactions).

sinful belfry
#

hey does anyone know if google has any vps services?

quartz kindle
#

yes

#

they have GCE (google compute engine)

sinful belfry
#

ah ok ty

copper cradle
#

GCP Google Gloud Platform

#

GCE is a micro service inside GCP

hushed berry
unique nimbus
#

waht

crimson vapor
#

Is there any efficient way to combat the slow await function for getting mongoDB data

amber fractal
#

Mine is pretty fast

#

are you self hosting the mongodb instance?

crimson vapor
#

I am not

#

Is that something that is an option?

hushed berry
#

is it possible that youre running an inefficient query?

#

@crimson vapor

crimson vapor
#

Well

#

Maybe

#

Just a findOne() searching for a specific ID that equals the member or guild ID

hushed berry
#

How exactly is the data laid out in the database?

#

is it indexed? etc etc

#

how many documents are there?

crimson vapor
#

There would be about 30k for users and I’m sorry that I do not know what you mean by indexed

hushed berry
#

If the data is not indexed, it means that mongo needs to scan through your documents manually to find ones that match your query

crimson vapor
#

Yes which probably causes the delay

balmy knoll
#

const { prefix, token } = require('./config.json');

I'm using this in a command file.js (not the main file index.js), but i receive an error message in console

internal/modules/cjs/loader.js:584
    throw err;
    ^
Error: Cannot find module './config.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/commands/utility/help.js:4:27)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
internal/modules/cjs/loader.js:584
    throw err;
    ^
Error: Cannot find module './config.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/commands/utility/help.js:4:27)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

How can i fix it?

crimson vapor
#

Check that you didn’t leave the file as Config.json

hushed berry
#

id guess its probably because of the relative paths

#

and the file.js one is under a folder or something

balmy knoll
#

@crimson vapor No I understand, what do you mean? (sorry, but I'm a beginner)

#

and the file.js one is under a folder or something
@hushed berry Yes is under a folder

summer torrent
#

../config.json try

crimson vapor
#

So make sure you spelled it correctly and the path is correct

slender thistle
#

There's an async version of mongo?

crimson vapor
#

How would I index my database?

balmy knoll
#

So make sure you spelled it correctly and the path is correct
@crimson vapor Yes, the correct name is config.json, maybe the file.js is under a folder. Solution?

summer sedge
#

in your database manager you can simply hit add index

crimson vapor
#

Simo what IDE do you use, VSCode?

balmy knoll
#

@crimson vapor At the moment, since I'm starting out, I use the glitch website, but once the bot is finished, I would like to pass it on VSCode.

summer sedge
#

vscode is pretty nice, it also has a build in beautifyer

crimson vapor
#

I really like the auto format

#

I don’t know if that’s normal

balmy knoll
#

@summer sedge yes, i know it. but at the moment i need a solution to my problem 😄

crimson vapor
#

Alright, I can’t say I know how to use glitch but on VSC you can tab the requires

summer sedge
#

Wait you can do that?

summer torrent
summer sedge
#

from where are you calling the index.js from?

#

and where is your config located

#

full path if possible

balmy knoll
#

wait i send a screen

summer sedge
#

make sure to not send sensitive data

balmy knoll
#

yes

summer sedge
#

like keys. tokens or your name etc

#

Social security numbers do get auto censored though

balmy knoll
summer sedge
#

8362.463.3736.3736

#

ah shit

#

yeah then you use

#

../config.json

#

where the 2 dots refer to going back a directory

#

wait not

#

the path seems
/commands/utility/help.js?

balmy knoll
#

yes

summer sedge
#

then

earnest phoenix
#

use two ../ for going back two directories

summer sedge
#

../../config.json

earnest phoenix
#

^

summer sedge
#

/path/to/file
This is a path

balmy knoll
#

Thank you all

summer sedge
#

did it work?

balmy knoll
#

yes

summer sedge
#

also if you are going to make your bot public

#

may I make a suggestion?

#

Create a database (sqlite)
And store your guildid and prefix in there

#

then in the future you can make other guilds add their data too and then you have a variable prefix

#

one for each server

balmy knoll
#

Ok thanks

crimson vapor
#

I suggest learning fs at first

summer sedge
#

fs is not very good for repeatedly calling/writing files

#

Especially if multiple guilds are going to make the same calls and write their own changes

crimson vapor
#

Ik but it’s something that I liked learning about

vivid island
#

i kinda like rocket-store

quartz kindle
#

there's something called "the right tool for the job"

#

and equally important: "using the tool correctly"

#

a bad database design will give you as much trouble as a bad json storage design (ok maybe not that much, but still...)

hushed berry
#

@summer torrent why would it? mongo is a database, not a hosted service

summer torrent
#

ik

#

i want to fetch current status

hushed berry
#

of what?

#

your own hosted database?

amber fractal
summer torrent
crimson vapor
#

I’ll look into it

amber fractal
#

It will increase performance as you dont have to send http requests

#

I'll run a test to see how fast mine is

hushed berry
#

...for mongodb cloud??

amber fractal
#

No

#

for hosting the mongo instance yourself

hushed berry
#

i was talking to nmw lol

amber fractal
#

o

hushed berry
#

also, that is just incorrect

#

mongo doesnt work over http, so it doesnt have to send http requests regardless

amber fractal
#

If it's in the cloud

#

you need to request to a database

earnest phoenix
#

Can anyone help me create a bot?

hushed berry
#

its just faster because it can work over lan instead across the internet

summer torrent
#

@hushed berry yes i want to add currenct mongodb cloud status to my status command.

amber fractal
#

Well it works over it's own protocol doesn't it?

hushed berry
#

yeah

crimson vapor
#

@earnest phoenix people don’t normally help people make bots, they just help with other people’s errors that they do not know how to fix

earnest phoenix
#

Oh ok

#

I can create the bot but I have a problem @crimson vapor

summer torrent
earnest phoenix
#

So I have a group on a game and I’m trying to create my own bot on discord so I can do !promote name rank straight away

crimson vapor
#

At that point you could use Mee6 or Dyno custom commands, there are definitely more bots but those are the biggest I think

earnest phoenix
#

yagpdb has really strong custom commands afaik

#

I don't use either though so take what I say with a grain of salt peepoWeird

earnest phoenix
#

@earnest phoenix Can I add a promotion system from another app#

#

?

crimson vapor
#

What do you mean?

earnest phoenix
#

So

#

On a different game

#

I have a group

#

There’s ranks in the group

#

I want to create this command

#

Like !promote player name rank and it will do it

crimson vapor
#

What is player, name, and rank?

earnest phoenix
#

Example !promote million Private

#

And it will do it

crimson vapor
#

What would the private mean?

outer niche
#
  File "C:\Users\culan\Desktop\echo\echo.py", line 32, in <module>
    bot.load_extension("gennbotlist")
  File "C:\Users\culan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 625, in load_extension
    self._load_from_module_spec(lib, name)
  File "C:\Users\culan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 584, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'gennbotlist' raised an error: RecursionError: maximum recursion depth exceeded```
quartz kindle
#

you have an infinite loop

outer niche
#
    async def postservers(self):
        await self.gbl.post_server_count(self.bot.user.id, len(self.bot.guilds))```this
#

????

quartz kindle
#

idk, you should know

#

whats the extension gennbotlist?

outer niche
#

Normie was the administrators on that bot list are able to figure out why it's in this and echo.py is my bot

slender thistle
#

Indentation for life

earnest phoenix
#

@crimson vapor private is the rank

slender thistle
#

Also what are those args

#

(assuming gbl is dblpy Client)

quartz kindle
#

@earnest phoenix well, you have two options:

  1. learn programming.
  2. use something like discord bot maker
earnest phoenix
#

?

quartz kindle
#

if you want to make your own bot

#

those are your options

earnest phoenix
#

Nah

#

I will use someone’s bot

quartz kindle
#

then check the bots people recommended and join their supports servers

#

they can help you better

lyric mountain
#

@earnest phoenix so you want a level-role bot?

earnest phoenix
#

N

crimson vapor
#

No they want a custom command bot

earnest phoenix
#

Does anyone know the possible reason that my bot is not online? The ready event is emitted and my bot is on two shards. I am using discord.js version 12.0.1

sudden geyser
#

Does your project/node die and/or with a message printed to the console?

ivory lantern
#

Hi guys!

earnest phoenix
#

@sudden geyser no errors

#

it just says logged in

#

which is logged with the ready event

#

I think i found the reason

#

only Shard 0 loaded

#

and Shard 1 didn’t load

#

any solutions to make it load?

#

my shard code:

const express = require("express");
let app = express();
const bodyParser = require("body-parser")

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.get("/", function(request, response) {
  response.sendFile(__dirname + "/views/index.html");
});

const listener = app.listen(process.env.PORT, function() {
  console.log("Your app is listening on port " + listener.address().port);
});

const Discord = require("discord.js");
const manager = new Discord.ShardingManager("./server.js");
manager.spawn(2);
lyric mountain
#

how many servers is your bot in?

earnest phoenix
#

How to ping a role?

lyric mountain
#

use <@roleidhere>

crimson vapor
#

ok so you are in the wrong server but <@roldID> would work

#

like KuuHaKu said

earnest phoenix
#

Thanks

lyric mountain
#

not here lol

crimson vapor
#

wrong chat man

charred jetty
#

Lol.. dev chat f... I thought it's testing 1

earnest phoenix
#

Ok so listen

#

Someone who made a bot wants to get it verified, but cant join the server because his phone is restricted by his parents so he cant add one

#

Can I vouch for them?

amber fractal
#

you dont even need to be in this server to add a bot

#

I don't think

#

Wrong channel though

crimson vapor
#

You do need to be in the server

slender thistle
#

You need to be in this server, that's all

crimson vapor
#

you could add the bot as the owner

earnest phoenix
#

@lyric mountain 1600

crimson vapor
#

wow d.js v12 is going to be a pain to move over to

#

how have your guys' move been?

earnest phoenix
earnest phoenix
#

stop using glitch

#

not a solution.

#

it very much is

#

invest into a proper domain and a webserver and then you can talk AdSense and SEO

flat pelican
#

@earnest phoenix Glitch isn’t SEO friendly as it’s an app for making dev, it’s not made for using it in final production

scarlet bane
#

glitch is also most likely on an Adsense blacklist

#

along with tons of other blacklists

earnest phoenix
#

oh

flat pelican
#

Yeah

earnest phoenix
#

ty

scarlet bane
#

Free stuff wont get you very far

#

best solution here is to move off to a real platform

#

tons of cheap solutions out there

flat pelican
#

If you have a real and cool project, you should spend money

#

You can’t get everything for free

scarlet bane
#

if you have enough visitors to be approved by adsense, you definitely need to move away from Glitch

#

adsense has a minimum pageview/month requirement

earnest phoenix
#

it just a dashboard of my bot and i have no money for spend

scarlet bane
#

then u cant put adsense anyway

#

these ads make 1 cent per thousand views, u wont make any money

flat pelican
#

^

earnest phoenix
#

ok

flat pelican
#

Better to make something like a patreon page if you need support from your community

earnest phoenix
#

hmm ty

pastel plaza
#

Hello

golden condor
#

@earnest phoenix you can use infinityfree

#

Can someone help me, I am trying to switch to heroku hosting but I keep getting an error

pale vessel
#

can you just tell us the error?

gleaming narwhal
#

is it working on your local machine?

golden condor
#

It is working on glitch

#

Yet not on heroku

pale vessel
#

what error did you get?

golden condor
#

Idk why, but it's tryna install node-gyp

pale vessel
#

what modules did you have on your bot?

golden condor
#

I had tons

pale vessel
#

one of them needs node-gyp

#

or some of them

golden condor
#

What is the version of node0gyp

pale vessel
#

can you send the error here*

pale vessel
#

nm i got it

#

i thought you sent the bot code

#

integer@1.0.7

#

it's the module that's causing the error

golden condor
#

Oh

#

@pale vessel I can't find that module anywhere

pale vessel
#

a module needs that module

#

yep

golden condor
#

I need to install integer?

#

Ohhhhhhhhhhhh

pale vessel
#

yes but that's the error you would get

golden condor
#

Whaaaa

pale vessel
#

it's trying to install integer because it was needed by a module and integer needs node-gyp and it throws that error while it was trying to install it

golden condor
#

I don't have node-gyp?

finite bough
#

try installing it using heroku console

golden condor
#

Ok

finite bough
#

lmao

golden condor
#

bash: npm: command not found

finite bough
#

bash?

pale vessel
#

just run it normally

finite bough
#

I mean the website heroku console

#

not gitbash

golden condor
#

?

pale vessel
#

click on open console on heroku

finite bough
#

console on heroku's website

pale vessel
#

and type npm i node-gyp

golden condor
#

Not run cosole?

pale vessel
#

it is the console

#

on heroku

finite bough
#

wait I will try

golden condor
#

I get the same error

pale vessel
golden condor
hoary elm
#

Click console

#

It's highlighted blue

finite bough
#

that's heroku run console

golden condor
#

console: command not found

finite bough
#

click on console under it

golden condor
#

I tried that

#

bash: console: command not found

#

And for some reason my dyno won't show up either

hoary elm
#

$ heroku config:set NPM_CONFIG_PRODUCTION=true YARN_PRODUCTION=true 
#

@golden condor ^^

golden condor
#

Where do I do that

hoary elm
#

It installs whatevers in the package by default

golden condor
#

And what does it mean

#

oh thanks

#

Where do I run this?

hoary elm
#

To add env variables go to your Heroku app > settings scroll to reveal config vars and add them there

golden condor
peak venture
#

how did i obtain the value of VcID using this webpage thing again?
room.html?VcID=596690518

golden condor
#

Is that right @hoary elm

#

It gives an error

hoary elm
golden condor
#

Should I use this

#

"scripts": {
"heroku-prebuild": "echo This runs before Heroku installs your dependencies.",
"heroku-postbuild": "echo This runs afterwards."
}

pale vessel
#

how did i obtain the value of VcID using this webpage thing again?
room.html?VcID=596690518
@peak venture details please

#

what are you trying to accomplish

golden condor
#

@hoary elm is that right or do i need to do smth else

peak venture
#

@pale vessel obtain parameter from VcID

hoary elm
#

@golden condor that's only if you have a buildscript.

golden condor
#

A buildscript?

pale vessel
#

using what?

peak venture
#

express nodejs?

pale vessel
#

req.query.VcID

finite bough
#

imagine scripting a bot

golden condor
#

@hoary elm is there any way I can do it please help

#

I am so confused

#

config:set NPM_CONFIG_PRODUCTION=false YARN_PRODUCTION=false

hoary elm
#

Honestly just adding the module name and version to your package and redeploying would probably be easiest.

golden condor
#

I did

#

It didn't work

hoary elm
#

What did you add?