#development
1 messages ยท Page 1625 of 1
hm?
console.log(`Launched shard ${shard.id}`)```How can I write how many shards to start here?
e.g: Launched shard 1/26
i wait 5s between each shard start
๐
does this work @toxic jolt
console.log(`Launched shard ${shard.id}/${shard.totalShards}`);```
oh thanks so much <3
each shard start is centralized on the master
pog
so it just goes down the list meaning it wont get ratelimited
worked thanks 
My bot uses a lot of ram and processor, how can I fix this? Is there a way to start Node.js with ram setting?
yw ๐ @high bobcat gave me the answer ๐
oh sorry
rewrite your bot in C++ like i did.... 6.7 million users, 75k servers in under 6gb ram
๐
@green kestrel is there a c++ lib? lmao
im dumb
bkahnwald, you indirectly gave me the max shards property ๐
omg
pfff what a noob, using 6gb with 75k servers
6 gb ram?
@crimson vapor ofc! https://github.com/zeroxs/aegis.cpp
githib
:D
get rekt
how many guilds
...
in only 2k servers
what theee...
d.js ftw
djs 
oh, i cache everything, too
yea yea
๐
im using 2 vds ....
unoptimised crap ngl, frick d.js
you should! its a fun language
first vds
no clue even where to start
should move to detritus
me?
I just rewrote to discord-rose
bro
lol
my prod has like 3 important servers
system... why....
and this is one of them
417 servers
best i can do is 2.5k at 900mb
damn
80mb
gonna flex... this is my current usages
actually, my bad, 824
What's the max char length of all permission bitfields ORd together, currently?
i need this in my graphs
look at that panel
im still trying to figure out a way to graph it dynamically
Does the panel update automatically?
yes
i have 4k servers and this
does it fetch an api?
its a hack, it just does a meta refresh ๐
how make it this panel omg
i have 26k guild :D
@toxic jolt easy... use an external db like mysql or redis, get each shard to push status and metrics into the db, and query the db to display the page
and this
I'm gonna try that
@crimson vapor yeah :D
hes got 22k servers?
ye
running a bot on windows. Kinda weird unless it's some windows only dependency
isnt that sort of thing expected with node and djs with many servers?
now
erwin you are poggers
WHAT THE
METRICS
lol
I love data
grafana and a shit ton of work
data is cool
nice, grafana?
ima setup grafana soonโข๏ธ
just gotta work on process communication to get stats
im using quick.db and vds is died
I wish I could do that
but making ti dynamic has been provindg to be quite the task
OH GOED
isnt quick.db blocking??
postgres ftw
OH MY
Anyone on DJS wanna tell me the value of the ALL BitfieldResolvable?
that reminds me
bro Kyoso does like 22k requests to his db a second or some shit
yes, quick.db locks the sqlite db to make an update
wio.db the best
yes but very fast.
I need to rewrite my db
Couldn't figure out how to transfer the quick.db data to mongodb
smol numbers
slow.db ftw
Iโve got the data transferred from mongo to postgres
i was hitting 120k a second with Leviatahn on twitch
why don't you cache???
now I need to read from postgres
fuck cache
database go brr
and itโs gonna fucking deal with it
my db code isn't too shit
one sec
oh erwin
my db code is shit
do you think you could help me with an issue im having
database go brrr
reeee
go brrrr
needless to say my bot managed to clog postgres
fuckin hell
that was the reason i went to cassandra
"how to solve race condition"
therw u go
postgres is awfully powerfull
Did you batch queries together
wasn't that easier?
basically when a user runs a command as their first message, there will be no data in the DB so it creates it. but it also creates it on the first message, creating the issue where the bot is erroring because of a duplicate unique data in the DB
postgres can easily handle 1 million rows a sec so i doubt you can truly clog it up
just need to actually set it up correctly :P
PFFFFFFF
INSERT () VALUES() RETURNING *
who would win?
a fast performance database
lol
or a return * boi?
so erwin do you know a possible solution to my issue?
look, some stuff was generated, so i had to return some generated values
yes, use detritus
all problems gone
upsert
was about to link that
This tutorial shows you how to use the PostgreSQL upsert feature to insert or update data if the row that is being inserted already exists in the table.
mongodb tho
mongo has it too
ah
erwin. Your genshin bot broke postgres in <3k guilds?
updateOne(filter, doc, { upsert: true })
@opal plank rewrite my db code and ill do it
no, hell naw
well, mongoose or whatever
leviathan
INSERT INTO table ON DUPLICATE KEY UPDATE ....``` ^ myqsql
how many guilds
that bot managed to get 98% of twitch's global traffic
levitahan is a twitch/discord bot
i was testing my caching library on it
REPLACE INTO table
managed to pull around 5 million live viewers
and you can kill postgres with a 1 million row table, same as mysql, if you dont properly index your fields
if every time you touch that table its doing a full table scan, you WILL kill your queries
Working on primary keys first, then gonna add multi column indexing
NO! replace into is tons of times slower than insert on duplicate key... replace into deletes the row and reinserts it
never ever use replace into if you care about performance, try doing 100,000 of them on a huge table, and comparing to insert on duplicate key update, and see the difference
@opal plank https://github.com/Million900o/terano-rose/blob/master/src/database/user.ts wouldn't even be that bad to rewrite this to use postgres
there you go, one step in, second is ditch that unfinished lib and come to detritus
no im not doing that
i will shard my bot 19 times because why npt
damn
https://github.com/brainboxdotcc/triviabot/blob/master/modules/bandwidth/bandwidth.cpp#L52 heres how i do my queries (see line 52)
but that one doesnt do "on duplicate key update" because its guaranteed unique
wish postgres supported ? as prepared statement identifiers
@green kestrel is there a reason you put the license at the top of every file?
just use the standard postgres place holders?
but I do like how you can de-dupe data sent by specifying index of prepared
Yes. That's what I do
heres some examples with on duplicate key update:
https://github.com/brainboxdotcc/triviabot/blob/master/modules/trivia/webrequest.cpp#L210
be the better man, use query().catch(() =>{}) , if you cant see the problem, there isnt one
the point of the place holders is you can have server pointers to the same value
e.g.
SELECT bob FROM thing WHERE foo = $1 AND baz = $1 AND x = $2
this query might be completely invalid btw i cant remember if it's AND or if it supported comma seperation
but same principles 
That's the use I found from switching to psql from maria.
Just a slight annoyance going and changing literally all of my sql statements
was nicer moving from sqlite to maria
sqlite !== psql
I'm aware
Oops.
They're both based on SQL, so I expected more compatibility, I guess
@modest maple did you end up getting your DB to work?
I wanted to output Hello World! initially but seems I did something better
yeah
i gave in trying to run a single local instance
its just running in cluster mode now
so my pc is just a datacenter connection rn
fun fun fun
Looking into indicies right now. Lets say I have a table with millions of chatlogs, where this gets saved:
ID - Date - Time - Username - Message
would it make sense to create an index for the username column, if I'm retrieving log entries by username alot?
ye
yes
How long does a single query take
I hope you delete those messages after the user leaves your scope 
data protection intensifies
Not a discord bot in that case, but a minecraft bot
still
SELECT * FROM logs WHERE username = 'LolRiTTeR';
that's pretty poor performance for a few million rows
yikes data protection is 
Yikes
I use the logs to provide leaderboard and such
how many messages a user said, how many kills, deaths etc.
Cause I have to get them by chat
what kind of data do you store
oh right. You did provide the column def previously. What exactly do you do with the message content column if I might ask? 
There's one command which shows you the last 5 messages written
Ah okay. I see. It would make sense to store that, then
Also a !quote command to get 1 random quote from a user
Lets break my table by adding an index I guess? ๐
Everything will be fine 
what db is it?
MariaDB
is that even gonna survive altering 17 million rows
Guess I'll find out? ยฏ_(ใ)_/ยฏ
Maria is pretty resilient
Ah, scaling, when will I get to do it ๐ญ
@viscid gale
const waiter = () => new Promise((r, j) => r(1));
(async () => {
const start1 = Date.now();
for (let i=0; i<999999; i++) {
await waiter();
}
console.log('Async:', Date.now() - start1, 'ms');
})();
const promise_func = (i) => {
if (i === 999999) {
console.log('Promise:', Date.now() - start2, 'ms');
return;
}
waiter().then(() => promise_func(i + 1));
}
const start2 = Date.now();
promise_func(0);
what are the timings
Promise: 386 ms```
not bad
promises are slow af
Though, in the second test you have recursion, which is generally slower than a regular loop
Doesn't some engines spawn promises on another thread?
this is why its not recommended to use them everywhere
only use promises when actually needed
func walkRoutes(r chi.Routes, path []string, base string) []string {
routes := r.Routes()
if len(routes) == 0 {
return path
}
var route chi.Route
for i:=0;i<len(routes);i++ {
route = routes[i]
if route.SubRoutes != nil {
path = walkRoutes(route.SubRoutes, path, base + route.Pattern)
} else {
path = append(path, base + route.Pattern)
}
}
return path
}```
Fun times with go recursion
how to do this ?
me nub

what
yeah lol async is faster kek @modest maple
Use recursion for the first test too
thats probably gonna depend on the eventloop and runtime itself
yeah I should
Also use performance.now() instead of Date and possibly run them separately
its just a demonstration
djs message obj and stuff never get garbage collected?
it keeps growing as many people keep typing commands
how is i use multiple prefixes
put the prefixes in array []
ok
and then you can just [].findIndex to check for the prefix
const waiter = () => new Promise((r, j) => r(1));
const async_func = (async (i) => {
if (i === 999999) {
console.log('Async:', Date.now() - start1, 'ms');
return;
}
await waiter();
await async_func(i + 1);
});
const start1 = Date.now();
async_func(0).then(() => {
const promise_func = (i) => {
if (i === 999999) {
console.log('Promise:', Date.now() - start2, 'ms');
return;
}
waiter().then(() => promise_func(i + 1));
}
const start2 = Date.now();
promise_func(0);
})```

Async: 1222 ms
Promise: 59 ms
uh what
this better
const waiter = () => new Promise((r, j) => r(1));
const async_func = async (i) => {
if (i === 999999) {
console.log('Async:', Date.now() - start1, 'ms');
return;
}
async_func(i + await waiter());
}
const start1 = Date.now();
async_func(0);
const promise_func = (i) => {
if (i === 999999) {
console.log('Promise:', Date.now() - start2, 'ms');
return;
}
waiter().then(r => promise_func(i + r));
}
const start2 = Date.now();
promise_func(0);```
That's way faster
chrome wtf HAHAHAHA
hrm makes sense
ok so we conclude promise is much faster
but honestly async/await and recursive func is quite dumb
but it makes the test fair
every time you add to that callstack youre slowing everything down
You can only store strings in a NameValueCollection, use a Dictionary and store a List of strings
someone help?
with what
Nobody can help until you ask your question
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)
Does someone know what this means?
You have too many event listeners
Explain yourself
That usually happens when you create an event listener inside another event without destroying it
or a loop
Either you've created too many message handlers, or you have a client.on("message") inside another event
could be, or inside a loop, or you just have too many event listeners in general
we can't tell exactly without looking at the code
hhmmmmm wait
I will try to delete a suspect one
And tell you what happen
ok didnt work
@cinder patio So I need to create another file, or smth?
if i want to create more events?
did u create that many listeners
no
so what do i need to do?
does that msg popup when u start bot?
You either
- Increase the max event listener size
- Destroy listeners after you don't need them / Combine multiple listeners of the same type into one
Hi
increasing the size is only good when you are 100% sure you need all the event listeners
yeah?
If I use emitter.setMaxListeners() i can make more events?
yes, but like I said, use it only if you are sure you need the event listeners
oh ok
It's better to just show us where you define your listeners
So we can find where all those listeners get created from
wait
Let me try one thing
And if doesnt work
๐โโ๏ธ
Um wait...
@cinder patio If I create a lot of commands in just one event, that would help, right?
of course
Are you creating a new message event for each command?
You should use only one message event
on("message", message => {
switch(message.content) {
case "~help": ...
case "~defef": ...
//etc
}
}
@flat pelican
You can also use a command handler, which is cleaner than switch statements
and allows for arguments
me realising im very dumb
if (message.content.toLowerCase().startsWith(prefix + "avatar")) {
const embed = new Discord.RichEmbed()
.setTitle("Your Avatar")
.setAuthor("Its_IsmailZ#8826", "https://cdn.discordapp.com/avatars/643091174243958814/9ec6fc0169e8c4658d87765b1d663efe.png?size=128")
.setColor(0x00AE86)
.setDescription("Your Avatar")
.setImage(message.author.avatarURL)
.setTimestamp()
message.channel.send({embed});
``` Why doesn't this work?
avatarURL is a method.
and how to fix?
call it
method or function?
it's the same thing
hey umm
A method is a function in a class.
how would you find out if an object is being stored outside of heap that doesnt get garbage collected?
how do you identity these
any idea why it dosent find the nested property? return member[values] if values is "plugins.verified"?
global variables? i doubt
.RichEmbed?
I believe thats not a thing.
Like shouldn't Ismail have received a noisy error detailing what went wrong
is that v11 guy
idk I got the code from a site lol (I edited a bit)
I'm new...
how to check if a guild member can receive dm's?
yes should I send it?
try catch dm them.
Why would you want to identify these? That doesn't sound like something you should be handling
send dm and catch errors
It's one of the common reasons for memory leaks
But it's not "stored outside of the heap"
Don't debuggers like Node.js' default one already show this
/home/container/index.js:57
const embed = new Discord.RichEmbed()
^
TypeError: Discord.RichEmbed is not a constructor
at Client.<anonymous> (/home/container/index.js:57:16)
at Client.emit (events.js:326:22)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:825:20)
oof
It just doesn't get sweeped by the garbage collector because there's an object pointing to it
Error #1: RichEmbed is not a thing anymore. Poof!
You're probably looking for MessageEmbed.
But how to fix it?
In fact a lot of your code is based on v11 conventions.
It's Discord.MessageEmbed() in discord.js v12
u should read the docs
erwin be like
So just change RichEmbed with MessageEmbed?
Yes
You should probably read https://discordjs.guide/additional-info/changes-in-v12.html
There's a detailed article on all the changes in between versions: https://discordjs.guide/additional-info/changes-in-v12.html
dang it
beat me to it
lol
Is there any message.author.name or message.author.tag r smth?
okay ty
how to make the bot ignore a specific id ? like if(member.id == " ") ignore or smth like that
check if the ids are the same, and if they are just return
if i return the command will stop and i don't want that, i just want the bot to continue executing the command for other members ( i make an announcement command for my yt videos and i want the bot to send a message to a member like every 10 seconds )
Are you DMing every member
yes, i know that if i do this at a certain amount of time it does not break the tos
No, you shouldn't be doing it in general.
Even if i'm the only 1 who has acces on the command ? i had some other bots with this command included and there was not any problem
Instead, how about using @ everyone or @ here (since you want to message a number of users)
If you donโt wanna return the function then execute your code if the statement is true
if(member.id != "12345")
{
doEvilShit();
}
i got my members attention faster with a dm but fine, i'll do with everyone
Yes, that's why developers like to DM instead. But you should use @ everyone instead. If you don't want a certain list of members from seeing those announcements, you can restrict their access to the channel you post it in (unless it's a channel with other stuff in it). Your issue from the start was probably using a raw loop and breaking (return) out of it, compared to something else like forEach or continue or doing what Fake said.
Uhm now NO command of my whole script work, except avatar (which works perfectly)...
The token isn't visible ig
lemme double check
ok it's safe
just use hatebin.com smh
thx
"no u", "avatar" and "help" works
two listeners too
ah k so what do I have to add? a ) or }
}
okay ty all
you would need to maybe learn javascript and proper syntax...
yesh I am new ๐
Good reference for you: #development message
I started again with a new script all over again cus my old one had some bugs (prob a } forgotten)
and you don't need those two lines in red
why not?
and the part circled in blue could be put inside the earlier if check
because you've already asserted user is not a bot, and you don't use prefix for anything there
also I don't think message.bot is a thing
ah k
/home/container/index.js:90
}}});
^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:931:16)
at Module._compile (internal/modules/cjs/loader.js:979:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
nvm
Does anybody have the invite for the discord for developers server
oh fck
ah, yeah
thats it, thanks!
TIL there are both /developers and /developer invites
im trying to make a command that disables keyword responses for my bot, but the variable isn't changing
client.on('message',async msg => {
const curServer = msg.guild.id;
with(curServer) {
serverToggle = true;
}
[ ... ]
if (msg.content.toLowerCase() === ",,togglekeywords") {
with(curServer) {
serverToggle = !serverToggle;
msg.channel.send(`${msg.guild.name} has keywords ${serverToggle}`)
console.log(serverToggle);
}
}
i want it to be its own setting for every server it's in, instead of having every server with the same setting, so that's why im trying to use curServer to get individual server IDs. is there an easier way to do this
you should realistically be using a db for any settings but you can make a map, Map<guildID, boolean>
map.set(guild.id, true | false)
map.get(guild.id) // true or false or undefined```
ah ok
yeah exactly
can someone help me understands how channel position works
i tried to make the bot re-arrange the channels according to a dict
like
channel_positions = {channel_id: position_number}
for channel in ctx.guild.text_channels:
position = channel_positions.get(channal.id)
await channel.edit(position=position)```
but sometimes the positions don't get right
like the channel that supposed to be on top sometimes it goes down to middle or bottom
and when i check the positions of the channels with another command they get back to their original position
i have no idea what you're trying to do
re-arrange channels in a certain category
i have a function that moves channels to a certain category if it's active
when it goes non-active it should go back to it's previous position but when i try to that it messes the other channels in the same category
so i am trying to re-arrange them
using the code above -_-
ฤฑ installed but when ฤฑ say node that gives error
yeah
like
{channel1: 0, channel2: 1, channel3: 2} and etc
but sometimes they get messed up as channel1 goes to bottom or middle instead of top
quick.db says these:
Error: Could not locate the bindings file. Tried:
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\build\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\build\Debug\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\build\Release\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\out\Debug\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\Debug\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\out\Release\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\Release\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\build\default\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\compiled\14.15.1\win32\x64\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\addon-build\release\install-root\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\addon-build\debug\install-root\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\addon-build\default\install-root\better_sqlite3.node
โ C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\lib\binding\node-v83-win32-x64\better_sqlite3.node
at bindings (C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\bindings\bindings.js:126:9)
at Object.<anonymous> (C:\Users\nedim\OneDrive\Masaรผstรผ\KBILGIbot\node_modules\better-sqlite3\lib\database.js:9:24)
when i say node command
help pls
chs = []
c = 0
for ch in ctx.guild.text_channels:
c += 1
chs.append({ch.id: c})
return chs.sort()```
is this what you're trying to do?
you'll have to access it like chs[0][id]
but, it sometimes put the channel that's supposed to be on top at the bottom
that's my issue
channel_positions = db.get().val()
for channel in ctx.guild.text_channels:
position = channel_positions.get(channal.id)
await channel.edit(position=position)```
like this
it's a dict where i get the channel_position from the database
can i see what channel_positions outputs?
okay lemme print it
OrderedDict([('718842573426524200', 101), ('718842591902302218', 103), ('718842604912902174', 104), ('718842619131854878', 106), ('718842629315362836', 107), ('718884729658802186', 102), ('720093709227786290', 108), ('804699003585167400', 105)])```
here they are, the position starts from `101`
they get back to their normal positions which is `19` ig
i suppose channels have to fill the gaps or smth
@latent heron
so the 2nd value in the lists is what you want to sort by, correct?
https://www.npmjs.com/package/ms
Does anyone no a good alternative to this package, which does not rounds the number?
ohh you're working with a DB table
at that point there's no point trying to sort by the 2nd
Can't you round it yourself?
just run .sort() when you append the whole list by the position it shares in the Database
that will solve your problem
it should not round. It rounds up 1h 30 min in "2h" ๐ฆ
oh I misread the question
well, you gotta split it
JS i think rounds up by default
okay i will try
and kinda hard to parse
does to much npm packages make my bot slow?
easier to just split by an empty space
ms in human
depends on the npm packages you're using
that's from ms lib
nonetheless, just split by space after letter
(?=[a-zA-Z])\s
the problem is transfering it back in , let it rounds it up
no
if you split it that way just process every part separately
then sum everything afterwards
if you input 1h 30m it'll become ['1h', '30m']
but when the usr pass 2hours 20 minutes?!
it'll become ['2hours', '20 minutes']
that regex will only split if there's a space preceded by a letter
when not?
2h30m , will the regex check to?
it'll not split
I'll not give you a "fit all" regex
I gave you the base to it
adjust it to your needs
cclient.on('message', message => {
const userID = '698183217215176783';
if (message.author.id !== userID) { return message.channel.send("bunu yapamassฤฑn")
}
client.on('message', message => {
if (!message.guild) return;
if (message.content.startsWith('!kick')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick('Optional reason that will display in the audit logs')
.then(() => {
message.reply(รye baลarฤฑyla atฤฑldฤฑ ${user.tag});
})
.catch(err => {
message.reply('รyeyi atamadฤฑm');
console.error(err);
});
} else {
message.reply("Bu kullanฤฑcฤฑ bu sunucuda deฤil!");
}
} else {
message.reply("Kullanฤฑcฤฑ bulunamadฤฑ");
}
}
}
});
what's my fault
what error comes up?
triggerarray.push(String("`"+element.trigger+"`"))```
why does this return Cannot read property 'push' of undefined
events declared in events
the element exist and i can console it
SyntaxError: missing ) after argument list
โ[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)โ[39m
โ[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)โ[39m
โ[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)โ[39m
โ[90m at Module.load (internal/modules/cjs/loader.js:928:32)โ[39m
โ[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)โ[39m
โ[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)โ[39m
โ[90m at internal/main/run_main_module.js:17:47โ[39m
C:\Users\Hp\Desktop\bot\efe.js:32
message.reply(รye baลarฤฑyla atฤฑldฤฑ ${user.tag});
this should work?
show remaining code
me?
yes
It should be
message.reply(`รye baลarฤฑyla atฤฑldฤฑ ${user.tag}`);
@dusky harness Try that
let triggerarray, triggertypearray, tokenarray, filenamearray =[];
data.forEach(element => {
console.log(element.trigger) //outputs valid
triggerarray.push(String("`"+element.trigger+"`")) triggertypearray.push(String("`"+element.triggertype.replace("word","message").replace("join","join/leave")+"`"))
tokenarray.push(String("`"+element.token+"`"))
filenamearray.push(String("`"+element.filename+"`"))
});
lemme format that properly
let triggerarray, triggertypearray, tokenarray, filenamearray = [];
data.forEach(element => {
console.log(element.trigger) //outputs valid
triggerarray.push(String("`" + element.trigger + "`"))
triggertypearray.push(String("`" + element.triggertype.replace("word", "message").replace("join", "join/leave") + "`"))
tokenarray.push(String("`" + element.token + "`"))
filenamearray.push(String("`" + element.filename + "`"))
});
hm, huge variable names, just a sec
let triggers, types, tokens, files = [];
data.forEach(element => {
console.log(element.trigger) //outputs valid
triggers.push(String("`" + element.trigger + "`"))
types.push(String("`" + element.triggertype.replace("word", "message").replace("join", "join/leave") + "`"))
tokens.push(String("`" + element.token + "`"))
files.push(String("`" + element.filename + "`"))
});
much better
first of all, switch forEach to a normal for call
okay
second, do you really need String()?
i just use it to test if it works
remove them
same error Cannot read property 'push' of undefined
i am trying with normal for
i mean, its causing memory leaks and my app crashes after an hour
โค๏ธ thx
A debugger is probably more reliable in this instance.
embed inline why is the last 
inline: false
max 3 per inline too
Go check that message on a mobile device and prepare to cry
ik ,bad for mobile user ๐
Exactly! >:D
Guys ฤฑ need help my music bot is not workng that always says u must ente a voice channel but ฤฑ was already in the voice channel why?
doesn't help if you don't provide your code.
const moment = require("moment");
require('moment-duration-format');
const ms = function(value){return moment.duration(value, "milliseconds").format("d[d] h[h] m[m]")}
``` When I parse the time with ms(value) . it gives me 8h 0m, how can I remove the 0?
7kb radio command ๐
lol, hmmm......nah no time to check 
im trying to play with numbers but 276497792526974996 == 276497792526975000...
how do i fix this
copying code and do not knowing, what the code means 
=== use this
thats just how js does numbers @shy turret, you can use strings tho
and use ""
"4568790675467890"
i want to detect if it's a valid snowflake
JavaScript numbers cannot be as large as snowflakes need to be so it has to be a string
is there a way to detect a valid snowflake?
other than length, and checking if the snowflake has a valid timestamp, i dont think so
its a combination of a few things
not just date
@quartz kindle why join and leave like that
accident
haha i suffer
any idea xD?
@solemn latch 
hihi
lol
Is this Discord or Web coding?
thats discord
i just use better discord
Better DIscord 
wanted to say 
I hope you know BD is against the discord terms of service, right?
wait what
as in, could potentially get you banned for using it
oop im deleting rn i rly didnt know
"Modifying the discord client" is against the ToS, and that's what betterdiscord does.
oh i didnt know im sorry ill change it rn

Best bet is to not do use inline fields
Can't have customizable spaces
should i just add an empty addfeild?
hmmm......
I doubt that will help
But, I mean
You'll have to use zero-width-space character for both field name and value for that
whats the !, did not ever see the ! as option
oh i wanted it to add an ! after the mention
i thought it would work
it'll add a crater to the embed
You'll have to do it via template strings instead
now this happens after adding emty field
whats that
you can't leave it empty
Template literals are string literals allowing embedded
expressions. You can use multi-line strings and string interpolation features with
them.
you gotta put two strings in it
.addField("He loved:" , target + "!", true)
or that
ok thx\
how would i keep staying motivated when i feel quite unmotivated
const embed = new MessageEmbed()
.setColor("GREEN")
.setFooter(message.guild.me.displayName, client.user.displayAvatarURL)
.setDescription("**Reactioneaza pentru a incepe jocul!**")
.setTimestamp();
const m = await message.channel.send(embed);
await m.clearReactions();
m.clearReactions is not a function
clearReaction was also changed in v12?
No
i dont remember clearReactions ever being a thing
it's actually .removeAll
yes alol
then i'm dumb xD
Ty
dosent work
I spoonfeed to much lol 
@earnest phoenix use this 
.addField("", "")
note, this WILL put a hole in your embed
that dosent add a line break, and it removes the mention as well
yes lol xD, imagine button for embeds 
button?
youcan use <@${target}>
inbuilt buttons embed, as a new feature, that would be insane
That's a planned feature
not embeds tho, they'll make a form-like feature
really , lol
and client-side messages
oh, 
are there already sneakpeaks ?
thx 
show full code
const Command = require('../Command.js');
const { MessageEmbed } = require('discord.js');
module.exports = class FindIdCommand extends Command {
constructor(client) {
super(client, {
name: 'love',
usage: 'love <user mention>',
description: 'Shows how much All About Ishaan loves you!',
type: client.types.OWNER,
ownerOnly: true,
examples: ['love @โฅยฐโขLexieโขยฐโฅ']
});
}
run(message, args) {
const target = this.getMemberFromMention(message, args[0])
if (!target)
return this.sendErrorMessage(message, 0, 'Please mention a user, role, or text channel');
const embed = new MessageEmbed()
.setTitle('All About Ishaan loved someone!')
.addField('He loved:', target, true,)
.addField('I hope he loves you forever! I am wishing you a wondeful day!', target, true)
.setImage('http://38.media.tumblr.com/9204649fd84d3df7223feb6712a89444/tumblr_n8pc8badUs1sg0ygjo1_500.gif')
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor(message.guild.me.displayHexColor);
message.channel.send(embed);
}
};
i want a link break between the two fields
true, that comma isn't needed I'm pretty certain
no clue
so there is no way to add a link break between fields
set inline to false
see my last image
wdym?
if you don't want them next to each other do "false"
ok
instead of true?
.addField('I hope he loves you forever! I am wishing you a wondeful day!', target, true) <-- false
for both
oh ok let me try
you can leave it out , default is false
ah good 2 no
.addField('I hope he loves you forever! I am wishing you a wondeful day!', target)
I always define true / false

I can remove some un needed words then in my own stuff
lol, thats use less code xD
ah, yes, seems legit
lol
OMG IT WORKED
THANKS SO MUCH
TIL gtranslate sucks at arabic


if (typeof options !== 'object') return Promise.reject(new TypeError('INVALID_TYPE', 'options', 'object', true));
^
TypeError [INVALID_TYPE]: Supplied options is not an object.
What does this mean ? ๐คจ
it means you didnt give it an object
message.members.permissions.has
is this correct?
message.member*
i bought a ovh vps but idk how to run 24/7 my bot there
use a process manager
Process manager?
manages processes
Like MobaXterm?
thats a terminal
How is everything with you guys in here I know I've been away for a couple of hours I'm just going over services policies
Ahh
what process manager should i use?
a terminal is used to connect to the vps and run commands on it
And how could I maintain the safety for the rest of you guys in here that's all just doing the right thing
a process manager is something that you can run with a command, and it keeps running even after you close the terminal
you what?
lmao wat
Oh ty
umm
hmm how xD it has been a lot time since i dd this
sudo npm i -g pm2
now it worked thank you
Yay now its hosted Thank you Kuu and Tim
its a good idea to read about pm2, theres a few things about it that knowing how it works helps.
for example, you must manually configure it for restarting automatically on reboot.
or auto restarting when you push new files to the folder
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Invalid Form Body
What could cause this ?
what`s your code?
wait
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
so i;m trying to make a report bug command, and the bot will send me the bug
what's up with that formatting?
ok
I'm a new bot developer, and am trying to access the names of all channels that the bot has access to in my testing server. I am using the discord.js interface, but cannot figure out how to list the names of the channels. I've looked up a few pages on the discord.js guide and some reddit / stackoverflow posts, but cannot figure this out.
Does anyone have any tips?
First you would need to get the guild object of your testing server
uhhh try looping over all the channels and checking if you have permissions in that channe;
*channel
you should able to get the channels of each type
like all text channels
and all voice channels
That was the last thing I checked, but it said that the channels were not iterable.
uhhh
i dont do JS i do py
but you could send that snippet?
wait
actually
found something
const Guild = await client.guilds.fetch("812507862030614538");
Guild.channels.forEach(channel => {
if(channel.permissionsFor(message.author).has('VIEW_CHANNEL')) listedChannels.push(channel.name);
});
message.channel.send(`You have access to: ${listedChannels.join(', ')}`);
``````txt
TypeError: Guild.channels.forEach is not a function
var textChats = message.guild.channels.cache
.filter((ch) => ch.type === 'text' && ch.topic === 'volturnbot')
.array()
try that
for you you can remove the message. I believe
guild.channels is a ChannelManager object, not the channel list itself
the actual list its accessible via the .cache property
guild.channels.cache
Ah
That worked
Thanks
I just started with js last night.
So this interface is very confusing to me.
just a tip: halt bot development and try to become more familiar with the language itself
I'm native to C++ and lua
ah cool
there are discord libs for both btw
if you're comfortable with c++, you could try getting straight into typescript
its kind of a javascript framework/superset with strict typing
that compiles to js
aka javascript but done right
non-typed was an error right from the start
Is there an introductory video to how TypeScript works somewhere?
I see.
Just looked it up.
On another note, are users cached to the bot's <client>.users.cache as soon as they join?
Or do I have to do something special here.
not exactly
recently discord applied new measures to protect users and members from bot scrapping
if you dont have the "guild members" nor the "presences" intents enabled in your developer portal, you will only see users after they interact with discord
offline and inactive users wont be available from the start
you can individually obtain them whenever you need them
but you cant obtain them in mass, you are limited to 100 members per request
if you have "presences" enabled in your dev portal, then you will additionally see all online members, even if innactive
and you will obtain them as they come online
I'm in my dev portal, where can I find intents?
if you have the "guild members" intent, then you will be able to get all members from a single guild at once
and optionally do it for all guilds at startup
should be under your "bot" section
privileged intents
found it, thanks
If I'm just using these intents to loop through members, would that be intensive?
yes
I see.
you need them all cached, aka downloaded, to be able to loop through them
they dont take up much space by themselves, but they quickly amount to a lot of memory when your bot joins a few large guilds
Is there a way to skip the caching, but still store the IDs of members to say a JSON file array?
you can do that yes
can I still interact with users without caching?
the fetch method allows you to prevent caching them
guild.members.fetch({cache:false})
if you dont specify an id, it will fetch all of them
you can find more info here
Ah, this fetch has different parameters than a user/channel fetch.
yup
So many things to learn lol. Time will tell I guess.
Thanks for the help, I definitely gained some insight here.
So many things to learn yes I'm coming to school here to advance in my coding and people skills
I would like to talk to some of you guys personally for tutor or not
I just signed up for classes myself and I'm looking for healthy and positive relationships during this growth in school
cool
What would be the best way to store data for getting top message sends and reacters in a channel
i would just have a counter for each user for each message sent, or reacted to, then just sort it
so say like I did
channelid, messagcount, reactcount, user
is that what you had in mind
yeah that works,
I would do a shared primary key(if your db supports it) between userid and channelid so you can have multiple of each
{
"channel_1": [
"user: {msgcnt, reactcnt}",
"user2: {msgcnt, reactcnt}",
],
"channel_2": []
}
what if I did something like that
json db? ๐
kinda sus tho
mongodb doesnt support composite keys? 
IM not gonna use mongo
oh i wasnt suggesting it
sql then?
yes
i just was looking it up out of curiosity
why tf u example a sql table with json?
idk
just use two tables then, one for user and one for channel, msgs and reactions
1 ----< N
compount keys in sql are a nono
since when ๐
since sql convention rules
channel: { messages: { aki: number }, reacts: { aki: number } }
can I do something like that
everyone seems to say its fine online
"Data should depend on the key, the whole key, and nothing but the key, so help me Codd"
which I think means BCNF 2 for "the whole key"
i forgot what this was called, but what's the function to make fiSheR into fisher
i think it was to lowercase
and can you do that to an arrya
array*
I guess it's only for strings?
I think you want MEMBER_ROLE_UPDATE
essentially, i have an array:
let array = ['Fishing Pole', 'Laptop']
then i check if args[0] includes any choices from array, but i want laptop to be acceptable
Or if you loop through the array
you could do array[i].toLowerCase() I guess?
But if my other code snippet works, good ๐
Wait, but lAptOp doesn't work
hmm
i want like any args they say to be lowercased
How are you checking if your word is in the array?
you could also do the other way around, make array = ['fishing pole', 'laptop'] and then check if it contains arg.toLowerCase()


