Reputation:
I am making a leaderboard command with replit database like I have stored data for users with their id and now I want to convert that ids to mention here's my code:
db.list().then(keys => {
const eachline = keys.split('/n')
for (const line of eachline) {
if(line.includes('Donation:')) {
const splat = line.split('Donation:')[1]
const final = '<@'+splat+'>';
message.chanel.send(final);
}}
});
This is what I can get from db.list()
But I am getting an error on the part const eachline = keys.split('/n')
the error is TypeError: keys.split is not a function
Upvotes: 0
Views: 399
Reputation: 64725
Well obviously keys
isn't a string, so you need to figure out what it is
db.list().then(keys => {
console.log(keys);
});
I'd assume from the image that it's an array of strings? In which case you can probably just do:
db.list().then(lines => {
for (const line of lines) {
if(line.includes('Donation:')) {
const splat = line.split('Donation:')[1]
const final = '<@'+splat+'>';
message.chanel.send(final);
}
}
});
Upvotes: 1