#development
1 messages ยท Page 659 of 1
It will be like mee6 but there's no premium
Rip
Nice random ping
@twilit rapids are you a bot developer
Give me $100 and I will code every bot you want
lmao timo
@topaz fjord can you do it for me
stop begging
No I'm busy
like how I said, no one will spoon feed you
you need to learn node.js
or a coding language
No one is gonna do everything for you. If you need help with code, ask the question and someone will get to you
then make your own bot
I have to finish my own bot /tableflip and I can't figure out why mongo is being gay rn
hecking mobile
I straight up ditched mongo
Mongo isn't gay, your code is.
Change my mind.
I went from mongodb to mongoose to mongodb
I'm not used to using it in java
Ok

mongoose uses mongodb lmao
no I know, I just meant my driver
oh
@opaque eagle discord.js
speaking of databases
My deal still stands ssundees
require('mongodb') vs require('mongoose')
Lavalink is dependent on database
wait really
Yes
I have no money
@oblique token learn to code
oh I was looking at the nodes part
F
You just need the jar file and a client for it
in the documentation const nodes = [ { host: "localhost", port: 2333, password: "youshallnotpass" } ];
I almost got ptsd
@twilit rapids only 100 bucks for a mee6-like? thats hella cheap
I don't even Code really hard for me
uhhh what client btw
I mean, it's not that hard
right that's what I was saying
I bet that their open source

That viciou
Map your client's guilds by its channels and flatten the array @earnest phoenix
that's like a month of solid work for mee6 from scratch
I'm really questioning why I don't look at Github repos often. Thanks Turtle
But yeah. If you give me $100 I will code you a bot like mee6
paid up front, no time wasters ๐
Oh yeah I'm using the discord.js-lavalink I guess it's good then @topaz fjord ?
yes
Mee6 super gay
Since I'm using javascript I guess I don't need to make jars...?
You can download the lavalink jar
imo a job like that would go for at least 500 bucks
damn I thought I won't need the jar since I'm using js
What's a groovy
okay if it is then I would be the co-owner ๐
No
Yes
Actually no
Ok #memes-and-media yeet
I'm allergic to Docker Images so I guess I don't have to touch it while using lavalink?
Same and in theory not
:+1:
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
@swift topaz don't use Lavalink then
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);```
Groovy doesn't either and we have multiple servers working fine
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
And my js bot which uses Lavaplayer works without it too
We use our sharding manager to manage Lavaplayer instances
I was just looking for alternate solutions since I'm having problems with ytdl-core
@twin kestrel did you wait for 15 seconds? does the bot appear online in both servers, or is it offline in one?
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)
As? I did not understand, sorry
client.channels.get('589393059545088001').send(crash)```
TypeError: Cannot read property 'send' of undefined
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
Okay
Then ... how do I fix the error that causes the bot not to recognize the commands (well, rather than not responding)
its probably not responding because the channel not found caused it to crash
So, how can I define it so that it sends the message?
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
A guide made by the community of discord.js for its users.
I fixed that, rebooted the bot and now does not respond to any of the servers
@oblique token ....... fuckin ping me again for no reason and I swear
And it does not give any error in the console
how did you fix it?
if(client.channels.get('589393059545088001')) {
client.channels.get('589393059545088001').send(crash)
}```
๐
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
thats normal, because it can only count the servers in the shard
Why not get server then channel?
if you want to do things across all shards, you need to use broadcasteval or fetchclientvalues
Fetch will be better
why is this 0?
@violet jetty that has nothing to do with the issue, we are talking about sharding
Okie
@vague chasm Day() returns the day of the week
sunday is 0, the first day of the week in your system
So quick question, Does any library/language have support for listening to someone's voice via voice channel?
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.
@opaque eagle flatten?
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
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
@west spoke fucking
@earnest phoenix Yes, flatten...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat
uh
If I look up I see the ceiling
isn't that against the rules?
If you reposted your question that would be helpful
Hmm - 44 minutes ago
I think he's asking for help with smth
oh that
uuuuuuuuuuuuuuuuuuuuuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
i mean swearing isnt against the rules
lol did he legit ping a mod for swearing
That's why #265156361791209475 was made
Why make Luca log deleted/edited messages when thousands of bots do it in #265156361791209475
@oblique token why did you randomly ping neko 
Wanted someone to build em mee6 but with the premium features ๐
oh
that was cute
@gilded plank mute @oblique token dbl is not a place for free developer labor | 6h
๐ค Muted Xxssundeespoop#7347 (@oblique token)
Well, clearly that was the brains behind the whole operation. Who else could come up with such a unique bot idea?
cant find this in master but how do i get the ping of the client
apparently client.ping isnt a thing anymore
Does anyone know how to use pm2
yo? guyz my bot dont wanna go online no more
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)
@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
oh ok
But it's not the only event / command that uses that variable
wdym
I have a command to report bugs and do exactly the same as in the guildCreate event
Ohh so the report guild is on a different shard from your support guild, so it can't send the message?
I'd use webhooks instead
I do not know how to handle webhooks
And get rid of the pain of searching for the guilds
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 */);
I'll try
So I asked this question the other day and got ignore but how to get <Guild>.iconURL in discord.js@12.0.0-dev
nvm found out.
Yeah bit odd. Thanks anyway.
Do you need to supply the param { format, size }
or not?
Ok, Another quick question if someone's pfp/guild icon is a gif will it use gif or png/jpg?
gif
Thanks!
is it acceptable to use
if(condition) {
//code
return
}
if(otherCondition) {
//otherCode
return
}```
instead of
```js
if(condition) {
//code
} else if(otherCondition) {
//otherCode
}```
that depends on what you want the code to do exactly
the first one can have both execute at the same time
it cant if it returns tho?
unlike the aecond one, where only one of the options will be executed
yeah context also changes that
it depends on what you want it to do and the code that gets run
if it has return both should work
@mossy vine preference is the only rule for that
sounds good to me
former is more clean imo
just a question, isn't "else if" elif?
not in javascript
thanks for your answer
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
thanks!
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?
never defined upembed?
UPembed sounds like it was never defined
the UPembed is set yes, it is an embed that the person has increased level

just put the part that I'm in doubt if it's right
@loud salmon
How to unmute your bot?
(my bot)
@earnest phoenix fix the issue, then contact a mod
ok
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
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
do you want to know the original message or who deleted it?
Who deleted it
yeah, you need to grab it from audit logs
Ok , thx for help @earnest phoenix and @mossy vine
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
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
is it because I need to do node . then pm2 start bot.js
you dont want to start it with node and pm2
then you have 2 instances
which doesnt make sense
I use forever, are there any advantages to pm2

I've honestly never used it, I've been using forever for like 6 years so if there's a better option lmao
lol I love that there's a pm2 conversation happening right now as I research for the article on pm2 im about to write
how have u not discovered pm2
bruh
Moos
yessir
I'm a front end dev, I don't really fire up node processes much ๐คท
๐คท

Am bb dev
lol writing an article on pm2 rn https://moosecorp.xyz/i/grieving-bone-3435.png
YO
Speaking of
anybody want to help me come up with all the uses for pm2
ye
you can write shit code because it doesnt matter if it crashes
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);```
@zealous veldt built in load balance
ah yes
I make a webhook fake message
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);```
๐ค i dont see iut
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
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?
make sure the bot can send messages, if it cant return
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}
}});```
the field part of an embed is an array of objects with name and value properties
.addField('Prefix' ,'puff.');
so I should make it field.name and field.value respectively inside that constructor?
oh I get it
there's a fields property in the embed that is an array
the embed visualizer helps
!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
@ember atlas delete the !e on the start of your programe
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
use codeblocks
How use codeblolcs please
```
code
```
```js
content/code
```
assuming everyone uses js
the not code block above is js ^
is there something not working with your code?
No it's perfect
Except when there are logs but just on help
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.
'x'.repeat(5)
Thanks 
@fiery pivot I know how to code, but thanks
hi, how can I delete other bot developers?
I am not the one who added the bot on page.
you can't then, the owner has to
He does not want to answer me..
then you can either
a. wait
b. contact a moderator
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..
i will dm you 
Hey I make bot and I want host it on heroku plese gave spirit
Please replay
Hello
I'd suggest better hosts like actual VPS
he just wants spirit
Is it considered API abuse to change presence every 12s
I think 12s is the recommended but I could be wrong.
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
Yes, 12 seconds is the absolute minimum. @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?
you could use array.findIndex()+1 || 0, but thats kinda weird too
also, your playing messages will never get updated, unless your bot restarts
Ay
So I have this bot that shows it's assigning roles in the audit log but the user isn't getting it
Hey! Can you guys offer me a video to make a web dashboard for my discord bot?
It's rare but it happens a noticeable amount of times. Anyone know how I can fix this
client.users only stores cached users, not all users
and how can I put it all in?
loop over guilds and use guild.memberCount
const count = 0;
client.guilds.array().forEach(a => {
count = count + a.memberCount;
});
message.reply(โAll of botโs users: โ + count);
``` @dusky inlet
Don't spoonfeed
You could use reduce?
^
client.guilds.array().reduce((prev, next) => prev + next.memberCount, 0);
you could use reduce to avoid an unnecessary variable
I don't actually know if that would work, I'm kinda asking will it work?
Does client.guilds have .reduce
idk, client.guilds.array() should?
yes it does if its .array()
@earnest phoenix does not work
It doea
collections have reduce
Really?
client.guilds.reduce is a thing
so you can directly do client.guilds.reduce()
@dusky inlet bet you copied his code without changing it to your variable names
Yeah saves doing .array()
@dusky inlet maybe you copied it too quickly? I changed it because I got an error at the first.
try the edited one now?
spoonfeed is not ok. Rule 7a and 7b smh
(node:1054) UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.
oh change const to let
You can't changes a consts variable
let or var they are like the same
noop
iirc
they are not the same
they works almost the same
let is locked to the current scope and cannot be redeclared
i think so, i might be wrong
var can be redeclared and can go beyond scopes
ok thanks for telling me
wdym can't be redeclared?
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?
let a = something
let a = somethingelse //error
i dont even got the time to read lol
@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
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
Tim big brain
^
lol wut
But not all users will be cached tim
i said fetch the user id lol

and how to do this now xD
thanks tim!
and this is possible from any shard? also if the user is not in any guild from that shard?
im not sure if you can fetch a user from another shard, try it out. if it doesnt work then do it via broadcasteval
can anyone send me a code of this because I do not know how to do this?
If you're using internal sharding it will work
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?
@dusky inlet what part are you not understanding?
@viral spade it could but in that case just go with the first guild available
I did not understand how to make this membercount for all
with bot.users.size
ok thanks. but thsi wont be useful when i wnat my bot to be horizontally scalable over different servers or?
bot.guilds.reduce((accumulator,value) => {accumulator += value.memberCount; return accumulator}, 0)```
where to put it
also, read this to understand
oh thanks you so much it works
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
@quartz kindle thanks you so much you are the king
but yours works as well
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.
how can i fix 2048 limit? On embed
- 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].
- 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?
@wintry jungle i believe 100 messages is the limit
@earnest phoenix you have to split it into multiple embeds/fields
@quartz kindle thanks
@quartz kindle, I'm now using array still
@viral spade you'd have to find a way to avoid duplicated dms, so have a centralized script overseeing the process
But my solution with using only 1 shard poses no threat to duplicate messages
if you run shards in different machines, you cant use broadcastEval, you need to use something to communicate between shards, like an api
?
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
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?
- yup, it should
- sending can be done from any shard, it doesnt make a difference
- there should always be a shard 0 yes, shard 0 always holds all dm channels
thanks a thousand times
so you can even do someting like if(client.channels.get(userid)) { send } else { fetchuser; send }
in shard 0
wait, u said shard 0 holds always all dm channels? but also only if any other shard had some business with it?
received dms are always in shard 0
oh i see
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
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^^
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
sorry, 5 what per 5 what?^^
5 messages per 5 seconds per channel
not sure about that
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?
- A guilds text channel can't be on two shards
- You can expect that only one shard with successfully complete the task if you give it the right id
- Yes that does make sense that shard 0 checks for dm messages since afaik it's the only shard that receives dms
France is a good location for putting a bot?
i would recommend US servers
In France, how much will my bot have more ping?
depends
have more??
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?
yes
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
Can someone from support help me?
Is there a way to put an image on top of a grid like this to figure out x/y coordinates?
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage
just put the image on the canvas?
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
I want to know if there's a program where I can see pictures in a grid like that
Eh I'm not a huge fan of trial and error
Br
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';
use the export statement
In what fashion?
export { Something } from './module-name';
simply outputs the same exact text to the *.d.ts file
export Something
Declaration or statement expected.
what error?
If anyone cares, I fixed it by adding some properties on package.json (see step 4 here https://www.tsmean.com/articles/how-to-write-a-typescript-library/)
@lucid iris Are you trying to add typings to your JavaScript project or work on a TypeScript project?
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"
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
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)
use / instead of \
const c = require('./commands\\common.js');
probably not considering there's a backslash
because windows uses \ for paths
other systems use /
windows also accepts / so just use / everywhere
too bad
heroku uses other systems tho
ty tho I'll test it out
im not sure why I had it written like that in the first place
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
fancy
yeah, I'm sure it solved that problem
I'm back to dealing with newbie mistakes on building/pushing to server
Path is always a safe option though.
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
lol
read docs
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
pretty self explanatory
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
@valid frigate message.author is 90% of your answer
i think if thats what your looking for
message.author?
if you're using a web dyno, you need to actually have a web server
no it's the message's id not the author's id
you want message object from message id?
if you have the id of a message wouldn't that mean its assigned to a variable somehow?
no
uh yeah
the id could come from anywhere
actually not sure if that works or not
eg a db
ah true
if you have a message and channel id, you can get the message
yeah i'm planning to store the message id in a db
& channel id
what i'm doing right now is getting the channel
the channel object should have a function for getting a message by id
oh yeah i see
i wasnt type casting Channel to TextChannel, so the function wasnt showing up
you can do channel.fetchMessage(โidโ)
what is a readme?
Tells others what your project is about @robust lantern
@robust lantern a document that has information about the project
channel.fetchMessage isn't a function on master?
Or .get if you're sure you have it cached
@maiden mauve Save this text to a file called Procfile and push it to heroku: worker: npm start
yeah it's cached
what if you restart the bot
oh shit wait no it isnt lmao
@opaque eagle I changed it from web to worker node index.js
gr8
mfw i still dont know the difference between get and fetch
i'd assume get is only cached and fetch requests if not in cache
wait maybe I screwed that up
yes, don't forget to await or .then
anything that needs to go back to the event loop to work is async
If your file isn't named index.js then it won't survive... if it is, then it will
read: io, (properly implemented) delays, etc
there are sync variants, but in general you'll want to do it async
thanks for all the help
Git is a headache when you don't understand the language they are using
wdym
Git is chill
sync io is the worst thing you can do in node besides one time things like require()
push commit stage all meant nothing to me a week ago
i thought too many async calls block the event loop
Git is legit the easiest VCS everr
they won't block the loop
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?
yeah you'd have to specify it in package.json
I thought you'd already have done that
"scripts": {
"start": "index.js"
},
nooo
{
"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"
}
}
"start": "node index.js"
it runs the exact command u specify... node index.js is a command, but plain index.js isn't
maybe we should face the fact that wouldnt be profitable at all
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
That's what heroku does... cram a bunch of processes in the same physical server
Does anyone know how I can make modules for my Discord.JS commands?
Wut
@abstract crow can you elaborate
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
oh
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?
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
@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
What's koa and is it any good?
So should I do a forEach folder and forEach command in that folder?
@opaque eagle koa is a new kind of express, same devs but more modular, give it a go
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
scan /commands
for each folder in commands
scan /foldername
for each command in foldername
require /commands/foldername/commandfile
done
One quick question, how to i get shard status like ping and how many servers/users with that shard (shard_id) (discord.py)
@ me
I was looking at the example... why does it use async when it doesn't need to lmao
can anyone answer my question?
@gritty bolt I don't understand your question, wdym a word or space between each word into a variable
I think he basically means splitting a string?
Well yeah you can 
Remember arrays start with 0
yeah, the first argument is 0, then 1, 2, 3, etc
noob question hours
how do i literally restart one shard
i cant access the shard object from anywhere 
w h i c h l i b r a r y
Make it publicly accessible then?
Idk how that can be done in JS but I'm pretty sure it's possible
sharded clients dont have access to the shardingmanager iirc
so whenever i try to get it via the ShardingManager it will return undefined
whats the ratelimit for changing your profile picture via the website?
oh
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?
@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
Why are you assuming I know discord.js ๐
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);
} );
var
lol I'm trying to make it cleaner
any of yall have original bot ideas? like i have a screenshare bot and discord bot.
just an example of a working embed
@maiden mauve to make it cleaner:
var => const
and add indentation before the .addField, .setTitle, etc
Yeah and donโt use backticks for regular strings like you do with .setFooter
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);
});
๐
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
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
RichEmbed().setColor().setTitle().addField() etc
it's the same with mongo query functions?
yes
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?
^
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
hahaha
I have a very unrefined project in general, any spacing was just done quickly to make sure braces lined up
correctly spaced ([{}]) make for much more readable code
especially with stuff like nested arrays
it does look prettier, can't debate that
:p
but yeah, with eslint you can greatly automate your code looking fancy
if you like my style you can copy the eslint config
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?
a lot more
also variable naming
destructuring
lots of that
in the end you'll get cleancodeโข
lol
note the JSDoc is not mine and also not included in the eslint-config
not quite sure what im looking at with the example
seems to be pretty standard spaced
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
its all automatic?
yes
that's kinda cool
corresponding config lines in https://github.com/Nekiono/eslint-config-raven/blob/master/.eslintrc.json
destructuring: 256
!= => !==: 57
spacing: 147, 149, 154, 159, ...
what if i want == null/!= null
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
also @inner jewel https://eslint.org/docs/rules/eqeqeq#allow-null
trying to brainstorm a better way to organize that
make a map of spell => minimum required level
check if user has said level else reply with error
spells = {
name: { levelNeeded: 123, dostuff: (args) => { ... } }
}
spell = spells[name]
if(!spell) return
if(level < spell.levelNeeded) {
reply()
return
}
spell.dostuff(...)```
yeah, thats the feeling i got
also pls don't use var
lol tbh I have read let,var, const
but they seem to virtually make no difference in output
obviously let is local
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
var is global actually
nope
as in file-scoped
it's function scoped
my entire project has no "let"
const/let > var
look at how beautiful they are
unless your code is like this https://i-was-scammed-by.dabbot.org/6J5jzY5.png you can globally replace var with let
aka variables used outside the scope they're declared
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?
if you don't need to reassign, yes
const values cannot be reassign (const - constant). otherwise use let
is there really a functional scope for "var" at all?
what
well, I guess the need to manipulate it outside of the local scope
which never happens 
it seems more forced that you would make it do that
what are some good databases compatible with js (other then mongodb)
postgresql probably
mongodb and also mongodb
what ravy said
oh okay good lmao,, thanks
mongodb is slam dunk ez
mongodb gives me nightmares
^^^
really?
with await and mongoose everything is so simple
imagine using mongoose
but what if you wanna access a certain collection without using the model
๐ญ
haha who would ever use mongoose panicking
I was learning a lot at once when i started with mongo
I wanna make a mongo wrapper called MongoBongo just for the lulz
and mongoose was a tool that put it all together better
wait if you don't use mongoose then how else
Mr Ravy sir how can I access a part of a collection without linking the schema
since the point of mongo is kinda not to have models
wokay nvm
Thanms
what's the official wrapper called
that's a dumb question I can figure that ouy
wait is it better then mongoose?
mongoose is a wrapper around mongodb
iirc
yuppers
but basically mongodb is the barebones functionality for interacting with mongo
while mongoose adds models






