Added the framework for the 'game battle --> item' command, fixed the 'buy' command, changed the currency symbol, added the 'game equip' command, added extra fields to the 'items --> wepaons category

This commit is contained in:
ION606
2022-06-17 16:41:02 +03:00
parent eb828a59c0
commit 388c65c6dc
8 changed files with 328 additions and 218 deletions
+151 -144
View File
@@ -2,150 +2,157 @@ let d = new Date();
const START = d.getTime();
const { MongoClient, ServerApiVersion } = require('mongodb');
const mongouri = process.env.MONGODB_URI; //DO NOT RUN LOCALLY (no process.env)
resetShop = false;
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
let collectiontemp;
client.connect(err => {
collectiontemp = client.db("main").collection("shop");
// perform actions on the collection object
collectiontemp.insertMany(
[
{ name: 'Grapes', cost: 2, icon: '🍇', sect: 'Food' },
{ name: 'Melon', cost: 5, icon: '🍈', sect: 'Food' },
{ name: 'Watermelon', cost: 5, icon: '🍉', sect: 'Food' },
{ name: 'Tangerine', cost: 3, icon: '🍊', sect: 'Food' },
{ name: 'Lemon', cost: 3, icon: '🍋', sect: 'Food' },
{ name: 'Banana', cost: 4, icon: '🍌', sect: 'Food' },
{ name: 'Pineapple', cost: 4, icon: '🍍', sect: 'Food' },
{ name: 'Mango', cost: 3, icon: '🥭', sect: 'Food' },
{ name: 'Red Apple', cost: 3, icon: '🍎', sect: 'Food' },
{ name: 'Green Apple', cost: 3, icon: '🍏', sect: 'Food' },
{ name: 'Pear', cost: 3, icon: '🍐', sect: 'Food' },
{ name: 'Peach', cost: 3, icon: '🍑', sect: 'Food' },
{ name: 'Cherries', cost: 4, icon: '🍒', sect: 'Food' },
{ name: 'Strawberry', cost: 3, icon: '🍓', sect: 'Food' },
{ name: 'Blueberries', cost: 3, icon: '🫐', sect: 'Food' },
{ name: 'Kiwi', cost: 3, icon: '🥝', sect: 'Food' },
{ name: 'Tomato', cost: 4, icon: '🍅', sect: 'Food' },
{ name: 'Olive', cost: 4, icon: '🫒', sect: 'Food' },
{ name: 'Coconut', cost: 3, icon: '🥥', sect: 'Food' },
{ name: 'Avocado', cost: 3, icon: '🥑', sect: 'Food' },
{ name: 'Eggplant', cost: 10, icon: '🍆', sect: 'Food' },
{ name: 'Potato', cost: 3, icon: '🥔', sect: 'Food' },
{ name: 'Carrot', cost: 3, icon: '🥕', sect: 'Food' },
{ name: 'Ear of Corn', cost: 3, icon: '🌽', sect: 'Food' },
{ name: 'Hot Pepper', cost: 3, icon: '🌶️', sect: 'Food' },
{ name: 'Bell Pepper', cost: 3, icon: '🫑', sect: 'Food' },
{ name: 'Cucumber', cost: 3, icon: '🥒', sect: 'Food' },
{ name: 'Leafy Green', cost: 3, icon: '🥬', sect: 'Food' },
{ name: 'Broccoli', cost: 2, icon: '🥦', sect: 'Food' },
{ name: 'Garlic', cost: 3, icon: '🧄', sect: 'Food' },
{ name: 'Onion', cost: 3, icon: '🧅', sect: 'Food' },
{ name: 'Mushroom', cost: 3, icon: '🍄', sect: 'Food' },
{ name: 'Peanuts', cost: 4, icon: '🥜', sect: 'Food' },
{ name: 'Chestnut', cost: 3, icon: '🌰', sect: 'Food' },
{ name: 'Bread', cost: 5, icon: '🍞', sect: 'Food' },
{ name: 'Croissant', cost: 7, icon: '🥐', sect: 'Food' },
{ name: 'Baguette Bread', cost: 10, icon: '🥖', sect: 'Food' },
{ name: 'Flatbread', cost: 9, icon: '🫓', sect: 'Food' },
{ name: 'Pretzel', cost: 5, icon: '🥨', sect: 'Food' },
{ name: 'Bagel', cost: 4, icon: '🥯', sect: 'Food' },
{ name: 'Pancakes', cost: 5, icon: '🥞', sect: 'Food' },
{ name: 'Waffle', cost: 5, icon: '🧇', sect: 'Food' },
{ name: 'Cheese Wedge', cost: 3, icon: '🧀', sect: 'Food' },
{ name: 'Meat on the Bone', cost: 5, icon: '🍖', sect: 'Food' },
{ name: 'Checken Leg', cost: 5, icon: '🍗', sect: 'Food' },
{ name: 'Cut of Meat', cost: 4, icon: '🥩', sect: 'Food' },
{ name: 'Bacon', cost: 4, icon: '🥓', sect: 'Food' },
{ name: 'Hamburger', cost: 5, icon: '🍔', sect: 'Food' },
{ name: 'French Fries', cost: 3, icon: '🍟', sect: 'Food' },
{ name: 'Pizza', cost: 6, icon: '🍕', sect: 'Food' },
{ name: 'Hot Dog', cost: 3, icon: '🌭', sect: 'Food' },
{ name: 'Sandwich', cost: 3, icon: '🥪', sect: 'Food' },
{ name: 'Taco', cost: 3, icon: '🌮', sect: 'Food' },
{ name: 'Burrito', cost: 5, icon: '🌯', sect: 'Food' },
{ name: 'Tamale', cost: 5, icon: '🫔', sect: 'Food' },
{ name: 'Stuffed Flatbread', cost: 5, icon: '🥙', sect: 'Food' },
{ name: 'Falafel', cost: 4, icon: '🧆', sect: 'Food' },
{ name: 'Egg', cost: 3, icon: '🥚', sect: 'Food' },
{ name: 'Hot Pot', cost: 12, icon: '🍲', sect: 'Food' },
{ name: 'Fondue', cost: 8, icon: '🫕', sect: 'Food' },
{ name: 'Green Salad', cost: 3, icon: '🥗', sect: 'Food' },
{ name: 'Popcorn', cost: 3, icon: '🍿', sect: 'Food' },
{ name: 'Butter', cost: 2, icon: '🧈', sect: 'Food' },
{ name: 'Salt', cost: 2, icon: '🧂', sect: 'Food' },
{ name: 'Canned Food', cost: 3, icon: '🥫', sect: 'Food' },
{ name: 'Bento Box', cost: 7, icon: '🍱', sect: 'Food' },
{ name: 'Rice Cracker', cost: 1, icon: '🍘', sect: 'Food' },
{ name: 'Rice Ball', cost: 3, icon: '🍙', sect: 'Food' },
{ name: 'Cooked Rice', cost: 3, icon: '🍚', sect: 'Food' },
{ name: 'Curry Rice', cost: 4, icon: '🍛', sect: 'Food' },
{ name: 'Ramen', cost: 4, icon: '🍜', sect: 'Food' },
{ name: 'Spaghetti', cost: 5, icon: '🍝', sect: 'Food' },
{ name: 'Roasted Sweet Potato', cost: 3, icon: '🍠', sect: 'Food' },
{ name: 'Oden', cost: 3, icon: '🍢', sect: 'Food' },
{ name: 'Sushi', cost: 4, icon: '🍣', sect: 'Food' },
{ name: 'Fried Shrimp', cost: 3, icon: '🍤', sect: 'Food' },
{ name: 'Fish Cake', cost: 3, icon: '🍥', sect: 'Food' },
{ name: 'Moon Cake', cost: 3, icon: '🥮', sect: 'Food' },
{ name: 'Dango', cost: 3, icon: '🍡', sect: 'Food' },
{ name: 'Dumpling', cost: 3, icon: '🥟', sect: 'Food' },
{ name: 'Fortune Cookie', cost: 3, icon: '🥠', sect: 'Food' },
{ name: 'Oyster', cost: 4, icon: '🦪', sect: 'Food' },
{ name: 'Ice Cream Cone', cost: 3, icon: '🍦', sect: 'Food' },
{ name: 'Shaved Ice', cost: 3, icon: '🍧', sect: 'Food' },
{ name: 'Ice Cream', cost: 3, icon: '🍨', sect: 'Food' },
{ name: 'Doughnut', cost: 3, icon: '🍩', sect: 'Food' },
{ name: 'Cookie', cost: 3, icon: '🍪', sect: 'Food' },
{ name: 'Birthday Cake', cost: 7, icon: '🎂', sect: 'Food' },
{ name: 'Shortcake', cost: 4, icon: '🍰', sect: 'Food' },
{ name: 'Cupcake', cost: 3, icon: '🧁', sect: 'Food' },
{ name: 'Pie', cost: 4, icon: '🥧', sect: 'Food' },
{ name: 'Chocolate Bar', cost: 2, icon: '🍫', sect: 'Food' },
{ name: 'Candy', cost: 1, icon: '🍬', sect: 'Food' },
{ name: 'Lollipop', cost: 1, icon: '🍭', sect: 'Food' },
{ name: 'Custard', cost: 3, icon: '🍮', sect: 'Food' },
{ name: 'Honey Pot', cost: 3, icon: '🍯', sect: 'Food' },
{ name: 'Baby Bottle', cost: 3, icon: '🍼', sect: 'Food' },
{ name: 'Glass of Milk', cost: 3, icon: '🥛', sect: 'Food' },
{ name: 'Coffee', cost: 3, icon: '☕', sect: 'Food' },
{ name: 'Teapot', cost: 3, icon: '🫖', sect: 'Food' },
{ name: 'Tea', cost: 3, icon: '🍵', sect: 'Food' },
{ name: 'Sake', cost: 3, icon: '🍶', sect: 'Food' },
{ name: 'Champagne', cost: 3, icon: '🍾', sect: 'Food' },
{ name: 'Wine Glass', cost: 3, icon: '🍷', sect: 'Food' },
{ name: 'Cocktail Glass', cost: 3, icon: '🍸', sect: 'Food' },
{ name: 'Tropical Drink', cost: 3, icon: '🍹', sect: 'Food' },
{ name: 'Beer Mug', cost: 3, icon: '🍺', sect: 'Food' },
{ name: 'Tumbler', cost: 3, icon: '🥃', sect: 'Food' },
{ name: 'Soda', cost: 3, icon: '🥤', sect: 'Food' },
{ name: 'Bubble Tea', cost: 3, icon: '🧋', sect: 'Food' },
{ name: 'Beverage Box', cost: 30, icon: '🧃', sect: 'Food' },
{ name: 'Mate', cost: 3, icon: '🧉', sect: 'Food' },
//Weapons
{ name: 'Swords_special', cost: 3, icon: '⚔️', sect: 'Weapons' },
{ name: 'Boomerang', cost: 300, icon: '🪃', sect: 'Weapons' },
{ name: 'Boomerang', cost: 200, icon: '🏹', sect: 'Weapons' },
{ name: 'Knife', cost: 20, icon: '🔪', sect: 'Weapons' },
{ name: 'Dagger', cost: 60, icon: '🗡', sect: 'Weapons' },
{ name: 'Shield', cost: 100, icon: '🛡', sect: 'Weapons' },
{ name: 'Axe', cost: 40, icon: '🪓', sect: 'Weapons' },
{ name: 'Trident', cost: 140, icon: '🔱', sect: 'Weapons' },
{ name: 'Scissors', cost: 10, icon: '✂️', sect: 'Weapons' },
//Potions (of varying sections)
{ name: 'HP Potion', cost: 20, icon: 'CUSTOM|healing_potion', sect: 'HP' },
{ name: 'MP Potion', cost: 15, icon: 'CUSTOM|mana_potion', sect: 'MP' },
{ name: 'Super HP Potion', cost: 50, icon: 'CUSTOM|superior_healing_potion', sect: 'HP' },
{ name: 'Super MP Potion', cost: 40, icon: 'CUSTOM|superior_mana_potion', sect: 'MP' }
]);
});
if (resetShop) {
const { MongoClient, ServerApiVersion } = require('mongodb');
const mongouri = process.env.MONGODB_URI; //DO NOT RUN LOCALLY (no process.env)
client.close().then(function() {
const END = d.getTime();
console.log(`Total time in SECONDS: ${(((END - START) % 60000) / 1000).toFixed(0)} ms!`);
});
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
let collectiontemp;
client.connect(err => {
collectiontemp = client.db("main").collection("shop");
// perform actions on the collection object
collectiontemp.insertMany(
[
{ name: 'Grapes', cost: 2, icon: '🍇', sect: 'Food' },
{ name: 'Melon', cost: 5, icon: '🍈', sect: 'Food' },
{ name: 'Watermelon', cost: 5, icon: '🍉', sect: 'Food' },
{ name: 'Tangerine', cost: 3, icon: '🍊', sect: 'Food' },
{ name: 'Lemon', cost: 3, icon: '🍋', sect: 'Food' },
{ name: 'Banana', cost: 4, icon: '🍌', sect: 'Food' },
{ name: 'Pineapple', cost: 4, icon: '🍍', sect: 'Food' },
{ name: 'Mango', cost: 3, icon: '🥭', sect: 'Food' },
{ name: 'Red Apple', cost: 3, icon: '🍎', sect: 'Food' },
{ name: 'Green Apple', cost: 3, icon: '🍏', sect: 'Food' },
{ name: 'Pear', cost: 3, icon: '🍐', sect: 'Food' },
{ name: 'Peach', cost: 3, icon: '🍑', sect: 'Food' },
{ name: 'Cherries', cost: 4, icon: '🍒', sect: 'Food' },
{ name: 'Strawberry', cost: 3, icon: '🍓', sect: 'Food' },
{ name: 'Blueberries', cost: 3, icon: '🫐', sect: 'Food' },
{ name: 'Kiwi', cost: 3, icon: '🥝', sect: 'Food' },
{ name: 'Tomato', cost: 4, icon: '🍅', sect: 'Food' },
{ name: 'Olive', cost: 4, icon: '🫒', sect: 'Food' },
{ name: 'Coconut', cost: 3, icon: '🥥', sect: 'Food' },
{ name: 'Avocado', cost: 3, icon: '🥑', sect: 'Food' },
{ name: 'Eggplant', cost: 10, icon: '🍆', sect: 'Food' },
{ name: 'Potato', cost: 3, icon: '🥔', sect: 'Food' },
{ name: 'Carrot', cost: 3, icon: '🥕', sect: 'Food' },
{ name: 'Ear of Corn', cost: 3, icon: '🌽', sect: 'Food' },
{ name: 'Hot Pepper', cost: 3, icon: '🌶️', sect: 'Food' },
{ name: 'Bell Pepper', cost: 3, icon: '🫑', sect: 'Food' },
{ name: 'Cucumber', cost: 3, icon: '🥒', sect: 'Food' },
{ name: 'Leafy Green', cost: 3, icon: '🥬', sect: 'Food' },
{ name: 'Broccoli', cost: 2, icon: '🥦', sect: 'Food' },
{ name: 'Garlic', cost: 3, icon: '🧄', sect: 'Food' },
{ name: 'Onion', cost: 3, icon: '🧅', sect: 'Food' },
{ name: 'Mushroom', cost: 3, icon: '🍄', sect: 'Food' },
{ name: 'Peanuts', cost: 4, icon: '🥜', sect: 'Food' },
{ name: 'Chestnut', cost: 3, icon: '🌰', sect: 'Food' },
{ name: 'Bread', cost: 5, icon: '🍞', sect: 'Food' },
{ name: 'Croissant', cost: 7, icon: '🥐', sect: 'Food' },
{ name: 'Baguette Bread', cost: 10, icon: '🥖', sect: 'Food' },
{ name: 'Flatbread', cost: 9, icon: '🫓', sect: 'Food' },
{ name: 'Pretzel', cost: 5, icon: '🥨', sect: 'Food' },
{ name: 'Bagel', cost: 4, icon: '🥯', sect: 'Food' },
{ name: 'Pancakes', cost: 5, icon: '🥞', sect: 'Food' },
{ name: 'Waffle', cost: 5, icon: '🧇', sect: 'Food' },
{ name: 'Cheese Wedge', cost: 3, icon: '🧀', sect: 'Food' },
{ name: 'Meat on the Bone', cost: 5, icon: '🍖', sect: 'Food' },
{ name: 'Checken Leg', cost: 5, icon: '🍗', sect: 'Food' },
{ name: 'Cut of Meat', cost: 4, icon: '🥩', sect: 'Food' },
{ name: 'Bacon', cost: 4, icon: '🥓', sect: 'Food' },
{ name: 'Hamburger', cost: 5, icon: '🍔', sect: 'Food' },
{ name: 'French Fries', cost: 3, icon: '🍟', sect: 'Food' },
{ name: 'Pizza', cost: 6, icon: '🍕', sect: 'Food' },
{ name: 'Hot Dog', cost: 3, icon: '🌭', sect: 'Food' },
{ name: 'Sandwich', cost: 3, icon: '🥪', sect: 'Food' },
{ name: 'Taco', cost: 3, icon: '🌮', sect: 'Food' },
{ name: 'Burrito', cost: 5, icon: '🌯', sect: 'Food' },
{ name: 'Tamale', cost: 5, icon: '🫔', sect: 'Food' },
{ name: 'Stuffed Flatbread', cost: 5, icon: '🥙', sect: 'Food' },
{ name: 'Falafel', cost: 4, icon: '🧆', sect: 'Food' },
{ name: 'Egg', cost: 3, icon: '🥚', sect: 'Food' },
{ name: 'Hot Pot', cost: 12, icon: '🍲', sect: 'Food' },
{ name: 'Fondue', cost: 8, icon: '🫕', sect: 'Food' },
{ name: 'Green Salad', cost: 3, icon: '🥗', sect: 'Food' },
{ name: 'Popcorn', cost: 3, icon: '🍿', sect: 'Food' },
{ name: 'Butter', cost: 2, icon: '🧈', sect: 'Food' },
{ name: 'Salt', cost: 2, icon: '🧂', sect: 'Food' },
{ name: 'Canned Food', cost: 3, icon: '🥫', sect: 'Food' },
{ name: 'Bento Box', cost: 7, icon: '🍱', sect: 'Food' },
{ name: 'Rice Cracker', cost: 1, icon: '🍘', sect: 'Food' },
{ name: 'Rice Ball', cost: 3, icon: '🍙', sect: 'Food' },
{ name: 'Cooked Rice', cost: 3, icon: '🍚', sect: 'Food' },
{ name: 'Curry Rice', cost: 4, icon: '🍛', sect: 'Food' },
{ name: 'Ramen', cost: 4, icon: '🍜', sect: 'Food' },
{ name: 'Spaghetti', cost: 5, icon: '🍝', sect: 'Food' },
{ name: 'Roasted Sweet Potato', cost: 3, icon: '🍠', sect: 'Food' },
{ name: 'Oden', cost: 3, icon: '🍢', sect: 'Food' },
{ name: 'Sushi', cost: 4, icon: '🍣', sect: 'Food' },
{ name: 'Fried Shrimp', cost: 3, icon: '🍤', sect: 'Food' },
{ name: 'Fish Cake', cost: 3, icon: '🍥', sect: 'Food' },
{ name: 'Moon Cake', cost: 3, icon: '🥮', sect: 'Food' },
{ name: 'Dango', cost: 3, icon: '🍡', sect: 'Food' },
{ name: 'Dumpling', cost: 3, icon: '🥟', sect: 'Food' },
{ name: 'Fortune Cookie', cost: 3, icon: '🥠', sect: 'Food' },
{ name: 'Oyster', cost: 4, icon: '🦪', sect: 'Food' },
{ name: 'Ice Cream Cone', cost: 3, icon: '🍦', sect: 'Food' },
{ name: 'Shaved Ice', cost: 3, icon: '🍧', sect: 'Food' },
{ name: 'Ice Cream', cost: 3, icon: '🍨', sect: 'Food' },
{ name: 'Doughnut', cost: 3, icon: '🍩', sect: 'Food' },
{ name: 'Cookie', cost: 3, icon: '🍪', sect: 'Food' },
{ name: 'Birthday Cake', cost: 7, icon: '🎂', sect: 'Food' },
{ name: 'Shortcake', cost: 4, icon: '🍰', sect: 'Food' },
{ name: 'Cupcake', cost: 3, icon: '🧁', sect: 'Food' },
{ name: 'Pie', cost: 4, icon: '🥧', sect: 'Food' },
{ name: 'Chocolate Bar', cost: 2, icon: '🍫', sect: 'Food' },
{ name: 'Candy', cost: 1, icon: '🍬', sect: 'Food' },
{ name: 'Lollipop', cost: 1, icon: '🍭', sect: 'Food' },
{ name: 'Custard', cost: 3, icon: '🍮', sect: 'Food' },
{ name: 'Honey Pot', cost: 3, icon: '🍯', sect: 'Food' },
{ name: 'Baby Bottle', cost: 3, icon: '🍼', sect: 'Food' },
{ name: 'Glass of Milk', cost: 3, icon: '🥛', sect: 'Food' },
{ name: 'Coffee', cost: 3, icon: '☕', sect: 'Food' },
{ name: 'Teapot', cost: 3, icon: '🫖', sect: 'Food' },
{ name: 'Tea', cost: 3, icon: '🍵', sect: 'Food' },
{ name: 'Sake', cost: 3, icon: '🍶', sect: 'Food' },
{ name: 'Champagne', cost: 3, icon: '🍾', sect: 'Food' },
{ name: 'Wine Glass', cost: 3, icon: '🍷', sect: 'Food' },
{ name: 'Cocktail Glass', cost: 3, icon: '🍸', sect: 'Food' },
{ name: 'Tropical Drink', cost: 3, icon: '🍹', sect: 'Food' },
{ name: 'Beer Mug', cost: 3, icon: '🍺', sect: 'Food' },
{ name: 'Tumbler', cost: 3, icon: '🥃', sect: 'Food' },
{ name: 'Soda', cost: 3, icon: '🥤', sect: 'Food' },
{ name: 'Bubble Tea', cost: 3, icon: '🧋', sect: 'Food' },
{ name: 'Beverage Box', cost: 30, icon: '🧃', sect: 'Food' },
{ name: 'Mate', cost: 3, icon: '🧉', sect: 'Food' },
//Weapons
// { name: 'Swords_special', cost: 3, icon: '⚔️', sect: 'Weapons', double: false },
{ name: 'Boomerang', cost: 300, icon: '🪃', sect: 'Weapons', double: false, def: false },
{ name: 'Crossbow', cost: 200, icon: '🏹', sect: 'Weapons', double: true, def: false },
{ name: 'Knife', cost: 20, icon: '🔪', sect: 'Weapons', double: false, def: false },
{ name: 'Dagger', cost: 60, icon: '🗡', sect: 'Weapons', double: false, def: false },
{ name: 'Shield', cost: 100, icon: '🛡', sect: 'Weapons', double: false, def: true },
{ name: 'Axe', cost: 40, icon: '🪓', sect: 'Weapons', double: false, def: false },
{ name: 'Trident', cost: 140, icon: '🔱', sect: 'Weapons', double: false, def: false },
{ name: 'Scissors', cost: 10, icon: '✂️', sect: 'Weapons', double: false, def: false },
//Potions (of varying sections)
{ name: 'HP Potion', cost: 20, icon: 'CUSTOM|healing_potion', sect: 'HP' },
{ name: 'MP Potion', cost: 15, icon: 'CUSTOM|mana_potion', sect: 'MP' },
{ name: 'Super HP Potion', cost: 50, icon: 'CUSTOM|superior_healing_potion', sect: 'HP' },
{ name: 'Super MP Potion', cost: 40, icon: 'CUSTOM|superior_mana_potion', sect: 'MP' }
]);
});
client.close().then(function() {
const END = d.getTime();
console.log(`Total time in SECONDS: ${(((END - START) % 60000) / 1000).toFixed(0)} ms!`);
});
} else {
console.log('To reset the main shop, please change the variable "resetShop" in the "COMPLETE_INIT.js" file to true');
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

+3 -3
View File
@@ -9,9 +9,9 @@ module.exports = {
//.setDescription('My professional resume')
.setImage('https://github.com/ION606/selmerBot/blob/main/Sleemer_Bringsjorgend.png?raw=true')
.addFields(
{name: 'My Epithets:', value: "Pearls of Wisdom"},
{name: '\t1. ', value: "Negative money is the best money"},
{name: '\t2. ', value: "There is no god, only logic"}
{name: 'My Epithets:', value: "~~Pearls of Wisdom~~"},
{name: '\t__Epithet 1__', value: "_Negative money is the best money_"},
{name: '\t__Epithet 2__', value: "_There is no god, only logic_"}
);
message.channel.send({ embeds: [newEmbed] });
+63 -16
View File
@@ -3,6 +3,7 @@ const { MessageActionRow, MessageButton, MessageSelectMenu } = require('discord.
const { STATE } = require('./econ');
const { winGame, getCustomEmoji } = require('./external_game_functions.js');
const { changeTurn } = require('../turnManager.js');
const { default: mongoose } = require('mongoose');
function postActionBar(thread, user_dbo) {
@@ -39,7 +40,7 @@ function attack_special() {
//Bow special phrase: Σ>―(´・ω・`)→
function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, items, xp_collection, interaction) {
function attack(client, user_dbo, other_dbo, bot, thread, xp_collection, interaction) {
//Get the weapon
user_dbo.find({'equipped': {$exists: true}}).toArray(function(err, docs) {
const doc = docs[0];
@@ -53,7 +54,7 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
dmg = doc.rank;
} else {
dmg = (doc.rank - 1) + Math.round(weapon.cost/5);
}
}
other_dbo.find({'equipped': {$exists: true}}).toArray(function (err, docs) {
const odoc = docs[0];
@@ -71,7 +72,7 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
if (new_hp <= 0) {
winGame(client, bot, client.db(user_dbo.s.namespace.db), user_dbo, xp_collection, interaction.message);
} else {
other_dbo.updateOne({'equipped': {$exists: true}}, { $set: { 'hpmp.hp' :new_hp }});
other_dbo.updateOne({'equipped': {$exists: true}}, { $set: { 'hpmp.hp' :new_hp, state: STATE.FIGHTING }});
}
});
@@ -85,13 +86,13 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
}
/**
* Called by "item"
*/
async function heal(interaction, client, user_dbo, bot, thread, command, mongouri, items) {
if (interaction.message.content.toLowerCase().indexOf('Which item would you like to use?') != -1) {
// The person picked out an item
//I think this is unecessary
}
//Get the 'healing' items (stored in "{item}: num" format)
user_dbo.find({'equipped': {$exists: true}}).toArray(async function(err, docs) {
const doc = docs[0];
@@ -100,8 +101,8 @@ async function heal(interaction, client, user_dbo, bot, thread, command, mongour
if (JSON.stringify(items) == '[]') {
postActionBar(thread, user_dbo);
return interaction.editReply("You don't have any items!");
interaction.editReply("You don't have any items!");
return postActionBar(thread, user_dbo);
} else { console.log(JSON.stringify(items))}
var itemlist = [];
@@ -142,22 +143,66 @@ async function heal(interaction, client, user_dbo, bot, thread, command, mongour
//Gets items by section/name, reacts with them to the message, when pressed, trigger a response
function item() {
throw 'THE "ITEM" COMMAND HAS NOT BEEN SET UP YET!';
function presentItems(interaction, client, user_dbo, bot, thread) {
// throw 'THE "ITEM" COMMAND HAS NOT BEEN SET UP YET!';
user_dbo.find({'equipped': {$exists: true}}).toArray(async function(err, docs) {
const doc = docs[0];
const items = doc.equipped.items;
// const items = rawitems.filter(function(f) { return (f.sect.toLowerCase() == 'hp') });
if (JSON.stringify(items) == '[]' || JSON.stringify(items) == '{}') {
interaction.editReply("You don't have any items!");
return postActionBar(thread, user_dbo);
} else { console.log(JSON.stringify(items))}
var itemlist = [];
items.forEach(function(item) {
let n = item.name;
itemlist.push({label: n, description: `${item.num} equipped!`, value: `${n}`});
});
//Find something to heal with
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId(`${interaction.user.id}|heal`)
.setPlaceholder('Nothing selected')
.addOptions(itemlist)
);
await interaction.editReply({ content: 'Please choose a health potion!', components: [row] });
});
}
function defend(user_dbo, bot, thread, command, mongouri, items) {
function defend(client, interaction, user_dbo, bot, thread) {
user_dbo.find({'equipped': {$exists: true}}).toArray(function(err, docs) {
const doc = docs[0];
const all_weapons = doc.get('weapons');
const shield = all_weapons.get('secondary');
//They don't have a shield
if (shield == undefined) {
thread.send("You don't have a shield equipped!");
return postActionBar(thread, user_dbo);
}
//Change state
user_dbo.updateOne({state: {$exists: true}}, {$set: {state: STATE.DEFENDING}});
})
changeTurn(client, bot, interaction);
postActionBar(thread, user_dbo);
}
function usePotion(interaction, client, user_dbo, bot, thread, command, mongouri) {
function usePotion(interaction, client, user_dbo, bot, thread) {
const name = interaction.values[0];
const cursor = user_dbo.find({'equipped.items': {$exists: true}});
@@ -176,7 +221,7 @@ function usePotion(interaction, client, user_dbo, bot, thread, command, mongouri
//If there's more than 1, subtract 1
if (items.num > 1) { items.num -= 1; allitems[ind] = items; }
else { allitems.splice(ind, 1) }
user_dbo.updateOne({'equipped.items': {$exists: true}}, {$set: {'equipped.items': allitems}});
})
@@ -196,14 +241,16 @@ async function handle(client, user_dbo, other_dbo, bot, thread, command, mongour
if (command == 'initalize') {
return postActionBar(thread, user_dbo);
} else if (command == 'attack') {
attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, items, xp_collection, interaction);
attack(client, user_dbo, other_dbo, bot, thread, xp_collection, interaction);
postActionBar(thread, other_dbo);
} else if (command == 'items') {
item();
presentItems(interaction, client, user_dbo, bot, thread);
} else if (command == 'heal') {
heal(interaction, client, user_dbo, bot, thread, command, mongouri, items); //.then(() => {postActionBar(thread, other_dbo)});
} else if (command == 'usepotion') {
usePotion(interaction, client, user_dbo, bot, thread, command, mongouri);
usePotion(interaction, client, user_dbo, bot, thread);
} else if (command == 'defend') {
defend(client, interaction, user_dbo, bot, thread);
}
// initiate(user_dbo, other_dbo, command, message);
+50 -37
View File
@@ -2,6 +2,9 @@ const { MongoClient, ServerApiVersion } = require('mongodb');
// const { update } = require('apt');
const { Collection, Client, Formatters, Intents } = require('discord.js');
const { CLIENT_ODBC } = require('mysql/lib/protocol/constants/client');
const { time } = require('@discordjs/builders');
let currencySymbol = '$';
//Declair an "enum" to help with BASE calculations
const BASE = {
@@ -91,7 +94,11 @@ function addxp(message, dbo, amt, xp_list) {
function getBalance(dbo, message) {
dbo.find({"balance": {$exists: true}}).toArray(function(err, doc) {
return message.reply('Your current balance is $' + String(doc[0].balance));
let bal = 0;
if (doc[0] && doc[0].balance) {
bal = doc[0].balance;
}
return message.reply(`Your current balance is ${currencySymbol}${bal}`);
});
}
@@ -114,26 +121,25 @@ function convertCurrency(id, amt, dbo) {
}
function checkAndUpdateBal(dbo, item, message, args) {
let b = false;
dbo.find({"balance": {$exists: true}}).toArray(b = function(err, doc) {
if (!String(doc)) {
message.reply("Your account doesn't exist, please contact the mods for support");
return false;
}
return new Promise(function(resolve, reject) {
dbo.find({"balance": {$exists: true}}).toArray(b = function(err, doc) {
if (!String(doc)) {
message.reply("Your account doesn't exist, please contact the mods for support");
return false;
}
const icost = args[0] * item.cost;
if (doc[0].balance < icost) {
message.reply("Insufficient funds!");
return false;
} else {
let temp = doc[0];
dbo.updateOne({balance: temp.balance, rank: temp.rank, lastdayworked: temp.lastdayworked}, { $set: { balance: doc[0].balance -= icost }});
message.reply("You have bought " + item.name + " for $" + icost + "!");
return true;
}
const icost = args[0] * item.cost;
if (doc[0].balance < icost) {
message.reply("Insufficient funds!");
resolve(false);
} else {
let temp = doc[0];
dbo.updateOne({balance: temp.balance, rank: temp.rank, lastdayworked: temp.lastdayworked}, { $set: { balance: doc[0].balance -= icost }});
message.reply(`You have bought ${item.name} for ${currencySymbol}${icost}!`);
resolve(true);
}
});
});
return b;
}
@@ -142,25 +148,29 @@ function buy(id, message, args, dbo, shop, xp_list) {
if (!isNum(args[0])) { return message.reply("Please enter a number for query 2"); }
let query = args[1];
let item = shop.filter(function (item) { return item.name.toLowerCase() == query.toLowerCase(); });
let item = shop.filter(function (item) { return item.name.toLowerCase() == query.toLowerCase(); })[0];
if (!String(item)) { return message.reply("This item does not exist!"); }
let success = Boolean(checkAndUpdateBal(dbo, item[0], message, args));
if (!success) { return; }
// let success = Boolean(checkAndUpdateBal(dbo, item, message, args));
checkAndUpdateBal(dbo, item, message, args).then((success) => {
if (!success) { return } //The message is handled in the CheckAndUpdateBal() function
var newObj = { name: item[0].name, cost: item[0].cost, icon: item[0].icon, sect: item[0].sect};
var newObj = { name: item.name, cost: item.cost, icon: item.icon, sect: item.sect};
addxp(message, dbo, Math.ceil(item[0].cost * 1.2), xp_list);
dbo.find(newObj, {$exists: true}).toArray(function(err, doc) {
if(String(doc)) {
let newnum = doc[0].num + Number(args[0]);
dbo.updateOne({ name: item[0].name }, {$set: {num: newnum}});
} else {
dbo.insertOne({ name: item[0].name, cost: item[0].cost, icon: item[0].icon, sect: item[0].sect, num: Number(args[0])});
}
});
addxp(message, dbo, Math.ceil(item.cost * 1.2), xp_list);
dbo.find(newObj, {$exists: true}).toArray(function(err, doc) {
if(String(doc)) {
let newnum = doc[0].num + Number(args[0]);
dbo.updateOne({ name: item.name }, {$set: {num: newnum}});
} else {
// dbo.insertOne({ name: item.name, cost: item.cost, icon: item.icon, sect: item.sect, num: Number(args[0])}); //Causes "cyclic dependancy"
dbo.insertOne(item);
dbo.updateOne(item, { $set: {num: Number(args[0]) }});
}
});
})
};
@@ -201,7 +211,7 @@ function sell(id, message, args, dbo, shop, xp_list) {
addxp(message, dbo, Math.ceil(functional_item.cost * 1.2), xp_list);
message.reply(`You've sold ${num} ${String(functional_item.name)} for $${amountSoldFor}`);
message.reply(`You've sold ${num} ${String(functional_item.name)} for ${currencySymbol}${amountSoldFor}`);
} else {
message.reply("You don't own this item!");
}
@@ -225,7 +235,7 @@ function work(dbo, message, xp_list) {
//Update the amount to the new TOTAL balance
dbo.updateOne({"balance": {$exists: true}}, { $set: { balance: doc[0].balance + amt, lastdayworked: date }});
addxp(message, dbo, xp_earned, xp_list);
message.channel.send('<@' + message.author.id + '> worked and earned $' + amt +' and ' + String(xp_earned) + ' xp!');
message.channel.send(`<@${message.author.id}> worked and earned ${currencySymbol}${amt} and ${xp_earned} xp!`);
}
});
}
@@ -235,10 +245,11 @@ function printInventory(dbo, message) {
let tempstring = "";
dbo.find().toArray(function(err, docs){
docs.forEach(val => {
if (!val.balance) {
if (!val.balance && val.name != undefined) {
tempstring += String(val.num) + " " + val.name + " (" + val.icon + ")\n";
}
});
if (tempstring == "") { tempstring += "You have nothing in your inventory!"; }
message.reply(tempstring);
});
@@ -266,7 +277,7 @@ function getShop(message, args, items, bot) {
}
const items2 = items.filter(function(f) { return (f.sect.toLowerCase() == args[0].toLowerCase()) }).slice((ind - 1)*10, (ind - 1)*10+10);
newText = Formatters.codeBlock(items2.map(i => `${i.icon} (${i.name}): \$${i.cost}`).join('\n'));
newText = Formatters.codeBlock(items2.map(i => `${i.icon} (${i.name}): $${i.cost}`).join('\n')); //${currencySymbol} doesn't owrk for some reason
if (noinp) {
newText += `(Use ${bot.prefix}shop [type] [page number] to access other pages)`;
@@ -305,6 +316,8 @@ module.exports = {
const dbo = db.collection(id);
if (err) { return console.log(err); }
currencySymbol = bot.currencysymbolmmain;
//test area
if (command == 'xp' || command == 'adbal') {
//Selmer Dev only command
+7 -1
View File
@@ -11,10 +11,11 @@ function loseGame(user_dbo, xp_collection, message, bot = null) {
if (doc == undefined) { return message.reply("Oops! There's been an error! Please contact support if this problem persists!"); }
if (doc.game == null) { return message.reply("You're not even in a game and you're trying to quit! Sad..."); }
var addbal;
//If this function was called from "winGame", return
if (doc.opponent) {
//If remove some money (looting) [maybe implement a "friendly" game setting later with no looting]
var addbal = doc.rank * 2;
addbal = doc.rank * 2;
if (doc.balance - addbal < 5) { addbal = addbal - doc.balance; }
if (doc.balance > 5) {
user_dbo.updateOne(doc, { $set: { balance: doc.balance - addbal}});
@@ -60,12 +61,17 @@ function winGame(client, bot, db, user_dbo, xp_collection, message) {
function equipItem(client, bot, db, dbo, message) {
if (!bot.inDebugMode) { return; }
let items = [
{ name: 'HP Potion', cost: 20, icon: 'CUSTOM|healing_potion', sect: 'HP', num: 2 },
{ name: 'Super HP Potion', cost: 50, icon: 'CUSTOM|super_healing_potion', sect: 'HP', num: 2 },
{ name: 'MP Potion', cost: 15, icon: 'CUSTOM|mana_potion', sect: 'MP', num: 2 }
]
for (let i = 1; i <= 10; i ++) {
items.push({ name: `${String.fromCharCode(i + 64)}`, cost: i * 10, icon: 'N/A', sect: 'N/A', num: i })
}
dbo.updateMany({}, {$set: {'equipped.items': items}});
}
+47 -6
View File
@@ -1,4 +1,4 @@
// @ts-check
// // @ts-check //Disabled
const { MongoClient, ServerApiVersion } = require('mongodb');
let ecoimport = require("./econ.js");
@@ -130,15 +130,52 @@ function hpmp(message, command, dbo) {
}
function equip(client, message, command, dbo, bot) {
function equip(message, args, command, dbo, bot, shop) {
const inp = args[1];
//Check if the user is already in a game
dbo.find({'game': {$exists: true}}).toArray(function(err, docs) {
const doc = docs[0];
if (doc.game != null) {
ret = true;
console.log(doc.game);
return message.reply('You can\'t equip while in a game!');
}
//If the thing is a shield, add it to secondary
if (inp.toLowerCase().indexOf('shield') != -1) {
dbo.find({def: true}).toArray(function(err, docs) {
if (docs[0] != undefined) {
dbo.updateOne({}, {$set: {'equipped.weapons.secondary': docs[0]}});
} else {
message.reply("You don't own a shield!");
}
});
} else {
//Else, equip the weapon(s)
dbo.find({name: inp, sect: 'Weapons'}).toArray(function(err, docs) {
if (docs[0] != undefined) {
//Equip the weapon
dbo.updateOne({}, {$set: {'equipped.weapons.main': docs[0]}});
} else {
message.reply(`You don't own any ${inp}s!`);
}
});
}
});
}
//#endregion
//#region GAME SPECIFIC
//#region Game Handlers
function in_game_redirector(bot, interaction, threadname, doc, client, mongouri, items, xp_collection) {
//Maybe fix this later......
@@ -276,7 +313,8 @@ module.exports ={
} else if (command == 'hp' || command == 'mp') {
hpmp(message, command, dbo);
} else if (command == 'equip') {
equipItem(client, bot, db, dbo, message);
// equipItem(client, bot, db, dbo, message);
equip(message, args, command, dbo, bot, items);
}
//#endregion
@@ -305,4 +343,7 @@ module.exports ={
client.close();
}, allGames, in_game_redirector
}
}
//#endregion
+7 -11
View File
@@ -151,6 +151,12 @@ bot.on('ready', async () => {
} else {
console.log("Testing testing 1 2 5...");
}
//Add the money symbol
let srv = bot.guilds.cache.get(bot.home_server).emojis.cache;
emj = srv.find((g) => { return g.name == 'selmer_coin' });
bot.currencysymbolmmain = `${emj}`;
});
@@ -239,7 +245,6 @@ bot.on('interactionCreate', async interaction => {
interaction.editReply(`<@${interaction.user.id}> used a _${interaction.values[0]}_!`);
//remove the old interation message
await interaction.message.delete();
@@ -283,7 +288,7 @@ bot.on('guildMemberAdd', async (member) => {
await welcome(member, welcomechannel, docs[0].welcomemessage);
})
})
})
});
@@ -312,16 +317,7 @@ bot.on('messageCreate', (message) => {
message.channel.send({ components: [row] });
}
//TEMP
if (command == 'emj') {
let srv = bot.guilds.cache.get(bot.home_server).emojis.cache;
// console.log(srv);
emj = srv.find((g) => { return g.name == 'healing_potion' });
// console.log(emj); exit();
message.channel.send(`${emj}`);
}
//Check if the user has sufficient permission
//Performes the command
//Admin section
if (command == 'reactionrole') { bot.commands.get(command).execute(message, args, Discord, bot); }