#development
1 messages · Page 1658 of 1
there's also the scroll event but be careful how and what you do with it
why
Because you pinged me 😭
it fires a lot of times, you can potentially block rendering by blocking the scroll event handler
eeeeee what?
@boreal iron I think I did this right, but 26069.0 != 500
cry is getting paid? lmao
oh epico
i wish
i wish i was paid
@vivid fulcrum let me help you get paid more lmfao
multiplying things by zero still gives zero 😔
I know?
it's a joke
i have no idea, sorry lol
yes its correct
i don't work with node enough
hmm?
?
what are some of the reasons why that people make their projects open source? just curious
why is what so big
to help others?
lol 
either because they dont want to sell it, or because they want the project to be self-maintainable by the community if need be
Tim what would you do to get the hosts system stats
ah thanks (:
exactly what you did
i dont have any, i dont measure system stats
only my bot's stats
but os.totalmem is the right way
what would you measure
i only measure my bot's memory usage and cpu usage
Which is
wdym which is
Anyone know how I could get the ping in ms from mongoose?
make a request and measure how much time it takes?
Using date.now
Yeah thought there was a built in function but it apparently doesn't return what I thought it did
so i tried to organize my commands but, it didnt work. The error was "fs.readdireSync" is not a function. what should i replace it with
what is fs defined as
where should i put require('fs')
this is where i have fs
and where the error is
should i replace that with require("fs")?
I would suggest learning javascript and node.js before attempting to code a discord bot
no no no
fs.readdirsync
learn how to use your brain cells first
:/
readdirsync is not a function because fs does not have a function called readdirsync in it
all fs is = to is "fs"
i dont think there is an e
?
const fs = require("fs") ?
did u do that
You need to define with requiring the node module
pretty rad dir sync
@unreal estuary Please look up before attempting to help uwu
hi
so this
who can help me ?
Ask your question so we know if we can help 
sorry lol did i give some incorrect info
;0
What about it?
how to make like this decription
and brain cells
try inspect element
I updated my command for #development message but I dont get all of the required badges
const flags = await member.user.fetchFlags();
const userFlags = flags.toArray();
let IncludeBadges = {
"DISCORD_EMPLOYEE": "emoji 1",
"PARTNERED_SERVER_OWNER": "emoji 2",
"HYPESQUAD_EVENTS": "emoji 3",
"BUGHUNTER_LEVEL_1": "emoji 4",
"HOUSE_BRAVERY": "emoji 5",
"HOUSE_BRILLIANCE": "emoji 6",
"HOUSE_BALANCE": "emoji 7",
"EARLY_SUPPORTER": "emoji 8",
"BUGHUNTER_LEVEL_2": "emoji 9",
"VERIFIED_BOT": "emoji 10",
"EARLY_VERIFIED_BOT_DEVELOPER": "emoji 11"
};
let DisplayBadges = [];
for (var key in IncludeBadges) {
if (userFlags.includes(key)) {
DisplayBadges.push(IncludeBadges[key])
}
}
console.log(DisplayBadges);
Because not all of them are public
EARLY_VERIFIED_BOT_DEVELOPER is not public?
iirc no
^
^
ahh ok
djs might wanna fix that
d.js just wants to be stinky and not update docs
is that in stable docs or master docs?
I just submitted a quick pr
I sent in the stable PR
How about this PARTNERED_SERVER_OWNER
is it correct
should be
oks
no discord did
rip
does anyone know why this doesnt work, the error is, "Cannot read property 'set' of undefined"
works now
spelling mistake. You declare your collection as client.command but later use it as client.commands
just throw the whole thing away best advice lol
?
@quartz kindle For cpu usage it returns system and user
they put
exactly what im doing
lol
```const commands = require(./commands/${file});````
in the for const file of command files
so commands doesnt even exist out of it
???
so how can nothing equal to "ban"or "kick"
just read the code im bad at explaining stuff
lol
@heavy marsh @blissful coral actually the docs are correct
this change was made in december 2020
your library is probably outdated
ooh
actually they didnt release it to stable
its on master only
not sure why the stable docs were changed tho
ok, i got everything to work... finally
Yeah @quartz kindle was boutta say that was stable that said that imo
And I ran it on my stable bot to check
Can someone explain me how i can export a variable from an asynchronous function
await it
function checkUser() {
var returnValue;
axios.get(`api/users/CheckUsername/${this.username}`).then(response => {
returnValue = response.data.error === 0;
}, errorCallBack => {
returnValue = false;
});
return returnValue;
}
It always return undefined
because .then() is the same as a callback
it doesnt pause the outer code while it waits
when the .then() is executed, the outer code doesnt exist anymore
you have to use async / await syntax
Ohh okay ty for helping
const NewPages= new require("DiscordEasyPages")
.set("test")
``` Just wondering, how would I use the new constructor for developing a package?
just what you did, but with parenthesis
Oh?
const test = (new require('MODULE_NAME')).set('test')
Okay. Thanks!
no problomo
Anyone use kurasuta?
Having this problem when I run this.client.shard.restart(0) or this.client.shard.restartAll()
do you have an error event listener?
idk
manager.on("error")
so someones trying to intentionally rate-limit my bot but idk how 2 counter it lmao
i do but they just cycle through my commands
nop
Set a cooldown for the whole guild
how
Can’t be easier
Just add a property to the guild obj
message.guild.commandTimeout
Check in your message event if that property exists and calculate now - timestamp
Oops I meant .commandTimestamp
Damn mobile auto correction
At the end of your message event just add the property = current timestamp
3 lines of code but a huge change
hmm
1 more line to send a message with some spam protection content (only send it once of course)
Very simple
With the check if time - timestamp > cooldown you can even go further and double the protection time each abuse for example etc.
the whole bot crashes when you try to restart a cluster from the cluster 
so the best thing you can do is an error listener or a sort of rolling restart
Yeah I figured it out lulw
Forgot to add my error event
how the frickity frack can I silence this
@quartz kindleothy any idea?
install an older mongoose
how older
ill send the version I use and don't get the error
"mongoose": "^5.11.15",
be sure to remove that ^
There we go
using System;
using System.Threading;
namespace full_calculator
{
class Program
{
static void wait(int time) {
Thread.Sleep(time);
}
static void Main(string[] args)
{
Boolean loop = true;
if (loop) {
Console.WriteLine("Please enter your expression below! Each term should be separated by a space.");
String expression = Console.ReadLine();
expression.Split(" ");
if (expression[1] == "+") {
Console.WriteLine(Int16.Parse(expression[0] + Int16.Parse(expression[2])));
}
}
}
}
}
what is wrong
cs
And thats my queue to leave
SOMEONEEEE
ahh
@sage bobcat sorry for ping but ur like the only person i know that knows c#
@scenic kelp
Argument 1: cannot convert from 'char' to 'System.ReadOnlySpan<char>'
oh yeah parm too
sorry faith
you're comparing a string to a char as well
well yeah but how can i turn it into a str?
i tried ToString() the index but it didnt work too
you tostringed the +
i did it with the index too
i judt didnt send it here
i tried both
cannot convert from 'char' to 'System.ReadOnlySpan<char>'
if (expression[1].ToString() == "+") {
also another nitpick, string should be lowercase when you're referring to the type
String expression
why are you splitting the string and not storing its value
you call expression.Split(" ") but do nothing with the output
yep
oops
i think its that
i just assumed it would auto save it
but idk why i did
now
using System.Threading;
namespace full_calculator
{
class Program
{
static void wait(int time) {
Thread.Sleep(time);
}
static void Main(string[] args)
{
boolean loop = true;
if (loop) {
Console.WriteLine("Please enter your expression below! Each term should be separated by a space.");
string expression = Console.ReadLine();
expression = expression.Split(" ");
if (expression[1] == "+") {
Console.WriteLine(Int16.Parse(expression[0] + Int16.Parse(expression[2])));
}
}
}
}
}
and Argument 1: cannot convert from 'char' to 'System.ReadOnlySpan<char>' still
oh
i know what i did
whoops
you're still comparing to a string as well as overwriting expression somehow which is not doable
i fixed it
string[] expressionArray = expression.Split(" ");
tho it adds the strings
not the ints
even though i int parse it?
you're adding a string to an int in the intparse
should be intparse(1) + intparse(2)
not intparse(1 + intparse(2))
oh lol
it was a mistek
typo
if (expressionArray[1] == "+") {
int output = Int16.Parse(expressionArray[0]) + Int16.Parse(expressionArray[2]);
}
Console.WriteLine(output);``` and it says output doesnt exist in current context?
do i need to set output as "" above?
you define output in the if
use int32 or 64 yeah
no reason to use 16
why would it be weird
cuz 64 gives some errors 32 doesnt
what errors
1 sec
Cannot implicitly convert type 'long' to 'int'
when 65
64*
when 32 it works fine
because you store it in an int
wdym?
you can't convert a long to an int implicitly because you're losing precision
whats a long?
64 bit int
int is 32 bit
You would call it bigint in js
when i specify an int by default its 32?
oh okay cool
in js all numbers are doubles
so how can i make it work?
bigints can store literally any intege
if 64 is a long?
store it in a long
ye
the reason why you can implicitly convert a 16 bit int to a 32 bit int i because you cannot lose precision
do longs have any limits?
64 bit integer
64 chars?
no
digits*
isnt a digit a bit?
no
8 bits is up to 255
oh
16 bits is up to 64k
2^64-1
geez okay
plus it's signed so
so i cant do like 10 billion + 5 billion?
on a long ye
no
on ints no
longs are 64 bits?
ye
oh
in some languages, long is 32 bit for some reason
i misread tims thing
cpp moment
1.8446744e+19 this isnt long enough
it cant even measure my pp size
you think itll work for my codebase
?!?!?
i think c# has arbitrary precision ints as well
each bit doubles the capacity size

looking into binary math is fun 👀
c# has BigIntegers
most computers are 64 bit, going above 64 bit and its slow 👀
some systems support native 128 bit numbers, buts its rare
unless you got a damn supercomputer
body {
margin: 0px;
};
#screen {
max-width: 100%;
max-height: 100vh;
margin: auto;
height: 100%;
display: grid;
};
why does body's margin: 0 break the grid
LOl
any more c# qs while i'm here?
also maybe this is just for me but use classes and not ids
if i remove the body, it works, but there's a scroll bar and a black space on the top
let me get my whole html code
and does c# still need glasses
how is c# weird
alr
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#screen {
max-width: 100%;
max-height: 100vh;
margin: auto;
height: 100%;
display: grid;
};
</style>
</head>
<body style="background-color: black;">
<video autoplay id="screen">
<source src="yay.mp4" type="video/mp4">
</video>
</body>
</html>
no c# sees sharp
removing the body style will
i personally love c#, it's super flexible
?
this is a ban cmd, does anyone know how i could use this to make a un-ban command
would i just make this unban?
well no because member wouldn't exist
thats the problem
so i would need to change "member" values
to a discord user
and then make it unban?
It's slight harder to make an unban than it is to ban
ya, i knew that
Can't u just start with simple stuff like ping, 8ball, choose, uptime, etc?
i guess
Why jump right into non-starter stuff?
well i cant really tell my self if its started or non-started
i just have to try then find out
ik lol
So start with easy stuff
what should i start with
Generic stuff like ping, uptime, 8ball, choose, say, repeat, etc
ok
Learning an experimenting with JS basics and some easier commands after
ill just go to the discord.js website
No
you dont think i should do lessons
And think
You need to learn the JS basics before you’re able to understand the docs
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Guess he was in a desperate situation 
You don’t even know how to run a business but can do so
That’s our sad world...
You don't need to know politics to be a politician
Aye probably the best example
Is there anywhere I could get more people using my bot?
Friends
Yea
Then friends of friends
91 servers are using it so far
Not yet
Submit then
Ima do it tomorrow
Do today
The earlier you do the earlier you get reviewed
Remember that it takes 2+ weeks
yeah he ponged me after then i did pro c# tutoring 😎
I can’t get guild info
What guild info?
For servers
I know, but what info?
One message removed from a suspended account.
I’d
Enable developer mode for discord
also @drifting wedge since i'm here i'll complain about your code again
It's under appearance menu
Ok
You should use Int32/Int64.TryParse instead of Parse. TryParse takes in the value as well as an output value and returns a boolean if the value was successfully parsed to the value, in which case you can access it in the out variable you passed to it
if you try to parse a non-int value it'll probably throw some sort of error
does the guild emojis intent being disabled still allow you to receive guild emojis with the guild packet?
win.on('focus', (event) => {
electronLocalshortcut.register(win, ['CommandOrControl+R','CommandOrControl+Shift+R', 'F5'], () => {
console.log(1)
});
});
... still googling how would you prevent reloads on electron
(my prefix is () )this is a remove message script. I didnt make the OG version but, it didnt work. This one doesnt work either but, when I type ()Clear then put a number, it just says "Not a valid amount" and if i just put ()Clear then it says the same thing. There are no errors in the terminal or debug console. can anyone help me find out why
console.log(args) and you'll see why
i dont want to sound dumb, but i dont get what you mean
do you know what console.log is?
thats why i said to use it
right after const args
in the next line
add
console.log(args)
ok
and see what it says on the console
Now u gotta wait
win.setMenu(null); works
How can I make my bot be like: "Type i just play stupid games as your job today!" and have the person respond after?
Lib: Discord.js
v12.5.1
use awaitMessages like msg.channel.awaitMessages()
In client.on('voiceStateUpdate', (oldMember, newMember) => { } how do I get the oldMember voice channel's name?
U still need help?
Before isNaN put a !
What would I do then? Something like:
msg.reply("You successfully earned $13500!")
})```
nah it would look smth like
const filter = res => {
if (res.author.id !== msg.author.id) return false;
if (res.content.toLowerCase() !== "i just play stupid games") return false;
return true;
}
const filtered_msg = await msg.channel.awaitMessages(filter, { max : 1, time: 60000} );
if (!filtered_msg) return console.log("I didn't receive anything the suits my filter!");
msg.channel.send("You successfully earned $13500!");
// add money to db
And how would I make sure the message it waits for is the author of the work command?
o jesus
so the filter basically makes sure its the author of the work command
and it also checks if the content of the message is equal to whatever u want
so, after it finds that message being sent, how do i make it respond with something and then make it add money to the db?
oh ok, thanks :D
Absolutely nonsense but he will find out as soon as he prints args
first off bro ur if statement is wrong. ur supposed to form an if statement like this if (something is true) { }, not use a semicolon
anything is wrong with his code... if(amount < 1 || amount < 100) ...
but he's refusing to learn the js basics or in general coding basics at all
@lost mirage that code works but even if they dont respond it works
it pays still no matter what
code:
module.exports = {
name: 'work',
run: async(client,message, args) => {
let msg = message
let discord = require('discord.js')
let db = require('quick.db')
let b = 'bal'+message.author.id
let w = ['i play stupid video games', 'i work for the idiot department']
let WR = w[Math.floor(Math.random() * w.length)]
msg.reply('You are currently working for $13500. Please type: `'+WR+'`\n\n\n*You have 25 seconds to type this phrase.*')
const filter = res => {
if (res.author.id !== msg.author.id) return false;
if (res.content.toLowerCase() !== WR) return false;
return true;
}
const filtered_msg = await msg.channel.awaitMessages(filter, { max : 1, time: 20000 } );
if (!filtered_msg) return message.reply('You did not respond in time with the required phase. Enjoy $0 loser.')
msg.channel.send("You successfully earned $13500!");
return db.add(b, 13500)
}
}
It's if (!filtered.first())
i used the variable msg instead of message
It returns a collection of messages
As we see daily in here, yes you can 
-_-
i mean its works the first way so
shouldve figured that tbf- bit dumb sometimes
never used a filter-
or if (!filtered_msg.size)
let msg = message -_-
that's as short as it can get
nah
lol
watch when ur using a filter
im just lazy tbf
types are important
u said if (res.content.toLowerCase() !== WR) return false;
ofc it wnt work bc u need a string
if (res.content.toLowerCase() !== "WR") return false;
uhm
I also suggest using WR.split("").join("\u200b") like Dank Memer so that people can't copy paste
No, w is array
w is a array WR is a random index from the array
so doing "WR" will make them be required to type WR
it IS
smh im dumb
you can't boolean a collection like that, it'll always return true making it pass
plz no booli
Can someone give me the code for where I put my bot token in?
hello, how may i help you?
umm, oh, you are not a bot, nothing, nvm
i'm not, but you need help with something?
I do.
I do.
I need help with the start of the coding like where the bot token and stuff.
show the code
show the error
and i will explain
I start of with my client.login("bot token")
But I don't know what comes before or next
-.-
I'm a beginner
why did you thinked that?
because your pfp and name
And your satus
rich presence isnt hard to do
no no
gets their ideas stolen
oh, that's an account for communicating with our customers ^^
poor poor erwin
i saw it in the developer server
f in chat for erwins ideas
it's a rich presence
Rich Presence ._.
oh, ok ok, what website do you have?
is that a self bot bot
maybe go dms? ^^
no
oh
go dms for this, it's not the proper server ^^
discord fkin shards are weird af wtf
idk why but it kept spam DM-ing the same user when other people voted
like tf
i restarted and everything went back to normal
i checked for shard crash logs and nothing
Possible memory leak detected
What's this? It's my first time encountering this issue.
Well, fs is a native package so that might be the reason, no idea about that really
is it possible to know how many servers my bot is on?
What library are you using?
none in particular to accomplish this ... I thought it was possible to do it on the site
Wut, you want to display the amount of guilds your bot is in, in the site?
I don't need it to show on the site, I thought the site itself had this function ... I was just curious to know how many servers my bot has, do you recommend any library for that?
as i mentioned ebfore, you can use oauth
You get the amount of guilds your bot is in by whatever library your bot was made with, not anything else, the site can't get the info of how many guilds the bot is in unless you post them, and a library is basically discord.js, discord.py, eris, discord-rose, detritus, discordgo, discord-net, serenity, etc etc
You can also use the raw API to get that information, without the need of libraries
oauth gives you the estimate of guilds
not precise, mind you
for a precise count you'd need your bot's token or a proxy
then you'd need to use the gateway to fetch your guildCount
@scenic shale
ty
ty
heheh, he mentioned detritus


What kind of coding?
In what language are you making your bot?
english
No, what programming language?
can i know that what what programming language can i use this is my first day of developing a bot
Well, I wouldn't recommend a bot to be your first project. But either JavaScript or Python is usually good for beginners.
You can use whatever programming language you want, but I recommend learning the basics of that specific programming language before attempting to make a bot
so i have used python so i am using that
now is there any specific link for that
If you're gonna use Python, do you know it's basics/fundamentals?
Learn basic Python, then you can delve into the Discord.py library here
https://discordpy.readthedocs.io/
yes
Then go ahead and have a look at discord.py's documentation which is a discord bot library you can use
can u give me the link
Spaxter already sent the link
If you need support about discord.py, you can also check their official discord server:
https://discord.gg/dpy
okay
Is anyone able to provide me the API that allows you to update "<value> Servers"
what is the support server of discord.js
Which library are you using?
https://docs.top.gg/libraries/javascript/
So then this should be it
No worries, you can use #topgg-api for any further questions about it
please when will my bot be sent :(
2 weeks
Why?
Eris.js or d.js
whichever one you like more
deeeetriiiitussssss
sends the memory usage difference image
also sends their support server invite
😩 detritus is kinda good though]
how to make a slash command on djs tho
I waited 8 weeks
i wait 1 week lul
Anyone know how to make google form post an HTTPS request to my express server?
send info
use node-fetch
i use d.js for bots but (trigger warning) ||e.js allows selfbotting||
even djs 11 allows that
no i mean in the google form. From Google
not i make request to google form
they make request to my server
smh
does anybody know how to make a join/leave vc command in discord.py
imgur images dont load on djs embeds?
they do
its not working tho
its not a thing with d.js V12 in V13 it will be a thing, if you want it so badly, there is a open PR for it on the Github repo
hm
link 🤔
does anyone know how to add ssl for db connections for node js postgres sequelize
due to the heroku recent update my insecure database connection without ssl is now rejected and my bot cant connect to my database
in java, for my mc server to db connection i had the same problem but in that case all i had to do was append autoSSL=false to my connection string
Correction
verifyServerCertificate=false and useSSL=true
ok so the thing is i found online guides telling me to add ssl: true somewhere but i cant find it, let me post some screenshots
Add that to your connection string
so in my main.js i have this line
so i go to models > index.js and open the file
am i on the wrong file?
@earnest phoenix could you please take a look thanks
module.exports = async (bot, guild) => {
if(!guild.me.hasPermission(["SEND_MESSAGES", "EMBED_LINKS"])) return;
if(guild.name === undefined) return;
const embed = new MessageEmbed()
.setColor(red)
.setTitle("Attitude was Removed from a Server")
.setThumbnail(guild.iconURL({ size: 2048 }))
.addField("Server Name", `${guild}`)
.addField("Member Count", guild.memberCount)
.addField("Attitude is now in", `${bot.guilds.cache.size} servers!`)
return bot.channels.cache.get("780712801961902100").send(embed);
};
cannot read property hasPermission of null
did you replace the actual database_url?
no its been like that since the start, it actually worked since last year when i launched it, but few weeks ago heroku changed their stuff and blocked non-ssl database connections which caused my connection to not work
You're checking for the permissions of the bot that the bot either left or got kicked/banned, you can't check for that
my heroku app looks like that, an app with a postgres add-on
let me see
You should use this format postgres://user:pass@example.com:5432/dbname and then postgres://user:pass@example.com:5432/dbname?verifyServerCertificate=false&useSSL=true
Should I add it after the guildname === undefined?
Precisely new Sequelize('postgres://user:pass@example.com:5432/dbname?verifyServerCertificate=false&useSSL=true')
No, just remove it, you can't check for the permissions of the bot in that since it left that guild already
Oh alright.
Make sure member intents are on
Intents have nothing to do with that
.. and question. .replace("{server_owner_name}", member.guild.owner.user.username), why does it say cannot read property user of null?
is it this part?
You have to show more code but supposedly what youre replacing is null
The owner of the guild is not always cached, you have to fetch it @feral aspen
Oh.
Yes. Right now youre authenticating using direct credentials. Auth using url instead
https://sequelize.org/master/manual/getting-started.html#connecting-to-a-database for more @restive wagon
An easy-to-use multi SQL dialect ORM for Node.js
the url is what you need
and to that append what i said above
sorry im quite bad at databases and its concepts, might need some spoonfeeding help
alright lemme do it and screenshot again
You should just try new Sequelize('url?verifyServerCertificate=false&useSSL=true')
password and stuff is already inside the url
@earnest phoenix seems like the problem is not fixed yet
Hey does anyone know of a bot that can post a message when someone receives a specific role? Not a welcoming bot because it can do it at anytime this role is given not just joining
does forEach do things one at a time? (1212121212)
or multiple at a time? (1111122222)
ok so the error message produced in the log when using the url?verifyServerCertificate=false&useSSL=true is the same as the original error which is:
(node:4) UnhandledPromiseRejectionWarning: SequelizeConnectionError: no pg_hba.conf entry for host "54.224.223.52", user "iqezzwhocrduzj", database "d1geqa245p50dm", SSL off
but i looked up a solution on stack overflow which told me to do url?ssl=true now i get this error:
(node:4) UnhandledPromiseRejectionWarning: SequelizeConnectionError: self signed certificate
i guess im on the right path?
my forEach is running multiple at a time. Start Start End End.
I want to make it run only one at a time, and only start another one if the current one is finished
Start End Start End
use a for loop then
ok thanks, worked perfectly
oh i found the solution @earnest phoenix thanks for your help on navigating the chunk of code to modify else i wouldnt know where to add it
Awesome!
-_ Don't be like that, bro
what's the best discord library i should use if my bot suddenly goes brr
like to make it lighter
depends
u have bot ideas?
for which language? @slender wagon
hi guys, im searching someone that wants to make a economy system for me. dm me for info ( i can pay in paypal and cashapp )
bobs
js
sorry for late reply didn't saw the ping
if you want to make your bot lighter, look into libraries that allow you to disable what your bot doesnt need, more specifically caching
detritus, discord-rose and discord.js-light allow you to do that, there might be more
okay ty! 🙂
no
Hello, I've been struggling with this issue for a couple hours now and finally gave in down here I have a function (previously made by Tim)
function test(data = [{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], string = "1:4,2:3") {
let array = string.split(",");
for(let d = 0; d < data.length; d++) {
for(let i = 0; i < array.length; i++) {
if(!array[i].startsWith(data[d].itemid+":")) { continue; }
let [key,value] = array[i].split(":");
array[i] = `${key}:${parseInt(value)+data[d].amount}`;
break;
}
}
return array.join(",");
}
What this essentially does is it adds the amount to the id in the string eg this function will return: "1:6,2:4" as it's adding the amount of each index in the data array to it's itemid in the string, now when I add something with an index like this: {itemid: 3, amount: 1} in the data for example it doesn't return "1:6,2:4,3:1" like it's supposed to but just returns "1:6,2:4 anyone knows why?
read what I said
the function looks for existing values in the string, and then looks for matching values in the data
it seems you need to add it to the string as well
it doesnt look for new values in the data
how would I make it so it adds new values?
it has to be rewritten to work the other way around
go over the values in the data, and look for existing values in the string
for(let item of data) {
let [key, value] = Object.entries(item);
if(!string.indexOf(key)) {
string += `${key}:${value}`;
} else {
let startIndex = string.indexOf(key);
let endIndex = string.indexOf(",", startIndex);
if(endIndex === -1) { endIndex = string.length; }
let piece = string.slice(startIndex, endIndex);
let existingValue = Number(piece.split(":")[1]);
string = string.replace(piece, `${key}:${existingValue + value}`);
}
}
something like that should do
This returns itemid,3:NaNamount,24:1
Where can I see the source code of djs
change let [key, value] = Object.entries(item); to let key = item.itemid; let value = item.amount
itemid,4:NaNamount,1itemid,3:NaNamount,24:1
yeah but on github, it is written in js.
Isnt this lib written in ts?
hint: discord.js
djs-next will be written in ts
detritus is written in ts
djs, eris, etc.. are all in js
show full code
One message removed from a suspended account.
/hug
function test(data = [ { itemid: '3', amount: 2 }, { itemid: '4', amount: 1 } ], string = "4:1") {
for(let item of data) {
let key = item.itemid;
let value = item.amount;
if(!string.indexOf(key)) {
string += `${key}:${value}`;
} else {
let startIndex = string.indexOf(key);
let endIndex = string.indexOf(",", startIndex);
let piece = string.slice(startIndex, endIndex);
let existingValue = Number(piece.split(":")[1]);
string = string.replace(piece, `${key}:${existingValue + value}`);
}
}
return string;
}
if(!string.indexOf(key + ":"))
let startIndex = string.indexOf(key + ":");
if(endIndex === -1) { endIndex = string.length; } right after endIndex
4:3:NaN I don't think this is right
How should I prepare an article for the opening of your existence and throw it on the disc?
????

show current code
function test(data = [{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], string = "1:4,2:3") {
for(let item of data) {
let key = item.itemid;
let value = item.amount;
if(!string.indexOf(key + ":")) {
string += `${key}:${value}`;
} else {
let startIndex = string.indexOf(key + ":");
let endIndex = string.indexOf(",", startIndex);
if(endIndex === -1) { endIndex = string.length; }
let piece = string.slice(startIndex, endIndex);
let existingValue = Number(piece.split(":")[1]);
string = string.replace(piece, `${key}:${existingValue + value}`);
}
}
return string;
}
console.log(test([ { itemid: '3', amount: 2 }, { itemid: '4', amount: 1 } ], "4:1"))
if(!string.includes(key + ":")) {
Now it returned 4:14
lemme make my own version
what is the meaning of this in a static method? Does it points to the static members of the class? (in js)
yes
string += `,${key}:${value}`; add a comma
it's the class itself
string = string.replace(piece, ${key}:${existingValue + value}); here?
Why not use a map or an object for the data instead of an array? All items in the array have unique keys, so a map would be more appropriate
no, in the string.includes
string.split(",").map(i => items.find(item => item.itemid === i.split(":")[0]) ? i.split(":")[0] + ":" + (parseInt(i.split(":")[1]) + items.find(item => item.itemid === i.split(":")[0]).amount) : i).join(",");
This is what I had at first, but Tim made a faster version and this version uph ere has the same issue so I looked in a file where I saved that function and used that one instead but it appears it has the exact same issue
thats not what he means
Oh
he means using new Map() and setting the data there
instead of array of objects
or one big object instead of array of objects
idk
anyway did you add the comma? it should work now
but it works now although 1 small thing if I put the string to "" it returns: ,3:2,4:1 how would I remove the first comma?
can I just do string.length <= 0 ? string += ${key}:${value}: string +=,${key}:${value};?
Yeah that works
alright tyvm Tim! 😄
string += `${string ? "," : ""}${key}:${value}`
ty 😄
Instead of doing... that you can simply change the data structure you're storing the items in and make your code cleaner and probably faster
so this is the working remove messages command, but if i type anything that starts with the prefix, it clears messages. Does anyone know why?
where should i put it to make it read the command instead of the prefix
that line says "if the message starts with prefix plus RemoveMessages, do nothing"
aka, continue the code like nothing happened
should i connect it with a ;
no
or put the rest of the code into a {}
yes
Also read https://js.evie.dev/conditions for reference 😉
read the entirety of https://js.evie.dev tbh
High praise coming from Tim 
<3
Then you didn't wrap it correctly
One message removed from a suspended account.
Read this: #development message
You need to have 5 } in the correct spots 
One message removed from a suspended account.
One message removed from a suspended account.
I suggest learning js
One message removed from a suspended account.
One message removed from a suspended account.
Don't just count the things, actually look at how they work and what they do.
One message removed from a suspended account.
^
As #development message tries to show you
We tried to tell him for 2 days now to learn the JS basics or at least any coding basics. 
bro whats this
You’re still copying code without understanding it.
Tbh, I did the same but I wouldn't recommend doing that as it doesn't teach you the fundamentals of js
i read the article, and i put down the code as it went. I didnt copy and paste, i followed the article that you guys sent me and did the instructions
Too bad I did that
any idea what this is i tried to add my bot
same lmao
TS too
it says close the window or tab
not just JS
Same and I regret it
same
yea but iam not able to add my bot
He’s asking what the error means
Not what it says
I don't regret it
When you actually start working on other projects then just bots you start to learn alot more of js imo
@shrewd creek you have a button on your discord dev portal that is requiring a code grant which you don’t have
Disable it there and generate a new link
Discord developer portal button, not the link
this
ohkay thx bud
isnt that the invite link
seems like i was messing with the oauth2 settings
Aye
We really appreciate it that you're trying to help, but please if you don't know what you're talking about don't try to you'll put other people on the wrong path
This
is something wrong with dbl??




