#djs storing data

23 messages · Page 1 of 1 (latest)

hushed spadeBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

near topaz
#

discord.js is a library for interacting with the discord api, not for storage

uneven widget
#

taken from discordjs guide

near topaz
#

where from? thats very much outdated

uneven widget
#

but this is for v12. in v14, it's a bit different

#

listen on the messageCreate event, process the user message then send it back

hushed spadeBOT
uneven widget
#

your JS knowledge seems very limited, so idk how to help you

icy swallow
#

Are you trying to store data in like a database or you want to make a block based variable that will be initiated every time the command is run ? I would of course encourage you to learn basic JS before diving into discord.js

#

You can find popular resources for learning in #resources

sturdy wind
#

go for a .starts with '!register ' and then slice it at the space and you van take the second part for the responce

radiant patrol
#

It's also possible with messages but slash commands are recommended

sturdy wind
#

this is what i got for something slightly simular, you'l just have to short it in to what you need

 if(msg.content.startsWith('tb! ')) {
            console.log('recognised')
            if(msg.content.startsWith('add reaction: ', 4)){
                if(msg.content.includes(';')){
                    const message = msg.content;
                    const reaction = message.slice(18);
                    const index = reaction.indexOf(';');
                    console.log(index);
                    const key = reaction.slice(0,index);
                    const value = reaction.slice(index+1);
                    reactions[key] = value;
                    console.log('reaction added');
                    console.log(reactions);
                }else{
                    msg.channel.send("no divider: ';'")
                }
            }
        }
radiant patrol
#

Then you can use args[0] for the first argument, 1 for 2nd, etc.

#

They are separated by spaces

#

And to get things after space as well you can use for example args[1].join(" ")

#

But it's still better to use slash commands instead

#

They have all those options built-in

sturdy wind
uneven widget
#

op already solved their problem, so this should be closed anyway