Dylan Neiger
@ThatGhost
16 year old programmer. Yes that's my real lastname.
Boston Massachussets
0
anime.js stagger header thingycool stagger grid affect thing inspired by https://youtu.be/bAwEj_mSzOs
4
0
0
1
Collections
Collections
A library which adds a Collection data type.
What is a Collection?
A Collection is like an array of objects, but a Collection does this in a much more organized and controlled manner.
Each object is required to have a unique key, and a value.
Adding Entries
When initiating the Collection, you can provide a rest parameter of objects which will automatically be added to the Collection.
const collection = new Collection(
// Add as many entries as you want.
{
key: "foo",
value: "bar"
},
{
key: "hello",
value: "world"
}
);
Or use the addEntry method which does the same thing as the constructor.
const collection = new Collection();
collection.addEntry(
// Add as many entries as you want.
{
key: "foo",
value: "bar"
},
{
key: "hello",
value: "world"
}
);
Retrieving Values
There are several ways to retrieve values.
If you want to get the value of the first entry in the object use the first method.
console.log(collection.first()); // > "bar"
Or if you want to get the value of the last entry in the object use the last method.
console.log(collection.last()); // > "world"
If you need a specific value, use the get method and supply it with the key to the entry.
console.log(collection.get("hello")); // > "world"
Removing Values
To remove a value, use the remove method and supply it with the key to the entry.
collection.remove("foo");
console.log(collection.get("foo")); // > undefined
The remove method does not return anything.
Getting a Random Key
To get a random key, use the randomKey method.
console.log(collection.randomKey()); // > "foo" or "hello"
If you want to get a random valye yse the random method.
console.log(collection.random()); // > "bar" or "world"
Iterating Through a Collection
A Collection returns the key of an entry and the value of an entry when being used in a for .. of loop.
for(const [key,value] of collection){
console.log(key,value); // > "foo bar" on first iteration and "hello world" on second iteration.
}
You can also just iterate through the keys using the keys method, which returns an array of all the keys in the Collection.
for(const key of collection.keys()){
console.log(key) // > "foo" on first iteration and "hello" on second iteration.
}
You can also just iterate through the values using the values method, which returns an array of all the values in the Collection.
for(const value of collection.values()){
console.log(key) // > "bar" on first iteration and "world" on second iteration.
}
`1
Toronto
Toronto is a custom programming language I made using deno.
Documentation can be found on the README.md file in the repository.5
1
1
So I have lots of cool projects planned, but for now I made a simple moving system. The camera moves when you press w, a, s, or d
Node.js
How do you make Replit Auth using Javascript.
Code
Anyone else think that CSS is way too hard and takes way too long.
If not then your wrong, its way too hard and takes way too long.
If your good at
Node.js
Carolinefort I found the other one after posting this but thanks for the helpful instruction. Hopefully it didn't confuse you too much. They should write instructions on how to handle two questions on the same topic.
https://www.advancedmd.run/1 year ago
JakeHu2020 use
res.sendFile(__dirname+'/public/index.html')
instead of
fs.readFile("public/index.html", function(err,data){
res.writeHead(200, {"Content-Type": "text/html"});
res.write(data);
res.end();
});
`1 year ago
We all know that repl doesn't support .htaccess but there are still ways to work around the issue!
First, make a new nodejs repl, then install expres
Version 2.1.2 is out!
And the api (finally) works!
Thanks to @JustCoding123 for helping me make release this version, couldn't have done it without t
JustCoding123 I know how to use the api. Make an account for the bot (or use an already existing one). Go to a channel and open dev tools. Navigate to network and send a message in the channel. You will see the request and the Request URL has every parameter you need.2 years ago
GameDev46 Do you have any idea to not make it a discord copy? I kinda want it to be its own chat site and not copy another!2 years ago
So, here is the background on my issue:
I am making a discord bot for my server. It has a dashboard and everything.
I am making a captcha system righ
Coder100 db.get returns a promise, meaning it takes time for the function to execute.
What you have to do is something like this:
client.on("message", async(msg) => {
let val = await db.get("value");
msg.channel.send(val);
})
DO NOT FORGET THE ASYNC ON LINE 1
it is required for the await syntax.2 years ago
Update: This was solved by @Coder100. I made a stupid mistake, after typing the redirect url in discord developer portal I had to delete the repl and
So here is my issue:
I am trying to make a login/signup system for my site.
By default buttons:
Look ugly
And automatically reloads the page
Both of
Coder100 Buttons in forms will automatically change the URL when clicked making it look like the website reloaded.
So add this:
document.querySelector("#signup").addEventListener("click", e => e.preventDefault());
By the way, line 20:
.then(res => res.json())
please take the time to learn the arrow function syntax. Without the curly braces, the immediate expression is returned.2 years ago
Bookie0 I'm not exactly sure what you want, but if you want a button to not reload and not do anything (like the title of your post), you can put the button in ` tags to make it a sort of link and inside the href="" add javascript:void(0);`.2 years ago
How would I script a login/signup system using html, css and javascript.
This was made with permission from GameDev46 himself.
Content
How did I do it?
Getting Started
Creating a new BotUser
Bot Security
Using the .when E