text: const Discord = require('discord.js')
  const client = new Discord.Client()
  
  const command = require('./command')
  const mongo = require('./mongo')
  const mute = require('./mute')
  
  client.on('ready', async () => {
    console.log('The client is ready!')
    client.user.setActivity('-', { type: 'LISTENING' });
    await mongo().then(mongoose => {
      try {
        console.log('Connected to mongodb')
      } finally {
        mongoose.connection.close()
      }
    })
  
    mute(client)
  
    command(client, 'ban', (message) => {
      const { member, mentions } = message
  
      const tag = `<@${member.id}>`
  
      if (
        member.hasPermission('ADMINISTRATOR') ||
        member.hasPermission('BAN_MEMBERS')
      ) {
        const target = mentions.users.first()
        if (target) {
          const targetMember = message.guild.members.cache.get(target.id)
          targetMember.ban()
          message.channel.send(`${tag} That user has been`)
        } else {
          message.channel.send(`${tag} Please specify someone to ban.`)
        }
      } else {
        message.channel.send(
          `${tag} You do not have permission to use this command.`
        )
      }
    })
  
    command(client, 'kick', (message) => {
      const { member, mentions } = message
  
      const tag = `<@${member.id}>`
  
      if (
        member.hasPermission('ADMINISTRATOR') ||
        member.hasPermission('KICK_MEMBERS')
      ) {
        const target = mentions.users.first()
        if (target) {
          const targetMember = message.guild.members.cache.get(target.id)
          targetMember.kick()
          message.channel.send(`${tag} That user has kicked`)
        } else {
          message.channel.send(`${tag} Please specify someone to kick.`)
        }
      } else {
        message.channel.send(
          `${tag} You do not have permission to use this command.`
        )
      }
    })
  })
  
  client.login(process.env.token)