#development

1 messages ยท Page 856 of 1

tight plinth
#

wat

terse trench
#

this literally doesnt work

#

I'm in great confusion

ruby bane
#

ive seen in another bot once

valid holly
#

can he use glob wildcards for windows ?

terse trench
tight plinth
#

wat dafuk

terse trench
#

turn bruh.exe into okay (just make shortcut of it in the same folder)

tight plinth
#

impossible

valid holly
#

okay shortcut can execute bruh.exe

#

If that's what you're looking for

#

but bruh.exe can't turn into okay or make sh

#

Why do you need that tho ?

terse trench
#

i need shortcut specifically

#

well shit

twin iron
#

-bots

gilded plankBOT
valid holly
agile dew
#

My custom bot wont go online / start ? any advice?

valid holly
#

Then you can get the location of bruh.exe within the same directory or other

#

./bruh.exe

#

And do whatever you want from there.

terse trench
#

its ait i found another way

valid holly
#

@agile dew did anything log ?

agile dew
#

@valid holly Nope

queen needle
#
client.on("message", message => {
  if (message.content.startsWith(PREFIX + "dice")) {
    let fish = Math.floor(Math.random() * 6) + 1;
    let fish2 = Math.floor(Math.random() * 6) + 1;
    let result = `${fish}-${fish2}\n`;

   if (fish == 1 || fish2 == 1){
      result += "Snake eyes";
    } 
    message.channel.send({
      embed: {
        color: 12745742,
        title: "Dice " + message.author.username,
        fields: [
          {
            name: "Dice game",
            value: result
          }
        ]
      }
    });
  }
});```
agile dew
#
   token: auth.token,
   autorun: true
}); 
console.log(bot)```
#
  presenceStatus: 'offline',
  connected: false,
  inviteURL: null,
  connect: [Function: bound ] }```
tight plinth
#

^wat

queen needle
#

how could i make it so if they both are equal to 1 it says snake eyes

terse trench
#

๐Ÿค”

tight plinth
#

fish1 === fish2?

valid holly
#

&& operator

queen needle
#

but then if they are 2 and 2 3 and 3 4 and 4 5 and 5 it would say snake eyes

valid holly
#

if(x && y == 1)

twin iron
#

@queen needle just use && operator

#

instead of ||

queen needle
#

i am now thank you desu

valid holly
#

@agile dew any entry where your bot connects to the websocket ?

lapis herald
#

,

valid holly
#

Or you just listed the client options ?

#

Np @queen needle

#

Can you also mention your lib version that you're on

agile dew
#
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
    // Our bot needs to know if it will execute a command
    // It will listen for messages that will start with `!`
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0];
       
        args = args.splice(1);
        switch(cmd) {
            // !ping
            case 'ping':
                bot.sendMessage({
                    to: channelID,
                    message: 'Pong!'
                });
            break;
            // Just add any case commands if you want to..
         }
     }
});```
#

Just copied this off somewhere :p

valid holly
#

To do so just run npm v discord.js

#

Don't copy code without knowing how to code.

agile dew
#

"discord.io": "^2.5.3"

#

xD

valid holly
agile dew
#

lets try discord.js :p

valid holly
#

I though discord.io was abandoned

queen needle
#

i have a 436 line file for my bot

#

thats where all my commands are

valid holly
#

well looking at how you wrote your code I guess 436 is a small number

queen needle
#

yeah

#

i could easily make it more

agile dew
#

@valid holly discord.js worked Thanks

valid holly
#

np

#

@queen needle

#

you can start with saving actual information you'll reuse into let

#

Like:

let cmd = message.content.trim().toLowerCase().startsWith("your_prefix");
if(cmd + "command") { // bool
}
copper cradle
#

@agile dew to run a bot in d.js you gotta use client.login()

#

passing the token as an argument doesn't work iirc

agile dew
#

yeah did that, Thanks @copper cradle

copper cradle
#

oh

#

what is 'logger'?

agile dew
#

winston library

#

good for creating logs

copper cradle
#

can I get a link to it?

agile dew
copper cradle
#

that's pretty nice

#

never heard of it

valid holly
#

I assume you can use Node's FS and console class

copper cradle
#

ยฏ_(ใƒ„)_/ยฏ

valid holly
#

For logs that would suffice for me.

agile dew
#

yeah fs can be used too

#

winston is nice though :p

quartz kindle
#

there are many logging libraries

#

log4js, pino, bunyan, winston, etc

queen needle
#

i cleaned up my code and got it down to 390

copper cradle
#

yeah, there are a lot

valid holly
#

oh it's Tim ! Wumplus

earnest phoenix
#

Anyone know some good API's I could use for my bot.

copper cradle
#

what do you want to use 'em for?

earnest phoenix
#

Just make my bot better that is all.

#

Like statistics. My bot is more of an information one.

copper cradle
#

hmm

valid holly
#

Really broad question tho

queen needle
#

Anyone know good APIs for images or memes

valid holly
#

giphy ? tenor ?

#

Idk, query anything no need for api

#

you can even use google

queen needle
#

Idk how to is the problem and when I tried I could find s video or article or sub reddit or anything

valid holly
#

Find restful API's

#

Use HTTPS's GET method

#

Giphy has restful api's

#

Here is a response to query search "meme"

queen needle
#

Okay I'll try that and up date you

valid holly
#

๐Ÿ‘

uneven wyvern
#

wish me luck, 6 months of not coding in discord.js and now making a discord bot...

royal portal
#

good luck

wide ridge
#

[D.js v12] anyone know how to handle sending dms to user using shardingManager and dblapi webhooks? I tried broadcastEval but it ends up sending duplicate dms.

Essentially I want to send a dm to a user after they vote but with shardingManager I'm not sure how it would work without the client.

queen needle
#

how would i make a command where its like !thanks @ a user thenit would say auser was thanked by my username

earnest phoenix
#

@queen needle discord.js?

queen needle
#

yes

earnest phoenix
#

Version?

queen needle
#

11.5.1

earnest phoenix
#

Hmm... I'm not sure it would work but are you interested on updating to a newer version of discord.js?

#

@queen needle

queen needle
#

now its 12.1.1

earnest phoenix
#

Oh nice...

#

Now

quartz kindle
#

@wide ridge send it only to shard 0

wide ridge
#

send the dm to shard 0?

quartz kindle
#

send the vote to shard 0, and send the dm from there

wide ridge
#

hmmm

queen needle
#
module.exports = function(controller) {
  controller.hears("!thanks", ["direct_mention", "mention"], (bot, message) => {
    let response;
    let sender = message.user;
    
    // Many bots use the this method but sometimes it doesn't work, for example if you mention more than one person
    //let recipient = message.mentions.users.last();
    
    
    // this method filters out any users that aren't bots
    // if you have a bot that does more administrative things like blocking people, you might want to filter even more
    // like filter out admins or the person sending the message
    // it's using Discord.js for all this, yep that's right you have access to everything in Botkit AND Discord.js
    // https://discord.js.org/#/docs/main/master/class/User
    let recipient = message.mentions.users.filter(user => user.bot === false).last();

    
    // this is a list of potential responses, it chooses from them randomly.
    // Try changing them or adding your own. 
    let responses = [
      `${recipient} got kudos from ${sender} ๐ŸŽ‰`,
      `${sender} thinks ${recipient} is awesome! โœจ`,
      `Hey ${recipient}! ${sender} appreciates you! ๐Ÿ˜`,
      `Hey ${recipient}! ${sender} thinks you rule! ๐Ÿ’ช`
    ]

    response = responses[Math.floor(Math.random() * responses.length)];
    
    bot.reply(message, response);
  });```
#

like that but i dont want to have to mention my bot

quartz kindle
#

you can do manager.shards.first().eval()

#

instead of broadcastEval

wide ridge
#

ahhhhh

#

so that would evaluate a script for just shard 0?

earnest phoenix
#
let Muser = message.mentions.users.first();
if (!Muser) {
return message.channel.send("You thanked yourself...")
} else if(Muser){
return message.channel.send(`${message.author.username} thanked ${Muser.username}!`)
}```
 @queen needle
#

This would work...

quartz kindle
#

ye gopi

wide ridge
#

yeah cause I'm trying to emulate this behavior:

#

hmm ok I'll try it out!

#

thanks a lot man, appreciate the response

queen needle
#

parrsing error return out of function

smoky matrix
#

can anyone help me with sql

wide ridge
#

potato I can try? what's the question

earnest phoenix
#

@queen needle huh?
Screenshot of your code...

smoky matrix
#

im watching a video im doing it just like him but its not working

#

it doesnt make a table when i run the bot

earnest phoenix
#

what language are you using?

smoky matrix
#

py

wide ridge
#

can you post some of the code and maybe the link to the video you're viewing?

queen needle
smoky matrix
#

thats the link

earnest phoenix
#

@queen needle yea that's the code but what does the error say?

west spoke
#

@queen needle press printscr and paste it into discord good lord

#

Also

smoky matrix
#
@bot.event
async def on_ready():
    db = sqlite3.connect('main.sqlite')
    cursor = db.cursor()
    cursor.execute('''
        CREATE TABLE IF TABLE NOT EXISTS main(
        guild_id TEXT,
        msg TEXT,
        channel_id TEXT
        )
        ''')```
west spoke
#

Missing a }

#

before the bot.login

earnest phoenix
#

Yup

quartz kindle
#

@wide ridge the user wont necessarily be cached in shard 0, but you can fetch it from any shard and create a dm channel from any shard

#

alternatively, you can broadcastEval to all shards and find which one has the user cached

queen needle
#

Parsing error: 'return' outside of function

west spoke
#

@smoky matrix what is you trying to do

queen needle
#

still have error

west spoke
#

I dont know what lang you're using cinnamon

smoky matrix
#

im trying to make a table for the database

copper cradle
#

that's js

wide ridge
#

alternatively, you can broadcastEval to all shards and find which one has the user cached
@quartz kindle but there can be multiple shards that cache the user right?

west spoke
#

.json exists

#

pls

copper cradle
#

they're using js

earnest phoenix
#

@queen needle wait... How's return outside of a function...

quartz kindle
#

@wide ridge yes

copper cradle
#

cinnamon roll

west spoke
#

dont jump to sqlite when starting a lang

#

learn the basics

queen needle
#

idk

west spoke
#

thank

copper cradle
#

if you get an error that says return outside of function

#

then what do you think you have to do?

quartz kindle
#

happy birthday @west spoke lol

wide ridge
#

oh so for the broadcastEval I'm just looking to return the user object?

copper cradle
#

check your code and see where you have a return statement outside of a function

west spoke
#

Ty tim

copper cradle
#

cinnamon roll, you have a return statement at the very end of your code

#

and that is outside a function

#

you can't use return outside of functions

#

I recommend learning the basics of functions and the language you're using before attempting this

quartz kindle
#

@wide ridge i see what you mean now, if the user is cached in more than one shard, it will send multiple dms. so then you have to fetch the user instead

wide ridge
#

yeah

quartz kindle
#

do the shard 0 method

wide ridge
#

fetch the user hmm

#

ohh

#

ok

quartz kindle
#

manager.shards.first().eval("client.users.fetch(id).then(u => u.send('voted'))")

queen needle
#

i got rid of the error but when i do the command nothing happens

wide ridge
#

I'll try it out, thanks so much Tim!

royal portal
#

stuck on fetching banned users

earnest phoenix
#

@queen needle... It doesn't even give any errors?

queen needle
#

no

#
client.on("message", message => {

if (message.content.toLowerCase().startWith === "!thanks") {
  let Muser = message.mentions.users.first();
  if (!Muser) {
    return message.channel.send("You thanked yourself...");
  } else if (Muser) {
    return message.channel.send(
      `${message.author.username} thanked ${Muser.username}!`
    );
  }
}
});```
#

code

copper cradle
#

@queen needle that code block is outside of the message event callback, holy cow, don't you see it? the underlined brackets are the ending of the message event, you literally tried to put code outside of it and you're still hoping it works

earnest phoenix
#

@queen needle why do you have that ); there?

pale vessel
#

channel send

copper cradle
#

wait

#

are you creating a message event for each command?

earnest phoenix
#

Hmm yea like creating a message event for each command is not a good thing...

#

@copper cradle also he put a ); there which shouldn't be there(under the last code line)

copper cradle
#

lemme see

queen needle
#

i got rid of that

copper cradle
#

where

earnest phoenix
#

Oh nevermind...

copper cradle
#

today we may see snails getting mad v8

earnest phoenix
#

Hmm that code should work tho...

copper cradle
#

yes that one should work

earnest phoenix
#

I gave him that code but he says it doesn't work...

pale vessel
#

@copper cradle also he put a ); there which shouldn't be there(under the last code line)
@earnest phoenix which one?

copper cradle
#

nono

pale vessel
#

it's correct

copper cradle
#

it was dank Voltrex's mistake

#

it's correct indeed

pale vessel
#

i was making sure

earnest phoenix
#

@pale vessel nevermind i thought it was a mistake

copper cradle
#

cinnamon roll, if it doesn't work

pale vessel
#

k

copper cradle
#

send the error you get

queen needle
#

so if the ); isnt there i have an error

copper cradle
#

don't you read?

#

we already said the ); goes there

#

dank had a stroke

earnest phoenix
#

Add that back...

copper cradle
#

and that's it

earnest phoenix
#

Lmao

queen needle
#

i added it back testing that code rn

pale vessel
#

reminds me of that cat loading picture

copper cradle
#

Cinnamon roll, I recommend you learn the lang first

royal portal
#

english language

pale vessel
#

no

queen needle
#

still didn't give a output

pale vessel
#

just show us the whole file lol

copper cradle
#

this is an obvious case of "I watched TSC's tutorials, and now I think I'm a programmer, now I gotta start on a big project without knowing that I'm doing, encountering thousands of errors which I don't know how to fix"

earnest phoenix
#

@queen needle do you store your commands in one file or make command handlers?

copper cradle
#

or do you make a message event for each command?

pale vessel
#

if he does that he has a small brain

earnest phoenix
#

how do i something like

if (message.channel.typeof == "DM") return;
copper cradle
#

type

pale vessel
#

if (!msg.guild)

copper cradle
#

and also

earnest phoenix
#

I cannot install any modules, Everytime i try doing it it sends a red ERR, help?

pale vessel
#

or message.channel.type == "dm"

copper cradle
#

@earnest phoenix show the err duh

earnest phoenix
#

Literally one message event in the first part of the code is enough...

copper cradle
#

they never said they used multiple message events

#

tho

pale vessel
#

just show us the whole file

royal portal
#

but not the token

pale vessel
#

yes

#

the token too

earnest phoenix
pale vessel
#

python?

#

wut

#

what did you do

#

ah gyp

#

install node-gyp

copper cradle
#

install node-gyp

pale vessel
#

so python and vs stuff

earnest phoenix
#

alright

copper cradle
#

you need python for that

pale vessel
earnest phoenix
#

also

#

stop transforming your strings in your command handlers ๐Ÿ˜ž

#

it's slower and you're wasting resources

#

use localeCompare

queen needle
#

im using one fike

#

file

pale vessel
#

oh damn he bought nitro

idle schooner
#

i just wrote some random shit in bot description lol

#

idk what to write for 300 characters oof

copper cradle
#

yeah you'll get declined

idle schooner
#

RIP the dream

copper cradle
#

@idle schooner congratulations on your first decline ๐ŸŽ‰

#

you better change that

idle schooner
#

what r u the one reviewing

copper cradle
#

you still have 2 weeks to think of a new desc

#

no, I'm not

idle schooner
#

it basically is nothing

copper cradle
#

but that's a very common issue here

idle schooner
#

im a starter

#

it won't matter much if it gets declined

copper cradle
#

check #mod-logs and see how many bots get declined for having random stuff in their long desc

idle schooner
#

so no problemo

copper cradle
#

well

#

you do you

idle schooner
copper cradle
#

yes

idle schooner
#

"you do you " means

#

?

pale vessel
#

you do you

worn spade
#

XD

idle schooner
#

okay buddy

#

lol

#

i got your emote

agile dew
#

how do u get user's voice channel id?

idle schooner
#

user's voice channel id ?

#

i have heard only of user id and channel id

quartz kindle
agile dew
#

@quartz kindle Thanks

idle schooner
#

wait what is that

#

@quartz kindle

quartz kindle
#

what is what?

idle schooner
quartz kindle
#

to get a member's voice channel id

#

in discord.js

idle schooner
#

ok

quartz kindle
#

did you create a bot in discord portal and immediately added it to top.gg?

idle schooner
#

who me ?

quartz kindle
#

yes

idle schooner
#

no i didn't

#

that bot was created like 4 months ago

copper cradle
#

but

#

like

idle schooner
#

just trying to add now for fun

copper cradle
#

you coded it

#

right?

idle schooner
#

yea

#

noob coding

copper cradle
#

what lang

#

lemme guess

#

js

idle schooner
#

py

queen needle
#

thats 40% of mine

copper cradle
#

ooh

#

that's 100% of most white names here tbh

#

noob coding

idle schooner
#

eh whut lol

queen needle
#

yeah

idle schooner
#

well why did u ask if i coded my bot @copper cradle

#

lol

copper cradle
#

bc there have been people that think that by creating a bot account in the dev portal you have a fully functional bot

idle schooner
#

seriously ?

copper cradle
#

yes

#

and you'll have a good laugh

cobalt scarab
#

Why am i having such a hard time finding the code to do something for say "!countdown 24h" and the bot to have it shown on the server?

copper cradle
#

for say

#

what

#

why do you want to find the code

#

just code it yourself

quartz kindle
#

code is not something you find, its something you do lol

idle schooner
#

wait a minute my bot has to be online when they review ?!

copper cradle
#

yes

#

they won't review tho

idle schooner
#

oh yea right

copper cradle
#

bc of your description

idle schooner
#

after the description right ?

mossy vine
#

how else would they test the bot

idle schooner
copper cradle
#

yeah

cobalt scarab
#

i cant find how to code it lol #nub

idle schooner
#

i think there are many bot codes in the internet

#

that people copy and make a bot

mossy vine
#

and copying them only makes u dumber

copper cradle
#

^

idle schooner
#

most bot tutorials on youtube do that

#

and people follow it

copper cradle
#

coding just requires common sense lol

#

like

mossy vine
#

yeah they just give you the code with no explanation of concepts and lol hf bothering others with that shit

copper cradle
#

take a sheet of paper

idle schooner
#

they are not coders , but common men trying to get a bot

copper cradle
#

and do the following

#

"what do I want to do?
what's the logic behind it?
If I want to do this, how can I do it?"

idle schooner
#

u seem to over simplify coding xD

copper cradle
#

that's what it is

#

coding is like the easiest shit ever

#

I mean

crimson vapor
#

lol

copper cradle
#

it requires knowledge and common sense

quartz kindle
#

well, you do have to learn some stuff, its a language after all

idle schooner
#

yea lol

copper cradle
#

yeah

crimson vapor
#

Honestly, learning is the way to go

idle schooner
#

and there are complex problems

#

that some brains can't get through

#

like mine

crimson vapor
#

what "complex problems"

idle schooner
#

millions are there

#

websites like hacker rank run you through them

mossy vine
#

writing code is easy. solving problems with code is not

crimson vapor
#

the hardest problem I have had with coding is trying to make a circle with the top up and the amount filled as a percentage

mossy vine
#

like come on any dumbass can write print("hi")

#

takes some iq to solve problems

idle schooner
#

that is what i said

crimson vapor
#

but I small brain and only needed to remove .5 PI from each and a little other shit

#

radeons are confusing tbh

idle schooner
#

radeon ?

crimson vapor
#

radians*

idle schooner
#

hmm

quartz kindle
#

convert them to degrees then convert them back lmao

idle schooner
#

hehe

crimson vapor
#

im not big brain enough for that

idle schooner
#

its easy brother

#

360 degress = 2 * pi radians

crimson vapor
#

ye ik

idle schooner
#

this is the equality u need to remember

#

whatever u do , do the same on both sides

wide ridge
#

Tim I was wondering for the method you mentioned earlier

    manager.shards.first().eval(`this.users.fetch(\`${userId}\`).then(u => u.send("voted"))`);```
This method would only check shard 0 for the user wouldn't it? How would it find users that are not on shard 0? Do all users get cached on shard 0?
crimson vapor
#

I know math

#

just change it

#
this.users.fetch(\`${userID}\`).then(u => {
  if (!u) return;
  u.send('voted!')
})```
quartz kindle
#

@wide ridge fetch gets the user from the API if not cached

#

thats why its a promise

wide ridge
#

ahhhhh I see

#

that would work, makes sense

#

Thanks!

crimson vapor
#

wait now im confused wut

wide ridge
#

I'm gonna try to push my shard voting tonight, and I'll see how it goes. You will not be forgotten Tim โค๏ธ

crimson vapor
#

does users.fetch() get a user no matter what shard its on?

wide ridge
#

from what Tim said, it calls the API if the user is not cached

#

so yeah

crimson vapor
#

oh got it

wide ridge
#

yeah

#

pretty useful

crimson vapor
#

once I learned to use docs, js came really easy to learn

queen needle
#

Theres a difference between following tutorial to copy it and have vs watching a tutorial to learn and understand it

mossy vine
#

then there are languages like rust where docs make it harder

crimson vapor
#

ye I never watched tutorials :D

finite bough
#
TypeError: prefixes.findOne is not a function
at Object.code (/app/commands/botinfo.js:15:13)
at /app/index.js:117:17
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4837:16
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4837:16
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/helpers/promiseOrCallback.js:24:16
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4860:21
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/query.js:4370:11
    at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/kareem/2.3.1/node_modules/kareem/index.js:135:16
    at processTicksAndRejections (internal/process/task_queues.js:81:9)
crimson vapor
#

what did you define prefixes as?

finite bough
#

as a Schema table

crimson vapor
#

what DB?

quartz kindle
#

show where you define it

#

and show where you call code()

crimson vapor
#

wait I see its mongo

finite bough
#

it works in all other files

#

so defining it is not the problem

#

but if u want

quartz kindle
#

show where you call code()

finite bough
#

this?

crimson vapor
#

no

#

call it

#

like the message.js I assume you named it

woeful fractal
#

I got a problem when typing node .

#

at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint
[as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47

finite bough
#

hmm

crimson vapor
#

@woeful fractal you didnt show the error

woeful fractal
#

I reinstalled it

mossy vine
#

congrats u managed to show everything but the error

woeful fractal
#

Is it not an error?

quartz kindle
finite bough
#

wut

quartz kindle
#

you switched them around

finite bough
#

a

#

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

quartz kindle
#

@woeful fractal thats not the complete error

#

there is likely more information before that

copper cradle
#

@woeful fractal learn to read an error

#

that gibberish is just the stack trace

woeful fractal
#

node .
C:\Users\skybl\Desktop\Discord Bot\index.js:2
const bot = new Discord.bot();
^

TypeError: Discord.bot is not a constructor
at Object.<anonymous> (C:\Users\skybl\Desktop\Discord Bot\index.js:2:13) at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47

pale vessel
#

lmao

#

you mean Discord.Client() ?

quartz kindle
#

Discord.Client()

copper cradle
#

there's so much wrong with that

woeful fractal
#

Its in there

#

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

copper cradle
#

?

pale vessel
#

find line 13

copper cradle
pale vessel
#

?

copper cradle
#

show your code

pale vessel
#

ok

copper cradle
#

why don't people learn to code before attempting on such a project

pale vessel
#

idk, desperate?

crimson vapor
#

lmao I didnt learn to code

pale vessel
#

me too

copper cradle
#

bad

pale vessel
#

but i ended up fine

copper cradle
woeful fractal
#

Finally!

#

I finally got it working.

queen needle
#

ive know js for a while im just bad with it

copper cradle
#

idk

#

doesn't sound too convincing

queen needle
#

my js skills are like maybe 30/100

prime cliff
#
  1. Create code
  2. Make a mess of your code
  3. Fail at making a bot
  4. Spend hours trying to fix a simple issue
  5. Accept that your code is bad
queen needle
#

i accpeted my code was bad before i coded

quartz kindle
#

your code never stops being bad

#

no matter how many times you improve it

#

my code is still bad

queen needle
#

yeah

copper cradle
#

but it'll never be worse than before

queen needle
#

what?

cursive thistle
#

I learned js from trying to make a discord bot ๐Ÿคท

#

Thatโ€™s how I was introduced to it

slim heart
#

so in jsdoc how would i define what a different instance of each value would mean?
so i have this typedef that is something that can be a 0, 1, or 2, each meaning like
0: mute
1: kick
2: ban
how would i document the meaning of each of those?

copper cradle
#

wdym

finite bough
#

ber is drunk

copper cradle
#

I didn't understand what you're trying to do

cursive thistle
#

Document? What?

queen needle
#

send a screenshot or something

copper cradle
#

I've used jsdoc before

#

but like

#

try to explain it in a different way

slim heart
#

so i have the @typedef {Integer} Name
i want the jsdoc to be able to tell the dev what each instance of its value means

#

so if that Name = 0 it means mute, 1=kick, 2=ban, etc. but i want that to be included in the documentation

slate quail
#

with discord.py how do you set a variable like "playing" to 0 in the after kwarg with voice_client.play()?

copper cradle
#

show us an example

#

bc I'm kinda drunk atm

slate quail
#
client.voice_clients[0].play(discord.FFmpegPCMAudio(str(message.id) + ".wav"), after=*SET PLAYING TO 0*)```
copper cradle
#

wouldn't @twilit halo work? @slim heart

slim heart
#

no? its not an object

#

its just an int

copper cradle
#

wait

#

it actually mentioned a guy

#

oof

quartz kindle
#

@slim heart not sure about this, but maybe a typedef line followed by param lines

#

for each possible param

slim heart
#

o alright that might work ok

quartz kindle
#

or some combination of that

copper cradle
#

that's what I said

slim heart
#

another jsdoc question as well is how can i set the default of a @property ?

copper cradle
#
/**
* @typedef {object} E
* @property {string} dow
*/
pale vessel
#

isn't there a docs

slim heart
#

@copper cradle no that wasnt the thing i was talking about lol

pale vessel
#

@cyan onyx ?

#

oh jeez

slim heart
#

no

#

wait i found it

pale vessel
#

sorry default

slim heart
#

@property {Type} name=[default] blah

copper cradle
#

wait whot

quartz kindle
#

jsdoc is weird af

slim heart
#

yeah

quartz kindle
#

i cba using it lmao

slim heart
#

i need it for good resume pandasad

quartz kindle
#

tbh i dont even comment my code

copper cradle
#

hmm

#

commenting your code is always a good practice imo

#

unless you're the only one who uses it

pale vessel
#

but you know, cba...

quartz kindle
#

^

#

lmao

#

i'll get github contributors to comment it

copper cradle
#

lmao

slim heart
#

nope param doesnt work oof

copper cradle
#

[at]link

#

fuck

pale vessel
#

oof

#

lmao

copper cradle
#

there

#

I fucking hate escaping

pale vessel
#

semi-ghost ping bad

copper cradle
#

yeah

oblique basalt
#

Glitch is down, rip my bots

earnest phoenix
#

same

pale vessel
#

well it's fReE

grizzled raven
#

if you do ```js
let val = promise().then(x => x)

// will it be the same as
let val = await promise()

mossy vine
#

i think so

cinder patio
#

I don't think so

mossy vine
#

why wouldnt it be

cinder patio
#

I think it would return a promise

#

so it would be pointless

grizzled raven
#

like

#

sometimes it is i think

mossy vine
#

what would

cinder patio
grizzled raven
#

ok it seems to just be when you return with .then, like ```js
return promise.then(val => val) // returns whatever the promise resolves

#

ok

cinder patio
#

The then() method returns a Promise

quartz kindle
#

await promise() returns the result of the promise

#

promise.then() returns the unresolved promise, and the result inside the callback

grizzled raven
#

oh ok

#

but when you do return promise.then(v => v), it returns the result of the promise, right?

quartz kindle
#

no

grizzled raven
#

ohh wait

quartz kindle
#

the result is only available in the callback

grizzled raven
#

no nevermind

#

okay

quartz kindle
#

but if you do await promise.then(val => val), it will return the final result of the promise chain

#

so you can for example modify the result of the promise before returning it

grizzled raven
#

yeah i see

#

but if you await a promise and catch it with .catch, will the .catch do nothing much?

quartz kindle
#

the catch will catch the error, and the await will receive the result of the catch function, if any

grizzled raven
#

oh

#

just thought i was still recieving errors because i catch a promise that gets awaited

#

but nvm thats just me

quartz kindle
#

essentialy, await something.catch(e => false) is the same as return something || false in promise form

grizzled raven
#

oh okay

wintry wing
#

What Linux distro is good for NodeJS discord bots?

steel heath
#

waitWhat ones that supports NodeJS I guess?

wintry wing
#

ยฏ_(ใƒ„)_/ยฏ

mossy vine
#

ubuntu

wintry wing
#

I was gonna choose ubuntu server but donโ€™t know

#

oh ok

mossy vine
#

very easy to set up and manage

wintry wing
#

Ok

mossy vine
#

otherwise it literally doesnt matter

wintry wing
#

16? Or 18?

#

Nvm

spice pier
#

There no best distro, you could probably even run it on Alpine

copper cradle
#

run it on DaveOS

terse trench
#

run it on gparted live

copper cradle
#

OpenBDS

royal portal
#

how would I check

#

if user is not banned

#

and if they arent banned

#

then return

#

in v12

copper cradle
#

?

summer torrent
#

d.js?

royal portal
#

yep

copper cradle
#

ofc

#

but like

summer torrent
#

fetchBan()

copper cradle
#

why are you even asking this

royal portal
#

because i made a bot for my friend's server

#

and it has

#

unban command

copper cradle
#

don't ya know how to use if statements and expressions?

royal portal
#

it sends the ban reason and all that in logs

summer torrent
earnest phoenix
lean pumice
dusky marsh
#

it takes up to two weeks afaik

earnest phoenix
royal portal
#

@lean pumice you'll be accepted or declined maybe like tomorrow because i added my bot same day

#

mods will get to your bot eventually

#

its in a queue

main laurel
summer torrent
#

that is for certified devs

modest maple
#

You need to be cert

main laurel
#

okay thanks

copper cradle
#

Only cert

summer torrent
earnest phoenix
#

Is it normal that my command sends an error message but still works fine?

quartz kindle
#

@summer torrent are you trying to make it restart itself, or are you restarting another process?

summer torrent
#

itself

copper cradle
#

impossible

summer torrent
#

maybe pm2 restart 2 ๐Ÿค”

copper cradle
#

not really

#

but like

white gate
#

@summer torrent Try this; exec("pm2 restart app"โ€‹, async(err, res) => { if (err) m.edit(...) else { ... } });

quartz kindle
#

that shouldnt even be working, but i think pm2 gives you a grace period before killing the process, thats why it works

#

are you promisifying exec?

summer torrent
#

yes

#

@white gate lemme try

quartz kindle
#

i believe exec can return both stderr and stdout at the same time, so maybe the promise is resolving with both lol

#

idk

earnest phoenix
#

Hey, so i made this prefix command using quick.db, when i execute the command it sends me a error message but the prefix still changes. Should i be worried?

quartz kindle
#

what is the error?

earnest phoenix
quartz kindle
#

that means set is not a promise

#

so you dont need to use .then or .catch

earnest phoenix
#

oh

#

thank you!

daring sage
#

guys, hello, i need some help here!

i'm trying to make a command that stores a to-do list in a .json file, i'm using fs, but when i run the command fs.writeFile it overlaps the already created info!

quartz kindle
#

json cannot be partially edited

#

you need to load the entire json file, modify it, and save the entire json file

#

json is very inefficient for storing dynamic data for that reason

daring sage
#

how can i create a efficient way to do it?

quartz kindle
#

by not using json

daring sage
#

create another .js file?

#

and create a array?

quartz kindle
#

are there to-do lists editable by users? can anyone create them?

daring sage
#

i just need to him add to storage and send to chat from storage

#

yep

#

is free to use

quartz kindle
#

then ideally you should use a database

daring sage
#

any suggestion?

#

mongo db?

quartz kindle
#

SQLite is a good option

#

mongo is also an option if you prefer nosql

daring sage
#

what's the difference?

quartz kindle
#

they are very different

#

SQLite is an embedded SQL database
mongo is a server NO-SQL database

#

SQLite is integrated into your bot. mongo needs to be installed separately and run as a server in your vps (or if you use a remote mongo service)

daring sage
#

ohh got it

#

i prefer to not difficult it lol

quartz kindle
#

SQLite uses the SQL language to move data

#

mongo uses a different style, with documents, promises and chains

daring sage
#

jeez

#

okay, i'll search about SQLite

#

thanks Tim!

dense drift
#
let filter = m => m.content.toLowerCase() === "accept" && msg.author.id == invm.id || m.content.toLowerCase() === "deny" && msg.author.id == invm.id

So does the && not apply in this type of filter?

This is for awaiting messages.

#

I am stupid!

topaz fjord
#

you can simplify that even more

copper cradle
#

yeah

earnest phoenix
#

stop transforming your strings for comparison NotLikeThis

#

use localeCompare

earnest phoenix
#

anyone here uses quick.db?

past trail
#

Welp, I am trying to make a bot that use a database with MongoDB on Python and I need a little bit of help. I am making a bot where it does boxing matches and depending on who wins or loses the wins get a +1 in the wins column and the loses +1 in the loses column and I am also calculating a percent for wins/total matches. My only issue is that in the dictionary keys cannot equal 0 and so I had to make them strings, but there really is no way to divide a string by a string, I've read the docs and have a decent understanding, but yeah

visual sandal
#

When i print the votes in console i get a number, but when i put it in the embed, it shows up undefined

    var votes = await vote();
    const embed = new Discord.RichEmbed().addField(`Votes`, votes, false);
    await message.channel.send(embed);
    async function vote() {
        request(`${url}`, { headers: { "Authorization": `${config.dbl_api}` } }, function (err, response, body) {
            let bot = JSON.parse(body);
            votes = bot.monthlyPoints;
        })
    }
#

nvm.. i got it

copper cradle
#

@past trail turn the strings into integers do the math and then turn back into strings

#

@visual sandal do you know what a return keyword is?

#

learn the basics of functions

#

you need to return votes duh

#

@visual sandal

#

inside the callback for request return votes

visual sandal
#

oh sry.. i was doing it a different way and sent the wrong code
this is the original

    var votes;
    request(`${url}`, { headers: { "Authorization": `${config.dbl_api}` } }, function (err, response, body) {
        let bot = JSON.parse(body);
        votes = bot.monthlyPoints;
    })
copper cradle
#

show more code

#

i don't know if that's insid a function or not

visual sandal
copper cradle
#

uh

#

didn't see that lol

astral yoke
#

I need help.

#

How would you get your socket less hung up?

#

To where it dosen't get hung up^ or fix it

copper cradle
#

...

#

you can't do anything

#

just bear with that ans

astral yoke
#

alright

#

thanks

#

!level

#

!level

#

That's not even a command.

#

!rank

#

..

#

!leaderboard

summer torrent
tranquil scroll
#

p!help

#

p!yardฤฑm

#

p!yardฤฑm

copper cradle
#

how come green names are doing this...

barren swallow
copper cradle
#

last one

#

looks less polluted @barren swallow

#

if you know what I mean

barren swallow
#

Ye

brittle ruin
#

hello

#

i wanna add my bot to the website

#

how

summer torrent
brittle ruin
#

thanks

earnest phoenix
#

hey dm me i need some bots im willing to pay

copper cradle
#

you're a bot dev...

#

code 'em yourself lol

vernal merlin
#

Hm

golden condor
#

In js if you use setTimeout, say as a timeout, would that use of lots of ram?

copper cradle
#

depends

#

like

#

setting a timeout won't do much

golden condor
#

@copper cradle like setTimeout function

dusky marsh
#

he knows, he answered the question

golden condor
#

Ok I was just making sure

#

Thanks

dusky marsh
#

yeye

worthy narwhal
#

@spare goblet Reason ?

spare goblet
#

@worthy narwhal can you not randomly tag me for no reason naniwdym

#

Idk what you're taling about

tight plinth
#

about:blank

spare goblet
tight plinth
#

lliterally a blank page

spare goblet
#

so why would it be a valid page

wide ridge
#

how come we can't perform async actions in

          console.log(`User with ID ${vote.user} just voted!`)
}
#

I tried to use async and await but it crashes or gives me errors when I try to fetch something from my db

tight plinth
#

works without

wide ridge
#

hmm

cinder patio
#

show your code, where exactly are you awaiting

earnest phoenix
#

The one time my bots down๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

burnt gyro
#

rip

lucid elk
#

GG

tight plinth
#

gg

#

buty its not the place

burnt gyro
#

idk even was my bot running or no when i applyed becosue i used garbage 24/7 host

earnest phoenix
#

is x! a common prefix?

true ravine
#

I don't think so

#

There's a list of common prefixes somewhere in this server

earnest phoenix
#

Oof

nocturne grove
#

Hi, stupid question here but have to know. Anyone knows since when (approximately) search for mentions using like mentions: Menno#0985 instead of using your id to search a mention? Is it like a couple of months (I guess that)?

tight plinth
#

yea, some months

nocturne grove
#

okay thank you

#

sorry for the very specific question

crimson vapor
#

I thought it was forever

nocturne grove
#

@crimson vapor well I have not seen it before at least this year, I thought

crimson vapor
#

idk then

blissful scaffold
#

Just searching for the id is usually enough to find all mentions of that person, so instead of mention: 481031493490049044 you can just do 481031493490049044

elder garnet
#

how do i check for a set if it haves something in it

#

im basically doing this

const myVariable = new Set();
const myVariableSeconds = 5
myVariable.add(msg.author.id)
setTimeout(() => {
  myVariable.delete(msg.author.id)
}, myVariableSeconds * 1000)
```but i want to check if ((myVariable)) has anything in it
cinder patio
#

myVariable.has

elder garnet
#

okay thanks

nocturne grove
#

Just searching for the id is usually enough to find all mentions of that person, so instead of mention: 481031493490049044 you can just do 481031493490049044
@blissful scaffold yeah I know, but that was not my question

earnest phoenix
#

The bot write [object object]
@earnest phoenix How do you saving to database?

plush remnant
#

how do i specify only specific roles can perform a command?

elder garnet
#

is it possible to make a rich presence in discordjs?

nocturne grove
#

@plush remnant something like this:

if (!member.roles.has(roleid1) && !member.roles.has(roleid2)) return;```
plush remnant
#

ok ๐Ÿ‘

nocturne grove
#

if you have a lot of role id's you should make an array of it. But I don't know the code to check that correctly out of my head

plush remnant
#

i will try it

nocturne grove
#

๐Ÿ‘

#

Does role.managed automatically mean the role is not possible to obtain for server members?

.managed
Whether or not the role is managed by an external service

Type: boolean```
iron lichen
#

So, I'm gonna ask something I'm sure is completely noob, but how am I supposed to send the 'config.json' with client id to, say, top.gg? I thing I am missing something and I can't find it.

modest maple
#

what?

slender thistle
#

Could you elaborate please?

iron lichen
#

I published a bot in top.gg. I must use the client id in the code to connect, but this client id was not commited in github. Locally, it is in a file (config.json seems to be a popular choice in tutorials), but how my bot is supposed to read this file, if I never sent it to top.gg?

earnest phoenix
#

please help me console error ```
uncaughtException: ReferenceError: guild is not defined

Code```js
const client = new Discord.Client({autoReconnect:true});


//MYSQL START
client.con = mysql.createConnection({
    host: "*****",
    user: "******",
    password: "******",
    database: "*****",
  });
  
  client.con.connect(err => {
    if(err) throw err;
    console.log("Connected to database!");
  });
  
  var con = client.con


  con.query(`SELECT * FROM prefix WHERE sid = ('${guild.id}')`, (err, rows) => {
    if(err) throw err;
  //MYSQL STOPED

client.on('error', helper.error);```
slender thistle
#

I don't think you need ID

#

All you need is your bot's token to connect to Discord

earnest phoenix
#

but more than one server requires the server ID for a unique prefix and commands

iron lichen
#

Sorry, when I said client id read token

#

I was talking about the token, got mixed up

earnest phoenix
#

so here's how I could access the guild id

iron lichen
#

Either way, this is not supposed to be in github, right?

slender thistle
#

Yeah, you must not expose your token

#

It's basically password for your bot's account and anyone who has your bot's token can do anything as your bot

cinder patio
#

I mean you can if it's in a private repository ig

iron lichen
#

That's my doubt, how will this work after publishing, the code expects to read this from a file that is not there

slender thistle
#

Make users enter their tokens themselves

#

You should use .gitignore btw

elder vine
#

Hedi, you need to define guild?

earnest phoenix
#

but how do we define it?

cinder patio
#

usually, const guild = something, but in your case, your code needs to be put somewhere where a discord guild object is present, for example, guildCreate

elder vine
#

Where is this Heidi?

earnest phoenix
#

discord js

elder vine
#

No, I mean.

#

Where is this code?

earnest phoenix
#

index.js

elder vine
#

Is it inside bot/client.on("something" ?

earnest phoenix
#

no

elder vine
#

Why would it need to execute then?

#

Where do you use the db?

earnest phoenix
#

server pc

elder vine
#

No, where in your code do you need the db?

#

in index.js

earnest phoenix
#

yes

elder vine
#

where?

iron lichen
#

Ok, so I thing a config.json file at root folder with a 'token' key is a convention, the publisher will create it for me.

earnest phoenix
#

index.js

elder vine
#

In which part?

#

in the bot.on("message", ?

earnest phoenix
#
const Discord = require('discord.js');
const fs = require('fs-extra');
const path = require('path');
const objectPath = require("object-path");
const chalk = require('chalk');
const mysql = require('mysql');

const osu = require('./osu.js');
const helper = require('./helper.js');

const client = new Discord.Client({autoReconnect:true});


//MYSQL START
client.con = mysql.createConnection({
    host: "****",
    user: "*****",
    password: "******",
    database: "*****",
  });
  
  client.con.connect(err => {
    if(err) throw err;
    console.log("Connected to database!");
  });
  
  var con = client.con
  //MYSQL STOPED```
elder vine
#

ok?

#

but

#

con.query(SELECT * FROM prefix WHERE sid = ('${guild.id}'), (err, rows) => {

#

you're looking for a prefix right?

earnest phoenix
#

SQL

elder vine
#

This would be in the bot.on('message' right?

#

yea

#

you need to con.query inside the bot.on message event

earnest phoenix
#

okey

elder vine
#
  • you would need to define let guild; before con.query => {}
#

then guild = (prefix from db here) inside con.query => { /* here */ }

grizzled raven
#

is messageReactionRemoveAll only emitted when every emoji is removed at once, or at the point where every emoji gets removed

elder vine
#

Where the button remove all reactions are clicked, I believe.

earnest phoenix
#

correct

#

messageReactionRemove is for removing a single reaction, messageReactionRemoveAll is for removing all reactions on the message, messageReactionRemoveEmoji is for removing all reactions of a single emoji

grizzled raven
#

oh i didnt know users could do that

#

never actually saw that button xd

#

but thanks

#

no actually it doesnt show up for me

nocturne grove
#

@grizzled raven you have to have the manage messages permission for that

grizzled raven
#

im the owner of the server

#

its probably just my discord

nocturne grove
#

huh that's weird

#

but the button is only there if there are reactions (of course ;))

#

Hi! I have a little problem. I have, to make it simple for now, two events: guildDelete and guildMemberUpdate. When my bot leaves a server, guildMemberUpdate is emitted before guildDelete. guildMemberUpdate starts executing a function, but that function should not be executed when the guild is executed. Unfortunately, the event is before guildDelete. I can't stop the function by doing things like this:

if (guild.deleted) return;
// or
if (client.guilds.get(guild.id).deleted) return;
// or
if (!client.guilds.get(guild.id)) return;```
A thing I don't want is using a setTimeout, as that can produce errors if the function after guildMemberUpdate will be executed **without** a deleted/left guild.
Question (in short): Is there any way of detecting a deleted guild in an event that's emitted before guildDelete, without having a noticable delay?
earnest phoenix
mossy vine
#

you dont

#

its discord being shit

earnest phoenix
#

nooo

#

@twilit rapids how to get the role

#

bot testing for my bot?

grizzled raven
#

does .then and .catch always apply to the original promise?

cinder patio
#

Afaik they both return the original promise, so yes

nocturne grove
#

@earnest phoenix ow this sounds really good! Can you tell me what you think my problem is?

#

so we know we're talking about the same thing

grizzled raven
#
promise().catch(() => null).then(p => p) // will p be null or the resolved result?
#

nvm ill just

#

yep p is null

#

only if the promise errors

#

that makes sense

nocturne grove
#

@earnest phoenix guess I know what you mean. When my bot leaves, it shouldn't trigger the events that delete the role etc. from my bot

#

right?

#

no that's not what I mean

#

hmm

#

Do you still have any other idea? I was excited for a moment but nothing to blame you for

#

hmm is that possible?

#

I mean, I have no idea how to do that other than something like if (!client.guilds.get(guild.id)) return;. But that doesn't work

quartz kindle
#

you can try checking if the guild is available

#

if(!guild.available)

nocturne grove
#

oh really? Is that another thing?

#

Will immediately try it

crimson vapor
#

How do you send a request to a http/https website using node and check if it returns?

quartz kindle
#

use any http library

#

or node's internal http api

nocturne grove
#

if(!guild.available) also doesn't work. However, first time I tried it, it said 'Cannot read property 'available' of undefined'. So I can conclude it's very random

#

I mean, that time client.guilds.get(guild.id) was undefined, and sometimes it's not

#

ohh okay

#

I'm totally confused now btw not by you

grizzled raven
#

is there a specific button or x to remove reactions from a single emoji for the messageReactionRemoveEmoji event

earnest phoenix
#

On discord js v11.6.3
bot.users.size not showing the correct number why ? Help me

opaque kite
#

XD

#

Lemme check

earnest phoenix
#

Can i fetchAllMembers ? If yes how to ?

spice pier
#

Tu devrais utiliser la derniรจre version et regarder la doc

crimson vapor
#

Noc you good?

spice pier
#

He speaks french and doesnt seem to be that good with english

crimson vapor
#

o

earnest phoenix
#

Le problรจme c'est que mon code n'est pas pour la v12 et je n'ai pas envie de le changer pour la v12 car c'est complexe pour moi

opaque kite
#

@earnest phoenix bot.on('ready', () => { setInterval(async () => { let users = 0; for (let g of bot.guilds.array()) users += (g.members.size - 1)); await bot.user.setActivity(`${users} user${users !== 1 ? 's' : ''}`, {type: 'WATCHING'}) .catch(err => console.error()); }, 15000); });

#

If you want to show in status

earnest phoenix
#

Not for status

#

For send in a RichEmbed

elder vine
#

to edit?

grizzled raven
#

is there a specific button or x to remove reactions from a single emoji for the messageReactionRemoveEmoji event
i meant, what do you do to trigger the event, like clicking the remove all reactions button to trigger the messageReactionRemoveAll event

elder vine
#

client.users?

earnest phoenix
#

No leny i make an embed with bot.users.size but it not showing the correct number

opaque kite
#

Can you explain

earnest phoenix
#

I have code an RichEmbed for see the total users of any server (bot.users.size) but bot.users.size not showing the correct numbers of members

late hill
#

When you update packages, you should consider checking the documentation to see what has changed

earnest phoenix
#

Me?

late hill
#

Le problรจme c'est que mon code n'est pas pour la v12 et je n'ai pas envie de le changer pour la v12 car c'est complexe pour moi

#

you, yes

earnest phoenix
#

Yes

late hill
#

yes

oblique basalt
#

Erm so I am using Glitch and discord.js and I cannot add anymore command files (we are using shards and a command handler), otherwise the bot goes offline or the bot doesn't respond to other commands.

#

I am having this error:
/app/bot.js:25
console.log(Command ${props.config.name}.js (#${props.config.id}) loaded!);
^
TypeError: Cannot read property 'name' of undefined
at files.filter.forEach.file (/app/bot.js:25:49)
at Array.forEach (<anonymous>)
at fs.readdir (/app/bot.js:22:78)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)

opaque kite
#

guild.members.filter(member => !member.user.bot).size; @earnest phoenix

earnest phoenix
#

Ok il going to test

opaque kite
#

Bots Not included

earnest phoenix
#

Yes

#

Np

opaque kite
#

It's only count members

elder vine
#

You can count members for each guild

earnest phoenix
#

that won't give an accurate count unless you have all members cached

elder vine
#

It will

earnest phoenix
#

no, it won't

elder vine
#
let members = 0
client.guilds.forEach(g => {
    members += g.memberCount;
});
members
oblique basalt
#

I need help asap

earnest phoenix
#

i

#

sis

opaque kite
#

It will

earnest phoenix
#

they said they want to filter out bots

#

which is why they can't use memberCount

elder vine
#

then filter out bots?

earnest phoenix
#

you can't

#

because memberCount is a number

elder vine
#

just -the bot count

earnest phoenix
#

jesus christ what is up with the moronic behaviour

elder vine
#

for each guild

earnest phoenix
#

yes, but you need to have all members cached to know how many bots there are in the first place

nocturne grove
#

idk probably wont work
@earnest phoenix hmm that's not hopeful. And I don't think it's better than just a loop over everything, or is it?

oblique basalt
#

Erm so I am using Glitch and discord.js and I cannot add anymore command files (we are using shards and a command handler), otherwise the bot goes offline or the bot doesn't respond to other commands.
I am having this error:
/app/bot.js:25
console.log(Command ${props.config.name}.js (#${props.config.id}) loaded!);
^
TypeError: Cannot read property 'name' of undefined
at files.filter.forEach.file (/app/bot.js:25:49)
at Array.forEach (<anonymous>)
at fs.readdir (/app/bot.js:22:78)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)

late hill
#

You probably forgot to add a config property to one of them

opaque kite
#

Name is undefined

oblique basalt
#

ok

earnest phoenix
#

Hey, I my bot is on github because I use Heroku to run it, but how I can link the .json file to the os-Command?
os.chdir(r'officialyr9/adbotupdate')
Because I would create a .json data

#

Look @opaque kite

#

Not work

elder vine
#

filter of undefined

#

guild probs not defined properly

earnest phoenix
#

I have defined guild

nocturne grove
#

oh okay

#

well thanks for the help, and Tim too! Sadly the problem is not solved yet (I give up for today xd)

elder vine
#

What's the issue Menno?

earnest phoenix
#

@elder vine
I have defined guild and filtre and nothing

elder vine
#

Show code

#

Why do you code on phone, still

earnest phoenix
#

No

opaque kite
#

It's works fine for me

earnest phoenix
#

I dont have my pc so

#

Yes

#

Il on my phone

elder vine
#

I'll see if it works for me?

opaque kite
#

Yeah create a variable of it

earnest phoenix
#
.addField("Utilisateurs ๐Ÿ‘ถ ", `${guild.members.filter(member => !member.user.bot).size}`, true)
        ```
elder vine
#

worked for me

earnest phoenix
#

I use an handler

opaque kite
#

;) I know right

earnest phoenix
#

Commands hanler

elder vine
#
.addField("Utilisateurs :baby: ", ${message.guild.members.filter(member => !member.user.bot).size}, true)
#

Is it in a command?

earnest phoenix
#

Yez

#

Yes

elder vine
#

where is guild defined?

earnest phoenix
#

Look my code

nocturne grove
#

What's the issue Menno?
@elder vine I want to stop code from executing when a guild is deleted. For example, when my bot is kicked, the guildMemberUpdate event (which takes away the roles) is before the guildDelete event. But the code in the guildMemberUpdate event should be stopped when the guild is not available anymore. Things like if(!guild.available) return, !guild.deleted, !client.guilds.get(guild.id), !client.guilds.get(guild.id).available or !client.guilds.get(guild.id).deleted don't properly work. And I am not a fan of using setTimeout as that can cause new errors

earnest phoenix
#
const Discord = require("discord.js");
const config = require('../config.json');
const moment = require("moment");
require("moment-duration-format");
const cpuStat = require('cpu-stat');
const os = require('os');



module.exports.run = async (bot, message, guild, filter, args) => {
    message.delete()

    let { version } = require("discord.js");
    const ram = bot.emojis.get("684502896758358116");
    const cpu = bot.emojis.get("684503576046862436");
    const node = bot.emojis.get("684505660167422155");
    const server = bot.emojis.get("684509665169899619");

    cpuStat.usagePercent(function (err, percent, seconds) {
      if (err) {
        return console.log(err);
      }
     
      

      let duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
      let embedStats = new Discord.RichEmbed()
        .setTitle("__**Informations du bot**__")
        .setColor("RANDOM")
        .addField("En ligne depuis โฒ", (Math.round(bot.uptime / (1000 * 60 * 60 * 24)) % 60) + " Jours, " + (Math.round(bot.uptime / (1000 * 60 * 60)) % 60) + " h, " + (Math.round(bot.uptime / (1000 * 60)) % 60) + " min, et " + (Math.round(bot.uptime / 1000) % 60) + " sec", true)
        .addField("Utilisateurs ๐Ÿ‘ถ ", `${guild.members.filter(member => !member.user.bot).size}`, true)
        .addField("Serveurs " + server, `${bot.guilds.size.toLocaleString()}`, true)
        .addField("Discord.js ๐Ÿ› ๏ธ", `v${version}`, true)
        .addField("Node " + node, `${process.version}`, true)
        .addField("CPU " + cpu, `\`\`\`md\n${os.cpus().map(i => `${i.model}`)[0]}\`\`\``)
        .addField("Utilisation du CPU ๐Ÿ“Š  ", `\`${percent.toFixed(2)}%\``, true)
        .setFooter("BryXou - Twixty")
      message.channel.send(embedStats)
    })
};

module.exports.help = {
    name: "bot"
};
nocturne grove
#

yeah, thanks. And I want to know the guildDeleted first

elder vine
#

Ahhh

earnest phoenix
#

?