Changed the Mongodb structure to include what's in the database, added the 'r' and 'reactionrole' commands

This commit is contained in:
ION606
2022-05-14 20:40:58 +03:00
parent 44d65fce98
commit a69d50ce9f
5 changed files with 48 additions and 8 deletions
+23
View File
@@ -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}
+2 -1
View File
@@ -211,7 +211,7 @@ module.exports = {
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 }); const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
client.connect(err => { client.connect(err => {
const db = client.db(server); const db = client.db(String(server) + "[ECON]");
const dbo = db.collection(id); const dbo = db.collection(id);
if (err) { return console.log(err); } if (err) { return console.log(err); }
//Initialize if necessary //Initialize if necessary
@@ -225,6 +225,7 @@ module.exports = {
//test area //test area
if (command == 'xp' || command == 'adbal') { if (command == 'xp' || command == 'adbal') {
//Selmer Dev only command
if (message.member.roles.cache.has('944048889038774302')) { if (message.member.roles.cache.has('944048889038774302')) {
if (command == 'xp') { if (command == 'xp') {
return addxp(message, dbo, Number(args[0]), xp_list); return addxp(message, dbo, Number(args[0]), xp_list);
+9
View File
@@ -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");
}
}
}
+14 -7
View File
@@ -1,4 +1,4 @@
const { Client, Intents } = require('discord.js'); const { Client, Intents, Permissions } = require('discord.js');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { MongoClient, ServerApiVersion } = require('mongodb'); const { MongoClient, ServerApiVersion } = require('mongodb');
const fs = require('fs'); const fs = require('fs');
@@ -27,14 +27,20 @@ const mongouri = process.env.MONGODB_URI;
const { connect } = require('mongoose'); const { connect } = require('mongoose');
bot.on("guildCreate", guild => { 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 }); const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
client.connect(err => { client.connect(err => {
const collection = client.db(guild).collection("shop"); const collection = client.db(String(guild)).collection("shop");
// perform actions on the collection object // perform actions on the collection object
console.log(guild); collection.insertOne({ owner: guild.ownerId });
client.close(); client.close();
}); });
}); });
@@ -92,7 +98,6 @@ bot.on('ready', async () => {
//Reaction map area //Reaction map area
console.log('SLEEMER BOT ONLINE!!!!! OH MY GOD OH MY GOD!!!'); 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 //Check if the user has sufficient permission
//Performes the command //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); } else { bot.commands.get('ECON').execute(bot, message, args, command, Discord, mongouri, items, xp_collection); }
}) })