diff options
Diffstat (limited to 'commands/setlogchannel.js')
| -rw-r--r-- | commands/setlogchannel.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/commands/setlogchannel.js b/commands/setlogchannel.js index c04e926..d989f8b 100644 --- a/commands/setlogchannel.js +++ b/commands/setlogchannel.js @@ -17,21 +17,30 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * * *************************************/ -const guildDB = require ('../models/guild-settings') -module.exports.run = async (client, message) => { +const { guildSettings } = require ('../models/guild-settings') +module.exports.run = async (client, message, args) => { //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 [ guild ] = await guildDB.findOrCreate({ where: { id: message.guild.id } } ) + + let channel; + + if (message.mentions.channels.first()) { + channel = message.mentions.channels.first().id; + } else if (args[0] && message.guild.channels.cache.has(args[0])) { + channel = args[0]; + } else { + return await message.reply('Please enter a valid channel ID.') + } + + const [ guild ] = await guildSettings.findOrCreate({ where: { guildID: message.guild.id } } ) if (!channel) { message.reply('No channel has been set, disabling the logging channel feature...'); - await guild.update({ channelId: null } ); + await guild.update({ logChannelID: null } ); } else { - await guild.update({ channelId: message.guild.id } ) ; + await guild.update({ logChannelID: channel } ); + await message.reply(`Logging channel has been set to <#${channel}>`); } - - await message.reply(`Logging channel has been set to <#${channel}>`); }; exports.conf = { |
