#development
1 messages · Page 989 of 1
i have now a MongoDB cluster running on 3 VPS servers. i can define to Write over the Master Node and Read only over the Secondary nodes
But like the 300MB ram is when it's on it's peak with 20 people doing commands at once
Oh I see
and this is still a basic setup
But ram shouldn't be a problem I have a full gig and can get more if I want to
iirc you can shard the nodes to read and write over mutiple nodes
I see
mysql can be sharded but with complex stuff
define nodes
not that i know
and never heard it
Cuz I've seen hosting services have multiple nodes
You get Mutiple VPS server that Communicate with each other
Oh yeah thats prob it
a different thing is it when you use Kubernetes
dont know what that is
a complete Overkill system for managing Mutiple Services on Mutiple servers
oh lol
bots like Mee6 use it for managing the Shards
oh
bcs they have a few thousand shards on mutiple servers
It does voice
the bot just got large enought to hit the limit
oh no i keep getting this error. I tried majking more bots and messing around with it and keep not working :(
discord js error [voice_connection_timeout]: connection not established within 15 seconds
Oh
Should I shard my bot before making it public? Or wait untill I maybe hit 2000 servers to then shard it?
Cuz sharding is required if you have like 2500 servers right?
wait until you hit 1800 then make plans about it
Alright
at 2000 start sharding
Alright
How do I make my internet faster
hi, i am making a warn command but i am getting this error that number is invalid. pls help
Get a better provider
or get a server
But will the music commands work for other ppl
Data @ ID: "warnings_720997710479491123_709293157279334431" IS NOT A number
@lusty spade you try to set a string as a number
IS NOT A number
but the amount = 1 also does not work
bcs it can get the 1 as a string
^^
so how do i fix it?
javascript can do 1+1 = 11
1 += 1
did you get the ID from a Database?
javascript can do 1+1 = 11
oh i didnt knew that
@woeful pollen if 1 is a string that will still result in 11
or did you want to save it to a database?
i want to save it
save it where
your field expects a number make it a string
to a database
mysql?
quick.db
Dont think thats mysql
idk never used quick.db
me neither
ah ok
does it uses mysql syntax or models
idk im not sure
db.fetch(`logchannel_${message.guild.id}`);
key and value
Yup
And somewhere you are adding a value that needs to be a number but you're passing a stringµ
this requires a table
ohh right @tulip ledge if you want to try mongodb i think you can get a free mongodb instance
mysql is fine but i think you will run into issues if you get a certain amount of Requests
I'm getting my own VPS soon so yeah
I'll see what happens
Those are concerns for later
I'm sure MySQL can hold up
sure but the most common way to scale a Mysql Database is getting more powerful hardware
larger companies run a 64 Core Epyc with a ton of ram for Mysql
you will be fine
but if you hit 2 million Guilds i dont think you can pay for the hardware you need for running Mysql
so if every of the 2 million guilds get about 2k users you have a shitton of data
It's only users that use a certain commands tho
And they get saved over 5 different tables
well there is some space for error
its sometimes better at that stage to write your own user objects that contain micro optimisations to save bytes per object
for example using an int for discriminator and storing user ids as bigint instead of strings
No
you'd only need that if you actually get to millions of users
I save the ID and then like 20 other columns
In 5 different tables
Maybe when I start sharding I should rewrite everything and use MongoDB
Or is that not a good idea
at small scale it doesnt really matter what you use, everything will be fine
small scale being less than 100k guilds or something like that
I wonder what database pokecord used
Quickdb
quickdb?
doubt it
i seriously doubt pokecord used quick.db lol
isnt it sqlite like?
Yeah no way he used duickdb
maybe mongo?
would guess Mongo, Mysql or Postgres
quick.db is a wrapper for sqlite
Isnt mongo worse then mysql?
¯_(ツ)_/¯
Which one does dank memer use?
mongodb is faster
postgres is the fastest db right?
mongo is not worse, its different
atleast if you have a setup for this
mongo is nice as you can edit/see changes
What's bad about quickdb
so you see if its working correctly
i use mongo its not bad
it stores locally and it has a rescource overhead
Oh
there is no clear cut between best/fastest databases, they are all equally good, and have their own pros and cons
what changes is how they are structured
So MySQL is bad when you have too much data?
not necessarily
What's bad about quickdb
@woeful pollen can get corrupted if your bot is in lot of servers
Oh really
MongoDB makes it easyer to shard the database
Frick
yea
And sharding the database is the best idea?
once again depends
But the thing is I don't save guilds, I save users
if you have alot of Bot Shards it can speed up querys for each bot shard
My bot is an RPG style game bot
since it can get its own Database Shard
yeah but shards is for guilds right
Not for users
Since a user can use the bot in multiple guilds
the reason to go for mongo is not the sharding or replication, is the database style
mongo is a nosql document-based store
I use MySQL since it's what my dad thought me a few years ago
And have always used it
you need to read about the differences in how databases operate, in order to chose one
mysql is fine, nothing wrong with it
mongodb is not magically better than mysql
So even with alot of data?
i currently switch from Mysql to MongoDB, the differences are there and for now l like it. Having a better fallback for the database.
even with a lot of data
And when I'm saying alot I mean ALOT
even sqlite can handle thousands of requests per second
MongoDB's scaleable, cloud-first architecture and transactional capabilities make it a viable option to replace MySQL, a legacy relational database.
Oh yeah I doubt I'm gonnaa need to handle a thousand per second
this is maybe helpful
which one do u use @quartz kindle ?
Doesn't JSON corrupt easily?
i use sqlite
@tulip ledge json-like doesnt mean json
it looks like json
mongodb uses document structures, which means all data is stored in a similar way to how a json file is organized, in objects, keys, values and nesting
mysql uses relational tables, which is the whole tables and columns setup
oh
And actually I prefer tables and columns
so stick with it
depending on the usage the document style can be faster than the relational tables
no reason to switch
with phpmyadmin I can easily access them and get an easy overview
i use mysqlworkbench
ew I hate workbench
phpmyadmin got a few security flaws
I use either command line or phpmyadmin
mongo is easy to use
mysqlworkbench is fine
mysql too if you know SQL
but MongoDB Compass is cleaner
and sql is literally just english
i tried mongo once and didnt really like it, but thats just personal preference
So you should choose your database on personal preference mostly?
all comes down to personal preference
i use mongoDB atlas
I use quickdb because I was unable to use any of the other databases
if you first step into mongo it can be overwhelming but if you get your structure going its relatively easy to use
I feel like it's the same with mysql aswell
@calm saddle i build my own MongoDB cluster
oh
big brain plays
i use one cluster in 2 diff bots
Alright ty very much!
i can access each other too
i have a dedicated sqlite instance for each bot
i pay 15€/Month for having 3 Nodes with 1GB ram
its enought for a few bots accessing it
i use free
i pay $3/month for everything
M0
im okay with the free M0 cluster
wtf did i write there
sleeping 2 hours is not a good idea
go sleep
its 13:40 for me
rip
Paid is cheaper than free
wow he knows the secrets of the universe lmao
@calm saddle does the free Cluster offers Replication?
Hey so I'm trying to make functions but how can i make them like this
"hey".toProperCase()
instead of
toProperCase("hey")?
oops wrong servre
Lol
Lol
lol
@calm saddle does the free Cluster offers Replication?
@lusty quest wut?
SQL can be quite easily scaled with k8s and stateful sets
infact kubernetes use MySQL as their example for user cases
So this is my toProperCase() function i made but how can i make it "String".toProperCase() instead of toProperCase("String")
let sptp = [];
for(w of string.toString().split(" ")){
for(wts of w.split("")[0]){
sptp.push(`${wts.toUpperCase()}${w.slice(1)}`);
}
}
return sptp.join(" ");
}```
@calm saddle my Cluster Replicates the Data on the Master Node to 2 Secondary nodes. If the masternode goes offline a Secondary Node gets elected as master node
@earnest phoenix you can add it to the string prototype
Attach it to the prototype
String.prototype.functionName = function() {
}
if the offline Master Nodes Comes back online it stays as a Secondary node
and replicates the data that is missing
@calm saddle my Cluster Replicates the Data on the Master Node to 2 Secondary nodes. Of the masternode goes offline a Secondary Node gets elected as master node
@lusty quest wait hold up lemme get some more brain cells to understand that lmao
did you know what Raid is?
@earnest phoenix here's an example
Oh... Thanks
@calm saddle https://docs.mongodb.com/manual/replication/
@calm saddle basically it means this:
you have 2 copies of the database, a main copy and a backup copy. everything the main database does, its copy makes a copy of it. if the main database dies, the backup automatically takes its place
and when the main database revives, it gets revived as a copy instead and now copies everything the new main database (the one that took its place) does and did while it was offline
it supports gif, png, jpg and webp
https://i.imgur.com/55kUYIS.png but this is what happens incase the master node goes offline
@quartz kindle it works but is this good?
let sptp = [];
for(w of this.toString().split(" ")){
for(wts of w.split("")[0]){
sptp.push(`${wts.toUpperCase()}${w.slice(1)}`);
}
}
return sptp.join(" ");
}```
Are you trying to capitalize a string?
can i have some help with image resizing for embed thumbnails?
code:
.setThumbnail(song.url({dynamic: true, size: 1012}))
its says that 'url is not a function'
you shouldnt need this.toString() since this is already a string
Trying to uppercase every single first letter of the words in the string @hasty sparrow
there are easier ways to do that
@calm saddle basically it means this:
you have 2 copies of the database, a main copy and a backup copy. everything the main database does, its copy makes a copy of it. if the main database dies, the backup automatically takes its place
@quartz kindle ooohh okay thnx for the knowledge
also, how do you want to handle multiple spaces?
Gotcha
you can simply do something like this btw
return this.split(" ").map(word => word[0].toUpperCase() + word.slice(1)).join(" ")
that should leave multiple spaces unaffected
otherwise you can use the regex / +/ instead of " " when splitting if you want multiple spaces to be reduced to a single space
Oh well it works better now, thanks tim and thanks to all that helped
Anybody know what's wrong here?
let can = 1;
return this.map(e => ${can++} + e);
}
["Something", "Another thing"].toCountArray()```
=>
`can't read the property 'toCountArray' of undefined`
Array.prototype is undefined
But how's it undefined tho
Idk
Wait no
["Something", "Another thing"] is undefined
You can see what line gives the error in the console
Then you'll see wich one is undefined
It doesn't... I'm using eval
oh
Lemme try something
Hi there, I am trying to use nodemon like pm2 so I can exit the cli and have it still running. Is there anyway to do this?
like
nodemon can't do that
oh
use both of them
Wtf?
use both of them
@restive furnace what lol
@tulip ledge try ` before and after ${can++}
@earnest phoenix EH????
pm2 start nodemon index.js
Lol
prob would work
Send code
No
No I don't need the editing stuff
I just wanted a good alternative to pm2 that's all
is there any that u could recommend
I just wanted to use chalk colours with something
Oh... So it doesn't accept direct arrays... It only accepts arrays from a variable
Why tho
idk
any idea how to have this behaving non caching? javascript bot.guilds.cache.size
Does someone know a tutorial for recording audio on a voice channel ?
@jovial nexus https://discordjs.guide/voice/receiving-audio.html
https://lumap.is-inside.me/nrShh4Lm.png I have no idea what i did wrong (the role id is valid, the role has admin perms. im using d.js v12)
FLAGS is a static member afaik
ok, so I have this bot that seems to have completely crashed. The web host shows a spike in cpu and ram (upto around 50% cpu at the time of crash), and the bot was not online in my guild at all, the bot seemed to reboot itself and come back online in the server, and it thinks its been online for over 5 hours
anyone got any idea what may have caused such a thing to happen?
memory leak?
check logs
discord gateway went fucking crazy
is it possible my bot somehow only went offline for certain servers?
logs show nothing abnormal
yes it is
Discord was returning 500 the other day
is it possible my bot somehow only went offline for certain servers?
@neat ingot if you shard then yes
FLAGS is a static member afaik
@cinder patio ?
only single shard atm
less than 120 servers too lol
Could have been a discord thing
FLAGS is a static member, meaning it's accessed from the class itself, not an instance of the class
so like,
const Discord = require("discord.js");
console.log(Discord.Permissions.FLAGS); // SHould return an object
Wait no, that wouldn't work cause Permissions isn't exported
any idea to get this in a non caching way? bot.guilds.cache.size
use a different lib 😄
Lol
Does anyone know why this is giving me errors
module not found
Is ber an npm?
index.js at line 6
There is nothing on line 6
you request /ber/index somewhere
is the path correct?
its possible that you need ../ber/index
^
Oh, where do I add that
the file where you request /ber/index
In the pathway?
you have somewhere require("./ber/index")
require*
where is this located? I cant find it
(node:7488) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined fix?
code const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
im not sure if guild.members is a manager
Yeah?
try without cache
@marble scaffold you wrote the code. you should know where you import a module
It's in the node_modules?
no the file you want to load
Yeah by using terminal
watch this https://www.youtube.com/watch?v=fBNz5xF-Kx4
In this crash course we will explore Node.js fundamentals including modules such as path, url, fs, events and we will create an HTTP server from scratch without Express and deploy to Heroku.
Watch Next: Express Crash Course:
https://www.youtube.com/watch?v=L72fhGm1tfE
Sponso...
thats actually basic filesystem knowledge
hmm I know now
Hi there, not sure if this is relevant but I am gonna ask, could I use ngrok as an alternative to a static IP like have it tunnel to my IP? Would that work?
How can I make the event if the bot cannot find the message with the ID I specified?
I need > if the message is deleted or not found
if(!message.channel.messages.fetch(id)) does not work and gives unknown message error (i'm using V12)
.catch?
@golden condor are you trying to mask your ip for a website or something? Or what are you trying to do?
Well
My ip is dynamic you see
I use cloudflare so the ip is hidden anyway
i just want try and use my rpi for hosting something
and ngrok seemed like it might work
Dynamic dns services might be what your looking for
res.render("index", { client: client });
})```
When I use client object then console show error
try removing the .ejs not sure if that'd change anything but
¯_(ツ)_/¯
@robust moth ^
Ok
it won't
How can I fixed it?
client.on('message', message => {
if (message.content === `${prefix}start sobble`) {
message.channel.send(new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('You chose Sobble!')
.setDescription(`Take good care of Sobble.`)
.setImage('./commands/816MS.png/'({ dynamic: true, size: 2048, format: 'png' }))
)}
});
i get that
can anyone help?
It's not a function.
Attachfiles?
use attachFiles()
plus MessageAttachment
embed.attachFiles(new Discord.MessageAttachment("./commands/file.png", "example.png"))
.setImage("attachment://example.png");```
oh wait i think you can directly use MessageAttachment to setImage()
anyway, something like that
let attach = new Discord.Attachment(message.author.avatarURL,"asdad.png")
embed.attachFiles(attach)
return embed.setImage('attachment://asdad.png')
}``` This can work?
So, it will work?
attachFiles takes an array
how do we get this array?
{"674275671878402063":{"bump":2,"author":"363402633752477696","link":"https://discord.gg/","bumpauthor":["363402633752477696","363402633752477696"]}}```
```js
if(!bump[message.guild.id].bumpauthor.includes(message.author.id)){
bump[message.guild.id].bumpauthor.push(message.author.id)
}```
looks correct
how do i make it so when i write .start sobble it also adds sobble to my mons.json file?
you need to add it to the object then write it to the file with fs.writeFile
oh idk how i'm new to json
did you read the json file in your code yet?
also why theres 2 message listeners?
ow i did that for nothing .. i didn't understand what you wanted xD
client.on('message', message => {
let args = message.content.split(" ").slice(1)
if (message.content.startsWith(prefix + "start")) {
if (args[0] === "sobble") {
....
} else {
...
}
}
})```
or you just made a json file and not do anything with it?
With sharding, how can you easily post stats to the top.gg page? With an interval manually getting the guild size and posting that one? Or is there a better option?
but I can't use the autoposter?
yeah you can also post shard stats, you're right
okay thanks. I will check the modules really quick and see
I was testing something with my bot and my bots saying I didnt mention someone but my bot should say I cant kick without a reason, can someone help
is that user in your server?
the code for the reason is
Defined Args: let args = message.content.substring(prefix.length).split(" ");
Reason: const reason = args.slice(2).join(" ");
If no reason:
if (!reason)
return message.channel.send(
`**error** You can't ban ${user} without a reason!`
);```
yes the user is on my server
your on discordjs?
yea
const Command = require('../../Structures/Command')
const { MessageEmbed } = require('discord.js')
module.exports = class extends Command {
constructor(...args) {
super(...args, {
aliases: ['snip'],
category: 'Moderation'
})
}
async run(message, args) {
const msg = this.client.snipes.get(message.channel.id)
if(!msg) message.reply(":x: there arent any recently deleted messages for me to show you")
const embed = new MessageEmbed()
.setAuthor(msg.author)
.setDescription(msg.content)
if(msg.image)embed.setImage(msg.image)
message.channel.send(embed)
}
}```when i do -snipe i get this error
oh apparently the user left when I had the mention .-.
(node:6468) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'author' of undefined
at module.exports.run (C:\Users\kenra\Desktop\Frosty Rewrite\src\commands\Moderation\Snipe.js:15:24)
at FrostyClient.<anonymous> (C:\Users\kenra\Desktop\Frosty Rewrite\src\Structures\FrostyClient.js:42:13)
message.mentions.members.first() @still merlin
I have that
just the user left quickly when they saw the backfire .-.
@restive furnace it doesn't seem like it's getting the guild size from all shards:
async postStats(serverCount, shardId, shardCount) {
if (!serverCount && !this.client) throw new Error('postStats requires 1 argument');
const data = {};
if (serverCount) {
data.server_count = serverCount;
data.shard_id = shardId;
data.shard_count = shardCount;
} else {
data.server_count = this.client.guilds.size || this.client.guilds.cache.size;
if (this.client.shard && this.client.shard.count) {
if (this.client.shard.ids && this.client.shard.ids.length === 1 && this.client.shard.count > 1) {
data.shard_id = this.client.shard.ids[0];
} else {
data.shard_id = this.client.shard.id;
}
data.shard_count = this.client.shard.count;
} else if (this.client.shards && this.client.shards.size !== 1) {
data.shard_count = this.client.shards.size;
}
}
const response = await this._request('post', 'bots/stats', data, true);
return response.body;
}```
It's only setting the server_count to the one you gave it or client.guilds(.cache).size
@hardy vector which line in the provided code?
.setAuthor(msg.author) this returns the error
wait what
thats line 15
you're passing message but using msg
no look closer
what is client.snipes
client.snipes = new Map()
client.on('messageDelete', function(message, channel) {
client.snipes.set(message.channel.id, {
content: message.content,
author: message.author.username,
image: message.attachments.first()
})
})```
in my main file ^
why are you doing that?
you're storing the last message of each channel
oh no nvm it's the messageDelete event
lol idk that bot really well 😂
which is why i never invite dank memer anywhere
what does the command do?
bruh
its really terrible
that's not how message deletion works
it grabs it from a cache
like client.snipes
yeah but still. If I'm deleting my message I don't want it to be visible for any user by a bot
people really like it
lots of bots do it lol
bruh
ive seen people delete a message with a password, and then someone snipes it
and then no mods delete it
lmao
see that's what I mean lol
what should be fixed then?
most logging bots still log deleted messages in log channels anyway
yeah but most log channels are staff only (afaik)
^ that also imo should be opt in by each user
wait but how do i fix then
@hardy vector anyway whats the issue again?
is it because of this.client?
wouldnt it be message.client?
uh my cmd handler needs this infront of stuff
ok im back
i think it does
woo, its because he's using classes
so can i not use that cmd then
the problem is that you dont return when there is no message
so the code continues even if there is no message
but if there is no message it tells them it couldnt find any recently deleted messages
yes, but continues the code anyway
hi, im making a unban command. But there is a problem everytime i run the command i runs perfectly the message output shows that the banned user was unbanned but it does not unban the user and it gives me a error.
fetchBans() returns all bans, you can use fetchBan() instead to only get one and not need to bans.get(args[0])
anyway, the ban object contains a user and a reason. you need to pass the user to the unban method, not the ban object
ie: .unban(banned.user)
oh ok thanks for the explaination
now when i delete a picture and try to snipe it, it gives me this error (node:5028) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.image.url: Could not interpret "{'attachment': 'https://cdn.discordapp.com/attachments/724469899413553213/725384172335530015/pixel.jpg', 'name': 'pixel.jpg', 'id': '725384172335530015', 'size': 9592, 'url': 'https://cdn.discordapp.com/attachments/724469899413553213/725384172335530015/pixel.jpg', 'proxyURL': 'https://media.discordapp.net/attachments/724469899413553213/725384172335530015/pixel.jpg', 'height': 620, 'width': 620}" as string.
is it possible for me to show the image that they deleted
or no
you 're saving the entire attachment and giving it to setImage
you need only the url
Is it possible to update a bot while having the node process active and 0 interruptions? 🤔 I don't think so but there's some smart people out here.
it is
if your code is based on required files, you can invalidate the require cache and force it to re-require said files
Ohhh wait so i can actually make it refresh basically.
yup, thats how many bots implement command refresh commands
Thank you a lot.
I have a restart command.
since my bot is mainly games, theres a 3 minute no new games from when the restart command was run, and then it restarts.
so no ones game gets lost.
I need to do the same for refreshing commands i just havent yet
due to lazyness
How do I make a bot restart command in eval? Last time I destroyed the client then logged back on but it didn't work:
bot.destroy().then(() => bot.login(token))
you could possibly try that, or just await it
client.destroy() just logs out, doesnt end the process
you could possibly try that, or just await it
Didn't work last time
if you want a full restart, you need process.exit()
Ooooooo
not sure, i haven't had a reason to have a restart command so i don't really know 
^:)
tim, i used ur method and did fetchBan() and change it to .unban(banned.user) but im still getting this error: https://pastebin.com/3cin5HYH
or if you just want release the cache, just set client to null and create new one :DD
I literally wanna log out then log back in-
whats your code now zhon
wait, was the error that token didnt exist? @pure lion ?
Nope
my code: https://pastebin.com/gCCMibSq

@lusty spade you need to give fetchBan() the id of the user
so it knows which ban to fetch
so i need to place the banned user's id in the brackets?
ok
is there a way to do unban few users without going in to the code and changing the user id?
@solemn latch yeah, request to use token but it was unavailable
theres no way to unban multiple users at once, but you can make your code call members.unban() multiple times
either from a list of ids, or from a list of bans
You'd have to get the token from the configuration file I would think
Hello
oh ok thanks, so i can log banned members into a db then get the members id from the db
sure
I can help too I am not a pro but I can help
ok thanks
Btw hi Dice and Woo
You'd have to get the token from the configuration file I would think
Where? bot.destroy?
Oh hey
Uh
use a database
What's a database?
Store items as IDs and use a db
Sorry I am still noob
Uh
Idk, never used quickdb
anyone here can shard in discord.js?
Use discord.js in built sharding manager i guess
can i show you something?
sharding is a method to split processes into multiple smaller processes to handle guilds
runs as flash cause cknat understand a fuck
it is required after 2.5k servers before your bot no longer works (aka doesnt login properly)
comes with Burger,Fries and Soda
i am sharding?
please stop roleplaying
Idk if you are
you could also simply be posting console.log('Shard 0 launched') 
but by the looks of it, perhaps?
Do you guys know why this would not make a square but a square like that?
ctx.moveTo(255, 150);
ctx.lineTo(295, 150);
ctx.lineTo(255, 195);
ctx.moveTo(255, 195);
ctx.lineTo(295, 195);
ctx.moveTo(295, 150);
ctx.lineTo(295, 195);
ctx.stroke();
ctx.closePath();```
you want to make a square?
Yea
then do 4 lineTo's
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./index.js', {
totalShards: 'auto',
token: process.env.token
});
manager.spawn();
manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));
here
Confused
moveTo(255,150); lineTo(295,150); lineTo(295,195); lineTo(255,195); lineTo(255,150)
like
@earnest phoenix yes that will shard automatically when needed
congrats
if you need to
hi
@quartz kindle that worked but so like... I don't need to use moveTo() many times?
TypeError: Cannot read property 'execute' of undefined
why am i getting this error
module.exports = {
name: 'math',
description: "used to perform mathematical operations",
cooldown: 0.01,
execute: (message, args) => {
}
}```
looks normal to me
Are you sure it's coming from there?
its happening when ido that command so
@earnest phoenix you didn't have to use moveto because when you were drawing the line, you were also "moving" the "pen" or the "dot"
if that makes sense
Oh i see
even my index.js looks normal
case 'math':
bot.commands.get('math').execute(message, args);
break;
That's where it comes from
but its normal
It usually says what line its on, you might wanna double check
It can't get the command
are you caching bot.commands properly?
try logging bot.commands and bot.commands.get('math') i guess
let operation = args[1];
if (!args[1])
return message.channel.send("Enter the operation to be performed")
if (args[1] === "add") {
let a = args[2];
let b = args[3];
if (!args[2])
return message.channel.send("Enter the 2 values.");
if (!args[3])
return message.channel.send(
"Enter the 2 values like this: `t!math add 10 3`"
);
if (args[2] && args[3]) {
var valueOne = parseInt(args[2]);
var valueTwo = parseInt(args[3]);
var valueAnswer = Math.floor(valueOne % valueTwo);
message.channel.send(
`The sum of ${valueOne} + ${valueTwo} is equal to ${valueAnswer}`
);
}
}```
is this correct
for v12
The command itself is tnot the issue
What you're having isn't the function itself
what function
its that it cant even find the command file / cached command object properly in the first place
the execute function you created

module.exports = {
name: 'math',
description: "used to perform mathematical operations",
cooldown: 0.01,
execute: (message, args) => {
suuuuuuuuuuuuuup
The issue is your CACHE doesn't HAVE THIS IN IT
module.exports = {
name: 'math',
description: "used to perform mathematical operations",
cooldown: 0.01,
execute: (message, args) => {
let operation = args[1];
if (!args[1])
return message.channel.send("Enter the operation to be performed")
if (args[1] === "add") {
let a = args[2];
let b = args[3];
if (!args[2])
return message.channel.send("Enter the 2 values.");
if (!args[3])
return message.channel.send(
"Enter the 2 values like this: `t!math add 10 3`"
);
if (args[2] && args[3]) {
var valueOne = parseInt(args[2]);
var valueTwo = parseInt(args[3]);
var valueAnswer = Math.floor(valueOne % valueTwo);
message.channel.send(
`The sum of ${valueOne} + ${valueTwo} is equal to ${valueAnswer}`
);
}
}
It doesn't have tHIS ENTIRE OBJECT CACHED IN IT
Not the OBJECT'S execute FUNCTION
so i wanna change the size of an image from a url, any ideas?
.setThumbnail(song.url({dynamic: true, size: 1012}))
wdym wdym
its saying url isnt a function
I'm not saying that <command>.execute() isn't defined
What is song
I'm saying <commandFile> isn't defined
bruh it is
all the other commands are working
but
aka its not cached properly
🤔
other commands are working
It doesn't matter whether all the other ones are working.
wat
'math' is obviously not fetching from your cache properly
What is
song
its the youtube video audio it downloaded to play, it can send the image but its too high res for some reason
That's why I told you to try console logging bot.commands.get('math')
and bot.commands
ok
and making sure the response has one key: value where the key is exactly "math"
case 'math':
bot.commands.get('math').execute(message, args);
break;
console.log(bot.commands.get('math').execute(message, args))
this is what i did
you're still helping him or her?
and nothing is logging
:0
thats because you already ended the switch case
how do i make it so when i write .start sobble it also adds sobble to my mons.json file?
:')
oh
Why are you adding a switch case for each command when you could just save the .get to a variable and see if it exists
What type of food do you want in your mouth
lmao
how do i make it so when i write .start sobble it also adds sobble to my mons.json file?
help
xD
@long yew slice up the message response using args to figure out what they typed, make sure they chose one of the three valid responses, then if they did, add it to your db
if you dont understand what i said google "js string methods" <- this will help you be able to learn how to figure out what they typed by slicing
and stop spammin gthe channelw ith your question
@long yew but why 2 message listeners??
how do i make it so when i write
.start sobbleit also adds sobble to my mons.json file?
@long yew dude im right here-
ok i messed something up somehow
@long yew but why 2
messagelisteners??
I was trying to explain this in dm um
and stop putting multiple message listeners for one purpose, you're upping your CPU n other resources for no reason
nothing is logging
no way you use message listeners for every command
@restive furnace idk
and im getting the error again
@pure lion dm
kk
its annoying to dm ppl with help but ok
@vale garden literally copy and paste
console.log(bot.commands)
and search through the log for a key that says math
Put it after(programatically) where you require all your commands, but above the erroring line
'math' => {
name: 'math',
description: 'used to perform mathematical operations',
cooldown: 0.01,
execute: [Function: execute]
im getting this
And that's your only command?
Then there's a problem
its not

its not my only one
It should log all your commands

@vale garden oh not sure why its not working then
try console.log(bot.commands.get('math')) and see if execute is also defined in that case
What does the command handler look like.
his status is a downer
i dont know how to use the dbl api thing to get server cout
count
you mean post server count?
yeah like on top.gg
move to #topgg-api
ill help there
ok
ok, hi so i have a little problem on the heroku thing, i hosted my bot, but is this problem, i think you all know it the problem when heroku cant "write" json files, i saw some sites where it says __ dirname casue on heroku the path is dif that the one on the laptop,
my question, after i do the __ dirname thing, will be anything else to do?
- I do not use heroku so my answer can be wrong
- No, I did not know the problem about heroku because I do not use heroku
- __dirname only returns the directory path iirc, could be wrong
rephrasing your question would help
also Heroku can't update json files in realtime
- if you're using json for a database, it's a terrible idea
@spare goblet what do you use?
any real database
um i use mysql
but you can use any "real" db ig
that isn't hosted on the same machine*
just anything thats not a local file
yh so mongodb is the option
I use DO, but any host usually works lol 
sqlite is also hosted on the same machine, very terrible for anything larger than like 1k servers lol
um well if they dont wanna use mongo there are also other options
1 i understand the database thing
i can swich is not a problem
but for me to be more easier i got json files
what was my problem
whats DO 
was how to make heroku
well if Auric is correct, even if your bot is in 1 server and you really want to use file database, it will notwork because of heroku's nature
digitalocean
paid?
no decent vps is free lol
if ur a student, u can get dg for free
so no one knows the answer cool
my bot's scale is way too large for a free host :')
nice help
via github tho
you CAN'T use heroku to edit files real time

yes mangodb
we all love mangoes 
mongodb*
yep
no mangodb
stop getting it wrong
smh
me getting bullied cool
ok
thanks
cya
not really bullying
but ok
take a joke 
^
^^
^^^
O_O
supcanihavesomehelpuwu
what do u need
me want to resize image so its lower resolution (from a url) but it no work (for context, song.url returns a url string for a youtube thumbnail)
.setThumbnail(song.url({dynamic: true, size: 1012}))
grr you didn't space it out <--- ignore that
it doesn't always work when resizing, its kinda weird, you're gonn have to get the right number, and use png if you're not already
use 1024
eh?
u can change it in ur clients options, but if u dont wanna do that u can just use replace
ookay
Hello
so in this server.. it has 110k.
and my bot says that it moderates only 19k from here.
caching
does anyone know the reason for this?
hm..
this is my code..
```bot.user.setActivity(`${bot.users.cache.size} members! || a!help````
how should it be?
you should use the .reduce and guild.memberCount
memberCount is the real member count
though they won't be unique
hm.. can you tell me the code that would be inside ${}
if you really want a precise user count, you would need to fetch all users
that option should be in the client options
refer docs
personally, i would say it's not worth it because of memory and stuff but if you still insist
hm.
sorry to ask.. as Im beginner
what would cache effect.. what would cache do if you include it?
your bot already caches members, just not all of them, only the ones that are online etc.
client.users.cache.size is the amount of users the bot cached, which is not an exact amount since not all users are cached
if you don't cache anything, you would need to fetch the member every time you need to see their info, which is a pain. this is where caching comes to action
if you decide to cache all users, it would take quite a bit of your memory to store all users
Hm.. okay!
if you still want to cache all users (to get the exact amount of users the bot serves), enable the "cache all users" in the client options
it could be called members instead of users
in the future, i belive that will be considered a privlaged intent
Does anyone know why im getting this error?
break doesnt make any sense right there
Remove the break at there.
but wont that make the rest of my code apart of my eval command? (below it)
return is how to stop a function, but you dont even need that there
the first if statement already handles that
ok
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=memberCount
@feral aspen
you can go through each guild, get the member count property and add them all together.
this will duplicate users(if your bot is in 2 guilds, and the same member is in both guilds, he gets counted twice)
more "space"?
woops
that's what i was referring, but yeah, duplicates
I meant memory
you can use the reduce function for that and no, it doesn't take memory
well, no. only caching every user does that
you can reduce member count?
oh duh
nvm
ignore that, i was thinking something else

😐
reduce is the right way

hm..
so what do i replace in here?
bot.user.setActivity(`${???????????????} members! || a!help
it was like that from before
```bot.user.setActivity(`${bot.users.cache.size} members! || a!help````
replace guilds with your client's guilds
it would be client.guilds
i think that's all
```bot.user.setActivity(`${bot.guilds.reduce((prev, next) => prev.memberCount + next.memberCount)} members! || a!help````
like that??????
🤦♂️
only one way to find out
probably
guilds.cache*
yep
guilds are already all cached
Ill try out now.
kind feel sluggish since it's 2am
:0
for me its 10PM
crazy
hello other side of the world

its saying Watching NON members..! 🤯
s a n d e r r
NaN
nan?
Yes./
could it be because some guilds don't have memberCount?


