aboutsummaryrefslogtreecommitdiff
path: root/commands/setlogchannel.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2023-03-25 21:25:43 -0400
committerAndrew Lee <alee14498@protonmail.com>2023-03-25 21:27:41 -0400
commit1a7a627446edfeb270850f0ed15c9c8d604380b2 (patch)
tree8435e5323ce8a81976cafe297a6c730b4f0695da /commands/setlogchannel.js
parent85a8f11507c0fb74b67914090bdfe10c361b775e (diff)
downloadAleeBot-1a7a627446edfeb270850f0ed15c9c8d604380b2.tar.gz
AleeBot-1a7a627446edfeb270850f0ed15c9c8d604380b2.tar.bz2
AleeBot-1a7a627446edfeb270850f0ed15c9c8d604380b2.zip
Now using sequelize; Minor tweaks; New activities
Diffstat (limited to 'commands/setlogchannel.js')
-rw-r--r--commands/setlogchannel.js35
1 files changed, 9 insertions, 26 deletions
diff --git a/commands/setlogchannel.js b/commands/setlogchannel.js
index 902a210..c04e926 100644
--- a/commands/setlogchannel.js
+++ b/commands/setlogchannel.js
@@ -17,36 +17,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* *************************************/
-const mongo = require('../plugins/mongo');
-const logSchema = require('../schema/logging-schema');
+const guildDB = require ('../models/guild-settings')
module.exports.run = async (client, message) => {
//This will be replaced in the future possibly
if (!message.member.permissions.has('MANAGE_GUILD')) return message.reply('It looks like that you can\'t manage this server.');
const channel = await message.mentions.channels.first().id;
- const cache = {}
+ const [ guild ] = await guildDB.findOrCreate({ where: { id: message.guild.id } } )
- if (!channel) return message.reply('I cannot find that channel, please specify...');
-
- cache[message.guild.id] = channel
-
- await mongo().then(async (mongoose) => {
- try {
- await logSchema.findOneAndUpdate(
- {
- _id: message.guild.id,
- },
- {
- _id: message.guild.id,
- logChannel: channel
- },
- {
- upsert: true
- }
- )
- } finally {
- await mongoose.connection.close();
- }
- })
+ if (!channel) {
+ message.reply('No channel has been set, disabling the logging channel feature...');
+ await guild.update({ channelId: null } );
+ } else {
+ await guild.update({ channelId: message.guild.id } ) ;
+ }
await message.reply(`Logging channel has been set to <#${channel}>`);
};
@@ -58,6 +41,6 @@ exports.conf = {
exports.help = {
name: 'setlogchannel',
description: 'Set the log channel.',
- usage: 'setlogchannel [channel id]',
+ usage: 'setlogchannel #channel',
category: '- Moderation Commands',
};