I'm completely new to this and encountering an error with my code. When I run this command on Discord, I get a TypeError: Cannot read properties of undefined (reading 'toLowerCase') without any error log appearing in the terminal/console. Can someone please assist me in resolving this issue?
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.aliases = exports.category = exports.run = exports.description = exports.name = void 0;
const name = 'setup';
exports.name = name;
const description = 'Setting up bot check';
exports.description = description;
const category = "Utility";
exports.category = category;
const aliases = ['s'];
exports.aliases = aliases;
const run = async (client, message, args) => {
const configcollection = client.db.get('config');
if (args[0].toLowerCase() == 'delete') {
configcollection.find({ guildId: message.guild.id }).then(docs => {
if (docs.length == 0)
return message.reply('No settings were saved');
configcollection.remove({ guildId: message.guild.id }).then(e => {
message.channel.send('Successfully removed settings');
}).catch(err => {
console.error(err);
message.reply('Failed to remove settings');
});
});
}
else {
configcollection.find({ guildId: message.guild.id }).then(docs => {
if (docs.length != 0)
return message.reply('Settings already exist, please delete current settings');
if (!message.mentions.roles.first() && !message.mentions.channels.first())
return message.reply('Please mention channel and role');
configcollection.insert({ guildId: message.guild.id, channelId: message.mentions.channels.first().id, roleId: message.mentions.roles.first().id }).then(a => {
message.channel.send('Successfully saved settings');
}).catch(err => {
message.reply('Failed to save settings');
console.error(err);
});
}).catch(err => {
message.reply('Failed to load data');
console.error(err);
});
}
};
exports.run = run;
//# sourceMappingURL=setup.js.map