How to make a SQL or FS database for claiming waifus. DISCORDJS

I want to make a database that stores the names of the waifu’s that someone claimed in a guild.

When I click the heart, it sends an embed:
image

and it also stores your account ID, the waifu name and the amount of waifu’s you’ve claimed in a database. All the data would also be stored in the guild ID you claimed the waifu in so that the waifu’s you’ve claimed won’t be global.

(I don’t want to manually put the guild ID’s or any of the other things I mentioned)

DM me on discord if you need any more details: HK#1331

https://www.w3schools.com/nodejs/nodejs_mysql.asp

lol

I don’t like my sql a lot nor mongo

Why not?

Can you show me an example of how I would do it?

The code for the waifu command:

const {
    Client,
    MessageEmbed,
    ReactionCollector
} = require('discord.js');
const {
    prefix
} = require('../../config');
const superagent = require('superagent');
const {
    urlencoded
} = require('body-parser');


module.exports = {
    name: 'waifu',
    category: 'waifu',
    description: 'Random Waifu',
    usage: `${prefix}waifu`,
    perms: 'Send Messages',
    cooldown: 5,
    run: async (bot, message, args) => {

        const rating1 = 10
        const rating2 = Math.floor(Math.random() * rating1)
        var rating = rating2

        const decimals1 = 100
        const decimals2 = Math.floor(Math.random() * decimals1)
        var decimals = decimals2

        const compatibility1 = 100
        const compatibility2 = Math.floor(Math.random() * compatibility1)
        var compatibility = compatibility2

        const {
            waifuID
        } = require("../../Database/WaifuNameDB.json")

        let randW = Math.floor(Math.random() * Object.keys(waifuID).length)
        let randomWaifu = waifuID[randW]

        let embed2 = new MessageEmbed()
            .setTitle(`🎀${randomWaifu.names}🎀`)
            .addField("Claims:", `${randomWaifu.claims}`)
            .addField("Rating:", `${rating}.${decimals}/10 ⭐`)
            .setImage(`${randomWaifu.img_url}`, innerHeight = '500', innerWidth = '500')
            .setColor('#f095d1')
            .setFooter(`| Powered by: @Twintails🎀 API `, `https://64.media.tumblr.com/1a1c3bcc08b5a048b90139a56fe7f415/tumblr_o9ku1rVS8z1vnqjx7o2_250.png`)

        var mg = await message.channel.send(embed2);

        mg.react('💖')

        function messageReaction() {

            bot.on('messageReactionAdd', async (reaction, user) => {
                if (reaction.mg) await reaction.mg.fetch();
                if (reaction) await reaction.fetch()
                if (user.bot) return;
                if (reaction.emoji.name == "💖") {

                    let embed = new MessageEmbed()
                        .setAuthor("Married!💗")
                        .setThumbnail(`${randomWaifu.img_url}`)
                        .setDescription(`**${user.username} married ${randomWaifu.names}** 💕`)
                        .setColor('#f095d1')
                        .setFooter('Powered by: 🎀Twintails API')

                    message.channel.send(embed)
                    mg.delete()
                    
                }
                console.log(mg.reactions)
            })
        }
        messageReaction()
        /*for (const [key, value] of Object.entries(waifuID)) {
            console.log(key, value.names)
        }*/
        
    }
}

Sorry, but we can’t spoonfeed.

You would have to insert your data into a table.

var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "yourusername",
  password: "yourpassword",
  database: "mydb"
});

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
  var sql = "INSERT INTO photos (image, discord_id) VALUES ('username', 'photo')";
  con.query(sql, function (err, result) {
    if (err) throw err;
    console.log("1 record inserted");
  });
});
2 Likes

@HK420 I would grab a free DB from MongoDB Atlas. There are tones of tutorials to set it up with node and even specifically for discord.js using the Mongoose npm package. The free DB plan should be above and beyond what you need.

1 Like

This tutorial looks OK:


I haven’t had time to fully watch the video, so it may not be great.
3 Likes

MYSQL, that is though

If this bot is for a personal server only, I recommend using free database sites, such as MangoBD and/or Google Cloud (I recommend Google Cloud.) If this bot is intentionally for more than 100+ servers, a paid database would be better.

1 Like

Or you can just use the MySQL on your Glitch project.

I’ve never really tried it so I don’t have an opinion about it. :man_shrugging:

Should just be the same as any other mysql database.

Thanks so much!

1 Like

but Mysql starts with the same letter as MongoDB lol :slight_smile:.
EVE stack = Endb, VS Code, Eris just for fun

since when did we start putting text editor names in stack acronyms lol. I thought the N in MEN was nodejs not notepad++ image