#development
1 messages · Page 930 of 1
🤦♂️
if he was using v11, the error would be cant read size of undefined
not guilds of undefined
Lol
he went the PHP way
@earnest phoenix you need to do string concatenation
do you know what that is?
for example
if you do js a = "abc" b = "zyx" then you can do a + b to get "abcxyz"
similarly, you can also do "abc" + b to get "abcxyz"
but you cannot do "abc".b which is what you tried to do
also, you put it in the wrong place
what is this php?
you have to add it to the "help" not to the watching type
`${//guild size}` works too
is > a common prefix
yes
at this point i believe all single digits are common
is # a common prefix ;-;
Æ is not common too
ẗ̶́͝h̸̋̓i̴͒̽s̴̏̂ is also not a common prefix i reckon
@ would be a nice prefix
Just use the bots mention tag 
hello sir, this not offtopic 
nice meme channel we got here 😂
@earnest phoenix what do you mean
you deleted it
I am trying to set up an ev command for a test bot, but I can not figure it out 😦 something doesnt really work, no matter what I try.
if(command === "ewv") {
if(!message.channel.id == "id")return;
else{
try {
if(toEval) {
const toEval = args.join(" ");
let evaluated = eval(toEval)
let embed = new RichEmbed()
.setTitle("eval")
.addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format:"js"})}\n\`\`\``)
.addField("Evaluated", evaluated)
.addField("Type of:", typeof(evaluated));
message.channel.send(embed);
}
} catch(error) {
message.channel.send({embed: {
color: 15158332,
title: "Evaluation Cancelled",
description: `${error}`,
author: {
name: message.author.username,
icon_url: message.author.avatarURL
},
timestamp: new Date()
}});
}
}}
this doesnt work for some reasons.
here what the chat gives me. I tried some stuff, but yeah.
i wouldnt put ` inside each other, even escaped, usually causes headaches
just do "```js\n" + beaufity() + "```"
you can also get the full stack trace if you use error.stack
ah, thanks! I ll try that
check the docs
what's so hard about checking the docs
People forget they exist and just ask as they expect everything to be spoonfed.
I found a way to solve that beautify problem, I use prettyJs now
but I still can not send messages.
hmm
if(command === "ev") {
if(!message.channel.id == "id")return;
else{
try {
let toEval = args.join(" ");
let evaluated = eval(toEval)
let embed = new Discord.MessageEmbed()
.setTitle("eval")
.addField("To evaluate:", `${prettyJs(args.join(" "), { format: "js" })}`)
.addField("Evalauted", evaluated)
.addField("Type of:", typeof(evaluated));
message.channel.send(embed);
} catch(error) {
message.channel.send({embed: {
color: 15158332,
title: "Evaluation Cancelled",
description: `${error}`,
author: {
name: message.author.username,
icon_url: message.author.avatarURL
},
timestamp: new Date()
}});
}
}}
no error
it won't solve your error, but it says evalauted now
xD
yeah
@quartz kindle no I can not
it says: toEval is not defined
when I do that
what if you do ?ev (() => toEval)()
xd
xd
How do I make canvas as a gif?
Code it
canvas does not support gif
Hi guys
getting the error js (node:24900) UnhandledPromiseRejectionWarning: Error [BAN_RESOLVE_ID]: Couldn't resolve the user ID to ban.
with the code js const memberId = args[0]; const reasons = args.slice(1).join('') client.guilds.cache.forEach(async guild => { await guild.members.ban({ memberId, reason: `${reasons}` }); });
Is memberId valid?
meaning is it a real discord account?
how would i do a latency check command in discord.js v12
websocket or rest?
idk
meaning is it a real discord account?
@frail ocean cough cough sorry for the ping cough cough
websocket = client.ws.ping
for rest you need to compare the time it takes for a request to finish
for example ```js
let time = Date.now()
let msg = await message.channel.send("bla");
await msg.edit(time taken: ${Date.now() - time}ms)
see edit
await only valis in a async funtion
@next mica well of course, make it a command
i fixed it
@willow wraith using a different library to handle the frames
How do I do it then
How then he did it @fast trench
@willow wraith idfk...did I do it? lmao
async function kickCommand() {
if (message.content.startsWith('.kick')) {
// get the first mention
const member = message.mentions.members.first()
// check if the command author has permission to kick people
if (message.member.hasPermission('KICK_MEMBERS')) {
try {
// kick him/her!
const kickedMember = await member.kick()
// tell the message author that this member was kicked
message.channel.send(`:wave: ${kickedMember.displayName} has been successfully kicked.`)
} catch (e) {
// handle the error
message.channel.send(`Failed to kick the member due to ${e.message}`)
}
} else {
message.channel.send(`You don't have the permission to kick people.`)
}
}
}
doesn't do anything when I do .kick [Insert random person]
how can i make it when some runs a command it detects it eithe as captial or non captial letters
All of a sudden, my (tester) bot doesn't fire all events, what am I doing wrong?
client.on('guildMemberRemove', async (member) => {
console.log(member.user.tag);
});```
ow nvm I see what this idiot did
@next mica compare their text with their message.content.toUpperCase(). If that's true, you know they used caps
if that's what you mean
you mean the PING command only gets executed when they send PING, not ping?
like that
So you want it to be caps sensitive? If so somewhere you either got toLowerCase() or toUpperCase(), remove that and it should work.
^
i dont have that
then it's already case sensitive
ohhh
compare their content toLowerCase() with your command name
So if you don't want it to be caps sensitive, do:
var command = message.content.toLowerCase()
And instead of message.content you do command
where do i put the car
client.on('message' , function(message){
if(message.content === '[p]test'){
message.author.send('Just testing my personal message ability');
}
});
in a garage
var
then it would detect both ways
Then it wouldn'tmatter if you did:
[p]test
[p]TesT
[p]TEST
[p]tEsT
so do i do message.command
Anything like that it'd be fine.
so say I have a reward, which is 1. I have 5 users, each with 10, 20, 25, 5, and 40 respectively. How do I convert it into a percentage of global values and split that 1 reward?
No, you'd replace message.content in the if statement with command.
let info = new Discord.MessageEmbed()
.setColor('363940')
.setDescription('**PAPER STATS**')
.addField('📂 Total Servers', `**${bot.guilds.size}** guilds`, true)
.addField('📡 Total Channels', `**${bot.channels.size}** channels.`, true)
.addField('👥 Total Users', `**${bot.users.size}** other users.`, true)
.addField('💾 Memory usage', `${Math.round(used * 100) / 100}MB`)
.addField('💾 Node', `${process.version}`, true)
.addField('💾 Library', 'discord.js', true)
.addField('💻 Operating System', `${os.platform} ${arch}`, true)
.addField('💽 CPU usage', `${cpu_usage}% Used`)
.addField('⏲️ Uptime', `Days: ${days} | Hours: ${hours} | Minutes: ${mins} | Seconds: ${realTotalSecs}`, true)
.setFooter(`${bot.user.username}`, bot.user.displayAvatarURL)
msg.channel.send(info)
help ?
thx @frail ocean
@halcyon ember note that if the total reward is 1, all you need to do is divide by 100
@lyric mountain am i supposed to do that for every user value in my score?
Don't you know how to do rule of 3?
what is that
@earnest phoenix what version of Node.js are you using.
i think the latest one
@earnest phoenix update your node version to v12
@copper cradle discord.js ? is already v12
He mean node, not djs
how can i rewrite this to work with d.js v12?
users = await message.reactions.get("🔫").fetchUsers();
for (user of users){ ```
@earnest phoenix I said node not discord js
That is the rule of three, the easiest way to get any percentage
yea i have like 50 users on a score, each one has a different y value. how am i supposed to put each one in?
do you not know how to read?
What is the total?
changes all the time
Ok, so I'll call it TOTAL
You'd do it like this:
desiredValue * 100 / TOTAL = percentage
for starters i dont even know how to get the total from a score lol
Or if you want the value instead of tge percentage :
I literally said update your node version
and the dude literally replies dIsCoRd.Js?
desiredPercentage * TOTAL / 100 = value
ok so
Save those two equations somewhere, it might help u later
i have reward of 50. say user 1 has rate of 20 and user 2 has rate of 70. how do i make it do that and add the respective amount to the user?
100% = 50
20% = X
Transforming that to equation:
20 * 50 / 100 = X
Do the same for 70
so i need to do that for every value in the score
@earnest phoenix did you update it already?
but it aint realistic to write that out for every user
is there like a for statement to do that for every user in a score?
@copper cradle yes
And put it inside a loop
how can i create a reaction collector with eris, i'd like to create my own instead of using something like eris-additions, even tho it doesn't have it
function getSlice(share, total) {
return share * total / 100;
}
Here it is, although spoonfed
can anyone tell me why the fuck this is a thing
then when i want to give user the reward
i do reward(userhash, 50)
but how to put that into a for statement
Hash?
Just iterate your users
huh
How are you getting the array of users?
Dude
?
How are you getting the score then?
score.value
score = client.getScore.get(message.author.id);
if (!score) {
if (!score) {
score = { id: `${message.author.id}`, user: message.author.id, btc: 0, eth: 0, usd: 100, i3: 1, i5: 0, i7: 0, i9:0, x1900:0, x1920:0, x1950:0, x2920:0, x2950:0, wx2970:0, wx2990:0 }
const embed = new Discord.MessageEmbed()
.setColor('#7FDB7F')
.setTitle('Use $profile to see your newly created profile!')
.setAuthor('Account Created', 'https://cdn.discordapp.com/emojis/710590499991322714.png?v=1')
message.channel.send(embed)
}
client.setScore.run(score);
}else {
const embed = new Discord.MessageEmbed()
.setColor('#ff9933')
.setTitle('You already have an account! Use $profile to see your account')
.setAuthor('Error', 'https://cdn.discordapp.com/emojis/710585568660291584.png?v=1')
message.channel.send(embed)
}```
@mossy vine what lib
yeah you need to fetch the users
but how do i fetch them
users.fetch()
IF I DONT EVEN GET THE SNOWFLAKES OF THE USERS THAT REACTED
lol you are able to fetch them 
ok what the fuck is this library
@halcyon ember that code is very confusing
i think its because the v7 api or whatever doesnt send reaction users when you fetch a message
It doesnt
You're checking for !score twice in a row
It says it doesnt give reactions when you fetch a message doesnt it?
no @lyric mountain, the same thing with djs which has awaitMessages, the same thing but in eris
You assign it before and after the check
but with reactions
djs has message.channel.awaitMessages, i want the same kinda thing with eris but with reactions,
yeah idk why d.js v12 doesnt and v11 does bit
hoping that makes mroe sense lol
@lyric mountain huh whats wrong?
no its not
v11 auto fetches in the background
v12 disabled that to allow it to use less resources
Because reactions arent always needed
oh ok
@halcyon ember if score is already true, you don't need a second check
Also, you redefined the score value
no likee how do i make a statement to put it into that equasion
i dont seem to be able to find where d.jsv11 auto fetches the reactions but
so currently i have a function thats set to run everey 10 minutes
Right
inside that it currently just sends a message to a specific channel
but I want it so that whenever that function runs it calculates rewards and distributes them accordingly
But what will it contain?
it doesnt say anything
im going to remove that and change it to the reward distribution
Ok dude, but I need a real scenario here to know where you'd calculate the share
omg ok im just going to explain the entire bot then
No need
is there a way to get a list of the people that reacted to a message? (discord.py)
just why i'd need to generate the distribution?
If you're gonna list all users you'll need to iterate over each
wdym?
Just calculate the share in that iteration
how do i do that from the score?
@bronze sail not talking to u, just do message.reactions
ooh ok
Ah, python
It might be different then
Just look at the docs
@halcyon ember that's the issue
Idk the value of score
Since you've defined it twice
@grizzled raven halp
huh let me check
ye im confused im looking at the docs, but it doesnt explain something


@bronze sail message has reactions property

bruh
i want the bot to send a message then react to it, then another command will get the reactions from that message
what are you using?
@bronze sail you want a reaction button?
?
im so confused
no i already know how to get the bot to react
i want to get the reactions from a certain message
No, I mean
I think it's a "how many reactions does message X have" command
$$reactions <messageid>
Reactiokn button, a reaction which has a function once clicked
what framework are you using?
So apparently my bot (using lavalink+shoukaku) leaves the vc sometimes before playing songs, and I found a error "Something broke" in the lavalink server logs. How can I solve this issue?
Oh no, not another issue

The bot logs returns a "song Finished" event, but no error
And then if the user retries it works
With the same song
Maybe it's because of YouTube ads
u got an idea 4 what i can do KuuHaKu?
@lyric mountain ok so the score code i have first checks if there is already a entry for the users. Then if there is not it creates a new one with the values I added in. Then I have a variable totalrate = score.i1*1000+score.i2*2000+score.13*3000. Which allows me to tell the user their current rate. But score is matched to the user id of the message author
What you want is related to reaction button functions @digital ibex
yes @lyric mountain
Time to meme: can I use ad block with lavalink
i'm not using Eris' command client
Then find a lib for that, it's not easy to do
Well fuck
Reaction buttons are very tricky to do if you don't know how to directly handle events
@tight plinth Normally if it cuts out mid way its because the Video stream timed out
@halcyon ember just apply that function there
Hmm
but i want a for statement for every user
how tf to do that
That's the question
Without a code I can't say how would you do it
That code you've shown I've not understood
I need to see how and where you're calculating each user's score
i dont calculate the score
^
SyntaxError: Unexpected token :```
?
const xmrhashrate = score.i3*1500+score.i5*2500+score.i7*4000+score.i9*5000+score.x1900*4500+score.x1920*8000+score.x1950*10000
const embed = new Discord.MessageEmbed()
.setColor('#ff9933')
.setTitle(message.author.username+"'s Hashrate")
.addField('RandomX (XMR)', convert(xmrhashrate))
.addField('Ethash (ETH)', '0H/s')
.addField('SHA-256D (BTC)', '0H/s')
.setFooter('$invite - Add me to your server')
message.channel.send(embed)
}``` thats where it prints it out
im not
^ SyntaxError: Unexpected token :``` ?
@clear wraith {}
So you gotta do that first
not []
how
O
Idk, do a little research, that's specific for your bot
Ok
Not u
k
lol, IK
i cant find anything on google about iterating something from a sqlite base
how are the scores stored?
I mean you dont rlly iterate over SQLite db
you iterate over the cursor after executing a Select query
right its stored in sqlite tied to the user
i mean theyre in a file
heres the guide i wasa following https://anidiots.guide/coding-guides/sqlite-based-points-system
what i want it to do is basically get the values from everybody
and then put them into a math equasion to distribute a reward
the easiest way to to that would be to get everyone
in better-sqlite3: database.prepare("SELECT * FROM table").all()
that will basically dump the entire database into an array
oh
of course thats not the most efficient way to do it, especially if your database grows large
but to make something more efficient requires some thought
i have a const xmrhashrate = score.i3*1500+score.i5*2500+score.i7*4000+score.i9*5000+score.x1900*4500+score.x1920*8000+score.x1950*10000 and i want it to geenerate that for every user
generate it one time only, or generate it and save it?
is it gonna be different every time it is generated?
then theres a total reward of say 5 and user 1 has 100 user 2 has 40 and user 3 has 60. i want it to distribute the 5 reward over to the users based on how much of the total
yes its going to be different
well itll only be different if somebody changes their profile in the bot
are you making a blockchain bot?
xD
what if you have 500 users
does the 5 get distributed among all 500?
is it global? not per sever?
global
so the most efficient way is to probably have SQL do the calculations internally
instead of getting everything from it, calculating and the shoving everything back inside
i have better-sqlite3 idk if that workss
it will work, you just need a somewhat complex SQL to do it
how to do that? i dont really understand sql
also does it get slow if im making it run every 20-30 seconds
for example, you could do something like SELECT i3*1500+i5*2500 FROM scores to have sqlite calculate it inside
i didnt test it, so idk if thats the proper syntax
but its possible to go further and use the value to directly distribute and update the database
without ever returning the value to you
if you dont use the WHERE clause, it will run for all entries by default
if you want to get all results, you have to use .all()
instead of .get()
so i just throw
SELECT i3*1500+i5*2500etc.. FROM scorees and that returns array or what
if you use .all() it should return an array
so test it, idk if it will work
you might need to put them in parenthesis
Will SQLite even accept you giving it a math equation when it expects column names?
and how am i supposed to make it process that array to distribute rewards
that will take a more complex query, i never tried doing something like that
ill try playing around with it a little
ok thanks im so confused on making it work lol
I dont actually think SQLite can even do that

Somthing like Postgres would allow an entire logical operation etc... but SQlite is bare bones
i mean right now i just have it calculate it whenever the user asks for it
whats the issue with that?
there is no issue
what i want is it to calculate that for EVERY user to distribute rewards
Overall i would advise not doing it that way
and instead doing it when a user checks or somthing
because if that DB gets bigger it will eat shit when you try to get everything and apply it and update it
its just a bit inefficient
i mean is there a better way to do it?
doing it when a user checks or somthing
Theres no point distributing rewards to a user that might never use it or check it
what im makin is like a crypto minin game
and i want it to distribute rewards everytime a 'block' is found
just like how it actually works
I am developing in C# and ran into a problem with the api.
This is in my ReadyAsync:
AuthDiscordBotListApi AuthDBApi = new AuthDiscordBotListApi(_client.CurrentUser.Id, Environment.GetEnvironmentVariable("DBO_TOKEN"));
_ = Task.Run(async () => {
IDblSelfBot DB_Bot = await AuthDBApi.GetMeAsync();
await DB_Bot.UpdateStatsAsync(_client.Guilds.Count);
await Task.Delay(1000 * 60 * 10);
});
But 4th line throws a NullReferenceException. What am I doing wrong?
@clear wraith you tried to pass in an array instead of an object
you can't do this [ something: 'something' ] but you can do this { something: 'something' } this is basic
here i successfully set all "name" columns to the result of "hint x 1500 + test x 2500" of each row
yea so it works
yes it works, just its a lot more complex to do such operations in raw SQL
but its probably more efficient since there is no round trip to and from your process
so how am I supposed to get that and put it into a math equasion to distribute rewards
idk how i would do the distribution part tbh, i'd need to research on it
you can't do this [ something: 'something' ] but you can do this { something: 'something' } this is basic
@copper cradle I did that... and now it says canvas is not defined even though i have it defined above.
cavas
cavas
https://kyoya.is-inside.me/PcpzidDi.png how can i fix this?
anyone?
did you install canvas correctly?
(if youre talking to me, yes)
including the dependencies?
@earnest phoenix did you follow this? https://github.com/Automattic/node-canvas/wiki/Installation:-Windows
no
lol
Is GitHub and website required when adding a bot
no
@still merlin i think having a git-repository is very helpful (regardless of if its public or private)
hi
just forcibly write what you want and teach vs whos boss
in discord.js v12 all collection methods have been moved to .cache
the version is the boss :^)
shush python user 
any lib over d.js anyday
d.js-next gonna be > all
no
jk it probably wont
could anyone explain to me how to switch from const token into const settings (the places where my bot token, and information stored) because it shown error about unexpected end of JSON input i'm still kinda struggle on these.
should this css be displayed on my bots page? (haven't submited yet)?
@fickle arch the json format follows specific rules
@grizzled raven it's the same in python the len property
it has to be like this ```json
{
"key":"value"
}
the len function is literally this
def len(a):
return a._len_
on the settings.json ?.
guess
so the value was the token ?.
json is very strict, if there is a single character wrong, it will invalidate the whole file
idk how your file looks like so idk
it just simple like ownerid,token,prefix,etc.
yes but how is it formatted?
@still merlin your long description is not an independent page
its injected into the existing top.gg page
all your css rules and html need to respect this, there are already existing html/head/body tags and existing css you need to consider
oh yeah-
it's like
{
"ownerid": "youridhere",
"prefix": "?",
"token": "yourtokenhere",
}
json doesnt accept trailing commas
that shouldn't be there
if the comma is not separating anything, it should be removed
so after token no need comma after that ?.
yeah
yes, since there is no next item
unless there another code after }
no, nothing should ever be after }
you'd add a comma if you wanted another item under token
aight, i get it unless no need to add another under token so there's no need to put another comma ?.
yes
hi, quick question. if i have array = [ { object1: { number: 1 }, object2: { number: 2 } } ] how can i get the last number, in this case object2.number? win javascript
after i replace const token with const settings it shown an invalid token was provided.
without me having to do array[0].object2.number ?
@fickle arch how did you import it and use it in your code?
@digital ibex thats exactly how you do it
yeah
there is no "without" doing that
but i don't want to hardcode it
which part you dont want to hardcode? the index 0?
what do you mean on import it ?.
like const settings = require(./settings.json); or something ?.
yes
so like, i'm trying to create a case system for modlogs, and uh
yeah, i can't really hardcode it
which part of the data is dynamic?
thats the db stuff
its like
moderations: [ { mute: { case: { type: Number }} })
and other ones
so you have an array of objects like that, and you want to find one object by their number?
then use the array.find() function
ah, oki, ty
Guys, does someone know how can I add this embed thingy to my website when displaying it in, for example, discord?
I have no idea.
twitter tags and opengraph tags ^
thaaank you :) couldn't find it in google.
Is there any way to find out if someone has started streaming in a discord channel?
VoiceState.streaming in discord.js
what is purpose of using mongoDB ?.
mongoDB is a fully featured no-sql database system
its main purpose is to be the primary storage system of a program/project/website/server/service/etc...
how i use the function sort() ?
.sort((firstValue,secondValue) => {
compare firstValue to secondValue
})```
prefix is not defined
but in settings.json i had "prefix": "?"
it said the problem is around here
client.on('message', message => {
let args = message.content.substring(PREFIX.length).split(" ");
anyone's familiar with Crowdin webhooks/api?
||i am trying to make it send a message to a specific channel on new translations||
thank you
@fickle arch how did you define PREFIX as?
before i use const PREFIX then i delete it and switch it with settings.json along side with other information.
well your code is looking for PREFIX.length
which means its looking for PREFIX
somewhere in your code
if you deleted it, then it will not find it
and throw the error
or change how you use it
you defined your file as settings right?
so make your code look for a prefix in there
instead of looking for PREFIX
so i added const PREFIX : '?'; below const settings : require ('./settings.json);
permissions or options?
elaborate
^
by right clicking on your server, then server settings
there you should see an option called "Roles"
@earnest phoenix this might help alot https://support.discord.com/hc/en-us/articles/206029707-How-do-I-set-up-Permissions-
np 
sure. ask
like roles ?.
@fickle arch you basically made your settings file useless lol

ahh i see lol.
For some reason when I try to do:
con.query(`SELECT * FROM fireballcool WHERE id = '${message.author.id}'`, (err, rows) => {
if (err) throw err;
const [ row ] = rows;
if (row && row.time + 1 <= ts) {
con.query(`DELETE FROM fireballcool WHERE id = '${message.author.id}'`, (err, rows) => {
if (err) throw err;
const role = message.guild.roles.cache.find(role => role.name === "Cooldown");
message.member.roles.remove(role);
})
}
})
It never removes my role. However, in my MySQL database it says the correct numbers. The variable ts is correct to my knowledge, but the role is never taken away. My bot has full permissions and can add/take away roles from my alt which just joined the server. What is going wrong?
add a console.log to it to see if your code ever reaches there
tried to invite my bot to my testing servers but when i click the link and press authorize it only shown X in the middle.
So I am trying to create a tow command, and this is its response, but its not giving me everything I want. I need the bot to also provide the vehicle name which is provided through Message.content, so if someone could help me out that would be amazing!
Current Code:
const embed = new MessageEmbed()
.setTitle('The Tow!')
.setColor(0xFF0000)
.setDescription(`<@${member.id}>` + '\'s car is being towed by: ' + `<@${message.author.id}>` + '!')
.addField('The Vehcile Is: ', `<@${member.id}>` + '\'s' + message.content.slice(prefix.length).slice(command.length).slice(member.id))
.setFooter(copyright);
await message.delete();
return await message.channel.send(embed);
}
Tim, maybe you remember, i am currently reprogramming my statistics bot. I wanted to ask, would it be wise to (as i have to redo a lot anyways), also switch from discord.js to eris /another framework?
what are you trying do here
message.content.slice(prefix.length).slice(command.length).slice(member.id)?
Trying to remove the prefix, command length, and the member that I mentioned so I can put the member ID in the front with an 's
u can use .tag
instead <@${message.author.id}>
.slice(.tag)?
message.author.tag
I'm not wanting it to retag the author, the author is the second mention (Fuzzy)
so how you defined member?
const member = message.mentions.members.first()
@viral spade if you want to future-proof as much as possible, the best thing would be to make your own library, for the lack of better alternatives, or switch languages lol
pretty much all big shots have their own home-made libraries designed specifically for their use cases
on another language is there a future-proof out of the box framework?
making your own framework, would this in a simple case mean fork f.e. the discord.js repo and cut off functionalities/reduce cache, that i dont need? Or are you talking about completely from scratch?
Just not using discord.js would be a good start lmao
depends how future proof you want to make it
i would make it from scratch, another alternative is looking into detritus
Discord.js is fucking awful for big bots without being heavily modified
making ur own lib is hard
^^
its not that hard, just annoying
if u rlly want to do it, i suggest starting with a solid foundation
again detritus can help with that :-)
do all the rlly annoying socket stuff for you
Unless it's d.js, making your own lib without knowing exactly what you're doing it'll probably be slower than the main libs
detritus client has completely modular cache
all parts can be controlled independantly
eris or detritus are both good libs tbh, my only problem with eris is the shit typings and how the client is structured
Eris is designed to be more lightweight
It just expects you know how Todo shit yourself
@white anvil have you tried benchmarking detritus? because from what i've seen, their implementation of zlib is async, which is considered not ideal
i havent benchmarked it
honestly if u want to know more about the lib its probably best to ask cake in the support server
Js's async system seems painfully slow compared to other Lang's systems which confuses me
not as dumb as py's indentation :^)
silence python user 
Smh
@quartz kindle detritus just uses the node provided zlib which is generally slow
lol
i dont think the async part matters too much
akairo is nice
Okay thank you for your answers. Then i would stay at discord.js for now and when i redo it, make it from scratch.
Tbf Eris should be enough for u lol
Idk how many bots use a custom lib at 14k guilds like
vexera uses a custom lib
so eris also good for over 1.000.000 guilds?
thats in 300k+
eris is decent but it doesnt provide native clustering
detritus does
Pokecord uses a modified version of eris
keyword modified
Why would u even need native clustering
all big bots that use eris use their own modifications
That kinda defeats the purpose lol
The whole point of clustering is it allows scaling across multiple processes and machines
yes
Every big bot that uses clustering doesn't use the in-built system
Cuz it's fucking shit as fuck
because there isnt any
detritus provides cluster client which is fully featured and also comes with cluster manager
If you're going to cluster properly K8s or Swarm are some of the best methods
No harm in using a 3rd party lib when it does it better than the main lol
other than docker swarm or just using k8s
I have low hopes for this question but....
is it possible to check if a channel id is in a certain server
Iterate through all channels ig
discord.js
that wont work if you dont have a complete cache
uh
channels are always cached by default
^
how do i make my bot editable through commands in the server?
there is rest endpoint to fetch all guild channels
dumb question and stuff
maybe I'll try doing it by name instead of id...
there is?
yes
Yeah
since when
Idk why you would use it tho
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
i would use it if i wanted all channels
since i dont have a cache
I'm only worrying about cache when the bot starts using 30GB ram lol
<5GB is good enough for me at 55k
well im not rich so
How i use sort() to the command top?
So when we speak of frameworks to be better for large bots, are we speaking mostly about ram or are other resources even more important to save with a better framework?
using 30gb with no cache is exponentially bigger in terms of guild count than 30gb with cache
Also @quartz kindle You say there are no good multi machine scaling options, have you actually looked at kubernceles statefulsets
@viral spade its kinda subjective
Most big bots don't even use a framework lol
depends what u want to do
statistics, which means i need most of the data cached
Ngl
in which case there will be little difference between frameworks
Mysql is fucking awful until it got to V8 where it's only just caught upto postgres in speed
And postgres still crushes mysql in features and power
yo answer his question mysql is my babe
There is litterally no reason to not use postgres over mysql
yeah but he said whats the issue with mysql
okay @modest maple i will do
Lacks utility, speed, security etc...
mysql can be considered faster for a lot of operations
and is simpler to use bcuz no vacuum
I'd hardly say postgres is hard to use lmao
guy didnt say postgres is hard to use he said mysql is simpler
a lot more web developers use mysql because it doesnt have features that they dont need
TL;DR: MySQL is a bad database. Don't use it unless you have literally no other option.
Why shouldn't I use MySQL?
- MySQL has no transactional DDL. This means that if you fuck up creating a table in the middle of a migration, you cannot rollback easily.
- MySQL has a lot of security issues. New zero-day vulnerabilities are found regularly.
- MySQL is owned by Oracle.
- MySQL is slow. It beats Postgres etc at some things, but once you move beyond basic queries it begins to slog.
- MySQL disconnects you randomly. Unless you setup your connection specially, it will break regularly.
- MySQL allows all kinds of insane data to be inserted. '0000-00-00' is valid in MySQL.
- MySQL is not ANSI compliant. You have to turn it on; even then it isn't fully compliant.
- MySQL has no feature advantage over other databases; PostgreSQL has many more useful features (such as RETURNs).
There is no reason to use MySQL over PostgreSQL, or even sqlite3. See also:
https://blog.ionelmc.ro/2014/12/28/terrible-choices-mysql/
https://grimoire.ca/mysql/choose-something-else
The terrible pitfalls I've gotten myself into while using MySQL — I've used MySQL for a while now, and there were lots of surprising things I needed to cater for. This is from a Django and MySQL 5.5 perspective...
It's a old review but still relevant
security issues arent a problem if u arent a moron
- MySQL disconnects you randomly. Unless you setup your connection specially, it will break regularly.
that's why we have connection pooling
lol most of whats written there isnt true (anymore). its from 2014..
yea
Alot is still relevant especially speed
mysql is a lot faster now than it was
Only took upto v8
Where it still lacks behind postgres
depends what you're doing
i dont care how long it took them...
I do lmao
mysql also has some better misc stuff like query caching
fuck does it mean to you, we're comparing the latest of both
Postgres has query caching? Lol
i agree postgres is better for complex query but in terms of web development where queries are normally simple it can be faster
For simple sites sure
For web development mysql is absolutely the choice
But the utility of postgres makes up for the slight speed decrease
hardly
I will take postgres over mysql every time
thats still very subjective
If you're only doing light stuff you might aswell use a nosql dB all things considered
Which is what mongo is litterally based around (web development)
harder???
sounds like a flame war is emerging
man i can write javascript instead of selling my soul and a kidney to satan and writing some broken english
lmao
it takes like 3 days to learn sql
lmao
Not proper sql
There's the 'i can do some querys' sql
And then there's actually properly knowing it
instead of selling my soul and a kidney to satan and writing some broken english
still sounds like javascript
lol tbh
True
maybe i dont like mongo because its actually mongoose thats crap
CPP is just selling your soul to satan then bending over for the pitch fork
mfw mongoose
mongoose is useless unless you absolutely need the schemas (you dont)
for somebody who uses typescript it might make sense
How i use sort() to the command top?
people told me to use it and then i ran into problems no one knew how to fix
so i switched to postgres
Yesssssssss
purely for the reason that mongoose broke
Convert the man
Tbf mongo is slower byitself
But mixed with a cache db
It starts to crush SQL for short sharp querys
it may be slow but goddamn is it easy
Which is why it's got popular
Reddis + Mongo or -insert mongo fork here I've forgotten the name- is a very popular combo
And pretty quick
reddis moment
just use redis as your db
if you dont use https://www.npmjs.com/package/db-discord then dont speak to me
Isn't that just discord.js tho -> just one really baddddd cache db
i keep meaning to implement redis but my lazy ass is too lazy
lazy guy's lazy cant blame him
detritus comes with pretty nice cache solution so i use that for discord bot instead
but redis would be ideal
cache all the things
You don't rlly need it unless shit gets big
just cache ur entire db on identify
We use it on one of the 30k/s APIs
if i didnt care about cache i would still be letting my bot use 1.7gb ram with d.js
how many guilds
600-700 at the time
fun fact, the bot needs basically no caching to operate
sliced down to 50-60mb with custom lib
my bot would benefit from cache but i sacrifice cpu time for better memory usage
i use about 50mb also lol
the only thing i cache is messages
and that had hard limit of 100 items
How can I put clickable links in the footer of a embed?
you cant
@earnest phoenix dont think you can in a footer
i couldve sworn you used to be able to but alright
how can i reduce the ram usage / cache size of d.js?
you can tweak with ClientOptions but it wont help a lot
Oof
So I got this
https://i.callumdev.pw/0q3pu.png
Why is it returning this?
https://i.callumdev.pw/9m955.png
ask the api
yea lol
cyber
wtf is the api running on :3002
the main bot
@delicate zephyr what
How to make a disable/enable {command} system? (Python:
)
@white anvil https://i.callumdev.pw/4kblg.png
use a db, store disabled commands in the db, query it to check if disabled, if disabled dont run the command
no
hardcode them
So when switching from discord.js to eris, is there some major things to consider? Whats the biggest differences?
eris is more low level and has less helper features
documentation is a headache
the thing works rn but.. well almost works. the disable/enable commands can disable and enable any command even if its not in my bot and adding a check for 58 commands is quite hard so i tried making a list and checking if the command name is in that list but it didn't work. (Python:
)
can you give example of a helper feature?
message embed class
User.tag
how can i host a lavalink music bot on replit
since lavalink requires java
you cant
its mind blowing how many people complain in eris channel in dapi that there is no User.tag
i love the freedom of writing my own library. sure it comes with a lot of headaches but the freedom it gives me with what i want to integrate and in what way is totally worth it
i wouldnt do it from scratch
if i made my own shit i'd use a premade gateway implementation
bcuz lazy
gateway is easy
until you get token reset at 5 am
because you yeeted your bot in a reconnect loop
the hard part for me was ratelimiting
but i stole some code from github and its nice now
im talking about https://github.com/detritusjs/client-socket
very low level socket
doesnt do ratelimiting or anything for you
what are websockets
its just a wrapper over the gateway
websocket is a method of establishing a persistent connection between two machines over network
So eris is mostly better because i can disable caches?
eris still doesnt provide great cache control
its better but its not great
eris is better for other reasons though
it has way less bloat
so why does discord.js not add this?
because it sucks
i had to work with discord.js earlier today and im pretty sure it decreased my life span by at least 5 years
haha
(await message.reactions.get().users.cache.fetch()).array() just fuck off what is this
then i should be dead already
is it possible to make welcome message into embedded things ?.
yes
yes
i don't have clue to do it xd.
put it in an embed xd
ah okay, last time i make embedded profile i screw it up for a while.
thanks !.
do you know how to make it so that when someone votes for my bot they get x coins
thats an EXTREMELY vague question
use webhooks
still the same like before or i just still need to understand more xd.
so we have eris, detritus, is there any other javascript frameworks for big bots to check out?
detritus?
oh
correct
so in eris, is caching of everything on by default and i cut it off, or the other way around?
caching is enabled by default
@fickle arch try to deconstruct the embed object by doing send.channel.send({embed});
im not sure how modular it truly is but it’s not very
Detritus is best option if you want full control
how will it affect the way i write the bot when using detritus? (except from not haveing an embed class)?
oh
better caching, better api implementation, less bloat, better stock command client
its a typescript library
@steel drum ok gonna tried it.
@viral spade all libraries are different
i was considering refactoring my project
@steel drum better cache control, less bloat from what i see
to typescript
you won’t write any two libraries the same way
might look into this
@steel drum detritus can be written with js
i was considering typescript anyways
it’s a ts library but you can use js when implementing it
so i just added guild.channels.fetch() to my djs framework, because for some reason djs doesnt have it lmao
still the same @steel drum
whats the biggest types of caches that should be considered deactivating, if you dont need them?
presences




