Closed walmart44 closed 3 years ago
When I hit delete it just brings be back to me page and doesn't delete the bot from the page on the me page
I can't help you without more information. I can't reproduce the erorr and neither can others. Try the setup guide in the wiki if it helps.
I can't help you without more information. I can't reproduce the erorr and neither can others. Try the setup guide in the wiki if it helps.
Ive followed that and there is no errors idk what else im suppose to say. as I said before if one of you guys want to go into discord I can screenshare and that may give you more information
this looks correct to me const { Router } = require("express"); const bodyParser = require("body-parser"); const { auth } = require("@utils/discordApi"); const Bots = require("@models/bots");
const { server } = require("@root/config.json");
const route = Router(); route.use(bodyParser.urlencoded({extended: true}));
route.delete("/:id", auth, async (req, res) => { let {id} = req.params;
const bot = await Bots.findOne({ botid: id }, { _id: false })
if (!bot) return res.sendStatus(404)
if (!bot.owners.primary !== req.user.id && !server.admin_user_ids.includes(req.user.id)) return res.sendStatus(403)
await Bots.deleteOne({ botid: id })
req.app.get('client').channels.cache.get(server.mod_log_id).send(`<@${req.user.id}> has deleted <@${bot.botid}>`);
req.app.get('client').guilds.cache.get(server.id).members.fetch(id).then(bot => {bot.kick()}).catch(() => {})
res.sendStatus(200)
});
module.exports = route;
$( document ).ready(async function() { $(".link").click((e) => { $(".section").hide(); $(e.target.href.split("/#").slice(-1)[0]).show() }) $(document).on("click",".delete", function () { let newval = prompt(Type ${$(this).attr("data-name")} to confirm)
if (newval.toLowerCase() === $(this).attr("data-name").toLowerCase()) {
fetch(`/api/bots/${$(this).attr("data-id")}`, {method: "DELETE"}).then(() => location.href = "/me")
} else location.reload();
}) })
but what that code look likes it doing is just looping it back to the me and doing nothing
Okay So first let's check if the code tries to delete the bot or not.
so go to src/routes/api/bots/delete.js
and replace with the code given below. After replacing restart the bot list and try deleing the bot. Then check console if it has logged I'm In
it means it is trying to delete the bot. If there is no log in console it means it's not trying to delete the bot.
const { Router } = require("express");
const bodyParser = require("body-parser");
const { auth } = require("@utils/discordApi");
const Bots = require("@models/bots");
const { server } = require("@root/config.json");
const route = Router();
route.use(bodyParser.urlencoded({extended: true}));
route.delete("/:id", auth, async (req, res) => {
console.log('I\'m In');
let {id} = req.params;
const bot = await Bots.findOne({ botid: id }, { _id: false })
if (!bot) return res.sendStatus(404)
if (!bot.owners.primary !== req.user.id && !server.admin_user_ids.includes(req.user.id)) return res.sendStatus(403)
await Bots.deleteOne({ botid: id })
req.app.get('client').channels.cache.get(server.mod_log_id).send(`<@${req.user.id}> has deleted <@${bot.botid}>`);
req.app.get('client').guilds.cache.get(server.id).members.fetch(id).then(bot => {bot.kick()}).catch(() => {})
res.sendStatus(200)
});
module.exports = route;
I got I'm in
Did your bot got deleted ?
No
Hmm... Some issue with database.
Replace the below code with src/routes/api/bots/delete.js
And check console after you press delete button.
const { Router } = require("express");
const bodyParser = require("body-parser");
const { auth } = require("@utils/discordApi");
const Bots = require("@models/bots");
const { server } = require("@root/config.json");
const route = Router();
route.use(bodyParser.urlencoded({extended: true}));
route.delete("/:id", auth, async (req, res) => {
console.log('I\'m In');
let {id} = req.params;
const bot = await Bots.findOne({ botid: id }, { _id: false })
if (!bot) {
console.log('Can\'t find bot in database.');
return res.sendStatus(404)
}
if (!bot.owners.primary !== req.user.id && !server.admin_user_ids.includes(req.user.id)) {
console.log('You are additional owner. Only main owner can edit this.');
return res.sendStatus(403)
}
try {
await Bots.deleteOne({ botid: id })
console.log('Bot successfully Deleted !';
catch(err) {
console.log("Error:-" + '\n' + err);
}
req.app.get('client').channels.cache.get(server.mod_log_id).send(`<@${req.user.id}> has deleted <@${bot.botid}>`);
req.app.get('client').guilds.cache.get(server.id).members.fetch(id).then(bot => {bot.kick()}).catch(() => {})
res.sendStatus(200)
});
module.exports = route;
I'm getting
I'm In You are additional owner. Only main owner can edit this.
Doesn't delete it
So it thinks im not the main owner
also in the users tab for the database is stuff suppose to store in there?
What do you mean by users tab ?
So it thinks im not the main owner
Oof..
in the database there is a section for users and idk if stuff is suppose to get stored in there because rn there is nothing in there
maybe thats why its not deleting it because my account isn't stored in the users table
No it wont be a reason
idk then
Go to your bot directory that is src/bot/commands/Bots
and create a file called updateid.js
over there. The location of the file will be src/bot/commands/Bots*updateid.js
and paste the following code
const { Command } = require('klasa');
const { MessageEmbed } = require('discord.js');
const Bots = require("@models/bots");
const { server: {mod_log_id, role_ids} } = require("@root/config.json");
var modLog;
module.exports = class extends Command {
constructor(...args) {
super(...args, {
permissionLevel: 8,
usage: '<User:user> <Member:user> [Add:string]',
usageDelim: ' '
});
}
async run(message, [user, member, add]) {
if (!user || !user.bot) return message.channel.send(`Ping a **bot** or Enter **Bot** ID.`);
let bot = await Bots.findOne({botid: user.id}, { _id: false });
if (!member || member.bot) return message.channel.send(`Ping a **User** or Enter **User** ID`)
if (!add) {
message.channel.send(`Updated ${user} with Owner ${member}`)
await Bots.updateOne({ botid: user.id }, {$set: {owners: {primary: member.id, additional: []}}});
} else {
message.channel.send(`Updated ${user} with Owner ${member} and Additional ${add}`)
await Bots.updateOne({ botid: user.id }, {$set: {owners: {primary: member.id, additional: add.split(',')}}});
}
//const botUser = await this.client.users.fetch(user.id);
//if (bot.logo !== botUser.displayAvatarURL({format: "png", size: 256}))
//await Bots.updateOne({ botid: user.id }, {$set: {}});
//else
//await Bots.updateOne({ botid: user.id }, {$set: { state: "verified" } })
//let owners = [bot.owners.primary].concat(bot.owners.additional)
/*let e = new MessageEmbed()
.setTitle('Bot Verified')
.addField(`Bot`, `<@${bot.botid}>`, true)
.addField(`Owner(s)`, owners.map(x => `<@${x}>`), true)
.addField("Mod", message.author, true)
.setThumbnail(botUser.displayAvatarURL({format: "png", size: 256}))
.setTimestamp()
.setColor(0x26ff00)
modLog.send(e);
modLog.send(owners.map(x => `<@${x}>`)).then(m => { m.delete() });*/
/*owners = await message.guild.members.fetch({user:owners})
owners.forEach(o => {
o.roles.add(message.guild.roles.cache.get(role_ids.bot_developer));
o.send(`Your bot \`${bot.username}\` has been verified.`)
})*/
/*message.guild.members.fetch(message.client.users.cache.find(u => u.id === bot.botid)).then(bot => {
bot.roles.set([role_ids.bot, role_ids.verified, role_ids.unmuted]);
})
message.channel.send(`Updated \`${bot.username}\``);*/
}
/*async init() {
modLog = this.client.channels.cache.get(mod_log_id);
}*/
};
would i do ?updateid Botid
nvm
I get the same thing
oh wait
I keep getting Ping a bot or Enter Bot ID.
That's probably the reason. Only primary owners can delete the bot.
but I am the primary owner of the bot
also you put user and member is the usage
hold up figured out command it the command worked
You need to ping the bot and ping the owner. Example .updateid @Bot @PrimaryOwner
On Thu, 3 Dec 2020, 8:54 pm walmart44, notifications@github.com wrote:
also you put user and member is the usage
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sank6/Discord-Bot-List/issues/369#issuecomment-738135847, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKUPS3GOJQMGDKMAOT55KLSS67F3ANCNFSM4UG5OCRQ .
yea but i still get the same message You are additional owner
That command updates the bot owner... it should work
On Thu, 3 Dec 2020, 8:59 pm walmart44, notifications@github.com wrote:
yea but i still get the same message You are additional owner
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sank6/Discord-Bot-List/issues/369#issuecomment-738138898, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKUPS46E3E4NVI3GYIC2M3SS67X7ANCNFSM4UG5OCRQ .
looks like it doesn't but what is the users table for?
The user table is for voting
And storing voting time
oh ok
I use that cmd to update bot owners... have u specified the correct mongo url ?
yea because when i add the bot it adds it to the bots table
And for checking the mongo database if u are using windows install Robo3T on ir device and connect to ir mongo db and check the data of the bot.
I have this mongodb://localhost:27017/admin
can't i use MongoDB Compass?
I have never used it just check the bot owner field and if i can send screenshot.
Check the bot owner field in mongo compass
yea its my id
Your id in which field ?
owners > primary
Oh
It should work clone the repo once again replace the config.json and run the botlist again
Im trying to connect to the database with this "mongo_url": "mongodb://localhost:27017/admin", but im,getting this error
(node:26140) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 at NativeConnection.Connection.openUri (C:\Users\uuu\Desktop\Discord-Bot-List\node_modules\mongoose\lib\connection.js:830:32) at C:\Users\uuu\Desktop\Discord-Bot-List\node_modules\mongoose\lib\index.js:342:10 at C:\Users\uuu\Desktop\Discord-Bot-List\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:5 at new Promise ()
at promiseOrCallback (C:\Users\uuu\Desktop\Discord-Bot-List\node_modules\mongoose\lib\helpers\promiseOrCallback.js:30:10)
at Mongoose._promiseOrCallback (C:\Users\uuu\Desktop\Discord-Bot-List\node_modules\mongoose\lib\index.js:1129:10)
at Mongoose.connect (C:\Users\uuu\Desktop\Discord-Bot-List\node_modules\mongoose\lib\index.js:341:20)
at C:\Users\uuu\Desktop\Discord-Bot-List\src\index.js:10:20
at Object. (C:\Users\uuu\Desktop\Discord-Bot-List\src\index.js:21:3)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
(Use
node --trace-warnings ...
to show where the warning was created) (node:26140) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:26140) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.