This is a simplified example of the code you need to achieve your goal. By reading and understanding it, you should be able to accomplish what you are looking for.
const discord = require('discord.js'); // Import discord.js
const client = new discord.Client(); // Initialize new discord.js client
const messages = [];
client.on('message', (msg) => {
if (!msg.content.startsWith('+')) return; // Return if the message doesn't start with the prefix
const args = msg.content.slice(1).split(' '); // Split the message content by spaces
const cmd = args.shift().toLowerCase(); // Get the command from the arguments
switch (cmd) {
case 'add':
messages.push(args.join(' ')); // Add the message to the array
break;
case 'get':
msg.channel.send(messages.map((message) => `${message}\n`)); /* Send all stored messages */
break;
}
});
client.login(/* Your Discord Bot Token */); // Log in using your token