MYSQL didn't work, trying MongoDB instead

This commit is contained in:
ION606
2022-05-09 12:11:18 +03:00
parent 8e26fb33b4
commit 1b0f3b721a
7 changed files with 3 additions and 515 deletions
-220
View File
@@ -1,220 +0,0 @@
module.exports = {
name: 'ECON',
description: 'ALL ECON STUFF',
async execute(clientTemp, prefix, message, args, com2, Users, currency) {
const { Op } = require('sequelize');
const { Collection, Client, Formatters, Intents } = require('discord.js');
const { CurrencyShop } = require('./dbObjects.js');
const command = com2;
const client = clientTemp; //new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
/*
* THIS REPO HEAVILY BORROWS FROM https://github.com/discordjs/guide/tree/main/code-samples/sequelize/currency
* Make sure you are on at least version 5 of Sequelize! Version 4 as used in this guide will pose a security threat.
* You can read more about this issue On the [Sequelize issue tracker](https://github.com/sequelize/sequelize/issues/7310).
*/
//If the table hasn't been created, use "node dbInit.js"
function isNum(arg) {
return (!isNaN(arg) && Number.isSafeInteger(Number(arg)));
};
Reflect.defineProperty(currency, 'add', {
value: async (id, amount) => {
const user = currency.get(id);
if (user) {
user.balance += Number(amount);
return user.save();
}
const newUser = await Users.create({ user_id: id, balance: amount });
currency.set(id, newUser);
return newUser;
},
});
Reflect.defineProperty(currency, 'getBalance', {
value: id => {
const user = currency.get(id);
return user ? user.balance : 0;
},
});
client.once('ready', async () => {
const storedBalances = await Users.findAll();
storedBalances.forEach(b => currency.set(b.user_id, b));
console.log(`Logged in as ${client.user.tag}!`);
});
// client.on('messageCreate', async message => {
//debounce();
// if (message.author.bot) return;
// currency.add(message.author.id, 1);
// });
// client.on('interactionCreate', async interaction => {
//if (!interaction.isCommand()) return;
//To replace this with an interaction, replace every instance of "message" with interaction
//Custom section
//const { commandName } = command;
//Replace all instances of "command" with "commandName"
//Replace "message.author;" with "interaction.options.getUser('user') || interaction.user;"
const user = await Users.findOne({ where: { user_id: message.author.id } });
// if (!user) { currency.add(message.author.id, 0); }
if (command == 'reset') {
if(message.guild.fetchOwner()) {
const target = message.author;
const oldBal = Number(currency.getBalance(target.id));
currency.add(target.id, -oldBal);
}
} else if (command == 'add') {
//Check if the person is a mod
if (!isNum(args[0])) { message.reply("No..."); }
else if (args[0] > 100) {
message.reply("That's over $100 you greedy pig!");
} else if (args[0] < 0) {
currency.add(message.author.id, args[0]);
}
else if (args.length < 2) {
const oldBal = Number(currency.getBalance(message.author.id));
if (oldBal > 0) {
currency.add(message.author.id, -oldBal);
}
currency.add(message.author.id, Number(args[0]) + oldBal);
} else {
for (let i = 1; i < args.size(); i ++) {
currency.add(args[i].id, oldBal + args[0]);
}
}
} else if (command === 'balance') {
const target = message.author;
currency.add(target.id, 0); //Make sure there's something
return message.reply(`${target.tag} has \$${currency.getBalance(target.id)}`);
} else if (command === 'inventory') {
const target = message.author;
const user = await Users.findOne({ where: { user_id: target.id } });
const items = await user.getItems();
if (!items.length) return message.reply(`${target.tag} has nothing!`);
return message.reply(Formatters.codeBlock(items.map(i => `\$${i.item.cost * i.amount} worth of ${i.amount} ${i.item.icon}`).join('\n')));
//return message.reply(`${target.tag} currently has ${items.map(t => `${t.amount} ${t.item.name}`).join(', ')}`);
} else if (command === 'transfer') {
const currentAmount = currency.getBalance(message.author.id); //interaction.user.id
const transferAmount = args[0]; //interaction.options.getInteger('amount');
const transferTarget = args[1]; //interaction.options.getUser('user');
if (transferAmount > currentAmount) return message.reply(`Sorry ${message.author} you don't have that much.`);
if (transferAmount <= 0) return message.reply(`Please enter an amount greater than zero, ${message.author}`);
currency.add(message.author.id, -transferAmount);
currency.add(transferTarget.id, transferAmount);
return message.reply(`Successfully transferred ${transferAmount}💰 to ${transferTarget.tag}. Your current balance is ${currency.getBalance(message.author.id)}💰`);
} else if (command === 'buy') {
if (!isNum(args[0]) || Number(args[0]) < 0) {
message.reply("Please enter a valid argument!");
return;
}
const numItems = Number(args[0]);
const itemName = args[1];
const item = await CurrencyShop.findOne({ where: { name: { [Op.like]: itemName } } });
if (!item) return message.reply('That item doesn\'t exist.');
if (item.cost > currency.getBalance(message.author.id)) {
return message.reply(`You don't have enough currency, ${message.author}`);
}
const user = await Users.findOne({ where: { user_id: message.author.id } });
await user.addItem(item, message, currency, args[0]);
return;
//return message.reply(`You've bought a ${item.name}`);
} else if (command == 'sell') {
const itemName = args[1];
const item = await CurrencyShop.findOne({ where: { name: { [Op.like]: itemName } } });
if (!item) return message.reply('That item doesn\'t exist.');
const user = await Users.findOne({ where: { user_id: message.author.id } });
let ll;
if (args.length > 1) {
ll = Number(args[0]);
} else {
ll = 1;
}
user.removeItem(item, message, currency, ll, CurrencyShop);
}else if (command === 'shop') {
const items = await CurrencyShop.findAll();
if (args.length == 0) {
let temp = Formatters.codeBlock(items.map(i => `${i.sect}`).join(' '));
temp = [...new Set(temp.split(' '))];
return message.reply("Please use the format /shop [type] [page number]\nTypes are: " + temp);
}
let ind = 1;
let noinp = false;
if (args.length > 1) {
if (args[1] < (items.length / 9)) {
ind = Number(args[1]);
} else {
return message.reply("That number is too large");
}
} else {
noinp = true;
}
const items2 = items.slice((ind - 1)*10, (ind - 1)*10+10);
newText = Formatters.codeBlock(items2.map(i => `${i.icon} (${i.name}): \$${i.cost}`)
.filter(f => f.sect = args[0]).join('\n'));
if (noinp) {
newText += "(Use /shop [type] [page number] to access other pages)";
}
return message.reply(newText);
} else if (command === 'leaderboard') {
return message.reply(
Formatters.codeBlock(
currency.sort((a, b) => b.balance - a.balance)
.filter(user => client.users.cache.has(user.user_id))
.first(10)
.map((user, position) => `(${position + 1}) ${(client.users.cache.get(user.user_id).tag)}: ${user.balance}💰`)
.join('\n'),
),
);
} else {
message.channel.send("'" + message.content + "' is not a command!");
}
// });
}
}
-143
View File
@@ -1,143 +0,0 @@
const Sequelize = require('sequelize');
/*
* Make sure you are on at least version 5 of Sequelize! Version 4 as used in this guide will pose a security threat.
* You can read more about this issue on the [Sequelize issue tracker](https://github.com/sequelize/sequelize/issues/7310).
*/
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
idle: 200000,
aquire: 1000000,
});
const CurrencyShop = require('./models/CurrencyShop.js')(sequelize, Sequelize.DataTypes);
require('./models/Users.js')(sequelize, Sequelize.DataTypes);
require('./models/UserItems.js')(sequelize, Sequelize.DataTypes);
const force = process.argv.includes('--force') || process.argv.includes('-f');
sequelize.sync({ force }).then(async () => {
const shop = [
CurrencyShop.upsert({ name: 'Grapes', cost: 2, icon: '🍇', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Melon', cost: 5, icon: '🍈', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Watermelon', cost: 5, icon: '🍉', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Tangerine', cost: 3, icon: '🍊', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Lemon', cost: 3, icon: '🍋', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Banana', cost: 4, icon: '🍌', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Pineapple', cost: 4, icon: '🍍', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Mango', cost: 3, icon: '🥭', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Red Apple', cost: 3, icon: '🍎', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Green Apple', cost: 3, icon: '🍏', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Pear', cost: 3, icon: '🍐', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Peach', cost: 3, icon: '🍑', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cherries', cost: 4, icon: '🍒', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Strawberry', cost: 3, icon: '🍓', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Blueberries', cost: 3, icon: '🫐', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Kiwi', cost: 3, icon: '🥝', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Tomato', cost: 4, icon: '🍅', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Olive', cost: 4, icon: '🫒', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Coconut', cost: 3, icon: '🥥', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Avocado', cost: 3, icon: '🥑', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Eggplant', cost: 10, icon: '🍆', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Potato', cost: 3, icon: '🥔', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Carrot', cost: 3, icon: '🥕', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Ear of Corn', cost: 3, icon: '🌽', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Hot Pepper', cost: 3, icon: '🌶️', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Bell Pepper', cost: 3, icon: '🫑', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cucumber', cost: 3, icon: '🥒', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Leafy Green', cost: 3, icon: '🥬', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Broccoli', cost: 2, icon: '🥦', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Garlic', cost: 3, icon: '🧄', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Onion', cost: 3, icon: '🧅', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Mushroom', cost: 3, icon: '🍄', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Peanuts', cost: 4, icon: '🥜', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Chestnut', cost: 3, icon: '🌰', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Bread', cost: 5, icon: '🍞', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Croissant', cost: 7, icon: '🥐', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Baguette Bread', cost: 10, icon: '🥖', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Flatbread', cost: 9, icon: '🫓', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Pretzel', cost: 5, icon: '🥨', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Bagel', cost: 4, icon: '🥯', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Pancakes', cost: 5, icon: '🥞', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Waffle', cost: 5, icon: '🧇', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cheese Wedge', cost: 3, icon: '🧀', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Meat on the Bone', cost: 5, icon: '🍖', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Checken Leg', cost: 5, icon: '🍗', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cut of Meat', cost: 4, icon: '🥩', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Bacon', cost: 4, icon: '🥓', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Hamburger', cost: 5, icon: '🍔', sect: 'Food' }),
CurrencyShop.upsert({ name: 'French Fries', cost: 3, icon: '🍟', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Pizza', cost: 6, icon: '🍕', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Hot Dog', cost: 3, icon: '🌭', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Sandwich', cost: 3, icon: '🥪', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Taco', cost: 3, icon: '🌮', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Burrito', cost: 5, icon: '🌯', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Tamale', cost: 5, icon: '🫔', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Stuffed Flatbread', cost: 5, icon: '🥙', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Falafel', cost: 4, icon: '🧆', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Egg', cost: 3, icon: '🥚', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Hot Pot', cost: 12, icon: '🍲', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Fondue', cost: 8, icon: '🫕', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Green Salad', cost: 3, icon: '🥗', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Popcorn', cost: 3, icon: '🍿', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Butter', cost: 2, icon: '🧈', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Salt', cost: 2, icon: '🧂', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Canned Food', cost: 3, icon: '🥫', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Bento Box', cost: 7, icon: '🍱', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Rice Cracker', cost: 1, icon: '🍘', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Rice Ball', cost: 3, icon: '🍙', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cooked Rice', cost: 3, icon: '🍚', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Curry Rice', cost: 4, icon: '🍛', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Ramen', cost: 4, icon: '🍜', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Spaghetti', cost: 5, icon: '🍝', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Roasted Sweet Potato', cost: 3, icon: '🍠', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Oden', cost: 3, icon: '🍢', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Sushi', cost: 4, icon: '🍣', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Fried Shrimp', cost: 3, icon: '🍤', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Fish Cake', cost: 3, icon: '🍥', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Moon Cake', cost: 3, icon: '🥮', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Dango', cost: 3, icon: '🍡', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Dumpling', cost: 3, icon: '🥟', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Fortune Cookie', cost: 3, icon: '🥠', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Oyster', cost: 4, icon: '🦪', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Ice Cream Cone', cost: 3, icon: '🍦', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Shaved Ice', cost: 3, icon: '🍧', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Ice Cream', cost: 3, icon: '🍨', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Doughnut', cost: 3, icon: '🍩', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cookie', cost: 3, icon: '🍪', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Birthday Cake', cost: 7, icon: '🎂', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Shortcake', cost: 4, icon: '🍰', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cupcake', cost: 3, icon: '🧁', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Pie', cost: 4, icon: '🥧', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Chocolate Bar', cost: 2, icon: '🍫', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Candy', cost: 1, icon: '🍬', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Lollipop', cost: 1, icon: '🍭', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Custard', cost: 3, icon: '🍮', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Honey Pot', cost: 3, icon: '🍯', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Baby Bottle', cost: 3, icon: '🍼', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Glass of Milk', cost: 3, icon: '🥛', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Coffee', cost: 3, icon: '☕', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Teapot', cost: 3, icon: '🫖', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Tea', cost: 3, icon: '🍵', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Sake', cost: 3, icon: '🍶', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Champagne', cost: 3, icon: '🍾', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Wine Glass', cost: 3, icon: '🍷', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Cocktail Glass', cost: 3, icon: '🍸', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Tropical Drink', cost: 3, icon: '🍹', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Beer Mug', cost: 3, icon: '🍺', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Tumbler', cost: 3, icon: '🥃', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Soda', cost: 3, icon: '🥤', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Bubble Tea', cost: 3, icon: '🧋', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Beverage Box', cost: 30, icon: '🧃', sect: 'Food' }),
CurrencyShop.upsert({ name: 'Mate', cost: 3, icon: '🧉', sect: 'Food' }),
];
await Promise.all(shop);
console.log('Database synced');
sequelize.close();
}).catch(console.error);
-94
View File
@@ -1,94 +0,0 @@
const Sequelize = require('sequelize');
/*
* Make sure you are on at least version 5 of Sequelize! Version 4 as used in this guide will pose a security threat.
* You can read more about this issue on the [Sequelize issue tracker](https://github.com/sequelize/sequelize/issues/7310).
*/
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
});
const Users = require('./models/Users.js')(sequelize, Sequelize.DataTypes);
const CurrencyShop = require('./models/CurrencyShop.js')(sequelize, Sequelize.DataTypes);
const UserItems = require('./models/UserItems.js')(sequelize, Sequelize.DataTypes);
UserItems.belongsTo(CurrencyShop, { foreignKey: 'item_id', as: 'item' });
Reflect.defineProperty(Users.prototype, 'addItem', {
/* eslint-disable-next-line func-name-matching */
value: async function addItem(item, message, currency, numItems) {
const userItem = await UserItems.findOne({
where: { user_id: this.user_id, item_id: item.id, sect: item.sect},
});
//Makes it so you can only buy as many items as you can afford
let numItemsFinal;
let n = Math.floor(currency.getBalance(message.author.id)/item.cost);
if (n > numItems) { numItemsFinal = numItems; }
else { numItemsFinal = n; }
currency.add(message.author.id, -(item.cost * numItemsFinal));
if (userItem) {
userItem.amount += numItemsFinal;
userItem.save();
} else {
UserItems.create({ user_id: this.user_id, item_id: item.id, amount: numItemsFinal, icon: item.icon, sect: item.sect });
}
//console.log(numItemsFinal);
return message.reply(`You bought ${numItemsFinal} ${item.icon} for \$${numItemsFinal * item.cost}. You have \$${currency.getBalance(message.author.id)} left.`);
},
});
Reflect.defineProperty(Users.prototype, 'removeItem', {
/* eslint-disable-next-line func-name-matching */
value: async function removeItem(item, message, currency, ll, CurrencyShop) {
const userItem = await UserItems.findOne({
where: { user_id: this.user_id, item_id: item.id },
});
let val;
if (userItem) {
if (userItem.amount > 0 && ll > 0) {
val = userItem.amount;
let i = 0;
val = userItem.amount;
if (ll > val) { i = val; }
else { i = ll; }
userItem.amount -= i;
userItem.save();
currency.add(message.author.id, i * item.cost);
if (userItem.amount <= 0) {
//START
const tagID = item.id;
// equivalent to: DELETE from tags WHERE name = ?;
const rowCount = await UserItems.destroy({ where: { item_id: tagID } });
if (!rowCount) return message.reply('That tag doesn\'t exist.');
}
return message.reply(`You've sold ${i} ${item.icon} for \$${i * item.cost}!`);
} else { return message.reply("You don't have this item!"); }
} else { return message.reply("You don't have this item!");}
},
});
Reflect.defineProperty(Users.prototype, 'getItems', {
/* eslint-disable-next-line func-name-matching */
value: function getItems() {
return UserItems.findAll({
where: { user_id: this.user_id },
include: ['item'],
});
},
});
module.exports = { Users, CurrencyShop, UserItems };
-22
View File
@@ -1,22 +0,0 @@
module.exports = (sequelize, DataTypes) => {
return sequelize.define('currency_shop', {
name: {
type: DataTypes.STRING,
unique: true,
},
cost: {
type: DataTypes.INTEGER,
allowNull: false,
},
icon: {
type: DataTypes.STRING,
unique: true,
},
sect: {
type: DataTypes.STRING,
allowNull: true,
},
}, {
timestamps: false,
});
};
-21
View File
@@ -1,21 +0,0 @@
module.exports = (sequelize, DataTypes) => {
return sequelize.define('user_item', {
user_id: DataTypes.STRING,
item_id: DataTypes.INTEGER,
amount: {
type: DataTypes.INTEGER,
allowNull: false,
'default': 0,
},
icon: {
type: DataTypes.STRING,
'default': '🤖',
},
sect: {
type: DataTypes.STRING,
'default': 'M',
}
}, {
timestamps: false,
});
};
-15
View File
@@ -1,15 +0,0 @@
module.exports = (sequelize, DataTypes) => {
return sequelize.define('users', {
user_id: {
type: DataTypes.STRING,
primaryKey: true,
},
balance: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
}, {
timestamps: false,
});
};
+3
View File
@@ -16,6 +16,9 @@ const bot = new Client({
const prefix = '/';
//MongoDB integration
const uri = process.env.MONGODB_URI;
const fs = require('fs');
const { exit } = require('process');
bot.commands = new Discord.Collection();