Giter Club home page Giter Club logo

Comments (10)

 avatar commented on June 17, 2024

@Conutik

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.

Conutik avatar Conutik commented on June 17, 2024

I dont understand hhow to use it

from quick.db.

 avatar commented on June 17, 2024

In basic terms, copy and paste it in your main file, or before wherever you need to use .startsWith().

from quick.db.

Conutik avatar Conutik commented on June 17, 2024

ok

from quick.db.

Conutik avatar Conutik commented on June 17, 2024

`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.

Conutik avatar Conutik commented on June 17, 2024

Like this?

from quick.db.

 avatar commented on June 17, 2024

No omg. You need to have a basic understanding of JS before asking for help here.

from quick.db.

Conutik avatar Conutik commented on June 17, 2024

I do but i dont really understand some stuff so plz help

from quick.db.

Conutik avatar Conutik commented on June 17, 2024

Its easier if they just add .startsWith() back

from quick.db.

DaemonBeast avatar DaemonBeast commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.