#Trying to make a better version of krpg bot

32 messages · Page 1 of 1 (latest)

drowsy kestrel
#

I need code to create a save data for each person who uses the command
/start basically my original attempt added to the same variable for everybody I need to create it so everyone has different data

robust mauve
drowsy kestrel
#

I need code that makes separate rata

#

Data

#

ik what your trying to say im not showing code or the problem

#

What im saying is I can't get it to be separate variables and need code to make separate user data

#

@robust mauve

#

If I need to show you what I currently have for my command /start

robust mauve
#

yes, you should describe the environment, explain what you've tried, explain why it didn't work, and show relevant code.

drowsy kestrel
#

Alt be

#

bet

#

let userStartTimes = [1];
//...

if(command == ('${/}start') {
// only add element if it doesnt exist already
if(!userStartTimes.some(el => el.id == message.author.id)) {
userStartTimes.add({id: message.author.id, time: Date.now()});
}
}
if(command == "logout") {
let index = userStarTimes.findIndex(el => el.id == message.author.id);
// check if user has logged in before
if(index != -1) {
let msecSpent = Date.now() - userStartTimes[index].time;
// add to leaderboard
}
}

#

this is what I tried to use to make different user data for each person who creates a profile using /start

#

@robust mauve

robust mauve
#

?share

drowsy kestrel
#

Wh

robust mauve
#

damn bot...

drowsy kestrel
#

Wha

robust mauve
#

see #faq for help formatting code on Discord

drowsy kestrel
#

?

#

Wym

#

Its JavaScript save data

robust mauve
#
  • you've provided nowhere near enough information
  • Discord supports code blocks. they make it far easier to parse/understand code. see #faq
#

note userStarTimes !== userStartTimes

drowsy kestrel
#

What part of faq

robust mauve
#

damn you're lazy

#

<#faq message>

drowsy kestrel
#

😶

robust mauve
#
  • you should always use === and !== instead of == and !=
  • userStarTimes !== userStartTimes
  • you still haven't explained exactly what you're trying to accomplish. if you want userStartTimes to be an array/object matching user IDs, do it?
#

also just use find() not findIndex()

drowsy kestrel
#

No I was trying to accomplish making a bot where you fight bosses and have mentors to get jutsu and I was gonna start with save data I tested my code by making a command that gives me coins and it changed the main variable meaning every user would share the same variable and I didn't wanna do it like that

#

Im gonna retry using bdscript