From a69d50ce9fb14e355b4d7c0d7790490ff6cdde2e Mon Sep 17 00:00:00 2001 From: ION606 Date: Sat, 14 May 2022 20:40:58 +0300 Subject: [PATCH] Changed the Mongodb structure to include what's in the database, added the 'r' and 'reactionrole' commands --- commands/admin/verify.js | 23 +++++++++++++++++++++++ commands/misc/econ.js | 3 ++- commands/misc/{reactions.js => react.js} | 0 commands/misc/rectionrole.js | 9 +++++++++ main.js | 21 ++++++++++++++------- 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 commands/admin/verify.js rename commands/misc/{reactions.js => react.js} (100%) create mode 100644 commands/misc/rectionrole.js diff --git a/commands/admin/verify.js b/commands/admin/verify.js new file mode 100644 index 0000000..83fa519 --- /dev/null +++ b/commands/admin/verify.js @@ -0,0 +1,23 @@ +function checkRole(message, args) { + let role = args[0]; + if (message.member.hasPermission('ADMINISTRATOR')) { return true; } + + /*Maybe implement this later, useless for now + const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 }); + client.connect(err => { + + + const role = client.db(message.guild.id).collection("admin-roles"); + shop.find().toArray(function(err, itemstemp) { + if (err) throw err; + + items = [...itemstemp]; + + client.close(); + }); + });*/ +} + + + +module.exports = {name: 'verify', checkRole} \ No newline at end of file diff --git a/commands/misc/econ.js b/commands/misc/econ.js index da1b8e5..5805438 100644 --- a/commands/misc/econ.js +++ b/commands/misc/econ.js @@ -211,7 +211,7 @@ module.exports = { const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 }); client.connect(err => { - const db = client.db(server); + const db = client.db(String(server) + "[ECON]"); const dbo = db.collection(id); if (err) { return console.log(err); } //Initialize if necessary @@ -225,6 +225,7 @@ module.exports = { //test area if (command == 'xp' || command == 'adbal') { + //Selmer Dev only command if (message.member.roles.cache.has('944048889038774302')) { if (command == 'xp') { return addxp(message, dbo, Number(args[0]), xp_list); diff --git a/commands/misc/reactions.js b/commands/misc/react.js similarity index 100% rename from commands/misc/reactions.js rename to commands/misc/react.js diff --git a/commands/misc/rectionrole.js b/commands/misc/rectionrole.js new file mode 100644 index 0000000..92a4794 --- /dev/null +++ b/commands/misc/rectionrole.js @@ -0,0 +1,9 @@ +module.exports = { + name: 'reactionrole', + description: 'Creates an embed that will give a role when reacted to', + async execute(message, args, Discord, bot) { + if (bot.commands.get('verify').checkRole(message, args)) { + console.log("IS ADMNIN"); + } + } +} \ No newline at end of file diff --git a/main.js b/main.js index af34231..3b2f446 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -const { Client, Intents } = require('discord.js'); +const { Client, Intents, Permissions } = require('discord.js'); const Discord = require('discord.js'); const { MongoClient, ServerApiVersion } = require('mongodb'); const fs = require('fs'); @@ -27,14 +27,20 @@ const mongouri = process.env.MONGODB_URI; const { connect } = require('mongoose'); bot.on("guildCreate", guild => { - // guild.owner.send('Thanks! You can use +help to discover commands.') + guild.members.fetch + guild.roles.create({ name: 'Selmer Bot Mod' }); +/* + const role = guild.roles.cache.find((role) => role.name === 'Selmer Bot Mod'); // member.roles.cache.has('role-id-here'); + let owner = guild.members.fetch(guild.ownerID); + owner.send('Thank you for adding Selmer Bot to your server!\nPlease give people you want to have access to Selmer Bot\'s restricted commands the <@&' + role + '> role.'); +*/ - //Get total inventory + //Get custom inventory const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 }); client.connect(err => { - const collection = client.db(guild).collection("shop"); + const collection = client.db(String(guild)).collection("shop"); // perform actions on the collection object - console.log(guild); + collection.insertOne({ owner: guild.ownerId }); client.close(); }); }); @@ -92,7 +98,6 @@ bot.on('ready', async () => { //Reaction map area - console.log('SLEEMER BOT ONLINE!!!!! OH MY GOD OH MY GOD!!!'); }); @@ -108,8 +113,10 @@ bot.on('messageCreate', (message) => { //Check if the user has sufficient permission //Performes the command + //Admin section + if (command == 'reactionrole') { bot.commands.get(command).execute(message, args, Discord, bot); } - if(bot.commands.has(command)) { bot.commands.get(command).execute(message, args, Discord, Client, bot); } + else if(bot.commands.has(command)) { bot.commands.get(command).execute(message, args, Discord, Client, bot); } else { bot.commands.get('ECON').execute(bot, message, args, command, Discord, mongouri, items, xp_collection); } })