Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Mod Mail v1.1

Latest
Compare
Choose a tag to compare
@raideno raideno released this 05 Dec 19:47
a8a2fa6

Version 1.1 of My Mail is here, here are all the news :

-First :
Now when the bot restarts and there are tickets open and they will not be deleted, they will be synchronized the next time the bot is started and that thanks to this function which was added:

client.FTOAfterRestart = async () => {
    const Tickets = client.Tickets.get('Tickets');
    const stuff = await client.checkStuff(DATA.GUILDID, DATA.TICKETCATEGORY, DATA.STAFFROLEID, DATA.LOGCHANNELID);
    if(stuff.category.children.size <= 0) return;
    const channels = stuff.guild.channels.cache;
    let num = 0;
    await channels.forEach(c => {
      if(c.parentID !== stuff.category.id || Array.from(Tickets.values()).includes(c.id) || Tickets.has(c.name)) return;
      const user = stuff.guild.members.cache.get(c.name);
      if(user) {
        Tickets.set(c.name, c.id)
        num = num+1
      }
    })
    console.log('[✅] I Synchronized', num, 'Ticket(s)')
  }

-Secondly :
Before if a person creates a ticket then the channel associated with this ticket is deleted and although this person is going to send a message to the bot an error was going to occur now this will no longer occur thanks to the channelDelete event which will prevent this:

module.exports = (client, channel) => {

  const Tickets = client.Tickets.get('Tickets');

  if(!Array.from(Tickets.values()).includes(channel.id)) return;

  const TicketOwner = channel.guild.members.cache.get(Tickets.findKey(data => data === channel.id))

  Tickets.delete(TicketOwner.id)

  TicketOwner.send('Your __Ticket__ has been closed.')
}

Thirdly : some code optimization 👀
Note : In the next update I will put comments on the code to help you better understand the code