#development

1 messages · Page 939 of 1

cosmic girder
#

the first line has 1 set of () and then theres a extra )

pale vessel
#

or just remove (

lyric mountain
#

it was just an example

#

discord is not the best IDE out there yknow

pale vessel
#

so they expect to be spoonfed

lyric mountain
#

what I meant was the way I've put the addRole INSIDE the promise

#

so it'll only run AFTER the promise gets the role

pale vessel
#

that wasn't clear enough ay

lyric mountain
#

compare both codes

cosmic girder
#
message.member.roles.cache.has(ID)
#

or tht can work

lyric mountain
#

where, why and what?

cosmic girder
#

lmao

#

if works

#

it works*

lyric mountain
#

remember that promises run in parallel, so most of the time you'll not be able to get the promise value directly

#

so you gotta put the code that'll use the returned value inside a .then() clause

still merlin
nocturne grove
#

@still merlin maybe tell us the error

still merlin
#

But Idk what that means ^^

nocturne grove
#

remove one of the two ( in the .setThumbnail line

#

it wants to see another ) somewhere, but in this case there was a ( too much

earnest phoenix
silent berry
#

is a global chat api abuse.

sullen salmon
#

How do I make it so "on_ready()" is only called once in discord.py?

earnest phoenix
#

no

silent berry
#

opt in feature

#

@earnest phoenix you telling me "no"?

earnest phoenix
#

yes its not api abuse

silent berry
#

ok thanks

earnest phoenix
#

json geçerli dosya değil diyor

silent berry
#

@earnest phoenix can you tell me how to make the code im about to put not be on a loop. v11.5.1

earnest phoenix
#

no

silent berry
#
helium.on("message", async(msg) => {
    let chatmoderators = ['539195184357965833', '550170362248429568', '437019658374348801', '641795527444529152']
   if (msg.author.bot)return;
   if(msg.channel.name !== 'helium-global-chat')return;
   msg.delete()
   

   let e = new Discord.RichEmbed()
            .setTitle("Helium Global Chat")
            .setAuthor(msg.guild.name, msg.guild.iconURL)
            .addField("Message content", msg.content)
            .setColor("RANDOM")
            .setThumbnail(msg.author.avatarURL)
            .setTimestamp()
            .setFooter(`Helium Global Chat System || SECURITY | Guild id: ${msg.guild.id} | msg author id: ${msg.author.id} | code by Airbus A350-1000#0001. thanks to him, this bot will have a functioning global chat.`);

            if(chatmoderators.includes(msg.author.id)){
                e.addField("Sent By", `🛠️ Chat Moderator | **__${msg.author.tag}__**`)
            }else{
                e.addField("Sent By", `**__${msg.author.tag}__**`)
            }
        await Promise.all(helium.channels.filter(c => c.name === 'helium-global-chat').map(c => c.send(e)))

        await Promise.all(helium.channels.filter(c => c.name === 'helium-global-chat').map(c => c.setTopic(`Last message is sent by <@${msg.author.id}>`)))

        
        


})
#

crap

lyric mountain
#

btw, stop using v11

silent berry
#

why?

lyric mountain
#

else your bot will have about 5 months of life left

nocturne grove
#

How do I make it so "on_ready()" is only called once in discord.py?
@sullen salmon in discord js that's called like client.once('ready', so maybe try once instead of on.
cool name

earnest phoenix
#

i dont have exprience in discord.js

silent berry
#

oh

#

crap

nocturne grove
#

@sullen salmon idk if it works though

silent berry
#

time to attempt to update

lyric mountain
#

it's easier now than later

sullen salmon
#

The documentations don't show that sadly @nocturne grove

#

Also thx

nocturne grove
#

oh the js docs also don't show that, it's not a very popular thing or something

silent berry
#

now to figure out what in my code i need to edit

nocturne grove
#

so you can still try it haha

sullen salmon
#

Doesn't work sadl

lyric mountain
#

client.on('ready') will only be called when your bot has booted up

#

so only once per restart

nocturne grove
#

that's not true I understood

sullen salmon
#

No that calls whenever it's ready which can be multiple times

#

Only client.once('ready') ensures it's called only once

nocturne grove
#

it will also get called when your client reconnects or something

sullen salmon
#

But it doesn't seem like this feature exists in discord.py

nocturne grove
#

yes but you can always try. It's not in the js docs too

earnest phoenix
#

client.on('ready') will only be called when your bot has booted up
so only once per restart
false

sullen salmon
#

I tried and it didn't work

nocturne grove
#

oh okay that's sad

earnest phoenix
#

ready can be fired multiple times during the lifespan of your app

white sentinel
#

i need help with adding a bulkdelete command and i have been trying alot any help me out

earnest phoenix
#

@earnest phoenix nasıl düzelteceğim

sullen salmon
#

Is there a function that fires only once though

earnest phoenix
#

onu biliyorum

sullen salmon
#

Or is there a way to simulate such a thing

earnest phoenix
#

why would you need that

sullen salmon
#

With like global variables

earnest phoenix
#

literally have a bool in your app

#

@earnest phoenix bilmiyorum javasciptle aram iyi değil

white sentinel
#

i need help with adding a bulkdelete command and i have been trying alot any help me out

sullen salmon
#

It considers it a different variable if it's outside of the function though @earnest phoenix

nocturne grove
#

@white sentinel tell us what language you're using and what kind of database

earnest phoenix
#

then keep it... outside of the function lol?

sullen salmon
nocturne grove
#

@white sentinel nvm ignore my message

sullen salmon
#

Dude @earnest phoenix

nocturne grove
#

but still tell us what language

sullen salmon
#

It says in the function that the variable gets used before init

#

That's why I said it considers it a different variable

earnest phoenix
#
some bool in a file

ready ->
if bool is true
  ready already fired once
else 
  first time firing ready
  bool = true
white sentinel
#

@nocturne grove im using .js

nocturne grove
#

okay

sullen salmon
#

I just told you that that gives you an error @earnest phoenix

#

I'm not stupid

earnest phoenix
#

what's your code and what's the error

sullen salmon
#

I literally put a screenshot above

earnest phoenix
#

oh python

sullen salmon
#

eg'e"béje&orfer'z"m

#

é&'"r

#

'

#

"f

#

zzf"

pale vessel
#

nice

nocturne grove
#

@white sentinel okay so you know you want to bulkdelete messages from a text channel

sullen salmon
#

I said I was using python

white sentinel
#

@nocturne grove yes

sullen salmon
#

Honestly coders are fucking losers in general

pale vessel
#

did you smash your head on your keyboard

white sentinel
#

i have been trying for 3 hours now

nocturne grove
sullen salmon
#

Always looking to smash some newbie who is so much dumber

#

Instead of trying to actually HELP

nocturne grove
#

omg where does that come from

sullen salmon
#

This is so characteristic of coders

pale vessel
#

victim andy

earnest phoenix
#

use the global keyword

#

to mark it as a global var

sullen salmon
#

Yes, I've found how to do it now too

#

Thank you

earnest phoenix
#

you could've done that before having a breakdown in the chat

white sentinel
#

@nocturne grove im confused

sullen salmon
#

You could've read back before assuming I was braindead @earnest phoenix

#

Coders do this all the time

#

I'm tired of it

earnest phoenix
#

i, nor anyone else, assumed or said you were braindead

sullen salmon
#

The coding community is not a community of genuinely helpful people

pale vessel
#

he literally just helped you

earnest phoenix
#

I can't find any docs about this,
Anyone know how I can force clear my bots cache?

pale vessel
#

you can use fetch

#

it'll overwrite the cache

sullen salmon
#

He didn't though @pale vessel

earnest phoenix
#

Ah, ty @pale vessel

sullen salmon
#

He wouldn't stop acting like I was stupid and offered the same solution multiple times when I told him it didn't work and he didn't even know what library I used

#

This is so typical of coding help forums

pale vessel
#

shut up karen

earnest phoenix
#

huge chad energy

sullen salmon
#

Everyone acts like you're a 12 year old that has stolen his dad's keyboard

#

I'm tired of it

earnest phoenix
#

you're being a keyboard warrior right now, you're voiding the point you're trying to get across lol

sullen salmon
#

What?

#

That sentence means nothing

slender thistle
#

I suggest this ends here

sullen salmon
#

I guess I will listen to the will of the almighty janny

trail trout
#

hey

#

is there any way to remove/compress the json.sqlite ?

earnest phoenix
#

uh... no

#

what are you storing there

pale vessel
#

you'll end up corrupting it

earnest phoenix
#

Code:

["command"].forEach(handler => require(`./handlers/${handler}`)(bot));```
trail trout
#

i store 2,2 millions link in there.

#

and i removed it.

earnest phoenix
#

Code:

["command"].forEach(handler => require(`./handlers/${handler}`)(bot));```

@earnest phoenix
are you sure that is where the error is coming from

#

yes

#

there's literally no way Thonk

#

unless that isn't the code you're using

pale vessel
#

check the stack trace

earnest phoenix
#

line 9

#

index.js

quartz kindle
#

did you save the file?

earnest phoenix
#

yes

quartz kindle
#

save it again

earnest phoenix
#

ok

#

don't ask to ask just ask your question

sullen salmon
#

What do you need help with? 🙂 @earnest phoenix

earnest phoenix
#

@quartz kindle i saved again, still same error

pale vessel
#

uh, no.

sudden geyser
#

The error is probably coming from within one of the handler files

sullen salmon
#

If you want someone else to write a bot for you I don't think you will have much success

#

But you could describe what kind of things you want? You never know, maybe someone has already made a bot with the features you want

nocturne grove
#

@white sentinel it was about the ( right?

sudden geyser
#

@earnest phoenix try expanding the forEach method with braces and log the handler before requiring it.

earnest phoenix
#
const { readdirSync } = require("fs");
const ascii = require("ascii-table");
let table = new ascii("Commands");
table.setHeading("Command", "Load status");
module.exports = bot => {
  readdirSync("./commands/").forEach(dir => {
    const commands = readdirSync(`../commands/${dir}`).filter(file =>
      file.endsWith(".js")
    );
    for (let file of commands) {
      let pull = require(`../commands/${dir}/${file}`);
      if (pull.name) {
        bot.commands.set(pull.name, pull);
        table.addRow(file, "✅");
      } else {
        table.addRow(file, "🚫 Error");
        continue;
      }
      if (pull.aliases && Array.isArray(pull.aliases))
        pull.aliases.forEach(alias => bot.aliases.set(alias, pull.name));
    }
  });
  console.log(table.toString());
};

this is the code from the handler

#

ok, i'll try

quartz kindle
#

whats the full error?

earnest phoenix
#
/app/index.js:9
["command"].forEach(handler => require(`./handlers/${handler}`)(bot));
            ^
TypeError: Cannot read property 'forEach' of undefined
at Object.<anonymous> (/app/index.js:9:13)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
    at internal/main/run_main_module.js:17:11```
sudden geyser
#

that's wack

earnest phoenix
#

try for looping instead of using forEach 🤷‍♂️

quartz kindle
#

that makes 0 sense

earnest phoenix
#

forEach is slow as fuck anyways

quartz kindle
#

wait

#

show your line 8

earnest phoenix
#
const prefix = botconfig.prefix```
haughty night
#

;

quartz kindle
#

add a ;

sullen salmon
#

Does js care about ;?

#

I thought they just tolerated its existence

slender thistle
#

It's optional

earnest phoenix
#

now that error is solved, but i have one more question

quartz kindle
#

this is why i always use ;

sullen salmon
#

That's the most cringe part about js tbh

earnest phoenix
#

it isn't when you're defining something like an array or an object

quartz kindle
#

fuck js's autocompleting

earnest phoenix
#

i will got that error at every command?
Error: Cannot find module './commands/admins/arrole.js'

#

even

#

if the command

#

is in that dir?

#

oh nvm

#

i forgot a .

#

tyvm guys

true ravine
#

If deliver is an async function, should this loop call the function, wait, then move on and do it again etc? Or do I need to specifically make deliver return a promise?

quartz kindle
#

if its an async function, it automatically returns a promise

true ravine
#

Yeah that's what I read on mdn but it appears they all called at once last time that code ran

quartz kindle
#

does your deliver function have any async logic in it? such as loading stuff from a website

true ravine
#

No but it relies on some other functions, one of which does

#

All other functions it uses return promises though

#

And they are handled with then blocks

quartz kindle
#

they have to be awaited as well

#

once you use then, that part of the code will not be considered anymore for the waiting

true ravine
#

Oh that would make sense based on the output I got

digital ibex
#

in nodejs v14 u can await outside of an asynchronous function

true ravine
#

Thank you very much

steel heath
#

u mean deno? kek

quartz kindle
#

@digital ibex only in top level afaik

#

like chrome's dev console does

digital ibex
#

oh, i've only been looking at it for like 2 minutes cuz i just saw it

#

its kinda cool tbh

#

idk if i prefer it or not doe

earnest phoenix
#
(node:12415) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of undefined

code:

bot.on('message', async message => {
  const botconfig = require("./botconfig.json");
  const prefix = botconfig.prefix;
  if(message.author.bot) return;
  if(!message.conent.startsWith(prefix)) return;```
quartz kindle
#

conent

earnest phoenix
#

-_-

#

i'm

#

dumb

low bolt
#

Can I use my bot's dblapi token in another bot, and use it for bot statistics? (dblapi.js package.)

viral spade
#

I am trying to cache stuff to take load off the database.
When a new guild is seen, the bot should cache the relevant properties of each sql table. I also want to load into cache the info i have on every guildmember, when loading the guild.

Now it would be nice to add to my client objects guild/channel/role/member items a new property AppData where i cache my stuff, so i have my own and discords cache at one place. But as guildmembers should never all be cached by discord.js on guild load, i cannot do this for those. Is there any workaround for this, without discord.js caching all guildmembers on startup?

The alternative would be make my own Collection of guilds for caching, would this be a good idea?

earnest phoenix
#
bot.on('message', async message => {
  const botconfig = require("./botconfig.json");
  const prefix = botconfig.prefix;
  if(message.author.bot) return;
  if(!message.content.startsWith(prefix)) return;
  
  if(!message.guild) return;
  if(!message.member) message.member = await message.guild.fetchMember(message);
  const args = message.content.slice(prefix.lenght).trim().split(/ +/g);
  const cmd = args.shift().toLowerCase();
  if(cmd.lenght == 0) return;
  const command = bot.commands.get(cmd)
  if(!command) command = bot.commands.get(bot.aliases.get(cmd)); //here
  if(command) command.run(bot, message, args)
})

Assignment to constant variable.

#

@viral spade why not create some sort of a service class where calling methods to it e.g. get looks the cache up first, if the user is not found in the cache, fetch from the db

#

you shouldn't cache all of your db data

quartz kindle
#

once you use const, you cant change it @earnest phoenix

earnest phoenix
#

only cache data you return

#

oh

quartz kindle
#

use let instead

earnest phoenix
#

Now when i use a command nothing happens, no errors, nothing, why ?

still merlin
#

anyone know why this is happening. I have setcolour defiend in another embed

viral spade
#

@earnest phoenix its not all my db data, its one int per guildmember. The db is many times that big.

sudden geyser
#

Amazri console.log() returns nothing.

still merlin
#

ok so do i remove console.log then

earnest phoenix
#

u shouldn't console.log within the embed

still merlin
#

ok

earnest phoenix
#

take the ; off

#

after the setTitle

still merlin
#

ohk

earnest phoenix
#

if u want to still console.log do it after the embed is sent

still merlin
#

ok ty

earnest phoenix
#

np

still merlin
earnest phoenix
#

on the .addField()

#

there are two arguments that need to be defined

hoary elm
#

.addField(Title, Descrip)

earnest phoenix
#

so .addField("Test", "Test Command")

#

yh like that as well^

hoary elm
#

😁

#

Lol you beat me to it but 🤷🏻‍♂️

earnest phoenix
#

true but u still got it

still merlin
#

I cant thank u enough-

earnest phoenix
#

np bro

still merlin
#

just to be sure-
.addField("<ban @User#0000, *this will ban a user from the guild*") is the correct way of doing it

earnest phoenix
#

u forgot the "

still merlin
#

oof ok

earnest phoenix
#

addField("<ban @User#0000", "*this will ban a user from the guild*") @still merlin like this

viral spade
#

Would it be ok for a mysql remote database to handle 1 connection (opening + closing) per guildmember cache miss for sent textmessages?

earnest phoenix
#

My bot sending 2 message in one commands

#

i regenerated the bot but it still sending 2 messages

#

pls help

royal herald
#

Error: Could not locate the bindings file. Tried:

still merlin
#

first, check if your bot has 2 of the same commands
if not close down the program and open again

#

@earnest phoenix

earnest phoenix
#

no

still merlin
#

no to what-

earnest phoenix
#

when i shutdown the pm2

#

it send only one

#

wtf

#

i regenerated the token

still merlin
#

I have no clue then.

earnest phoenix
#

you have node processes still running in the background

#

i used killall node

#

but nothing

#

/f as well

#

and killall forever

#

killall pm2

#

but . . . .

#

/f ??

#

so now i have a free hosting

#

wtf

#

wait i will restart the vps

#

so the vps shuted down

#

and the bot is not working

#

ok

#

done

#

Fixed

#

I tried making a new command handler but now none of my commands work, here is the message event

const Timeout = new Set();
const ms = require("ms")
module.exports = async (bot, message) => {
  const botconfig = require("../../botconfig.json");
  let prefix = botconfig.prefix;
  if(message.author.bot) return;
  if(!message.content.startsWith(prefix)) return;
  
  if(!message.guild) return;
  if(!message.member) message.member = await message.guild.fetchMember(message);
  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const cmd = args.shift().toLowerCase();
  if(cmd.length == 0) return;
  let command = bot.commands.get(cmd)
  if(!command) command = bot.commands.get(bot.aliases.get(cmd)); //here
  if(command) command.run(bot, message, args)
  
}

and here is the handler

const {readdirSync} = require("fs");
const ascii = require('ascii-table');
let table = new ascii("Commands");
table.setHeading('Command', 'Load status');
module.exports = bot => {
  readdirSync('./commands/').forEach(dir => {
    const commands = readdirSync(`./commands/${dir}`).filter(file => file.endsWith('.js'));
    for(let file of commands){
      let pull = require(`../commands/${dir}/${file}`);
      if(pull.name){
        bot.commands.set(pull.name, pull);
        table.addRow(file, '✅')
      } else {
        table.addRow(file, '🚫' )
        continue;
      }if(pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => bot.aliases.set(alias, pull.name))
    }
  });
  console.log(table.toString());
}
astral yoke
#

how come i have this const { channel } = message.member.voiceChannel I have if(!channel) return message.reply("join a channel)" but im already in a channel and it tells me to join one, so if i leave it then try it, it says (node:19126) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `channel` of 'undefined' or 'null'.

quartz kindle
#

assuming you are on v11

astral yoke
#

mhm

quartz kindle
#

{ channel } = voiceChannel
is the same as
channel = voiceChannel.channel

#

there is no voiceChannel.channel

#

as voiceChannel is already a channel

astral yoke
#

OHH ty

true ravine
#

My bot relies on an image attached to a command message for one of it's functions, and I'm encountering an issue where the image seems to have only partially uploaded to discord when my bot starts trying to download it, resulting in the image appearing invalid

#

Is there a way to "wait" for discord to receive the full image before I start downloading?

#

Actually scrap that

earnest phoenix
#

anyone know any good bot stat websites?

modest maple
#

wdym @earnest phoenix

earnest phoenix
#

where you can see bot growth etc

modest maple
earnest phoenix
#

.tk is a decent free domain

lyric mountain
#

how can you get a .tk domain?

#

it always say it's unavailable

quartz kindle
#

people still use tk? thats so old school

lyric mountain
#

that's expensive

quartz kindle
#

jesus

#

thats like 8k usd

lyric mountain
#

I wonder if I get a free ferrari upon purchase

knotty steeple
#

@lyric mountain freenom

lyric mountain
#

@lyric mountain freenom
@knotty steeple always unavailable despite me writing random characters

white anvil
#

i am cursed

#

i cannot see R$ any more without thinking of robux

still merlin
#

hmm maybe off topic would be better for this convo lol

white anvil
#

ngl i thought this was off topic

earnest phoenix
#

UnhandledPromiseRejectionWarning: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number. confused why i keep getting this

#

my flags are all correct

quartz kindle
#

you sure?

earnest phoenix
#

yes

#

MANAGE_SERVER is a correct flag

quartz kindle
#

you sure?

modest maple
#

yeah manage server isnt a thing

earnest phoenix
#

well boys

modest maple
#

you would of thought it was but nop

earnest phoenix
#

i think im done

#

it's manage_guild

modest maple
#

mhmm

earnest phoenix
#

i just went from pro to amateur

quartz kindle
#

there is no such thing as a pro

#

everyone is a noob :^)

earnest phoenix
#

😭

#

ur hurt my feelings

modest maple
#

true

earnest phoenix
#

anyway is manage server v11

modest maple
#

probably not

#

tho idk d.js

#

well

#

idk d.js well enough

earnest phoenix
#

it's aight

quartz kindle
#

its still manage guild in v11

earnest phoenix
#

imma go over the flags to double check every command i have

#

thanks for the handy image

gilded ether
#

its in the guide too

steel drum
#

its okay discord themselves flip flop btwn guild n server lol

charred cargo
#

anybody can help with this

(node:9068) UnhandledPromiseRejectionWarning: RangeError: RichEmbed field values may not exceed 1024 characters.

#

Its my server info cmd

gilded ether
#

self explanatory

steel drum
#

the value in your embed field is > 1024

#

whic isnt allowed

gilded ether
#

aka you put more letters than 1024 and it isn't allowed

charred cargo
#

Ok thx

earnest phoenix
#

I want to make it so my bot blocks users from the specified command so I have this
instead of it being the id of the user i want it to take the ids from the file config.json bannedusers

#

its coded in JS

#

the code is quite old

sudden geyser
#

Store an array in config.json like blacklisted: [id1, id2, ...]

#

Require the file with require()

earnest phoenix
#
const discord = require("discord.js")
const botconfig = require("../botconfig.json");


module.exports.run = async (bot, message, args, color) => {
    let prefix = botconfig.prefix;
if (!message.content.startsWith(prefix)) return
    if (message.author.id !== '519861424017768451' && message.author.id !== '519861424017768451') return;
  if(args <=0) return msg.reply(`Say what ?`);
  let content = args.join(" ");
  let embed = new discord.RichEmbed().setTitle(content).setColor("0x3d3d29");
  msg.channel.send(embed)
    
}

exports.help = {
  name:"say"
}
sudden geyser
#

and check the blacklisted property like blacklisted.includes()

earnest phoenix
#

that would be my code for a file

sudden geyser
#

Are you doing that for every command file? Why not in the single message event?

earnest phoenix
#

how would one go about doing that

#

my code is 2 years old

sudden geyser
#

It may be two years old but as long as you have knowledge on JS it should be straight forward. Simply check if the user is blacklisted in your message on event.

earnest phoenix
#

okie

#

as well i just got a error saying this is undefined

#

${message.author.username}

sudden geyser
#

what do you mean by? can you show the actual error message? do you still have good knowledge on JS?

earnest phoenix
#
2020-05-22T21:02:03.113957+00:00 app[worker.1]: [LightBenefits 💎][BAN] Brandonn_01#8690
2020-05-22T21:02:03.117457+00:00 app[worker.1]: /app/index.js:120
2020-05-22T21:02:03.117458+00:00 app[worker.1]:     console.log(` Banned By ${message.author.username}`);
2020-05-22T21:02:03.117459+00:00 app[worker.1]:                               ^
2020-05-22T21:02:03.117460+00:00 app[worker.1]: 
2020-05-22T21:02:03.117460+00:00 app[worker.1]: ReferenceError: message is not defined
2020-05-22T21:02:03.117460+00:00 app[worker.1]:     at Client.<anonymous> (/app/index.js:120:31)
2020-05-22T21:02:03.117461+00:00 app[worker.1]:     at Client.emit (events.js:310:20)
2020-05-22T21:02:03.117461+00:00 app[worker.1]:     at GuildBanAddHandler.handle (/app/node_modules/discord.js/src/client/websocket/packets/handlers/GuildBanAdd.js:12:31)
2020-05-22T21:02:03.117462+00:00 app[worker.1]:     at WebSocketPacketManager.handle (/app/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
2020-05-22T21:02:03.117463+00:00 app[worker.1]:     at WebSocketConnection.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
2020-05-22T21:02:03.117463+00:00 app[worker.1]:     at WebSocketConnection.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
2020-05-22T21:02:03.117464+00:00 app[worker.1]:     at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:120:16)
2020-05-22T21:02:03.117464+00:00 app[worker.1]:     at WebSocket.emit (events.js:310:20)
2020-05-22T21:02:03.117464+00:00 app[worker.1]:     at Receiver._receiver.onmessage (/app/node_modules/ws/lib/websocket.js:137:47)
2020-05-22T21:02:03.117465+00:00 app[worker.1]:     at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:409:14)
#

i use to be good at it but i took a 2 year break

#

im not sure if I need to change the message.author to a newer one

#

but it shows no errors in VSC when i load it up

sudden geyser
#

The error is self-explanatory: message is not defined. I don't know what "the new one" means but it may help to try learning more about JS again.

earnest phoenix
#

ok

#
bot.on('guildBanAdd', function(guild, user) {

    //log to console
    console.log('[' + guild.name + '][BAN] ' + user.username + '#' + user.discriminator);
    console.log(` Banned By ${message.author.username}`);
    //post in the guild's log channel
    var log = guild.channels.find(ch => ch.name === 'mod-log');
    if (log != null)
        log.sendMessage('**[Banned]** ' + user);

});
``` thats my code i load it up in VSC but no error of it being undefined
smoky spire
#

its still undefined

shy rose
#

does anyone know how to stub the discord api
Context being to test bot under specific circumstances that are painful to do in actual discord (eg people spamming messages or thousands of reactions etc)

#

been suggested litecord although not 100%

earnest phoenix
#

What's wrong?

#

It still has unknown command responses

sudden geyser
earnest phoenix
#

Oh it isint

#

How do I disable unknown command responses tho?

sudden geyser
#

There's a registerDefaultCommands method allowing you to change it under CommandoRegistry class.

earnest phoenix
#

What do I do from there?

smoky spire
#

unknownCommand: false

#

btw true is default you dont have to include those

earnest phoenix
#

Didint work

#

rip

white anvil
#

can u have hyperlink in embed titles

#

i forgot

quartz kindle
#

not in titles, but you can in the author field

earnest phoenix
#
const Discord = require("discord.js");
const colours = require("../../colours.json");
const db = require("quick.db");

module.exports = async (client, message, channel) => { 

    const logs = db.fetch(`logs_${message.guild.id}`);
    let logChannel = client.channels.cache.get(logs);

    if (!logs) return;
    if (!logChannel) return;

    const channelCreated = new Discord.MessageEmbed()
    .setColor(colours.auxcrd)
    .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL())
    .setDescription(`**Channel Created:** ${channel}`)
    .setTimestamp()
  
    if (logChannel) logChannel.send(channelCreated);

};``` how would i get the channel name?
quartz kindle
#

which channel?

#

the logs channel?

earnest phoenix
#

oh

#

the channelCreate can only have one param

hasty lotus
#

is there any property to change the name of a channel ?

#

i haven't seen anything about this in the docs

#

*using discord.js

#

v11

#

the only method i see in the doc is delete :/

digital ibex
#

.setName()

steel drum
hasty lotus
#

i'm on v11

steel drum
#

exists in v11 too

hasty lotus
#

uh

#

yes

#

ok

#

yep

#

for text channel

#

i was at channel

#

ok thx

steel drum
#

npnp

hasty lotus
#

^^

steel drum
hasty lotus
#

oki 😂

#

i'm fine with text channel 😉

steel drum
#

lol

earnest phoenix
#
import discord
import json
from discord.ext import commands
import random

players = {}

def get_prefix(client, message):
    with open('prefixes.json', 'r') as prefixesjson:
        prefixes = json.load(prefixesjson)


    return prefixes[str(message.guild.id)]

client = commands.Bot(command_prefix = get_prefix)

@client.event #onready
async def on_ready():
    await client.change_presence(status=discord.Status.dnd, activity=discord.Game("with Python"))
    print('Webhookisback Loaded.')

@client.event #addprefix
async def on_guild_join(guild):
    with open('prefixes.json', 'r') as prefixesjson:
        prefixes = json.load(prefixesjson)
    prefixes[str(guild.id)] = 'web.' # web. is the default prefix for custom prefixes
    with open('prefixes.json', 'w') as prefixesjson:
        json.dump(prefixes, prefixesjson, indent=4)

@client.event #deleteprefix
async def on_guild_remove(guild):
    with open('prefixes.json', 'r') as prefixesjson:
        prefixes = json.load(prefixesjson)
        prefixes.pop(str(guild.id))
    with open('prefixes.json', 'w') as prefixesjson:
        json.dump(prefixes, prefixesjson, indent=4)

@client.command() #prefixchange
async def changeprefix(ctx, prefix):
    with open('prefixes.json,', 'r') as prefixesjson:
        prefixes = json.load(prefixesjson)
        prefixes[str(ctx.guild.id)] = prefix
    with open('prefixes.json', 'w') as prefixesjson:
        json.dump(prefixes, prefixesjson, indent=4)
#

espasmo

#

spasm

paper phoenix
#

@quartz kindle - Sorry to ping you again. Any idea how to send a message embed using eval? Lol

quartz kindle
#

build the embed on the destination, ie: inside the eval code

paper phoenix
#

Right, but how do I access discord.MessageEmbed in the eval?

quartz kindle
#

or define a function in the shards, and call the function from the eval

#

you need to either have discord defined in the shards, or require it inside the eval code

amber fractal
paper phoenix
#

I'll have to require it - stupid me was attempting to import( )

astral yoke
#

if you have something like this let prefix = bot.db.fetch(`prefix_${message.guild.id}`) ? bot.db.fetch(`prefix_${message.guild.id}`) : config.prefix; how do you make it so that you can also ping the bot for the prefix

white sentinel
#

anyone help me with this it says message is not defined

client.on('guildMemberAdd', member => {
console.log('User ' + member.user.username + ' has joined the server!')
let role = message.guild.roles.cache.find('name', 'Community');
member.addrole(role)
});

#

@astral yoke

astral yoke
#

dont ping people because they are a recent message

white sentinel
#

okay sorry i just need help

astral yoke
#

wait

upper hinge
#

does any1 kno a list of swear words

#

ye know, for a swear filter

graceful dock
#

anyone know how to retrieve the number of users on all of the guilds that my bot is in?

astral yoke
#

message.client.users.size.toLocaleString() @graceful dock

graceful dock
#

ty

astral yoke
#

make sure all of the peoples are cached though

graceful dock
#

oh, cant i use something with the ctx.bot.guilds?T

#

like members in ctx.bot.guilds.members

#

or anything like that

astral yoke
#

for this

#

const client = new Client()

#

add

#

({ fetchAllMembers: true })

#

so its like this

amber fractal
#

oh god

#

rip memory

astral yoke
#

const client = new Client({ fetchAllMembers: true })

amber fractal
#

you will be missed

astral yoke
#

lmao agree

amber fractal
#

should just iterate the memberCount property of each guild (in d.js)

astral yoke
#

^

amber fractal
#

the fact they use ctx indicates probably python

graceful dock
#

im using python ye

astral yoke
#

oh then

amber fractal
#

you on the latest version of d.py?

graceful dock
#

yes

amber fractal
#

Iterate your guilds and add up the member_count of each guild

#

it returns the count of members regardless of cache

#

it'll be the most accurate

paper phoenix
#

({ fetchAllMembers: true })
@astral yoke - That won't work come October unless you're verified

white sentinel
#

anyone help me with this it says message is not defined

client.on('guildMemberAdd', member => {
console.log('User ' + member.user.username + ' has joined the server!')
let role = member.guild.roles.cache.find('name', 'Community');
member.addrole(role)
});

earnest phoenix
#

?

#

quien habla español?

#

spanish?

halcyon ember
#

whats the thing in disocrdjs v12 that chekcs if someone has a role or not

white sentinel
#

Creo que esta es una discordia inglesa así que no muchas son guerreras españolas.

#

@earnest phoenix

earnest phoenix
#

@white sentinel ok, pera sabes js?

white sentinel
#

ci

earnest phoenix
#

@white sentinel espar saber como hago un cmd asi tipo inviter manager

#

ejemplo pongo -invites

white anvil
#

@paper phoenix it will work for bots in less than 100 guilds also

white sentinel
#

no se mucho sobre js

graceful dock
#

@amber fractal ctx.bot.guilds.member_count ?

white sentinel
#

anyone help me with this it says message is not defined

client.on('guildMemberAdd', member => {
console.log('User ' + member.user.username + ' has joined the server!')
let role = member.guild.roles.cache.find('name', 'Community');
member.addrole(role)
});

white anvil
#

and essentially every bot in more than 100 will verify

paper phoenix
#

@paper phoenix it will work for bots in less than 100 guilds also
@white anvil Bots don't stay in less than 100 for long when on DBL. 😛

white anvil
#

i beg to differ

paper phoenix
#

It double my server count in 2 days

white anvil
#

it always does when it just got added

astral yoke
#

once its down and deep on the front page you get one server a week

white anvil
#

since it appears in the new list

#

yeah lol

#

@white sentinel that error wont be thrown in that code

#

u havent referenced message anywhere there

white sentinel
#

how tdo i reference it in that way

paper phoenix
astral yoke
#

cool then

#

we dont care

white sentinel
#

@white anvil how would i reference it

amber fractal
#

@graceful dock Each guild has the property member_count, you should loop over each guild and add up that property

paper phoenix
#

^ That won't get you unique users, though. Could have someone in multiple mutual servers

white anvil
#

this also wont work if you dont request all members

#

..i think

amber fractal
#

well if you want to cache all users and kill your ram usage for a more accurate member count be my guest

paper phoenix
#

this also wont work if you dont request all members
@white anvil - You can still access member count without having all cached/requesting all

wheat valve
#

Im still kinda of new to coding, does anyone know how to get the bot to respond when you mention it using discord.js?

sullen yacht
#

You could check if the message contains <@[id]> or <!@[id]>

drowsy vale
#

help pls

indigo flax
#

Do you know how to make a fetchinvite (serverid) command, and the bot makes an invite and give to u, bot owner only

earnest phoenix
#

Why would you want to have something like that?

#

because it sounds quite malicious and might seem like a privacy breach in some cases

hoary elm
#

Lol why does everyone ask for help with backdoor commands 😂

delicate zephyr
#

@indigo flax thats a privacy breach and is against ToS

earnest phoenix
#

GWhurpyShrug People just want some kind of Control

#

@delicate zephyr unless described on the bot page and can be opt-in/out

delicate zephyr
#

yea

#

it has to be out-in

earnest phoenix
#

yes

white gyro
#

Just don't give the bot create instant invite or administrator

rain jacinth
#

can i have help, i try doing custom prefix cmd but when i change it ut lets any prefix work

#

my whole prefix.js file

warm marsh
#

Because you don't have a check

rain jacinth
#

Whaaat

warm marsh
#

under the prefix line you should have something like if !message.content.startsWith

rain jacinth
#

On which file??

warm marsh
#

index

warm marsh
#

No

#

under let prefix

rain jacinth
#

let(!message.content.startsWith);

#

?

warm marsh
#

No

#

if

#

And it's a function

rain jacinth
#

if(!message.content.startsWith);

warm marsh
#
let prefix = prefixes[messageg.guild.id].prefixes;
if (message.content.startsWith(prefix)) {
  // Put command running stuff in here
}```
warm marsh
#

No

#

Exactly what I sent.

rain jacinth
#

like that?

warm marsh
#

You need to put the if (!prefixes[]) bit above let prefix

warm marsh
#

No

#

The whole if statement.

rain jacinth
#

like that?

warm marsh
#

No.

#

You need to move the }; above let prefix

rain jacinth
#

??

warm marsh
#

Yes like that. Take a look at the link I sent.

rain jacinth
#

is mine right tho

warm marsh
#

Yeah it is.

warm marsh
#

Ah

#

Missing a closing bracket somewhere.

rain jacinth
#

whaaat

warm marsh
#

Look for a missing } or )

#

Remove the ! before message.content

#

Otherwise the stuff inside that if statement won't work.

rain jacinth
#

still doesn't work

warm marsh
#

Same error?

rain jacinth
#

idk

warm marsh
#

What doesn't work?

#

There is nothing for it to do so it just voids.

rain jacinth
#

my prefix.js file

warm marsh
#

Send what you have in index.js file now

rain jacinth
warm marsh
#

Put everything from line 53 to 79 into the if statement

#

53 - 79 into the if (message.content.startsWith(prefix)) { // here }

rain jacinth
#

what?

warm marsh
#

Everything from line 53 to 79 put where the //here is

warm marsh
#

Yes where that // here is replace it with everything from line 53 to 79

rain jacinth
#

so put everything in that bracket

warm marsh
#

No

#

Only the stuff from lines 53 to 79

earnest phoenix
#

Or you can just require the json file and tell it to require the text inside the bracket instead of doing it so confusingly

warm marsh
#

What you just said makes less sense.

earnest phoenix
#

Why exactly

warm marsh
#

Tell a JSON file to require another file.

rain jacinth
warm marsh
#

yes

rain jacinth
#

like that

warm marsh
#

Yeah

rain jacinth
#

do you know stuff about custom log channel cmd @warm marsh ?

warm marsh
#

I've done it in the past.

earnest phoenix
#

Like logging certain actions?

rain jacinth
clear wraith
warm marsh
#

Just setting the default logs channel?

#

@clear wraith Language and Lib?

#

Rami you should probably look into using a sqlite3 database or something

#

JSON is very bad.

#

It's not made for being constantly edited.

#

Roman <@id>

#

not @<id>

clear wraith
#

JavaScript and Discord.js

#

Ok

rain jacinth
#

well, idrc about that tbh, i'm just tryna make a custom log channel cmd, i'vebeen using json for a while and it works fine

warm marsh
#

Alright.

#

It's kinda the same as your prefix one.

#

Just make sure they mention a channel

#

then store it.

rain jacinth
#

idrk what to do next:(

earnest phoenix
#

You should learn more JS and get better at it

#

Not trying to be rude or anything

warm marsh
#

Idk what you're trying to do and yeah learning a bit more might help with the "how" side.

earnest phoenix
#

You can always go on stackflow as well

#

They have some really useful threads on discord.js

warm marsh
#

Might be out-dated now though.

rain jacinth
#

basically imagine you need a channel names staff logs to have logs working but i want to make it as you can change thta location to another channel like staff logs to admin chat

warm marsh
#

Some concepts might still work but the methods and properties, etc.. might have changed.

#

I know how logging works.

earnest phoenix
#

Yeah but atleast it gives a basic idea

warm marsh
#

Just listen to the events

#

check if the guild has a logs channel

#

if so send the message

#

Do you have a log feature setup or not?

rain jacinth
#

yes i have logs feature ste up

warm marsh
#

The changing of the channel is really easy to do, Literally almost the same way as your prefix changer.

rain jacinth
#

like warn logs ban logs kick logs

#

report logs

warm marsh
#

Yeah

robust moth
warm marsh
#

?

robust moth
#

Why !args = false

warm marsh
#

because !![] = true

rain jacinth
warm marsh
#

I saw.

robust moth
#

Ok

warm marsh
#

As you can't convert circular to string

rain jacinth
#

where do i do that

warm marsh
#

Also use the correct variables.

#

logchannel and channel are two different variables.

rain jacinth
warm marsh
#

Only one of which are defined

earnest phoenix
#

Duck wrong one

warm marsh
#

ffs

#
earnest phoenix
#

I’m on my phone lmao

warm marsh
#

Websites not supporting www in 2020 rip

earnest phoenix
#

Lmao

robust moth
#

This is my args message.content.split(" ").slice(2);

warm marsh
#

Oh

#

rip

earnest phoenix
#

Oof

warm marsh
#
let args = message.content.substring(message.content.indexOf(prefix) + prefix.length).trim().split(/\s+/)```
#

That's how I did args when I used JS.

#
let cmd = (args.shift()).toLowerCase();
#

and cmd

robust moth
#

Ok

warm marsh
#

What?

#

jk and JK

#

prefix.toLowerCase() ?

earnest phoenix
#

Yeah figured that out last second

warm marsh
#

ah lol

earnest phoenix
#

Anyways ima head to bed before my brain kills me any more

warm marsh
#

Alright, Have a good one!

earnest phoenix
#

You too

silent berry
#

Hello, I have just updated to djs v12.2 and get this error.

const errorembed = new Discord.RichEmbed()
TypeError: Discord.RichEmbed is not a constructor
at Client.<anonymous> (/home/container/bot/bot.js:370:24)

#

Any fix?

hoary elm
#
#

It's MessageEmbed in v12

silent berry
#

Oh thank you@hoary elm

lime torrent
#

i just add api to one of my testing bot before adding it to my main bot. I wanna test if the coding is working as a intend but how do i test?

#

i mean i am sure if i add my bot to the site it will get rejected

#

cuz it has noting

#

its just to test my code

#

anyone? how do you test it?

hoary elm
#

If the API is setup correctly you can catch an error and console log the response 🤷🏻‍♂️@lime torrent

#

The language you use would obviously differ how you would go about achieving this but just a suggestion

lime torrent
#

i mean i want to test by having a member of my team vote and then seeing if my bot rewards it or not.

hoary elm
#

Oh 🤔 idk about that

silent berry
#

Is it possible to run these without .map

await Promise.all(helium.channels.cache.filter(c => c.name === 'helium-global-chat').map(c => c.send(e)))

        await Promise.all(helium.channels.cache.filter(c => c.name === 'helium-global-chat').map(c => c.setTopic(`Last message is sent by <@${msg.author.id}>`)))
astral yoke
wild solar
#

#roles

#

#daily

#

#user

pale vessel
honest whale
#

I keep getting this error randomly I tried handling it with on('error') but with no avail

Error: This socket has been ended by the other party
    at Socket.writeAfterFIN [as write] (net.js:453:14)
    at JSStreamSocket.doWrite (internal/js_stream_socket.js:170:19)
    at JSStream.onwrite (internal/js_stream_socket.js:28:57)
    at TLSSocket.Socket._final (net.js:416:28)
    at callFinal (_stream_writable.js:599:10)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'EPIPE',
  source: 'socket'
}
#

It crashes the bot every time it occurs so it's quite a nuisance

woven sundial
#

anyone who know what was the djs version in september 2018 ?

pale vessel
#

why?

woven sundial
#

I need it

restive furnace
#

@woven sundial prob v11 or v10

#

but why

pale vessel
woven sundial
#

Bc I need to help a friend who is using a code on an older version that he dont remember. I just have the file creation date

pale vessel
#

they should upgrade instead

woven sundial
#

He don't want to lmao

pale vessel
#

he needs to

woven sundial
#

sure

pale vessel
#

it'll stop working

woven sundial
#

thanks @pale vessel his code seems to be working now

lean swan
#

How do i get something like this "div.game-calls-to-action > div.game-title-container > h2" in edge?

pale vessel
#

what

#

do you need the tags?

lean swan
#

yes

#

I dont know how to call them

silent berry
#

This is preventing me from starting bot

tight plinth
#

It should be} catch {

silent berry
#

@tight plinth } catch (error) {
SyntaxError: missing ) after argument list

haughty night
#

Show full code

silent berry
#

Ok

tight plinth
#

That's logic

#

Yea show code

dusky marsh
#

youre missing a right paren somewhere where you are calling a function

silent berry
#

Damn 2000 limit

tight plinth
#

Hatsebin

silent berry
#

I'ma create txt file

vivid crescent
#

ye hastebin

haughty night
#

The section would've probably be enough, like the try catch section

#

But txt file will be okay too

silent berry
#

There ye go

#

?

#

I can't start bot

#

Bc of it

tight plinth
#

Solution: use your brain. Try to guess where else you can put the missing ) by looking at where it starts and where it needs to be closed

silent berry
#

I do that I get old error

#

As shown

tight plinth
#

Try, try, retry...

#

With others places

vivid crescent
#

There are a few missing return statements as well

tight plinth
#

Personally that's what I do

#

Yea too

silent berry
#

@vivid crescent half the bot like that, still ran

tight plinth
#

Do you know Javascript in general?

silent berry
#

I'm new

vivid crescent
#

Yeah but your code will bleed into other things

tight plinth
#

That's why

silent berry
#

Learning

tight plinth
#

Don't learn js by making a bot

#

That's the worst idea ever

#

Except if you're smart enough to read errors and solve them by urself

silent berry
#

Well time to back up to old file

#

Thank you for helping

haughty night
#

You have } and ) that are unnecessary and aint closing anything

#

They are just there

#

To break your code

#

Like the last }); isnt closing anything

#

Soooo, you have an editor no? Go through all your statements and look if they're closed correctly

earnest phoenix
#

What is the fastest time your bot is allowed to change its status on discord without it being considered API absue

pale vessel
#

5s

golden raven
#

heloo

#

can someone help me

earnest phoenix
#

ok

slender thistle
#

I suggest doing at least 10 seconds

pale vessel
#

F

golden raven
#

whenever i try to my mongo db database

#

connect ECONNREFUSED 127.0.0.1:27017

#

this error appears

earnest phoenix
#

ok cause I always change the status withing 1 minute intervals

pale vessel
#

that's good

golden raven
#

pls someone help me

#

whenever i try to my mongo db database
connect ECONNREFUSED 127.0.0.1:27017

pale vessel
#

make sure you actually setup your db correctly

golden raven
#

@pale vessel this happens when my bot tries to connect

#

it has some economy commands so i used a database for it

#

but whenever i try to connect

#

this appers

#

@pale vessel

pale vessel
#

stop pinging me smh

#

i can't help you sorry

golden raven
#

anyone else

#

here

#

doesnt looks like so

haughty night
robust moth
spice smelt
#

Hey. In the following code, the concerned user has voted and it's week-end. The console confirms that it has detected that indeed the user has voted and it's weekend. But the embed isn't modified. Did I make a mistake?

  dbl.hasVoted(msg.author.id).then(voted => {
  dbl.isWeekend().then(weekend => {
// \/\/\/\/
    if (weekend && voted) { console.log(`voted & weekend`); topggEmbed.addField(`🎉 Yaay, it's weekend! Earn bonuses by voting!`, `✅ You have already voted in the past 12 hours`) }
// /\/\/\/\
    if (weekend && voted === false) { topggEmbed.addField(`🎉 Yaay, it's weekend! Earn bonuses by voting!`, `⚠️ You haven't voted in the past 12 hours`) }
    if (weekend === false && voted) { topggEmbed.addField(`❎ It isn't week-end yet. Wait for friday!`, `✅ You have already voted in the past 12 hours`) }
    if (weekend === false && voted === false ){ topggEmbed.addField(`❎ It isn't week-end yet. Wait for friday!`, `⚠️ You haven't voted in the past 12 hours`) }    

  });
  });```
I have already tried to use `topggEmbed = new Discord.MessageEmbed(topggEmbed).addField('...')`
#

btw, topggEmbed is declared and used above this part of code

#

I think i've found why it doesn't work

#

The API takes time to get the values

#

When I got the values, the embed is already sent. But I can't use await here... How could I do this ?

#

no need to answer thx

#

i've found

#

:)

#

I used this: js let voted = await dbl.hasVoted(msg.author.id) let weekend = await dbl.isWeekend()

neat ingot
#

random question:
how long do you guys normally spend on designing elements? like, changing placement or format of text in embeds etc.

spice smelt
#

Since embeds are prety simple (author, title, color, description, fields, footer), I don't spend much time on them. But recently I've found bots that send very strange embeds (I couldn't define what is a field or a description), so these times I'm trying to figure out their secret xD

neat ingot
#

embeds are only as simple as you want to make them 😛

spice smelt
#

that's true

#

btw what's the plural of 'bonus'? i'm french x)

#

bonuses? bonus?

haughty night
#

bonuses

zenith terrace
#

random question:
how long do you guys normally spend on designing elements? like, changing placement or format of text in embeds etc.
@neat ingot sometimes I just use the .setDescription one for the embeds cause it looks nicer than doing the .addFields, depends on what it is though

neat ingot
#

yea i've tried that out as well 😛

spice smelt
#

sometimes I just use the .setDescription one for the embeds cause it looks nicer than doing the .addFields, depends on what it is though
@zenith terrace About replacing fields by description : i've tried this, but the space between lines is too big. Do you have any trick to avoir this?

still merlin
#

I have a question- I'm trying to have a "Join Support Server:", "click here." but where would I add a .setURL(url)

#

on a embed

spice smelt
#

with .setURL, you'll add a URL on the Title. Not very practical. If you want to set a link in a field or the description, you can do this: js '[click here!](http://this.is.the/url "this is the text when you hover the link")'

still merlin
#

alright ty

spice smelt
#

np

nocturne grove
#
const channels = guild.channels.cache.filter(c => c.type == 'text' && c.permissionsFor(guild.me).has(['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'])).array();
for (const channel of channels) {
    const message = await channel.messages.fetch({ limit: 1 });
    ...
}```
How can that give this? ```json
DiscordAPIError: Missing Access
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
name: 'DiscordAPIError',
message: 'Missing Access',
method: 'get',
path: '/channels/xxx/messages?limit=1',
code: 50001,
httpStatus: 403
}```
#

that's the only spot in my whole code where it's fetching one message

earnest phoenix
#

What are you trying to do

spice smelt
#

The error code is 403. Your code seems right, but you just can't do that apparently

nocturne grove
#

oh this is weird. That code is executed in a guildCreate event, but no guild was joined before that error

slender wagon
#

heya guys so i'm trying to verify my bot and i wanna remove anything that might make it look suspicious, how could i remove my bot from all the servers with 3 members or less

nocturne grove
#

but what I'm doing is just normal, it normally works

#

heya guys so i'm trying to verify my bot and i wanna remove anything that might make it look suspicious, how could i remove my bot from all the servers with 3 members or less
@slender wagon loop through all guilds and do guild.leave() when its membercount is less than 3

slender wagon
#

oh alrightys

earnest phoenix
#

Well you can catch the error at the loop

nocturne grove
#

but this only happened once, so next time it will probably not happen again

slender wagon
#
bot.guilds.cache.forEach(guild => {
    console.log(" - " + guild.name, +guild.memberCount);

could i add it here

nocturne grove
#

yes you can do that

#

but it won't leave

slender thistle
#

I have an element <button onclick="click()">Calculate</button> in my HTML file and my click function doesn't get fired
Script tag right below the button:

        <script rel="script">
            function click() {
                console.log(resultstr);
            }
        </script>
slender wagon
#

yeah ik that just logs the servers

nocturne grove
#

@slender thistle idk how that works but is resultstr defined somewhere?

slender thistle
#

To add more details to my issue, I can run click() from browser console just fine

#

resultstr will just be undefined

nocturne grove
#

okay so you'd just like to log undefined 😁

slender thistle
#

or an error, I don't exactly care which one. I just want it to run 😂

nocturne grove
#

well idk, I'm sorry

dusky marsh
#

you cant use the function name click on a button

#

buttons already have a click method that has higher priority than your function

slender thistle
#

That explains it then, thanks

dusky marsh
#

ye

nocturne grove
quartz kindle
#

if the bot joined a guild with 500 channels, it could happen that someone edited or deleted a channel while your bot was fetching them lol

#

you could change the logic to check for permissions inside the for loop

earnest phoenix
#

wouldn't that be a 404

#

and not a 403

quartz kindle
#

its a missing access error

#

can happen because you dont have view channel permission

earnest phoenix
#

oh i see yeah someone could've changed permissions for the channel

#

while looping

quartz kindle
#
for(let [id,channel] of guild.channels.cache) {
  if(channel.permissionsFor(guild.me).has([a,b,c])) {
    await channel.messages.fetch()
  }
}
nocturne grove
#

hmm okay thanks

#

but could that really take 7 minutes? Also, I don't think it had a lot of channels

#

but I will try that instead 👍

earnest phoenix
#

i don't know if node has something like that, but in mutlithreaded langs you can just offload the async tasks to another thread, so the for loop just queues the task and forgets about it without blocking itself from continuing

#

ok a quick google search it does

#

look up the fire and forget pattern if you're interested

nocturne grove
#

isn't that just a foreach?

earnest phoenix
#

if you mean the forEach method

#

kind of

#

forEach is super slow compared to a native for loop though

nocturne grove
#

but I can just do what Tim said right?

earnest phoenix
#

yeah

nocturne grove
#

yeah I hear that often from you haha I transferred some

earnest phoenix
#

i was just noting if you don't want the for loop to block you can follow the fire and forget pattern

nocturne grove
#

oh okay. Well I can read about it. Thanks

robust moth
viral spade
#

In node.js discord.js, whats the easiest way to let all shards share the same db (mysql) connection pool (possibly in the sharding managers process) ?

earnest phoenix
#

@robust moth try adding if (!commandFile) return

rain jacinth
earnest phoenix
#

@rain jacinth wat?

rain jacinth
#

Oh ok..

zenith terrace
#

@zenith terrace About replacing fields by description : i've tried this, but the space between lines is too big. Do you have any trick to avoir this?
@spice smelt wdym by lines being too big

spice smelt
#

@zenith terrace wait 1min i'll create an exemple

zenith terrace
#

Mkay

robust moth
#

@earnest phoenix An error occurred while the command matched

viral spade
#

whats the easiest way to let all shards share the same db (mysql) connection pool (possibly in the sharding managers process) ?

spice smelt
#

@zenith terrace well it looks like my issue is gone 😓

zenith terrace
#

Lol what did you use

spice smelt
#

simply .setDescription('description \nto the line \n to the line')

zenith terrace
#

Fun

spice smelt
#

why?

#

is there another way to do this?

zenith terrace
earnest phoenix
#

Ok

zenith terrace
#

It looks a whole lot better than .addField(). And no that looks good

spice smelt
#

not bad

#

true

#

I see you're an extremist of the Dark Theme x)

earnest phoenix
#

bot is not defined

const { MessageEmbed } = require("discord.js");

module.exports = {
    name: "ping",
    category: "info",
    description: "Returns latency and API ping",
    run: async (client, message, args) => {

      let msg = await message.channel.send('🏓 Pinging... 🏓')

      const p = new MessageEmbed()
      .setTitle("🏓 Pong! 🏓")
      .setColor("#ff9900")
      .addField("Letancy", `${Math.floor(msg.createdTimestamp - message.createdTimestamp)}ms`)
      .addField("API letancy", `${Math.round(bot.ws.ping)}ms`);

      msg.edit(p);
    }
}

Help ?

zenith terrace
#

I love the amoled theme

spice smelt
#

you got an amoled display?

#

these people are rare xD

zenith terrace
#

@earnest phoenix ur running it as async (client

#

Not bot

earnest phoenix
#

oh right

zenith terrace
#

Thats why it aint defined

earnest phoenix
#

ty

zenith terrace
#

Are you copying it from somewhere

rain jacinth
#

how can i make it as when you level up on the amount of xp you need to level up adds like 70 per new level to the amount that you need to level up

earnest phoenix
#

the handler yes, because i tried so many times making one good and i didn't made it 😅

true ravine
#

I'm trying to wait for an async function to finish and then call it again with different arguments, but it finishes but my code keeps waiting

#

The function I'm waiting for only uses awaits for async stuff and I return true at the end just to be sure

#

But nothing happens once it finishes the first time

earnest phoenix
#

what's your code

true ravine
#
async function cycleStart(oids){
    for(i=0;i<oids.length;i++){
        console.log(i)
        res = await deliver(oids[i])
    }
}
cycleStart(oids);
#

deliver is the async function I'm waiting for

robust moth
#

I fixed it and thanks

tight heath
#

these people are rare xD
@spice smelt I think any major phone that was created recently has amoled :o

spice smelt
#

i'm talking about amoled monitors

#

of course that's something else with phones

zenith terrace
#

Well I used my phone to take that ss

viral spade
#

In node.js discord.js, whats the easiest way to let all shards share the same db (mysql) connection pool (possibly in the sharding managers process) ?

zenith terrace
#

I have no idea as well Delivery

#

Lol

rain jacinth
#

how do i make it as every level you earn it adds like 70 to the amount you need to level up?

true ravine
#

It definitley retuns because I can log what the function returns, I guess it just gives up because it isn't able to socially distance from the function

restive night
#

I also have a problem with DB when sharding

viral spade
#

where is tim? 😭

zenith terrace
#

Hibernating

earnest phoenix
#

You're asking for the exceedingly rare thing GWahreeSure

fickle arch
earnest phoenix
#

are you really trying to use "this" in js?

zenith terrace
#

Yes

earnest phoenix
#

is "this" a thing in js?

coral trellis
#

Yes

earnest phoenix
#

understandable

zenith terrace
#

@earnest phoenix he definitely defined it as

const this = message.author
/s

earnest phoenix
coral trellis
#

Is client users attached to this?

viral spade
#

xignotic can you help me

coral trellis
#

Maybe

viral spade
#

In node.js discord.js, is there an easy way to let all shards share the same db (mysql) connection pool (possibly in the sharding managers process) ?

fickle arch
#

ahhh okay i get it.

viral spade
#

I thought of redirecting queries via ipc. but i did not manage to "await" return values from messages i send from a shard to the sharding manager using the libraries own functions / using node-ipc.

fickle arch
rain jacinth
#

WYM

#

it's 50 to get to level 2

#

and i want to make it as 134 to add to the amount

earnest phoenix
#

:)

rain jacinth
fickle arch
#

how to make send a dms to person to notice that they got kick/ban from a server ?

rain jacinth
#

my level.js file

hasty sparrow
#

@viral spade If all shards share the same connection pool, then you could end up with one shard could starving all others

rain jacinth
#

@earnest phoenix what do i do and on which file

fickle arch
#

so just add toBan.Send like that ?

#

the reason not string doesn't work.

viral spade
#

@hasty sparrow True, but on the other hand this way it can balnce in a way that one shard that needs more get more from those who dont at that time.

hasty sparrow
#

Make sure to send the DM before the user is kicked/banned

fickle arch
#

yes i mean how i tried my friend code but it instead sending error.

viral spade
#

@hasty sparrow more importantly, i dont need one connection per shard per database

hasty sparrow
#

How many databases do you have?

viral spade
#

only two for testing purposes, but i want to design it in a way that i can have multiple.

#

for the long term

hasty sparrow
#

Are we talking multiple databases on one or multiple servers?

viral spade
#

multiple servers, one db per server

hasty sparrow
#

Odd design choice

viral spade
#

what would be better?

#

im open ears

hasty sparrow
#

Depends on your use case, but a single (no)sql server can easily manage multiple databases

viral spade
#

i mean its the same scheme, the guild data is sharded accross these databases

hasty sparrow
#

You might not even need multiple databases (like 1 per shard/guild is wasteful)

viral spade
#

no i hope to manage like 100k server per db

#

so 100 shards

#

per db / per server

hasty sparrow
#

So that's like 100 idle connections to each db server, no big deal and much faster than having to create new connections cause the shared pool is empty

#

Not to mention the fact that you can't really share the pool to start with

viral spade
#

yes but i want to build for like 1000 shards

#

so its too much of idle connections

hasty sparrow
#

Get to a 1000 shards and then worry about these kind of things, chances are other parts of your bot will fail before then

fickle arch
#

wait is member.user.tag mean to tag the person or it's user.tag to tag the person i'm a little bit confused because member.user.tag only shown the name and the tag but not pinged them.

hasty sparrow
#

What db are you using?

viral spade
#

mysql

#

i know it can handle that many connections. its just too much ram, when say 10 bot servers à 100 shard exist, and each shard connects to all 10 databases.

earnest phoenix
#

@fickle arch the docs are your saviours during difficult moments

hasty sparrow
#

Why would each shard connect to all databases though?

fickle arch
#

@earnest phoenix
for example it's

      `${member.user.tag} Has been muted.${
        reason ? ` Reason ${reason}` : ""```
so i changed it to this ?
```return msg.sendMessage(
      `${member.user} Has been muted.${
        reason ? ` Reason ${reason}` : ""```
viral spade
#

because what guild is on what shard changes when increasing shards

fickle arch
#

it's sure to ping the person right ?

viral spade
#

so possibly, most likely each shard of 1000 guild will have at least one guild on each db server

fickle arch
#

like ${@member.user.id} ?

#

ahh okay thanks a lot.

hasty sparrow
#

The only way to share the connection between shards that I can think of right now would be to have all querying be done by a separate/parent process

fickle arch
#

tag is same with id or it's different ?

viral spade
#

Right but as i said, i cannot find a way (node-ipc, d.js build in sharding messaging) to send a message and wait for the results

hasty sparrow
#

How would you even determine which server has which guild, if the shard a guild is in changes when the bot grows?

viral spade
#

first time a guild is seen it caches the location

fickle arch
viral spade
#

it caches location from coordinator server

fickle arch
#
    return msg.sendMessage(
      `@${member.user.id} Has been kicked.${
        reason ? ` Reason : ${reason}` : ""```
#

before i write member.user.tag instead of id.

#

let me replace tag with id

#

oh wait there's none.

#

like this ?

    if (member.id === msg.author.id) throw "You cannot kick yourself.";
    if (member.id === this.client.user.id) throw "I cannot kick myself.";

    if (member.roles.highest.position >= msg.member.roles.highest.position)
      throw "You cannot kick this user.";
    if (!member.kickable) throw "I cannot kick this user.";

    await member.kick(reason);
    return msg.sendMessage(
      `@${member.user.tag} Has been kicked.${
        reason ? ` Reason : ${reason}` : ""```
hasty sparrow
#

@viral spade You could send your payload along with a unique identifier to the other process, register a callback with this identifier in your sharded process and when the shard receives a message/the result, check the identifier and call the registered callback with the returned payload/query result

viral spade
#

interesting, but i would need to transfer guild, client etc. objects

#

to be able to keep on working after the callback has returned

fickle arch
#

@earnest phoenix i already make it into level 6 (people who have kick perm)
define i already tag the person it works before but it doesn't ping them only shown their name and tag but not ping
third the user is below mods.

viral spade
#

As an alternative, what would you say about making one connection per query. The most critical part is that i need to cache the guildmember info i have (not much, a few properties) to the clients guildmember object, when that user first writes a message or talks in a voicechannel.