Comments (10)
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
}
});
}
Try that. It's a polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
from quick.db.
I dont understand hhow to use it
from quick.db.
In basic terms, copy and paste it in your main file, or before wherever you need to use .startsWith()
.
from quick.db.
ok
from quick.db.
`const { MessageEmbed } = require("discord.js")
const { cyan } = require("../../colours.json");
const db = require('quick.db');
module.exports = {
config: {
name: "top",
description: "Test The Bot",
usage: "To annoy kiddoz who want to ping me",
category: "miscellaneous",
accessableby: "Members"
},
run: async (bot, message, args) => {
let money = db.startsWith(`scores_${message.guild.id}`, { sort: '.data'})
let content = "";
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
value: function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
}
});
}
for (let i = 0; i < 10; i++) {
let user = bot.users.get(scores[i].ID.split('_')[2]).username
content += `${i+1}. ${user} ~ ${money[i].data}\n`
}
const embed = new MessageEmbed()
.setDescription(`**${message.guild.name}'s Coin Leaderboard**\n\n${content}`)
.setColor("#FFFFFF")
message.channel.send(embed)
}
}`
from quick.db.
Like this?
from quick.db.
No omg. You need to have a basic understanding of JS before asking for help here.
from quick.db.
I do but i dont really understand some stuff so plz help
from quick.db.
Its easier if they just add .startsWith() back
from quick.db.
You can get an array of the entries by using db.all()
. Then you can filter and sort the results. You need to change the following line:
let money = db.startsWith(`scores_${message.guild.id}`, { sort: '.data'})
to the following:
let money = db.all().filter(entry => entry.ID.startsWith(`scores_${message.guild.id}`)).sort((a, b) => a.data < b.data);
I'm not sure if this will work with the rest of your code, so you may have to do some modifications.
from quick.db.
Related Issues (20)
- Removing an item from array HOT 2
- Add db.ping() HOT 1
- Starts with function HOT 2
- [Feature Request] Encryption HOT 10
- So I'm making a ban type system for a game from Discord. But.. I get this error. HOT 2
- Bot wont start ERR_DLOPEN_FAILED HOT 2
- invalid ELF header HOT 4
- SyntaxError: Unexpected token '?' on ubuntu HOT 3
- Can you create more than one file HOT 2
- Few questions HOT 3
- Custom Queries HOT 1
- [Bug report] performance issues? im not sure HOT 5
- mySQL update to v8 HOT 3
- `has` method always returns true HOT 2
- Dependency Dashboard
- "Error: connect ETIMEDOUT" HOT 5
- Add data update feature for 2 or more keys
- Could not connect with mongo driver HOT 2
- [Feature Request] Support for cassandra-driver HOT 3
- Pulling an object doesnt work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quick.db.