#development
1 messages · Page 701 of 1
Ok thanks
But freeram of module os give me total ram of my machine, not the process of node ??
You wanted to know the total freeram/totalmem, so I figured you wanted to use the operating system of which the bot is hosted on to determine that.
But, if that ain't it you gotta figure it out.
Could someone help me with an event so my bot sends a message when someone voted?
2 Questions,
- How would I map out all of the shards data in an embed
- How would I restart a shard in a command.
^ Mostly is how could I call a shard I spawned in a command..?
what lib
and what version?
^11.5.1
process.memoryUsage tells you the usage of your node process
Hey can someone help me?
I have the code for a pat command but it only sends 1 gif. Does somebody know the code to make it send a random gif?
Array of files
Send a random picture
Or you can use an api if you dont want local files
Okay, thank you for the answer 
And pls use string interpolation
I mean does it matter?
good practices are always good
Does using the + operator have any drawbacks over template literals?
no
I mean I use template literals, but is there anything wrong with using a + operator
nothing wrong with it, i use it too when concatenating only one or two variables
Template literals are easier processing compared to do "text" + "more text" + variable
How to make like when that the fs says how much files are in a map in the code like (commands)
Libary: discord.js btw
c = a + b
c = `${a}${b}`
Nobody me
How Do I Integrate A Discord Bot With A Site / Game?
What do you mean? @earnest phoenix
@torn folio
For example, how do I get analysis on a Minecraft server?
Man that is a loaded question. Probably a query server into a script that checks your .yml files and other Minecraft files relevant to your tastes/setup
There is a lot of ways you could do that. Look into how other users are doing it. Minecraft has a pretty grand knowledgebase of information to go through
Thanks 🙂
If you get stuck anymore, come back here with more specific development questions with code
People are more than happy to help you fix your code but a really broad question like that will only give broad to no answers lol
can anyone please help me with this - i'm using Discord.JS and just tried to get better-sqlite3 via npm
i already looked at problems on websites like stackoverflow, etc... and none of the answers on those websites helped
Error: The module '/[path to my bot]/node_modules/better-sqlite3/build/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).```
If you need any info just tell me please
P.S. npm rebuild and npm install don't solve the problem
if (!message.content.startsWith(ayarlar.prefix) | message.content.startsWith(`<@${client.user.id}>`)) return;
It does not work . Please help me .
|| instead of |
@storm solar No Error Message.
try what cyber28 said
Not Work
negate your second statement
i realized same thing
(node:2082) DeprecationWarning: Collection#find: pass a function instead
i have message.js **```(const ayarlar = require('../ayarlar.json');
let talkedRecently = new Set();
module.exports = message => {
if (talkedRecently.has(message.author.id)) {
return;
}
talkedRecently.add(message.author.id);
setTimeout(() => {
talkedRecently.delete(message.author.id);
}, 2500);
let client = message.client;
if (message.author.bot) return;
if (!message.content.startsWith(ayarlar.prefix) || message.content.startsWith(<@${client.user.id}>)) return;
let command = message.content.split(' ')[0].slice(ayarlar.prefix.length);
let params = message.content.split(' ').slice(1);
let perms = client.elevation(message);
let cmd;
if (client.commands.has(command)) {
cmd = client.commands.get(command);
} else if (client.aliases.has(command)) {
cmd = client.commands.get(client.aliases.get(command));
}
if (cmd) {
if (perms < cmd.conf.permLevel) return;
cmd.run(client, message, params, perms);
}
};)```**
http://prntscr.com/p9x8dy ) before const is not necessary
What should I do ?
i've never seen a command handler like thatt
trying to make a list of server name + member count
gotten it to work with just server names but not sure how to also get member count at the same time
also tried this
but it only returns member count
the example at the very top returns this
Ight likely a dumb, and probs off topic question. I digged around through google, how do I get+store player coordinates in 1.12.2 using scoreboard values

@earnest phoenix I mean you are mapping to an object...
So why are you surprised when you get an object back
:<
Alternatively you can map to a string and use template literals
@earnest phoenix think about what map does. First explain that to me.
Then I will help you with the next step
to my understanding map lets you go through an array or similar and run a function on each element ?
depends on the function ?
Well what will the overall result of a map me
Be
Regardless of the function itn operates on
It returns an Generic Type of U aka it'll be be an array of what you return
an array :>

But yeah it returns an array
So if you want to display data what should your map function return
string ?
str = a+" "+b ?
I mean yeah but this is where I was talking about template literals
i looked into it a bit
but wasn't sure how it related
from what i saw it's handy if you want to avoid using stuff like "\n"
for readability
Template literals are just this: ${any} in an "`" strings
^
Could somebody please send me these symbols for server moderation? I want to put them In my bot to show which level of moderation the guild has but i cant find the symbols online https://gyazo.com/8237155723c236a373dd037487b55d61
Instead of a lot of pluses, you can do that
But I think you can figure it out now @earnest phoenix
@earnest phoenix nice
very nice
👌
so string literals uses placeholders like in c ?
asking cause i ended up just using the plus operator :>
${any} cause that confused me, never seen that before
my var value is ${var} ?
Exactly
so just like placeholders in c ?
Equiv to “my var value is “ + var
printf("my var value is %d",var);
ye
ye
%s String.
%d,%i Integer number.
%f Floating point number.
%o Object hyperlink.
but
node.js doesn't support %f
just use %d
ye
all the servers with arabic names has the order of servername, membercount switched
so it's membercount, then server name
because arabic is being written in right to left
so anything that has a arabic letters in it is assumed to be an arabic system and auto flips for it to be readable to arabs
yeah

isn't that problematic for Arabic coders though ?
because they would have to write their code in "reverse" order
You can switch to right-left in some code editors I'd expect
ah okay
Wait what, you would have to code from right to left if ur arabian and coding in arabian?????????
yes
That hurts my brain
oof
arabic shouldn't exist #remove-arabic
if only you knew the historic impact
yes
bruh what
So member.kick isn't working, and I assume I'm doing it wrong. Lib is discord.js
Are you sure member is an instance of GuildMember
try logging it to see if it's a guildmember object
Aight
What does a stringified FormData look like when it’s sent in a request body? Like how does it send it
How can I make a variable that is set to args[0] be optionla?
optional&
**
Because that variable is meant to pick up a number
but in some casses a number may not always be required
and it errors saying that -users is not a valid int
if you're giving it to a function, you can declare the function with default values
function something(arg = "default") {
// arg will be "default" if nothing is given to the function
}```
Nah
It is for a purge command
I am having flags and such to delete certain things like:
-bpurge 100 -users //Deletes 100 user messages but
-bpurge -users //Will only delete 1 user message (1 being the default) but it errors saying -users is not a valid int
let num = args[0];
const parse = isNaN(num);
if(parse){
args[0] = 1
}
Someone was talking about replacing what args[0] was
because in your case, if you omit an argument, the next argument becomes the previous
if the input was not a number
so you need to check if args[0] is one or the other
yes
But that doesn't work
Huh?
But I thought the code is checking if it is not a number and if it isn't replacing what args[0] is?
Huh?
command number user
It isn't a specific user
Yea I know
I am trying to find a way to either replace what args[0] is if it isn't a number or add in the default value in front of the array
I understand it isn't a number bc it is a user
you're not doing anything wrong
you are replacing it correctly
but if you need args[1] anywhere else in the code, you need to move it from args[0] before you replace it
Oh wait
Yea
Also I think I found the problem
LOL
num is set as args[0]
and I am using that here:
await message.channel.messages.fetch({limit: num})
That is one of the problems
well, you can also do it like that, move everything off args
and use num instead everywhere
Wait what?
@slim heart afaik it should be a buffer/binary, since it can send files and such
Btw I don't think I need to use args[1] for the "user" flag
if(message.content.endsWith("-users")){
const delMessage = await message.channel.messages.fetch({limit: num}).then(msgs => {
return msgs.filter(m => !m.author.bot)
});
await message.channel.bulkDelete([...delMessage.keys()])
await message.channel.send("I have deleted " + num)
}
This works perfectly fine no?
even if they do:
-bpurge 100 -users
it will still delete 100 user messages correct?
Yea that works fine
yes should work
My issue is just if they don't want to supply a number of messages to delete
but then you need to think about consistency
as your command will work if you do -bpurge 100 uoheofuhqouhqfoq qoufhoquwhf ouqhwfouq -users
but not if you do bpurge 100 -users ouehfowuefw
dont use endsWIth?
@quartz kindle I think it just sends a buffer with it as the value?
not necessarily the entire thing but again idk
i think the formdata is sent as a buffer yes, since there isnt any way of stringifying it
but you can enumerate it and extract data from it and build an object or query strings
@lusty dew sure
unless you have arguments that need spaces
like -bpurge 100 user name with spaces
using a delimiter/identifier and flags is imo the best option
then you can just split on those delimiters
command -option1 value1 -option2 value two .split("-")
then it becomes easy to select everything in between two delimiters and recognize it as an option and value
you mean an argsv parser?
something like that
no, because your args is probably the message content split on spaces
that would be a replacement for args
splitting the message content on delimiters instead of spaces
but thats only really needed if you have more complex arguments
if all your arguments are simple words and such, you dont really need it
then stick with args
No not the package
i mean it works
i also use -- delimited arguments like that package, but i just made it myself
also, there are many phones that automatically convert -- to emdash
which will screw that up
pr yargs ezpz
i like not having tons of deps lul
Okay well yargs looks easy how you’re using it
If I may ask what is 'setting' in that example @slim heart
Is that what you’re applying the 'key' and value too?
well its just another argument example
meaning you can use _ to parse your command name and the rest of your arguments while still having argv args
so key could be --users?
Is it possible that with the discordjs sharding manager two shards have the same guild at the same time, even if only for a short moment?
@viral spade thats not really how discord sharding works
so, no
not unless its logging into the same shard twice
or running different shard counts
ok and when the autosharding program creates a new shard becasue of rising serversize, will the servers be newly distributed and some servers shift from one shard to the other?
What version of d.js are you using?
@viral spade no, thats not how sharding works
a server will always map to the same shard
servers can never move between shards
so the new shard will start with 1 server?
No
Here, let me try and explain it
basically, this is the formula that determines which shard a guild maps to
(guild_id >> 22) % shard_count
This formula will always produce the same shard id
when a shard logs in, any guilds that map to that shard via that formula will be assigned to it
There's no load balancing involved, guilds cant move between shards
etc etc
if you try to spawn 2 shards on a bot with 1 guild
one shard will have no guilds at all
there will be no duplicate guild on another shard
I have a question, which command can i use to see how many servers my bot is in?
if discord.js client.guilds.size
ok thanks
so im working on a fighting system, where i want to determine how many times the player/enemy attacked since the last tick (determined by a speed value) (every tick is 3 seconds) but im getting outputs alternating between 0 and 3 or -1 and 4, and i have no idea how i would do it properly (it should be 3 consistently, because speed is 1000 and every tick is 3000 ms)
im essentially determining number of attacks since last tick as (lastTick - lastAttacked) / speed and lastAttacked as lastTick + Math.floor(times) * speed
Couldn't you just use an interval (3 sec) and every time it's called it would output and reset the accumulated attacks given by player/enemy?
i am using an interval
lemme show the code i have rn
function determineAttacks(lastTick, lastAttacked, speed) {
console.log(lastTick, lastAttacked, speed)
times = (lastTick - lastAttacked) / speed
console.log(times)
return [Math.floor(times), lastTick + Math.floor(times) * speed]
}
module.exports.fightManager = async (message, enemy, player) => {
let lastTick = Date.now()
enemy.lastAttacked = Date.now()
player.lastAttacked = Date.now()
const m = await message.channel.send('', construct(enemy, player))
const v = setInterval(_ => {
console.log(enemy, player)
m.edit('', construct(enemy, player))
atks = determineAttacks(lastTick, player.lastAttacked, player.speed)
let [dmg, lastAttacked] = atks
player.lastAttacked = lastAttacked
lastTick = Date.now()
}, 3000)
}```
So we're essentially just measuring timestamps?
basically
I'd recommend using moment, to which you can use .fromNow and .diff
lemme check it out
It would make sense for the first run to be 0 as lastTick and lastAttack will be equal/very similar
You're only editing them after determining the attacks
It does seem right so it's probably just the timestamps that aren't exactly reliable
Have you tried debugging it, putting some breakpoints to see what exactly is going on
yes, i have a ton of console.logs but i have no idea why the end result is not what i expect
Ok so
I've tested a bunch of stuff
For testing purposes I didn't use message at all
The results I get are 0 3 0 3 ...
I'm thinking your 4 and -1 is because awaiting the message increases the time slightly
Which offsets a bunch of stuff
yeah and rounding causes it to be 4 and -1
Yes
but why isnt it 3 consistently?
I can explain that too
Sec
You're editing lastAttacked to lastTick + the time it attacked
Which makes it so that the next run
lastTick is ~equal to lastAttacked
Meaning it becomes 0
Basically the issue is just the order of which you're saving stuff
ouch
Ok so
I think it makes more sense for your determineAttacks to check between lastTick and the current time
Basically just doing this
will present you with a constant -3
Because the order is just wrong in the calculation if you're doing it that way
would that work even if speed is larger than 3000?
yeah thats why im calculating from lastAttacked
That would mean that you should compare lastAttack with the current date
Instead of the lastTick in my above example
and lastAttack would have to be updated only if there was an actual attack
oh yea
Is the interval always gonna be 3000?
Yeh I got it to work with speeds above 3000
Basically you just have to pass player.lastAttacked instead of lastTick
And it works
Cant you just 3000/player.speed then?
uh good question
function determineAttacks(lastAttacked, currentTime, speed) {
console.log(lastAttacked, currentTime, speed);
times = (currentTime - lastAttacked) / speed;
console.log(Math.floor(times));
return [Math.floor(times), lastAttacked + Math.floor(times) * speed];
}
module.exports.fightManager = async (message, enemy, player) => {
let lastTick = Date.now();
enemy.lastAttacked = Date.now();
player.lastAttacked = Date.now();
//const m = await message.channel.send('', construct(enemy, player));
const v = setInterval(_ => {
console.log(enemy, player);
//m.edit('', construct(enemy, player));
//atks = determineAttacks(lastTick, player.lastAttacked, player.speed);
atks = determineAttacks(player.lastAttacked, Date.now(), player.speed);
let [dmg, lastAttacked] = atks;
player.lastAttacked = lastAttacked;
lastTick = Date.now();
}, 3000);
};
//run test
module.exports.fightManager(undefined, {}, {speed: 4000});```
This will give 0 1 1 1 0 ... as attacks
Which is correct
If you understand this
Calculating the attacks there should be per time unit
yeah, thats exactly how it should be

As for the delay with the message
You could just ignore the promise and not await it
Or send the message after setting the interval
im not awaiting the one thats in the interval tho
If you remove my commented line awaiting the message, it means the time between lastAttacked and now won't be exactly the time of the interval anymore
Instead it'll be the time of the interval + the awaited time
A ticks system should not be date based, because date is inconsistent
Unless you work with low level languages and cpu ticks or somethong
That's a fair point
The interval delay is a consistent hard coded value so you should be able to achieve the same thing without using any dates at all
Instead of comparing times, you just assume that your 3000 tick has passed
lastAttacked has nothing to do with the tick interval tho
Then why do yoi set it on every interval?
You can define it from a date outside of the interval, then increment it by ticks
lastAttacked should be the timestamp the last attack occured on. if speed is 4000, then lastAttacked should still be 0 after 1 tick
If it should be 0 then its not a timestamp
this is why you dont cut out a few words from a sentence without reading through the entire thing
it should be the last ticks timestamp
yeah i know, i fucked up my logic there
check if the message content is your bot id, and if it is, send your prefix
@mossy vine ```js
function determineAttacks(lastTick, lastAttacked, speed) {
let times = (lastTick - lastAttacked) / speed;
return [Math.floor(times), lastAttacked + Math.floor(times) * speed]
}
async function test(message, enemy, player) {
let d = Date.now();
let tick = 3000;
let lastTick = d;
//enemy.lastAttacked = d;
player.lastAttacked = d;
//const m = await message.channel.send('', construct(enemy, player))
let v = setInterval(_ => {
//m.edit('', construct(enemy, player))
lastTick += tick;
let atks = determineAttacks(lastTick, player.lastAttacked, player.speed);
let [dmg, lastAttacked] = atks;
player.lastAttacked = lastAttacked;
console.log(dmg,lastTick,lastAttacked)
}, tick)
}```
i tested it and gives consistent timestamps
with a speed of 4000
with 1000
If I’m using the master branch of discord.js rather than the npm release will the dbl object still be able to take the client object as a parameter or will I have to handle member/server count submission manually? Djs master updated to using a userstore so I imagine there’d be some differences in how that’s handled under the hood
dbl doesnt care about users
it takes the guilds object, which is the same in master
so yes, it should work
Sounds good, thanks
Well guild object isn’t the same it’s now a GuildStore
Ooh
However the property of client.guilds is still a collection
So client.guilds.size is still the same thing and that’s what djs uses so ye
Ok I’ll give it a go, thanks guys
Okay so I'm trying to make a website using Express JS. Currently trying to make it so I can just link CSS files from within my EJS files. Looked online however so far nothing has worked.
File path/structure
`
Website
- server.js
/views- index.ejs
/public
/CSS
* styles.css
`
server.js: https://pastebin.com/LeZD7e1G
index.ejs: https://pastebin.com/shjV0eXU
Don't mind some of the code/names since I'm still only just starting this out and it's mostly just something to try and improve.
- index.ejs
I've tried:
Absolute and normal paths, with and without the /public in the CSS href path (since EJS should render that out).
Dont you just link it normally?
I already followed everything on there still cannot load the file
Cause apperently as long as you tell EJS where the files are you should be able to just link them
But it's not working for me
Yeah even at home it's not finding it so it's not my school network blocking it either
How do I show this in my bot 
what language are you using
I dont use ejs much, but I'll see if I can get something working for you Timo
Thanks I appreciate it
I got it to work one sec
Wait you already have <link href="/CSS/styles.css" rel="stylesheet" type="text/css">
🤔
Weird it works for me
Welp idfk then
Could you DM me the whole thing you have working as a zip just to make sure it's not some dumb thing?
I just uploaded it to github lmao
do you have express configured to serve static files from /CSS ?
https://github.com/steven4547466/testejs thank uber for it being neat I use his ejs boilerplate 
I would've just put it in to a zip, but Im at school and discord is blocked on the chromebooks so I wouldnt be able to upload it
As far as I'm aware yes I have Tim
Oh well currently just using regular html with live servers. I'll look more into it when I get home
I dont think it would matter, but you could try to use path instead of concatenating with +, but I really dont think it'd make a difference
I'm doing some image manipulation stuff where I'm drawing two circles using canvas but for some reason it only draws one circle instead of two:
const a = await Canvas.loadImage(message.author.displayAvatarURL);
ctx.beginPath();
ctx.arc(415+radius2, 59+radius2, radius2, 0, Math.PI * 2, true);
ctx.closePath();
ctx.drawImage(a, 415, 59, radius2*2, radius2*2);
const avatar2 = await Canvas.loadImage(user.user.displayAvatarURL);
ctx.beginPath();
ctx.arc(509+radius, 377+radius, radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
ctx.restore();
ctx.drawImage(avatar2, 509, 377, radius*2, radius*2);```
I've been trying to solve this problem for days now
Result of the command: https://cdn.discordapp.com/attachments/566054411378491393/626045219942563900/punish.png
I basically want both to be circles
You just need to add a filter to the image
@quartz kindle @late hill thank you guys so much, its working perfectly
@ivory pebble any reason why you're using ctx.restore() there?
im looking at topics on clustering a node process, what would I have to modify on my bot to make clustering possible (via pm2 for example)
doesn't have to be specific, just a general idea
pm2 clustering requires your process to be stateless (mostly)
meaning, it cant contain cached/saved/identifiable data without a way to share it across instances
clustering via node-cluster is the same as having a master process that spawns child processes
you can run a different set of code if the current instance is the master
yeah i was mainly concerned about making the app stateless
since a lot of libs cache messages
does this matter?
for a discord bot, the main problem is figuring out which instance is which process
because of sharding
if instance 3 doesnt know which instance it is, it wont know which shards to assign itself
hmm yeah
the way i did it was to use the pm2 package to gather info about the processes in the cluster
it has many lul
like pm2/io which lets you send commands from a pm2 command line into a running process
@quartz kindle even if I remove it nothing happens
@valid frigate sharding overlap? 2 processes logging in with the same shard id
@ivory pebble what if you remove the clip?
so the problem is with the first image, not the second
what if you add the clip to the first image?
@quartz kindle so if im correct on this, i just have to make sure that when spawning a new process that its client doesn't occupy guilds that are already being served
@ivory pebble save(); clip(); draw(); restore();
@valid frigate make sure that its shard id is not already logged in elsewhere
shard ids take care of organizing guilds for you
in the second or first image
in both
ok
hmm?
so just ignore logging in if the shard is already logged in
and move on to shard x, etc
if you have a way to detect that, then yes
what would be your preferred method?
like asking other processes which shard id they are currently on
i did it the easy way
get process id and how many shards per process
for example, if shardsPerProcess = 2; and total processes = 2; then process0 = shard 0,1 and process1 = shard 2,3
oh ok
👍
ok cool yeah let me try that out
alternatively (and probably the easy way) would be to have an external process/script controlling that
which goes back to the master/children system that everyone uses lol
discord is really made for a master/children setup
but i decided to be stubborn xD
hooh
Will you give me a script that will create a server invitation? in discord.js
~ i am using google translate
no
thank you
question for that. How can i do that when my Bot dont have Permissions to create an Invite that it says sth like No Create available
You dont
If it doesnt have perms, there's a reason
Also, creating invites without the permission of the owner is not allowed.
Oh
hes asking how to detect that it cant, and provide a message accordingly
Yes exactly
if i understood correctly
but how
the easy way is to try to do it, and catch an error
the best way is to check for permissions
Whats the Bot ID?
send a dm to the mod that approved it
how would i get the size of streamers?
what
@earnest phoenix obviously he wants the size of the bytes when people are streaming
1024 
wait no
he might be talking about the weight of streamers
that would involve scraping wikipedia 
or the actual size of the word streamers
db.query(`UPDATE minillama SET ${Object.keys(form).indexOf(question) + 1} = '${r.first().content}' WHERE userID = '${msg.author.id}'`)
does anyone know wtf I am doing wrong
use prepared statements 👀
what lang and what database engine @wheat jolt
also yea
preparedstatements unless getting your sql injected is a plan of yours
@hushed berry inject me with ur sql
just use an orm 🙃
ok so i need some help with clustering a little bit
basically i'm not sure how to prevent a sharded client from logging in to a shard that already has a connection
and if it's relevant the lib i'm using is eris
😩
just don't let it log in
ok cool
what exactly are you trying to do
uh to summarize
i'm using the node cluster module to spawn, say 2 workers of my main file
which spawns a client with 2 shards
the whole thing doesn't make sense to me but that's the general idea lmao
hm i see
ye well i don't really like that way of "clustering"
so i've never used that
so can't help that much
do you prefer single process?
i prefer clustering with containers
oh kubernetes
well that would be proper clustering
i guess the same concept still stands
i mean i guess after this my question is how do i communicate between processes
yeah that's hard to do with that kinda setup
ugh
Just use/make an api imo
@valid frigate are you still trying to do it on pm2? or are you using node-cluster now?
for pm2 you need either to get info from the process list, or communicate between processes, which can be done either through the pm2 module, or through an external library such as message brokers or pub/sub databases
something like rabbitMQ would also work
mm ok
Hi, I tried to make a DirectMessage, but I cant, I wanna do that my bot send a dm to the tagged person in X command like:
command @junior gale | arg
BOT: Sends arg to the tagged person (@junior gale)
@junior gale what library
I tried to:
if (message.author.id !== 'id') return
const user = message.mentions.users.first();
const member = message.guild.member(user);
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
let a = args.join(" ").split("|")
let msg = a[0];
if(!mensaje) return message.channel.send(`Escriba un mensaje para enviartelo por privados.`);
message.author.send('${msg}');```
I use .js
meh no experience with it and I dislike it
I searched at all the guides I know but nothing xd
You cant have your bot dm people from another user's command
wdym
You can look at all these declines, or read the ToS&Guidelines for yourself
A dm command
It's not allowed
ofc
@junior gale use ===
never use ==
use strict comparators
they check for equality
Depends tbh
while this fucker == checks for a common type
ik
but I mean
most ppl here will never use ==
(I'll include myself)
== 🤢
@copper cradle if u need an id is ==
BOTH == and === works
=== is strict type
@copper cradle there may be a case where you want to use == :)
It's like you say something is bad before you even consider it's usage
He used if (command == 'xx') @modern elm
!= or !== is the same concept, just one is strict
But, I can use if (message.author.id !== 'id') return
he used that
and was then admonished for using ==
when he didnt even
See the top line in that codeblock
Yes he used pure ==
Is it really that important
an awkward silence commences as he realized he was wrong
he slowly leaves the conversation
Let's not
?
It is important to stop others teaching others retarded stuff :)
By the way, === is always slower than == so there where you don't need it, don't use it
Because it is

It does the same as == plus one operation more
So lets say == does n operations
=== does n+1
n < n+1
== sometimes has to do type conversions
=== does not
And where are you getting that info from?
=== has to compare types
If I read your code as a developer, and I see that you used == instead of === I would assume that it's possible the 2 values aren't of the same type.
If they will always be the same type, you should use ===
As that makes it clear.
@quiet dagger yeah but == has to convert both to a common type
Also in == I assume it also check if they are the same type to break out of the evaluation faster
So what you said doesn’t really make sense to me
Tim is a smart guy
He can answer this
== and === are roughly the same if the type is equal, but == is slower if the type is not equal
but == is still faster than converting types and then using ===
(according to some articles and benchmarks)
it also depends on browser/node/v8 versions
I think we were looking at the same benchmarks 😉
I think it's also just safe to assume that the difference performance wise will be that miniscule that unless you're working for google, facebook, ... rly shouldn't be something for you to worry about.
That too ^
Focusing on readability/consistency should be higher on your list of concerns 
type comparisons on a for loop, looping over millions of items
every microsecond counts
I usually just use == because I rarely care about types. I don't like typed langs for a reason 
@earnest phoenix that thing u asked
yes
you could probs make a http post
doing like
and how i didnt do ever before ._.
ok so like
the api endpoint is https://discordapp.com/api/auth/login
Yes
great way to get your account banned
vim file.js
:% s/===/==/g
@earnest phoenix?
u ther
my bad wasnt sure if to keep going
oi
when its bannable lol
is it bannable from here?

Pls someone tell me that doesnt give a frick how to send data into the https://discordapp.com/api/auth/login thing
with request
pls thanks
fill the parameters for email and password
and post
HOW
and get response
i never did before
idk how
no one here is going to help you break the discord tos
oof
you also have a sextillion resources online telling you how to do a post request
Shit
ok then thanks
Uh wrong channel? Or
this is basically an ad but ok good job bud
the ad has sneak 100
its not the first time
wait why is it a discordapp gif url
weird flex but ok
wait why is it a discordapp gif url
probably uploading it to some other channel and then returning the url of it lol
can you try npm --v and node -v and tell me what they show?
is nvm node version manager? just curious
never heard of it before 
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs is what I did
ew piping stuff to shell
yes, nvm is node version manager
just how the https://github.com/nodesource/distributions/blob/master/README.md#debinstall tells you to do it
¯_(ツ)_/¯
message.channel.bulkDelete([...delMessage.keys()], true)
.then(messages => {
message.channel.send(`:check: Deleted ${messages.size} messages`)
})
Any reason why this would return 0 instead of the actual number of messages deleted?
What lib
Yes it deletes em
and triggers the messageDeleteBulk event which shows the proper number of deleted messages
That’s awfully strange
yea
I've had the same issue, but rare/sometimes. I'm assuming delMessage is a collection of messages
async run(message, args){
args[0] = isNaN(parseInt(args[0])) ? 1 : parseInt(args[0]);
if(args[1] === "-users"){
const delMessage = await message.channel.messages.fetch({limit: args[0]}).then(msgs => {
return msgs.filter(m => !m.author.bot)
});
message.channel.bulkDelete([...delMessage.keys()], true)
.then(messages => {
message.channel.send(`:check: Deleted ${messages.size} messages`)
})
}
limit is a string, not number
No?
oh you re-assigned it nvm
yes and even if limit was a string
it wouldn't fetch anything and delete it
it'd error
in the example it's spawning 2 shards/client
Does anyone have any automated testing for their bots?
Wdym
Yeah, unit tests are a start
Just make a separate bot to test things?
you could implement interfaces to test discord facing code as well
I've seen other projects like REST api's that will actually spin up the HTTP server and throw stuff at it to see if it works.
that's pretty hardcore
I’ve seen people use applications to make post requests and such to test their apis
I've looked at some projects on github that mock the discord api but itooks like none of them finished.
I could roll my own but I was wondering if someone had a framework or something already done.
i mean you could implement your library's interfaces to mimic receiving data from discord
i guess that doesn't test your library's code though
That's what mockcord was supposed to do but its abandoned. https://github.com/b1naryth1ef/mockcord
Ok cool, well I'll keep thinking about it. I was just wondering if anyone had anything already.
lol im saying implement whatever library you're using just to mimic receiving data
not set up a whole discord api implementation
like figure out which functions are called when it receives data from discord and just call those yourself
You could do that. Most bots probably only use a handful of the apis features.
Different topic. Does anyone know how long it takes to get a bot approved to get on the bot list?
hotasfaq 2
Click the link to get more information on the question:
2) How long is approval?
how do I send a text message to my discord chat channel when a member joins my server ?
i'm using discord py
Is there a remote mongodb viewer in website form similar to what chateau is to rethink?
language - discord.js
code:
if(!message.member.hasPermission("MANAGE_SERVER")) return message.channel.send("You do not have access to use this command!");
?
try instead of "channel.send" add "channel.sendMessage "
i have a similar code to that and it works like this
if you dont know dont try to help maybe?
sendMessage is deprecated
dont use it
its MANAGE_GUILD not MANAGE_SERVER
when did that get changed?
when did what get changed
it used to be manage server
i think it was always MANAGE_GUILD
no
servers have always been called guilds in the api
yes
cool
i just looked at the old bot i did
and it said MANAGE_SERVER
so it would of changed to MANAGE_GUILD
weird
in an update
It's always been MANAGE_GUILD in both Discord API and Discord.js
u sure?
Yes
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
lol tsc
@unreal hollow you still need help with https://discordapp.com/channels/264445053596991498/272764566411149314/626355129309986816 ?
yes
Okay, well there is a on_member_join(): event that you can use.
And then you can define the channel using utils.get
And then you can send a message/embed to the defined channel
ok i'll try
how does dbl determine whether a bot is online? My bot status shows ???
yeah i'm searching in that site now
👍
thanks
Np, mention me if you need more help
:)
How can I check if someone voted my bot in dbl?
@sullen yacht just 1 question what is the bitrate ??
Bitrate is for voice channels im pretty sure
On what? utils.get?
yes
Yeah
ok
name="channel_name"
ok
How to filter the Size of Streaming Pepole?
@bot.event
async def on_member_join(member):
channel = discord.utils.get(guild.text_channels, name='test-1')
await member.channel.send(
f'Welcome to coding hell,{member.name}!')
@sullen yacht i tried this code but it didn't work it says
name 'guild' is not defined
because guild is not defined 😩
but what the type? @sinful lotus i mean: stream or streaming?
@stray garnet read docs
k
ok i'll try
outputs me fricking 0
did you look what status contains?
it still didn't work it says
AttributeError: 'Member' object has no attribute 'channel'
@sinful lotus wym
also you dont need status
wait its game?
oh

streaming is an activity type
Docs are very helpful https://discord.js.org/#/docs/main/master/class/Activity?scrollTo=type
not a status
@unreal hollow show me your current on_member_join(): event
Welp...
@bot.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(
f'Hello {member.name}, welcome')
channel = discord.utils.get(guild.text_channels, name='test-1')
await member.channel.send(
f'Welcome to coding hell,{member.name}!')
no i want to send it in a text channel
well you could either:
- change guild.text_channels to member.guild.text_channels
or - add guild = member.guild
Try this, without the dm thing.
@bot.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.text_channels, name='test-1')
await channel.send(f'Welcome to coding hell,{member.name}!')```
And also i think the reason that it wouldn't send is because you had member.channel.send() but you don't need member. as you defined channel
so it's just channel.send
ok
I have to go, but that should work. If it doesn't, mention me or somebody else will probably help
oh tere
@sullen yacht yes it works now thank you
exports.run = async (neko,message,args) => {
const filter = (reaction, user) => ['🇦', '🇧', '🇨'].includes(reaction.emoji.name) && user.id === message.author.id;
let embed = new RichEmbed()
.setAuthor("Advanced Testing Commands")
message.channel.send(embed).then(async msg => {
await msg.react('🇦')
await msg.react('🇧')
await msg.react('🇨')
await msg.react('❌')
msg.awaitReactions(filter, {
max: 1,
time: 30000,
errors: ['time']
}).then(collected => {
const reaction = collected.first();
switch(reaction.emoji.name) {
case '🇦':
let embed2 = new RichEmbed()
.setAuthor("succes")
msg.edit(embed2)
break;
case '🇧':
let embed3 = new RichEmbed()
.setAuthor("succes.")
msg.edit(embed3)
break;
case '🇨':
let embed4 = new RichEmbed()
.setAuthor("again succes")
msg.edit(embed4)
break;
case '❌':
msg.delete()
break;
}
})
})
}
module.exports.help = {
name: "test2",
aliases: []
}```
when i react to ❌ it dont deletes the message
Could it be that your bot doesn’t have permission to manage messages?
it has Administrator in my test server
there are legitimate use cases for mixing await with .then
eg fetch
await fetch(x).then(r => r.json())
vs
await (await fetch(x)).json()
@stray garnet your filter doesn't seem to include the ❌ emoji
Also there seem to be spaces between the switch case. When I ran "'🇨'".length, it returned 4. You should check that.
thats normal because these characters require a supplemental character
so letters take 2 but the normal x will take 1 
Anyways, the Unicode codepoint range goes from U+0000 to U+10FFFF which is over 1 million symbols, and these are divided into groups called planes. Each plane is about 65000 characters (16^4). The first plane is the Basic Multilingual Plane (U+0000 through U+FFFF) and contains all the common symbols we use everyday and then some. The rest of the planes require more than 4 hexadecimal digits and are called supplementary planes or astral planes. I have no idea if there’s a good reason for the name “astral plane.” Sometimes, I think people come up with these names just to add excitement to their lives.
@sudden geyser oops thx
"💩" === "\u{1F4A9}". Unfortunately, this is also true: "💩" === "\uD83D\uDCA9". What is this nonsense? All astral codepoints can also be represented by “surrogate pairs”, and this is used for backwards compatibility reasons. This is why "💩".length === 2. There’s a formula to calculate surrogates from astral codepoints, and vice versa.
also, "👩❤️💋👩".length === 11
lmao
bruh
Please use code blocks for their purpose!
Kindly asking
Plemso```
i know this is going to be just as off-topic as the message above this, but why are you using them for something that isnt their "purpose" lmfao
Because code blocks look sexy af
Hy
No problem @unreal hollow
:)
how can i do that when i react to the message that the reactions from me get cleared?
exports.run = async (neko,message,args) => {
const filter = (reaction, user) => ['🇦', '🇧', '🇨', '❌'].includes(reaction.emoji.name) && user.id === message.author.id;
let embed = new RichEmbed()
.setAuthor("Advanced Testing Commands")
message.channel.send(embed).then(async msg => {
await msg.react('🇦')
await msg.react('🇧')
await msg.react('🇨')
await msg.react('❌')
msg.awaitReactions(filter, {
max: 1,
time: 30000,
errors: ['time']
}).then(collected => {
const reaction = collected.first();
switch(reaction.emoji.name) {
case '🇦':
let embed2 = new RichEmbed()
.setAuthor("succes")
msg.edit(embed2)
break;
case '🇧':
let embed3 = new RichEmbed()
.setAuthor("succes.")
msg.edit(embed3)
break;
case '🇨':
let embed4 = new RichEmbed()
.setAuthor("again succes")
msg.edit(embed4)
break;
case '❌':
msg.delete()
break;
}
})
})
}
module.exports.help = {
name: "test2",
aliases: []
}```
why would you make a new embed
just do embed.setAuthor("success") and then edit msg with embed
boolin
it doesnt matter if you create a new one, in the end the message will be sending a new one anyway
and hes probably using them as placeholders to later add more data to them
sure editing an existing embed will save a few bytes of ram, but not that big of a deal
what's the most reliable way to get the information about all shards on all clusters using ipc? right now i'm storing an array of shard data in the master process and the workers send messages which updates on the master process, then broadcasts new shard array to all workers


