#development

1 messages ยท Page 659 of 1

woven zealot
#

Start googling

wheat jolt
#

:/

#

for what do you want a bot

oblique token
#

It will be like mee6 but there's no premium

woven zealot
#

Rip

oblique token
#

Premium is free

#

@west spoke

twilit rapids
#

Nice random ping

woven zealot
#

No one is gonna code you a mee6 clone

#

At least not for free

oblique token
#

@twilit rapids are you a bot developer

topaz fjord
#

why

#

why ping me

oblique token
#

?

#

Sorry that was an accident

twilit rapids
#

Give me $100 and I will code every bot you want

topaz fjord
#

mmLol lmao timo

oblique token
#

@topaz fjord can you do it for me

wheat jolt
#

stop begging

topaz fjord
#

No I'm busy

wheat jolt
#

like how I said, no one will spoon feed you

#

you need to learn node.js

#

or a coding language

slender thistle
#

No one is gonna do everything for you. If you need help with code, ask the question and someone will get to you

wheat jolt
#

then make your own bot

topaz fjord
#

I have to finish my own bot /tableflip and I can't figure out why mongo is being gay rn

#

hecking mobile

woven zealot
#

I straight up ditched mongo

twilit rapids
#

Mongo isn't gay, your code is.

Change my mind.

woven zealot
#

I went from mongodb to mongoose to mongodb

topaz fjord
#

I'm not used to using it in java

oblique token
#

OkFeelsMusicMan feelsrainman

topaz fjord
#

mongoose uses mongodb lmao

woven zealot
#

no I know, I just meant my driver

topaz fjord
#

oh

earnest phoenix
#

@opaque eagle discord.js

swift topaz
#

speaking of databases

twilit rapids
#

My deal still stands ssundees

woven zealot
#

require('mongodb') vs require('mongoose')

swift topaz
#

Lavalink is dependent on database

topaz fjord
#

No

#

It isnt

swift topaz
#

wait really

topaz fjord
#

Yes

oblique token
#

I have no money

unique nimbus
#

@oblique token learn to code

swift topaz
#

oh I was looking at the nodes part

twilit rapids
#

F

topaz fjord
#

You just need the jar file and a client for it

swift topaz
#

in the documentation const nodes = [ { host: "localhost", port: 2333, password: "youshallnotpass" } ];

#

I almost got ptsd

topaz fjord
#

So uh

#

Anyone use the MongoDB java driver with POJOs

quartz kindle
#

@twilit rapids only 100 bucks for a mee6-like? thats hella cheap

oblique token
#

I don't even Code really hard for me

swift topaz
#

uhhh what client btw

twilit rapids
#

I mean, it's not that hard

quartz kindle
#

unless you literally clone their source

#

its not hard, but takes time

topaz fjord
woven zealot
#

right that's what I was saying

twilit rapids
#

I bet that their open source

woven zealot
#

fully functional web dashboard?

#

no ty

twilit rapids
topaz fjord
#

That viciou

opaque eagle
#

Map your client's guilds by its channels and flatten the array @earnest phoenix

woven zealot
#

that's like a month of solid work for mee6 from scratch

swift topaz
#

I'm really questioning why I don't look at Github repos often. Thanks Turtle

twilit rapids
#

But yeah. If you give me $100 I will code you a bot like mee6

woven zealot
#

paid up front, no time wasters ๐Ÿ‘€

quartz kindle
#

including the web dashboard and all commands?

#

lmao

swift topaz
#

Oh yeah I'm using the discord.js-lavalink I guess it's good then @topaz fjord ?

twilit rapids
#

Oh, you're right lmao, a webdashboard

#

oof

topaz fjord
#

yes

twilit rapids
#

I mean, all command won't be an issue

#

But I forgot about the web dashboar-

tight heath
#

Mee6 super gay

swift topaz
#

Since I'm using javascript I guess I don't need to make jars...?

topaz fjord
#

You can download the lavalink jar

quartz kindle
#

imo a job like that would go for at least 500 bucks

topaz fjord
#

They provide a link

#

Fuck

#

I spelt gay wrong

tight heath
#

Groovy best bot

#

๐Ÿ˜ค

swift topaz
#

damn I thought I won't need the jar since I'm using js

unique nimbus
#

@tight heath whats groovy?

#

oh

#

nvm

tight heath
#

@unique nimbus the best music bot

#

๐ŸŽท

twilit rapids
#

What's a groovy

unique nimbus
#

okay if it is then I would be the co-owner ๐Ÿ˜Ž

tight heath
#

No

unique nimbus
#

Yes

tight heath
#

Actually no

twilit rapids
tight heath
#

Being staff requires actually working

#

Also yes

swift topaz
#

I'm allergic to Docker Images so I guess I don't have to touch it while using lavalink?

tight heath
#

Same and in theory not

swift topaz
#

what

#

oh nice Lavalink uses Spring... the framework that made me quit my job

tight heath
#

:+1:

twin kestrel
#

Hi all!
I put them in situation quickly because I need help

I am using shard on my Discord bot and today when I went to do the tests on a Discord server that I do not use, I realize that it does not react to commands. Then I have returned to my usual server and it works correctly.

I also have a statistics command where it gives me the number of servers in which the bot is linked and marks me 1 instead of 2.

If anyone knows the answer, let me know

#

Excuse me for my English

quartz kindle
#

how are you sharding?

#

show your sharding code

tight heath
#

@swift topaz don't use Lavalink then

twin kestrel
#

This is my script

const { ShardingManager } = require('discord.js');
const config = require("./config.js");
const manager = new ShardingManager('./index.js', { token: config.token });
const shards = 2;

manager.spawn(shards, 15000, false);
manager.on('launch', shard => console.log(`[Sistema] Se ha cargado el Shard #${shard.id} correctamente.`));

setTimeout(() => {
    console.log("Reiniciando")
    manager.broadcastEval("process.exit()");
}, 21600000);```
tight heath
#

Groovy doesn't either and we have multiple servers working fine

swift topaz
#

I see I see

#

I guess I shouldn't really dwell much on libraries since I'm literally only deploying my bot on a single server

tight heath
#

And my js bot which uses Lavaplayer works without it too

#

We use our sharding manager to manage Lavaplayer instances

swift topaz
#

I was just looking for alternate solutions since I'm having problems with ytdl-core

quartz kindle
#

@twin kestrel did you wait for 15 seconds? does the bot appear online in both servers, or is it offline in one?

twin kestrel
#

Yes

#

The bot appears online

#

Load everything well until it reaches the ready.js event

#

It gives a supposed error when loading the shard # 1 of an indefinite channel (which if it is defined)

quartz kindle
#

well thats your problem then

#

show the code that loads the channel

twin kestrel
#

As? I did not understand, sorry

quartz kindle
#

show the code

#

where you defined the channel

twin kestrel
#
client.channels.get('589393059545088001').send(crash)```
#

TypeError: Cannot read property 'send' of undefined

quartz kindle
#

when you shard, each shard will only have access to half of the servers

#

which means, that channel doesnt exists in one of the shards

twin kestrel
#

Okay

#

Then ... how do I fix the error that causes the bot not to recognize the commands (well, rather than not responding)

quartz kindle
#

its probably not responding because the channel not found caused it to crash

twin kestrel
#

So, how can I define it so that it sends the message?

quartz kindle
#

the easy way to fix is to check if the channel exists before doing anything if(...get(id)) { ...get(id).send() }

#

but doing that will make that line only work in that shard, not in others

#

if you want to send messages to that channel from all shards, you need to use broadcasteval

twin kestrel
#

I fixed that, rebooted the bot and now does not respond to any of the servers

west spoke
#

@oblique token ....... fuckin ping me again for no reason and I swear

twin kestrel
#

And it does not give any error in the console

quartz kindle
#

how did you fix it?

twin kestrel
#
if(client.channels.get('589393059545088001')) {

  client.channels.get('589393059545088001').send(crash)

        }```
violet jetty
#

๐Ÿ‘€

twin kestrel
#

Oh, I already found the error, it was another event with the same system

#

Now if it reacts on both servers, but the server counter keeps dialing 1 instead of 2

quartz kindle
#

thats normal, because it can only count the servers in the shard

violet jetty
#

Why not get server then channel?

quartz kindle
#

if you want to do things across all shards, you need to use broadcasteval or fetchclientvalues

violet jetty
#

Fetch will be better

vague chasm
quartz kindle
#

@violet jetty that has nothing to do with the issue, we are talking about sharding

violet jetty
#

Okie

quartz kindle
#

@vague chasm Day() returns the day of the week

#

sunday is 0, the first day of the week in your system

vague chasm
#

Oh

#

Damn I totally forgot difference between Day and Date in my mind

warm marsh
#

So quick question, Does any library/language have support for listening to someone's voice via voice channel?

twin kestrel
#

I have already run the server counter, although the game activity stopped working in shard 0, in the other shard it works

#

Error: Still spawning shards.

earnest phoenix
#

@opaque eagle flatten?

twilit rapids
#

That means the manager hasn't launched all shards yet @twin kestrel

#

So wait until all shards are laucnhed

#

e.g. by checking the current shards count

twin kestrel
#

They already loaded all and the only one that does not work is the first one that starts

EDIT: I made a waiting time in the presence code

oblique token
#

@west spoke fucking

opaque eagle
wheat jolt
#

@loud salmon sorry for ping but...

#

look up

loud salmon
#

uh

opaque eagle
#

If I look up I see the ceiling

wheat jolt
#

isn't that against the rules?

loud salmon
#

what am i supposed to be looking at

opaque eagle
#

If you reposted your question that would be helpful

loud salmon
#

the random ping?

#

dbl snipe

covert turtleBOT
#
iLxlo_#4204 (266103595949096960)

Hmm - 44 minutes ago

opaque eagle
#

I think he's asking for help with smth

loud salmon
#

oh that

#

uuuuuuuuuuuuuuuuuuuuuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

i mean swearing isnt against the rules

opaque eagle
#

lol did he legit ping a mod for swearing

loud salmon
#

though its kinda strange that he just did it out of nowhere

#

oh lmao

tidal relic
#

He's been doing that

#

But the other messages from it are gone now

opaque eagle
loud salmon
#

@oblique token why did you randomly ping neko thinkie

woven zealot
#

Wanted someone to build em mee6 but with the premium features ๐Ÿ˜‚

loud salmon
#

oh

opaque eagle
loud salmon
#

i saw

opaque eagle
#

that was cute

loud salmon
#

@gilded plank mute @oblique token dbl is not a place for free developer labor | 6h

gilded plankBOT
#

๐Ÿค Muted Xxssundeespoop#7347 (@oblique token)

opaque eagle
#

"you can be my bot developer" as if it's a privilege

#

more like a burden

woven zealot
#

Well, clearly that was the brains behind the whole operation. Who else could come up with such a unique bot idea?

earnest phoenix
#

ok

#

map2map

valid frigate
#

cant find this in master but how do i get the ping of the client

#

apparently client.ping isnt a thing anymore

broken shale
#

Does anyone know how to use pm2

stray garnet
twin kestrel
#

Sorry to bother again, but I have a small problem, my bot sends a record in a channel of my server when the "guildCreate" event is executed and takes the ID, how can I make this affect all the shards (I do not know if I explain it well enough)

opaque eagle
#

@valid frigate client.ws.ping

#

@broken shale post ur question and someone will help if they can

#

@twin kestrel I'm pretty sure you don't have to worry about that

valid frigate
#

oh ok

twin kestrel
#

But it's not the only event / command that uses that variable

opaque eagle
#

wdym

twin kestrel
#

I have a command to report bugs and do exactly the same as in the guildCreate event

opaque eagle
#

Ohh so the report guild is on a different shard from your support guild, so it can't send the message?

twin kestrel
#

Correctly

#

My support server is at number 0 and the one I use to test in 1

opaque eagle
#

I'd use webhooks instead

topaz fjord
#

^

#

Use webhooks

#

They're easy to set up

twin kestrel
#

I do not know how to handle webhooks

topaz fjord
#

And get rid of the pain of searching for the guilds

opaque eagle
#

Go to the channel where you want logs and make a webhook there. @twin kestrel

#

Then, you can do js client.logs = new Discord.WebhookClient("Webhook ID", "Webhook Token"); client.logs.send(/* You can send text/embeds/files */);

twin kestrel
#

I'll try

warm marsh
#

So I asked this question the other day and got ignore but how to get <Guild>.iconURL in discord.js@12.0.0-dev

twin kestrel
#

@opaque eagle thanks you very much โค

#

Is working

warm marsh
#

nvm found out.

opaque eagle
#

It's a function now @warm marsh

#

oh nvm

warm marsh
#

Yeah bit odd. Thanks anyway.

#

Do you need to supply the param { format, size }

#

or not?

opaque eagle
#

they're optional

#

same for user avatars... User.displayAvatarURL()

warm marsh
#

Ok, Another quick question if someone's pfp/guild icon is a gif will it use gif or png/jpg?

opaque eagle
#

gif

warm marsh
#

Thanks!

earnest phoenix
#

:lmao:

#

:lmao:

mossy vine
#

is it acceptable to use

if(condition) {
    //code
    return
}
if(otherCondition) {
    //otherCode
    return
}```
instead of
```js
if(condition) {
    //code
} else if(otherCondition) {
    //otherCode
}```
somber verge
#

that depends on what you want the code to do exactly

#

the first one can have both execute at the same time

mossy vine
#

it cant if it returns tho?

somber verge
#

unlike the aecond one, where only one of the options will be executed

#

yeah context also changes that

smoky mica
#

how do you put a space in your prefix?

#

like prefix help

mossy vine
#

in first example otherCode doesnt get executed

#

because of the return statement

somber verge
#

it depends on what you want it to do and the code that gets run

#

if it has return both should work

cursive dagger
#

@mossy vine preference is the only rule for that

mossy vine
#

sounds good to me

earnest phoenix
#

former is more clean imo

dark dust
#

just a question, isn't "else if" elif?

mossy vine
#

not in javascript

dark dust
#

thanks for your answer

mossy vine
#

youre welcome but why are you starring that

#

elif doesnt exist in javascript

quartz kindle
#

i'd say the second option if strictly deciding between two logic paths

#

first option if going through a checklist that could possibly change or require more checks in the future

mossy vine
#

thanks!

earnest phoenix
#

this level up message code is right?

let anchannel = message.guild.channels.find(`id`, "265156361791209475")
      if(message.guild.id === '264445053596991498') return anchannel.send(UPembed)
      message.channel.send(UPembed);
#

Can someone answer me, please? If you have any errors, can you correct me?

grim aspen
#

never defined upembed?

woven zealot
#

\id`` ?

#

Bah

#

Why is id in ticks

grim aspen
#

UPembed sounds like it was never defined

earnest phoenix
#

the UPembed is set yes, it is an embed that the person has increased level

grim aspen
earnest phoenix
#

just put the part that I'm in doubt if it's right

#

@loud salmon
How to unmute your bot?

#

(my bot)

loud salmon
#

@earnest phoenix fix the issue, then contact a mod

earnest phoenix
#

ok

quartz kindle
#

you should pass a function to .find() instead

#

also checking for a guild after the channel is useless, because channels are already unique if you're using the channel id

earnest phoenix
#
    console.log(`${HERE I NEED HELP} Deleted ${message.id} ${message.name}`)
})``` i can somehow to get the name if he delete the message?
#

the event doesn't provide that info

#

you can attempt to grab it from audit logs though

#

then it's a big F word

#

for me

mossy vine
#

do you want to know the original message or who deleted it?

earnest phoenix
#

Who deleted it

mossy vine
#

yeah, you need to grab it from audit logs

earnest phoenix
#

Ok , thx for help @earnest phoenix and @mossy vine

broken shale
#

Anyone know how to keep my node.js bot alive with pm2

#

It shuts down after 5m (hosted on vps)

#

It still crashes after 3mins

bright spear
#

If it crashes then that's an issue with your code

#

And you need to check logs and figure out the issue

#

pm2 just restarts it when it crashes

broken shale
#

is it because I need to do node . then pm2 start bot.js

amber fractal
#

you dont want to start it with node and pm2

#

then you have 2 instances

#

which doesnt make sense

broken shale
#

theres no error, says it's online

#

yet bot crashes

woven zealot
#

I use forever, are there any advantages to pm2

amber fractal
#

pm2 is a real process manager

#

jk, but most people prefer pm2

earnest phoenix
woven zealot
#

I've honestly never used it, I've been using forever for like 6 years so if there's a better option lmao

zealous veldt
#

lol I love that there's a pm2 conversation happening right now as I research for the article on pm2 im about to write

woven zealot
#

pm2 looks nifty af

#

definitely gonna switch from forever

valid frigate
#

how have u not discovered pm2

zealous veldt
#

bruh

upper vault
#

Moos

zealous veldt
#

yessir

woven zealot
#

I'm a front end dev, I don't really fire up node processes much ๐Ÿคท

hollow saddle
#

pm2 is amazing

#

Highly recommend switching to it papa

languid dragon
#

im a frontend dev and i have 6 servers with pm2

woven zealot
#

๐Ÿคท

languid dragon
woven zealot
#

Am bb dev

zealous veldt
#

YO

#

Speaking of

#

anybody want to help me come up with all the uses for pm2

languid dragon
#

you can run a Minecraft server using it

#

in fact you can run any java app afaik

zealous veldt
#

ye

scenic vapor
#

you can run things that restart when they crash

#

It epic

bright spear
#

you can write shit code because it doesnt matter if it crashes

swift topaz
#

So I made my music bot play music but when I want it to play music again it doesn't respond anymore

#

the certain command that is

#
                const voiceChannel = msg.member.voiceChannel;

                if (!voiceChannel) return msg.channel.send("Not in voice channel");
                try{
                    var connection = await voiceChannel.join();
                }   catch (error) {
                    msg.channel.send(`${error}`)
                }

                const dispatcher = connection.playStream(ytdl(args[0], {filter : 'audioonly'}))
                    .on('end', () => {
                        console.log('Song ended');
                        voiceChannel.leave();
                    })
                    .on('error', error =>{
                        console.error(error);
                    });
                dispatcher.setVolumeLogarithmic(5 /5);```
amber fractal
#

@zealous veldt built in load balance

zealous veldt
#

ah yes

swift topaz
#

is tehre anything wrong with my code?

#

there*

earnest phoenix
#

I make a webhook fake message

bright spear
#

btw @swift topaz syntax highlighting makes your code easier to read

#

```js

swift topaz
#

I did syntax highlighting

#
                const voiceChannel = msg.member.voiceChannel;

                if (!voiceChannel) return msg.channel.send("Not in voice channel");
                try{
                    var connection = await voiceChannel.join();
                }   catch (error) {
                    msg.channel.send(`${error}`)
                }

                const dispatcher = connection.playStream(ytdl(args[0], {filter : 'audioonly'}))
                    .on('end', () => {
                        console.log('Song ended');
                        voiceChannel.leave();
                    })
                    .on('error', error =>{
                        console.error(error);
                    });
                dispatcher.setVolumeLogarithmic(5 /5);```
bright spear
#

๐Ÿค” i dont see iut

swift topaz
bright spear
#

yeah thats not syntax highlighting

#

you need to do it like
```js
code here
```

swift topaz
#

ahh my bad

#
case 'play':
                const voiceChannel = msg.member.voiceChannel;

                if (!voiceChannel) return msg.channel.send("Not in voice channel");
                try{
                    var connection = await voiceChannel.join();
                }   catch (error) {
                    msg.channel.send(`${error}`)
                }

                const dispatcher = connection.playStream(ytdl(args[0], {filter : 'audioonly'}))
                    .on('end', () => {
                        console.log('Song ended');
                        voiceChannel.leave();
                    })
                    .on('error', error =>{
                        console.error(error);
                    });
                dispatcher.setVolumeLogarithmic(5 /5);```
#

anyway that's my problem. it won't run again after running once

#

I tried debugging my args but they're both undefined

old geyser
#

my bots throwing errors, because it doesnt have permission to post in this server when commands are made, is there a way to fix this? or just make it so my bot doesnt see chat?

amber fractal
#

make sure the bot can send messages, if it cant return

swift topaz
#

how do I convert this .addField(' ', ' ') to something like this

module.exports.run = async (bot, msg, args) => {
    msg.channel.send({embed:{
        title: 'Jigglypuff!',
        description: 'Puff!',
        field: 'Prefix',
        text: 'puff.',
        color: 0xfca2dd,
        thumbnail: {url: bot.user.displayAvatarURL}
    }});```
amber fractal
#

the field part of an embed is an array of objects with name and value properties

swift topaz
#

.addField('Prefix' ,'puff.');

amber fractal
swift topaz
#

so I should make it field.name and field.value respectively inside that constructor?

#

oh I get it

amber fractal
#

there's a fields property in the embed that is an array

#

the embed visualizer helps

ember atlas
#

!e const Discord = require(discord.js); const modembed = new Discord.RichEmbed() .setTitle("Moderator Guidelines") .addField("Expectations", "You are full Moderators. You help train the assistants and keep the server secure by taking care of anyone who breaks the rules. You are a role model and held to a very high standard.") .addField("Commands", "You can use all of the moderation commands with Dyno. These can be found [here](https://dyno.gg/commands#/Moderator). You can also use the following commands:\n?lock- Locks a channel from allowing people to talk in it\n?unlock- Unlocks a channel\n?setnick- Set someoneโ€™s nickname") .setColor("bbaaee") .setFooter("ChannelBot Support") message.channel.send(modembed)

What is this?

#

Ping with response

fiery pivot
#

@ember atlas delete the !e on the start of your programe

ember atlas
#

@fiery pivot Why?

#

Lmao

#

I figured it out, but thanks for trying

fiery pivot
#

Ok

#
const Discord = require ('discord.js');

module.exports.run = async (bot, message, args) => {
	let botIcon = bot.user.displayAvatarURL;
		let helpEmbed = new Discord.RichEmbed()
			.setColor('#fffff')
			.setThumbnail(botIcon)
			.setTitle('Page des Commandes')
			.addField('b1help', 'Affiche la page des commandes')
			.addField('b1xp', 'Donne votre nombre d\'Xp que vous avez sur tout les serveur ou je suis (Syncro) par le nombre de message')
			.addField('b1ping', 'Rรฉpond pong ou donne le ping du bot')
			.addField('b1invite', 'Donne le lien d\'invitation pour que je rejoigne vos serveur discord')
			.addField('b1support', 'Donne le lien du support ')
			.addField('b1info', 'Donne mes informations')
			.addField('Commandes Admin', '----------------------------------')
			.addField('b1clear', 'Supprime tout les messages chargรฉ du channel ou la commande ร  รฉtรฉ รฉxรฉcutรฉ')
			.addField('b1channel', 'Crรฉer le channel pour recevoir mes news')
			.setFooter('BakusBot par benjimania74')
		message.delete();
		message.channel.send(helpEmbed);
		let logsChannel = message.guild.channels.find('name', 'logs');
		if(!logsChannel){
			return;
		}
		message.delete();
		logsChannel.send(`${message.author} a utilise la commande help dans ${message.channel.name}`);
}

module.exports.help = {
	name: "help"
};```
Its an exemple. Sorry it is in french @ember atlas
sick cloud
#

use codeblocks

fiery pivot
#

How use codeblolcs please

sick cloud
#

```
code
```

shy rose
#

```js
content/code
```

sick cloud
#

assuming everyone uses js

shy rose
#

the not code block above is js ^

fiery pivot
#

This is on js

#

I is an axemple for Boss

#

No probleme

maiden mauve
#

.setColor('#fffff')

#

5 digits intentional?

fiery pivot
#

Yes

#

This is ร  very good color

maiden mauve
#

is there something not working with your code?

fiery pivot
#

No it's perfect

maiden mauve
#

๐Ÿ˜„

#

usually people post code blocks that need help

fiery pivot
#

Except when there are logs but just on help

late hill
#

In python you can do this (see below), is there some way to do this in javascript? I'm currently using a for loop to do it.

woven zealot
#

'x'.repeat(5)

late hill
#

Thanks blobsweat

ember atlas
#

@fiery pivot I know how to code, but thanks

pulsar mango
#

hi, how can I delete other bot developers?

mossy vine
#

from your bot?

#

just remove their ids on the edit page

pulsar mango
#

I am not the one who added the bot on page.

sick cloud
#

you can't then, the owner has to

pulsar mango
#

He does not want to answer me..

sick cloud
#

then you can either
a. wait
b. contact a moderator

pulsar mango
#

I think it's better to i wait for a moderator

#

i have quarreled with other devs, so i do not expect them to respond..

spare goblet
#

i will dm you blobthumbsup

modest remnant
#

Hey I make bot and I want host it on heroku plese gave spirit

#

Please replay

#

Hello

slender thistle
#

I'd suggest better hosts like actual VPS

mossy vine
#

he just wants spirit

broken shale
#

Is it considered API abuse to change presence every 12s

warm marsh
#

I think 12s is the recommended but I could be wrong.

icy glen
#

Aight, my bot kept on getting denied for presence ratelimiting, would this fix it?

    const playingMessages = [
      "v!help for help",
      `${client.users.size} users | v!help`,
      `${client.guilds.size} servers | v!help`,
      `${config.version} | v!help`
    ]
    var counter = -1;
    setInterval(() => {
      counter++;
      client.user.setActivity(playingMessages[counter], { type: 0 });
      if (counter >= 3) counter = -1;
    }, 12000);```
#

Also I'm pretty sure there's a more efficient way to do this... but I'm not sure how

drowsy sentinel
#

Yes, 12 seconds is the absolute minimum. @icy glen

icy glen
#

Is there a more efficient way to do this? Like setting a counter to -1 and doing that kinda seems gimmicky

#

Also, am I safe to reapply?

quartz kindle
#

you could use array.findIndex()+1 || 0, but thats kinda weird too

#

also, your playing messages will never get updated, unless your bot restarts

icy glen
#

It updates

#

It updates correctly

quartz kindle
#

i mean, the users and guilds size

#

unless you redefine the array

icy glen
#

Ah

#

Hmm I'll put the array into the setInterval

cinder harbor
#

Ay

#

So I have this bot that shows it's assigning roles in the audit log but the user isn't getting it

earnest phoenix
#

Hey! Can you guys offer me a video to make a web dashboard for my discord bot?

cinder harbor
#

It's rare but it happens a noticeable amount of times. Anyone know how I can fix this

dusky inlet
#

why do you ask me to have 17k total players on the bot if I have 60k +

quartz kindle
#

client.users only stores cached users, not all users

dusky inlet
#

and how can I put it all in?

quartz kindle
#

loop over guilds and use guild.memberCount

dusky inlet
#

if you can do it to me

#

I did not understand you

earnest phoenix
#
const count = 0;
client.guilds.array().forEach(a => {
count = count + a.memberCount;
});
message.reply(โ€œAll of botโ€™s users: โ€œ + count);
``` @dusky inlet
twilit rapids
#

Don't spoonfeed

warm marsh
#

You could use reduce?

topaz fjord
#

^

warm marsh
#
client.guilds.array().reduce((prev, next) => prev + next.memberCount, 0);
topaz fjord
#

you could use reduce to avoid an unnecessary variable

warm marsh
#

I don't actually know if that would work, I'm kinda asking will it work?

topaz fjord
#

Does client.guilds have .reduce

warm marsh
#

idk, client.guilds.array() should?

earnest phoenix
#

yes it does if its .array()

dusky inlet
#

@earnest phoenix does not work

topaz fjord
#

It doea

quartz kindle
#

collections have reduce

warm marsh
#

Really?

topaz fjord
#

client.guilds.reduce is a thing

quartz kindle
#

so you can directly do client.guilds.reduce()

twilit rapids
#

@dusky inlet bet you copied his code without changing it to your variable names

warm marsh
#

Yeah saves doing .array()

topaz fjord
earnest phoenix
#

@dusky inlet maybe you copied it too quickly? I changed it because I got an error at the first.

#

try the edited one now?

dusky inlet
#

okay wait

#

again

topaz fjord
#

spoonfeed is not ok. Rule 7a and 7b smh

dusky inlet
#

(node:1054) UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.

earnest phoenix
#

oh change const to let

topaz fjord
#

You can't changes a consts variable

earnest phoenix
#

let or var they are like the same

sudden geyser
#

noop

earnest phoenix
#

iirc

topaz fjord
#

they are not the same

earnest phoenix
#

they works almost the same

quartz kindle
#

let is locked to the current scope and cannot be redeclared

earnest phoenix
#

i think so, i might be wrong

quartz kindle
#

var can be redeclared and can go beyond scopes

earnest phoenix
#

ok thanks for telling me

sudden geyser
#

wdym can't be redeclared?

viral spade
#

I have a strange thing, please help! (Discordjs, sharded but only 1 shard atm)
I am saving the channelid of a channel in that the user has written a certain command .
I do this so i can later write him back.
I did not do any differenciation between direct message channels and guild channels. I tought the channelid is unique and i can simply but.channels.get and channel.send without making a difference between those two.

With guild channels it works all fine, but with direct messages, it only sometimes cannot find the channel anymore and i get 'undefined' back. Can a direct message channel id change?

quartz kindle
#

let a = something
let a = somethingelse //error

earnest phoenix
#

i dont even got the time to read lol

topaz fjord
#

Then dint

#

Dont

quartz kindle
#

@viral spade when you receive a dm, your client will cache the channel id, but if you restart the bot or something, it will no longer be cached

viral spade
#

so i need the api?

#

fetch or smth?

quartz kindle
#

i dont know if you can fetch the dm channel by id

#

but you can fetch the user id and send it through the user.send method

#

which will recreate the channel in the cache

twilit rapids
#

Tim big brain

earnest phoenix
#

^

quartz kindle
#

lol wut

topaz fjord
#

But not all users will be cached tim

quartz kindle
#

i said fetch the user id lol

topaz fjord
dusky inlet
#

and how to do this now xD

viral spade
#

thanks tim!
and this is possible from any shard? also if the user is not in any guild from that shard?

quartz kindle
#

im not sure if you can fetch a user from another shard, try it out. if it doesnt work then do it via broadcasteval

topaz fjord
#

afaik it won't

#

But as time said you can use broadcast eval

dusky inlet
#

can anyone send me a code of this because I do not know how to do this?

topaz fjord
#

If you're using internal sharding it will work

viral spade
#

ok and then it also could be that i send the message twice, because the user could be in 2 shards because of 2 separate guilds. or not?

quartz kindle
#

@dusky inlet what part are you not understanding?

topaz fjord
#

@viral spade it could but in that case just go with the first guild available

dusky inlet
#

I did not understand how to make this membercount for all

quartz kindle
#

@dusky inlet how are you counting now?

#

show your original code

dusky inlet
#

with bot.users.size

viral spade
#

ok thanks. but thsi wont be useful when i wnat my bot to be horizontally scalable over different servers or?

dusky inlet
#

@quartz kindle

quartz kindle
#
bot.guilds.reduce((accumulator,value) => {accumulator += value.memberCount; return accumulator}, 0)```
dusky inlet
#

where to put it

quartz kindle
#

also, read this to understand

dusky inlet
#

oh thanks you so much it works

topaz fjord
#

you can do this tim```js
bot.guilds.reduce((accumulator,value) => accumulator + value.memberCount, 0)

#

same thing but afaik you don't need the return

dusky inlet
#

@quartz kindle thanks you so much you are the king

topaz fjord
#

but yours works as well

quartz kindle
#

ye true

#

i usually go for the brackets just in case

wintry jungle
#

Is there a limit to how many messages you can purge at a time with one command? Some people say yes and some say no.

earnest phoenix
#

how can i fix 2048 limit? On embed

mossy vine
#

its.. its a limit set by discord

#

you dont fix a limit that someone else set

viral spade
#
  1. When i want to direct message a user by userid, and not in direct response to a message from him, i will always have to use fetch to send it (as it might not be cached), true?

Assume i have many shards on multiple vps and many messages to different specific users that have to be sent (within rate limits). Assume i have those messages ready in a remote database [userid,message].

  1. How would i go about it? Grab all rows from the database with shard 0, fetch all users for those messages and send them with only this one shard?
quartz kindle
#

@wintry jungle i believe 100 messages is the limit

#

@earnest phoenix you have to split it into multiple embeds/fields

wintry jungle
#

@quartz kindle thanks

earnest phoenix
#

@quartz kindle, I'm now using array still

quartz kindle
#

@viral spade you'd have to find a way to avoid duplicated dms, so have a centralized script overseeing the process

viral spade
#

But my solution with using only 1 shard poses no threat to duplicate messages

quartz kindle
#

if you run shards in different machines, you cant use broadcastEval, you need to use something to communicate between shards, like an api

viral spade
#

?

quartz kindle
#

have you tried fetching a user from another shard? does it work? i havent tested that myself

#

btw d.js master has a way to fetch channels

viral spade
#

Well if user or channel doesnt really matter atm, i have both ids saved.
Yes tim it works, i successfully fetched a testuser, that has no guild in common with the bot.
1 So doing the whole sending from shard 0 should do the trick without duplicates y?
2 And there is no more efficient way of sending from the according shards themselves right? The user might not even be cached, if he is in a guild of the shard right?
3. Is there always a shard with id 0 and is it safe to put a if (bot.shard.id == 0) into my cronjob that fetches the remote database?

quartz kindle
#
  1. yup, it should
  2. sending can be done from any shard, it doesnt make a difference
  3. there should always be a shard 0 yes, shard 0 always holds all dm channels
viral spade
#

thanks a thousand times

quartz kindle
#

so you can even do someting like if(client.channels.get(userid)) { send } else { fetchuser; send }

#

in shard 0

viral spade
#

wait, u said shard 0 holds always all dm channels? but also only if any other shard had some business with it?

quartz kindle
#

received dms are always in shard 0

viral spade
#

oh i see

quartz kindle
#

other shards can send dms, and should in theory also hold channels for dms they themselves create

#

but if the channel is being received, it will always go to shard 0

#

also, im not sure, but other shards should not receive dms, even in channels they create themselves

viral spade
#

okey nice so once any user from any shard sent a dm and my bot didnt restart since then, it will simply be ablte to .get it without api on my shard 0?

#

oh and what is the rate limit, do you know? the discord doku page about it confuses me^^

quartz kindle
#

if the users reply to the dm yes, im not sure if the sending already does create it in shard 0, another thing you can test

#

rate limit should be the same everywhere, 5 per 5 per channel

viral spade
#

sorry, 5 what per 5 what?^^

quartz kindle
#

5 messages per 5 seconds per channel

viral spade
#

oh ok

#

oh i actually mean for fetchuser

quartz kindle
#

not sure about that

viral spade
#

okey another question to the topic.

cron.schedule('0 * * * * *', async function() {
  try {
    if (bot.shard.id == 0)
      await sendDm(bot);

    await sendGuild(bot);
  } catch (e) { console.log(e); }
});

Only shard 0 checks for ready dm messages. all shards check for ready guild channel messages. Does this make sense?
When i let all shards query the guild channel messages (at the same time) from my remote db, can i 100% expect that only 1 shard will successfully bot.channels.get() for each one message? Is every guild text channel only on 1 of my shards ever?

topaz fjord
#
  1. A guilds text channel can't be on two shards
#
  1. You can expect that only one shard with successfully complete the task if you give it the right id
#
  1. Yes that does make sense that shard 0 checks for dm messages since afaik it's the only shard that receives dms
vagrant bison
#

France is a good location for putting a bot?

languid dragon
#

i would recommend US servers

vagrant bison
#

In France, how much will my bot have more ping?

languid dragon
#

depends

vagrant bison
#

have more??

languid dragon
#

depends?

#

i mean, your bot is going to respond faster in servers that are closer to where it's located

#

i don't think that directly affects your ping, i think your ping only matters to it's closest discord datacenter?

vagrant bison
#

yes

quartz kindle
#

afaik, the discord gateway is in US east

#

those regions are only for voice servers

#

if your bot is hosted in france, it will have lower ping to the Central/Western Europe voice servers, but will have a higher ping to the discord gateway

earnest phoenix
#

Can someone from support help me?

opaque eagle
mossy vine
#

just put the image on the canvas?

opaque eagle
#

yeah but I need to overlay an image on top of another image and I need to figure out the dx and dy coordinates to put it at

#

This doesn't even require code

maiden mauve
#

trial and error with simple images

#

๐Ÿ˜„

#

use the halfway method

opaque eagle
#

Eh I'm not a huge fan of trial and error

earnest phoenix
#

Br

lucid iris
#

Any idea how to setup an index.ts file so tsc exports it as a module?
Or do I need to write it by hand?
I'm trying to find out how but the results I find have little to do with what I'm trying to find.

#

What I'm trying to achieve is being able to use
import { Something } from 'module-name';

mossy vine
#

use the export statement

lucid iris
#

In what fashion?
export { Something } from './module-name';
simply outputs the same exact text to the *.d.ts file

mossy vine
#

export Something

lucid iris
#

Declaration or statement expected.

storm lily
#

When I go to advertise it, it says error.

#

Can I get any help with that

quartz kindle
#

what error?

lucid iris
opaque eagle
#

@lucid iris Are you trying to add typings to your JavaScript project or work on a TypeScript project?

maiden mauve
#

anyone know if you have to code file paths different when being run on Heroku?

#

I added my project but it's saying cannot find module "./folder/file.js"

opaque eagle
#

what's that file exactly

#

and can u give me the full path of both a) "./folder/file.js" and b) the file ur requiring "./folder/file.js", without censoring anything.

#

@maiden mauve

maiden mauve
#

one sec let me pull it all up

#
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module './commands\common.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/app/index.js:9:16)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
mossy vine
#

does the file exist

#

also maybe you shouldnt use relative paths

inner jewel
#

use / instead of \

maiden mauve
#
const c =                     require('./commands\\common.js');
amber fractal
#

probably not considering there's a backslash

maiden mauve
#

is the actual code in file

#

which works fine on my PC

inner jewel
#

because windows uses \ for paths

#

other systems use /

#

windows also accepts / so just use / everywhere

maiden mauve
#

me no like other systems

inner jewel
#

too bad

mossy vine
#

heroku uses other systems tho

maiden mauve
#

ty tho I'll test it out

#

im not sure why I had it written like that in the first place

opaque eagle
#

Use path

#
const path = require("path");
require(path.join(__dirname, "commands", "common.js")) // you can chain as much as you want```
#

When you do it this way path will join all those using the proper type of slash for the OS it's running in

maiden mauve
#

fancy

inner jewel
#

you can just use /

#

windows apis accept that and treat as a \

maiden mauve
#

yeah, I'm sure it solved that problem

#

I'm back to dealing with newbie mistakes on building/pushing to server

tight heath
#

Path is always a safe option though.

maiden mauve
#

omg

#

i did it

#

my bot is on a server and working

quartz kindle
#

its probably good to use if you're packaging your app for multiplatform, but if all you're doing is running it on a server, its kinda un-needed lol

maiden mauve
#

I have climbed the mountain of Git and posted my flag

#

๐Ÿ‘

opaque eagle
#

lol

valid frigate
#

ok yo how do i get a Message class based on an id

#

like message.get(id) or smth

mossy vine
#

read docs

maiden mauve
#
2019-07-22T22:09:21.155357+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-07-22T22:09:25.717940+00:00 app[web.1]: Loaf Bot MONGOOSE POWERED, ONLINE!
2019-07-22T22:10:21.471253+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-22T22:10:21.383196+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-07-22T22:10:21.383458+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-07-22T22:10:21.449657+00:00 heroku[web.1]: Process exited with status 137
#

short lived victory

#

it handled 1 comamnd and crashed

valid frigate
#

cyber pls

#

ok ill read the docs

inner jewel
#

pretty self explanatory

#

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

maiden mauve
#

@valid frigate message.author is 90% of your answer

#

i think if thats what your looking for

valid frigate
#

message.author?

inner jewel
#

if you're using a web dyno, you need to actually have a web server

valid frigate
#

no it's the message's id not the author's id

maiden mauve
#

there's another option right?

#

I had changed that in compiling it all somewhere

inner jewel
#

you want message object from message id?

maiden mauve
#

if you have the id of a message wouldn't that mean its assigned to a variable somehow?

inner jewel
#

no

valid frigate
#

uh yeah

inner jewel
#

the id could come from anywhere

valid frigate
#

actually not sure if that works or not

inner jewel
#

eg a db

maiden mauve
#

ah true

inner jewel
#

if you have a message and channel id, you can get the message

valid frigate
#

yeah i'm planning to store the message id in a db

#

& channel id

#

what i'm doing right now is getting the channel

inner jewel
#

the channel object should have a function for getting a message by id

valid frigate
#

oh yeah i see

#

i wasnt type casting Channel to TextChannel, so the function wasnt showing up

earnest phoenix
#

you can do channel.fetchMessage(โ€œidโ€)

robust lantern
#

what is a readme?

opaque eagle
#

Tells others what your project is about @robust lantern

mossy vine
#

@robust lantern a document that has information about the project

valid frigate
#

channel.fetchMessage isn't a function on master?

tight heath
#

.messages.fetch

#

On master

valid frigate
#

yeah thats it

#

i'm using messages.get, dont know if that will make a difference

tight heath
#

Or .get if you're sure you have it cached

opaque eagle
#

@maiden mauve Save this text to a file called Procfile and push it to heroku: worker: npm start

valid frigate
#

yeah it's cached

tight heath
#

what if you restart the bot

valid frigate
#

oh shit wait no it isnt lmao

maiden mauve
#

@opaque eagle I changed it from web to worker node index.js

opaque eagle
#

gr8

valid frigate
#

mfw i still dont know the difference between get and fetch

tight heath
#

@valid frigate fetch is async

#

So uh await it

#

But

inner jewel
#

i'd assume get is only cached and fetch requests if not in cache

maiden mauve
#

wait maybe I screwed that up

tight heath
#

Fetch gets the message from api call if it's not cached

#

Either way it's still async

valid frigate
#

ah

#

a lot of functions are async tho

maiden mauve
#

lets see if this survives ๐Ÿ˜„

tight heath
#

yes, don't forget to await or .then

inner jewel
#

anything that needs to go back to the event loop to work is async

opaque eagle
#

If your file isn't named index.js then it won't survive... if it is, then it will

inner jewel
#

read: io, (properly implemented) delays, etc

tight heath
#

io works sync

#

in js

inner jewel
#

there are sync variants, but in general you'll want to do it async

maiden mauve
#

thanks for all the help

tight heath
#

yeah

#

I use it promisified

maiden mauve
#

Git is a headache when you don't understand the language they are using

opaque eagle
#

wdym

tight heath
#

Git is chill

inner jewel
#

sync io is the worst thing you can do in node besides one time things like require()

maiden mauve
#

push commit stage all meant nothing to me a week ago

valid frigate
#

i thought too many async calls block the event loop

opaque eagle
#

Git is legit the easiest VCS everr

valid frigate
#

like

#

well most of the time my async functions are db queries

inner jewel
#

they won't block the loop

valid frigate
#

im dumb then

#

lmao

#

thanks for the help yall

maiden mauve
#

yeah, as I use Git more it's doing a lot for minimal input

#

just every "tool" has its own language

#

@opaque eagle npm start would require another command line to point to your main file right?

opaque eagle
#

yeah you'd have to specify it in package.json

#

I thought you'd already have done that

maiden mauve
#

"scripts": {
"start": "index.js"
},

opaque eagle
#

nooo

maiden mauve
#

{
"name": "LoafBot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "index.js"
},

"dependencies": {
    "discord.js": "^11.5.1",
    "mongodb": "^3.2.7",
    "mongoose": "^5.6.2"
}

}

opaque eagle
#

"start": "node index.js"

maiden mauve
#

lol

#

im connecting dots after 15 failed attempts at getting this up

opaque eagle
#

it runs the exact command u specify... node index.js is a command, but plain index.js isn't

maiden mauve
#

right

#

what's the point of "main": "index.js",

#

then?

topaz fjord
#

to specify the main file

#

it allows you to do node .

#

afaik

maiden mauve
#

hm

#

oh well it works thanks for explaining the process more

mossy vine
#

maybe we should face the fact that wouldnt be profitable at all

maiden mauve
#

lol sell something free

#

to accommodate peoples laziness

#

I have no idea what the data usage of different bots is

#

my biggest issue was having to compress my bot folder and physically change the launch point

#

having 3 different PCs host it

#

web became a necessity

#

even though the javascript itself is like 100 kb it's amazing how annoying that gets

opaque eagle
#

That's what heroku does... cram a bunch of processes in the same physical server

abstract crow
#

Does anyone know how I can make modules for my Discord.JS commands?

topaz fjord
#

Wut

warm marsh
#

Modular commands I think.

#

Like external commands?

topaz fjord
#

@abstract crow can you elaborate

abstract crow
#

Like Dillon said, modular commands. I have a command handler, just not folders for each type of command

#

So in my commands folder I have like 20 files instead of folders

topaz fjord
#

oh

warm marsh
#

export each file inside external folder

#

then make a loader.

gritty bolt
#

is there a way to make each word or phrase between a space into a varible?

#

like each argument, without having to separately slice them all?

#

since I dont think im doing it right

#

currently im trying to use 'args' in my command handler, but can someone point me the right way as in how to use it?

maiden mauve
#
2019-07-22T22:19:25.071745+00:00 app[worker.1]: Loaf Bot MONGOOSE POWERED, ONLINE!
2019-07-23T00:00:01.007010+00:00 app[worker.1]: DAILY RESET!
#

there's a special love for programming when all you can do is laugh

#

midnight zulu on server

sick cloud
#

@abstract crow
instead of:
/folder/
and scan folder then add commands

do this:
/folder/command group/
scan folder, for each folder in folder, scan command group, add commands

#

it's just a bit more logic

opaque eagle
#

What's koa and is it any good?

abstract crow
#

So should I do a forEach folder and forEach command in that folder?

sick cloud
#

@opaque eagle koa is a new kind of express, same devs but more modular, give it a go

topaz fjord
#

scan the folder for it's directories

#

Then go through each directory and add the commands in those

#

@abstract crow

#

so basically a foreach in a foreach

#

koa is the better expre

#

express

#

Written by the same devs using all the knowledge they've gained from writing express

sick cloud
#

scan /commands
for each folder in commands
scan /foldername
for each command in foldername
require /commands/foldername/commandfile
done

trail dagger
#

One quick question, how to i get shard status like ping and how many servers/users with that shard (shard_id) (discord.py)
@ me

opaque eagle
gritty bolt
#

can anyone answer my question?

sick cloud
#

i make all my requests async

#

@gritty bolt just wait and someone will

amber fractal
#

I do everything as async

#

Is there a downside?

spare goblet
#

@gritty bolt I don't understand your question, wdym a word or space between each word into a variable

pale marsh
#

I think he basically means splitting a string?

gritty bolt
#

I just figured it out

#

yes

spare goblet
#

Oh big brain

#

Just use split then ig
Glad you figured it out tho

gritty bolt
#

i can use args[numberhere]

#

which id already been trying to do but not right

spare goblet
#

Well yeah you can kellyhmm

gritty bolt
#

but i fixed it

#

thanks

spare goblet
#

Remember arrays start with 0

gritty bolt
#

yeah, the first argument is 0, then 1, 2, 3, etc

valid frigate
#

noob question hours

#

how do i literally restart one shard

#

i cant access the shard object from anywhere mmulu

earnest phoenix
#

w h i c h l i b r a r y

valid frigate
#

yknow which one

#

djs

pale marsh
#

Make it publicly accessible then?

#

Idk how that can be done in JS but I'm pretty sure it's possible

valid frigate
#

sharded clients dont have access to the shardingmanager iirc

#

so whenever i try to get it via the ShardingManager it will return undefined

wanton nova
#

whats the ratelimit for changing your profile picture via the website?

earnest phoenix
#

it isn't defined

#

ratelimits are dynamic

wanton nova
#

oh

maiden mauve
#

is there a standard strategy to mask a login for web front end?

#

ie, mongo server connect?

#

like a file no user can access as a require?

earnest phoenix
#

@slender thistle is the code right?

let UPembed = new Discord.RichEmbed()
      .setAuthor("SUBIU DE LEVEL!!")
      .setDescription(` <@${user.id}> subiu de nรญvel para Level:   **` + level + "**!")
      .setColor([0, 195, 255]);
      if(message.guild.id !== '264445053596991498') {
      message.channel.send(UPembed);
      }
#

?

#

i'm brazilian don't worry about embed

slender thistle
#

Why are you assuming I know discord.js ๐Ÿ‘€

tight heath
#

why would you use template strings AND concatenation

#

I have physical pain

maiden mauve
#

lol

#

I feel like the definition should be inside of the conditional rather than vice versa

#

but it appears to be correct-ish

#
var statEmbed = new Discord.RichEmbed()
.setColor('#0099ff')
.setTitle(playerStr)
.addField('Level',levelStr,true)
.addField('Attack',atkStr,true)
.addField('Defense',defStr,true)
.addField('EXP',`${target.exp}/${target.nextlevel} ${expStr}`,true)
.addField('Perk', perkStr, true)
.setFooter(`...`);

message.channel.send(statEmbed).catch((e) => {
     if(e.code === "50013")
           c.reply(message,"Bot does not have permissions to embed links!");

     console.log(e); 
} );
tight heath
#

var

maiden mauve
#

lol I'm trying to make it cleaner

earnest phoenix
#

any of yall have original bot ideas? like i have a screenshare bot and discord bot.

maiden mauve
#

just an example of a working embed

tight heath
#

@maiden mauve to make it cleaner:
var => const

#

and add indentation before the .addField, .setTitle, etc

hollow saddle
#

Yeah and donโ€™t use backticks for regular strings like you do with .setFooter

tight heath
#

oh also

#

might wanna put a space after a comma

#

improves readability greatly

#

my version:

const embed = new Discord.RichEmbed()
    .setColor('#0099ff')
    .setTitle(playerStr)
    .addField('Level', levelStr, true)
    .addField('Attack', atkStr, true)
    .addField('Defense', defStr, true)
    .addField('EXP',`${target.exp}/${target.nextlevel} ${expStr}`, true)
    .addField('Perk', perkStr, true)
    .setFooter('...');

message.channel.send({embed}).catch((e) => {
    e.code === "50013"
        ? message.reply("Bot does not have permissions to embed links!")
        : console.log(e); 
});
maiden mauve
#

๐Ÿ˜‰

#

I never really questioned the syntax

#

but technically it's just an additive property with all the periods right?

#

line-by-line is just so it doesn't look like a dumpster fire

tight heath
#

chained function calls

#

the deeper you go the more you indent

#

since all of those add to the embed object, they're on level indented

maiden mauve
#

RichEmbed().setColor().setTitle().addField() etc

tight heath
#

if something would add to the field object, you'd indent it on level 2

#

etc.

maiden mauve
#

it's the same with mongo query functions?

tight heath
#

yes

maiden mauve
#

ah

#

it's a bit different but it makes sense

#

for example

#
    players.find( {level: {$gte: rangeLo, $lte: rangeHi}, serverId: message.guild.id } )
        .sort( { level: -1} )
        .limit(lim)
        .exec (function (err,playerArray) {
            ...
#

would be the same idea?

tight heath
#

yes

#

except the fact your spacing is giving me an aneurysm mmlul

scenic vapor
#

^

tight heath
#
 players
    .find({ level: { $gte: rangeLo, $lte: rangeHi }, serverId: message.guild.id })
    .sort({ level: -1 })
    .limit(lim)
    .exec(function(err, playerArray) { ... });
#

the proper way

#

btw if you wanna have a fancy pants style guide

#

have a look at eslint & my config :p

maiden mauve
#

hahaha

#

I have a very unrefined project in general, any spacing was just done quickly to make sure braces lined up

tight heath
#

correctly spaced ([{}]) make for much more readable code

#

especially with stuff like nested arrays

maiden mauve
#

it does look prettier, can't debate that

tight heath
#

:p

#

but yeah, with eslint you can greatly automate your code looking fancy

#

if you like my style you can copy the eslint config

maiden mauve
#

I sorta skipped over all the linting recommendations when I started out

#

sublimetext is 90% with js

#

what exactly will it do?

#

just scan over spacing and braces?

tight heath
#

a lot more

#

also variable naming

#

destructuring

#

lots of that

#

in the end you'll get cleancodeโ„ข

maiden mauve
#

lol

tight heath
#

note the JSDoc is not mine and also not included in the eslint-config

maiden mauve
#

not quite sure what im looking at with the example

#

seems to be pretty standard spaced

tight heath
#

that's the point

#

and dw about the actual code

#

it also checks stuff like destructuring, like in line 2

#

or using !== instead of !=, like in line 33

maiden mauve
#

its all automatic?

tight heath
#

yes

maiden mauve
#

that's kinda cool

tight heath
#

destructuring: 256

#

!= => !==: 57

#

spacing: 147, 149, 154, 159, ...

inner jewel
#

what if i want == null/!= null

tight heath
#

then that works

#

because eslint is smart

#

:)

maiden mauve
#

btw, while I have a local enthusiast

#

I don't want to persue this

#

the double error checking in every case

#

but you can probably get the idea of whats going on

tight heath
maiden mauve
#

trying to brainstorm a better way to organize that

tight heath
#

make a map of spell => minimum required level

#

check if user has said level else reply with error

inner jewel
#
spells = {
    name: { levelNeeded: 123, dostuff: (args) => { ... } }
}

spell = spells[name]
if(!spell) return
if(level < spell.levelNeeded) {
    reply()
    return
}
spell.dostuff(...)```
tight heath
#

or object

#

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

maiden mauve
#

thank you for derailing my terrible experiment

#

๐Ÿ˜‰

#

a local object โœ…

tight heath
#

if you see lots of duplicated code, you're doing something wrong

#

:p

maiden mauve
#

yeah, thats the feeling i got

tight heath
#

also pls don't use var

maiden mauve
#

lol tbh I have read let,var, const

#

but they seem to virtually make no difference in output

#

obviously let is local

inner jewel
#

var is function scoped and can be reassigned
let is lexically scoped and can be reassigned
const is lexically scoped and can't be reassigned

tight heath
#

var is global actually

inner jewel
#

nope

tight heath
#

as in file-scoped

inner jewel
#

it's function scoped

maiden mauve
#

var will produce "undefined"

#

vs no value

#

if used wrong

inner jewel
tight heath
#

oh wow

#

either way it's ugly

maiden mauve
#

my entire project has no "let"

tight heath
#

const/let > var

maiden mauve
#

it just simply got to the point where theres too many vars

tight heath
maiden mauve
#

look at how beautiful they are

inner jewel
#

aka variables used outside the scope they're declared

maiden mauve
#

I just had a misconception starting out

#

that "const" was more of a global definition

#

and "var" was the go-to tool for multipurpose

#

I'd say 80% of my variable definitions are readability and not manipulated

#

so they should all be consts?

inner jewel
#

if you don't need to reassign, yes

steel cloak
#

const values cannot be reassign (const - constant). otherwise use let

maiden mauve
#

is there really a functional scope for "var" at all?

tight heath
#

what

maiden mauve
#

well, I guess the need to manipulate it outside of the local scope

tight heath
#

which never happens mmLol

maiden mauve
#

it seems more forced that you would make it do that

steel cloak
#

what are some good databases compatible with js (other then mongodb)

scenic vapor
#

postgresql probably

tight heath
#

mongodb and also mongodb

scenic vapor
#

what ravy said

steel cloak
#

oh okay good lmao,, thanks

maiden mauve
#

mongodb is slam dunk ez

scenic vapor
#

mongodb gives me nightmares

steel cloak
#

^^^

maiden mauve
#

really?

tight heath
#

why tho

#

it's super chill

maiden mauve
#

with await and mongoose everything is so simple

tight heath
#

imagine using mongoose

scenic vapor
#

but what if you wanna access a certain collection without using the model

maiden mauve
#

๐Ÿ˜ญ

scenic vapor
#

haha who would ever use mongoose panicking

maiden mauve
#

I was learning a lot at once when i started with mongo

tight heath
#

I wanna make a mongo wrapper called MongoBongo just for the lulz

maiden mauve
#

and mongoose was a tool that put it all together better

steel cloak
#

wait if you don't use mongoose then how else

tight heath
#

using the official wrapper

#

I don't like models

scenic vapor
#

Mr Ravy sir how can I access a part of a collection without linking the schema

tight heath
#

since the point of mongo is kinda not to have models

scenic vapor
#

wokay nvm

tight heath
#

Mr Minty I have no clue

scenic vapor
#

Thanms

#

what's the official wrapper called

#

that's a dumb question I can figure that ouy

tight heath
#

mongodb iirc

scenic vapor
#

Tough name

#

Doesn't relate much huh

steel cloak
#

wait is it better then mongoose?

tight heath
#

mongoose is a wrapper around mongodb

#

iirc

#

yuppers

#

but basically mongodb is the barebones functionality for interacting with mongo

#

while mongoose adds models

steel cloak
#

oh then I'm definitely switching to that. when I did research for mongodb and nodejs I thought you had to use mongoose. obviously I didn't do enough research

#

wait then what about for caching? or would you have example redis alongside with mongodb

scenic vapor
#

Yeah I thought there was only mongoose to lol

#

too*