From 3c3ea9d90d212353dd36a0ad156eb2778c748c86 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 12 May 2023 21:21:09 +0300 Subject: [PATCH] bugfix --- README.md | 29 +++++++++++++++-------------- structure/ChannelHandler.js | 2 +- structure/Modmail.js | 1 - 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6c0d040..7c2939d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,19 @@ # WIP MODMAIL BOT -**Still a work in progress, has no actual integration with the main bot at this point due to the main bot still being very much a work in progress.** +**Still a work in progress, has no actual integration with the main bot at this point due to the main bot still being very much a work in progress.** -Uses json for storage. If this is a problem, feel free to start a branch and write your own cache handler, alternatively use another bot. -Shouldn't require much setup, fill in the relevant fields in config.js, should be well commented. +Uses json for storage. If this is a problem, feel free to start a branch and write your own cache handler, alternatively use another bot. +Shouldn't require much setup, fill in the relevant fields in config.js, should be well commented. -I've tried refactoring some of the original code that I wrote initially in haste, but a lot of it's still very questionable and in need of rewriting/refactoring. +I've tried refactoring some of the original code that I wrote initially in haste, but a lot of it's still very questionable and in need of rewriting/refactoring. Contributions welcome. ## Docker image **Highly recommend making a named volume for the storage** -> Create a named volume `docker volume create ModmailStorage` -Make sure to have a config.js ready to go, see the example file for a template +> Create a named volume `docker volume create ModmailStorage` +Make sure to have a config.js ready to go, see the example file for a template > Start the container + ``` docker run -d --name modmail \ -v /path/to/config.js:/modmail/config.js \ @@ -21,18 +22,18 @@ navydotgif/modmail:latest ``` ## How to use -> Install [Node.js](https://nodejs.org/en/download/), at least v12, though I'd recommend at least 14 due to Discord.js requiring it in v13. +> Install [Node.js](https://nodejs.org/en/download/), at least v12, though I'd recommend at least 14 due to Discord.js requiring it in v13. -> Run `git clone https://github.com/GalacticBot/modmail.git` +> Run `git clone https://github.com/GalacticBot/modmail.git` -> Run `yarn install`, alternatively `npm install` if you don't have yarn for some reason. +> Run `yarn install`, alternatively `npm install` if you don't have yarn for some reason. -> Rename `config.example.js` to `config.js`, open it and fill in the relevant values. The comments should explain what they are for. If something is unclear open an issue and I'll attempt to make it more clear. +> Rename `config.example.js` to `config.js`, open it and fill in the relevant values. The comments should explain what they are for. If something is unclear open an issue and I'll attempt to make it more clear. -> At this point you'll probably notice you need to add 3 new categories. I'm planning on automating a part of the setup process, but for now this is how it be. Make those, add their IDs to the array. +> At this point you'll probably notice you need to add 3 new categories. I'm planning on automating a part of the setup process, but for now this is how it be. Make those, add their IDs to the array. -> I'd recommend getting PM2 or whatever you prefer for process management. -> Start up the bot and if you did everything right it should boot up and just work. If something goes wrong submit an issue, alternatively if you know how to fix it, issue a pull request. +> I'd recommend getting PM2 or whatever you prefer for process management. +> Start up the bot and if you did everything right it should boot up and just work. If something goes wrong submit an issue, alternatively if you know how to fix it, issue a pull request. ## Commands @@ -46,7 +47,7 @@ Both of these can be used with `!r` and `!cr` respectively and both of them supp `!mmqueue` - Shows users in queue. `!id [channel]` - Get the target user ID for the modmail thread. Can be used without the channel argument in a modmail channel, outside of a modmail channel will return the user ID for the channel's target if available. -The bot has an `!eval` command which you can grant access to in the config file. +The bot has an `!eval` command which you can grant access to in the config file. **Creating canned/pre-written replies** Simple as using `!cr create `. Updating an existing entry is done by overwriting it. diff --git a/structure/ChannelHandler.js b/structure/ChannelHandler.js index c79bd39..a534bd9 100644 --- a/structure/ChannelHandler.js +++ b/structure/ChannelHandler.js @@ -92,7 +92,7 @@ class ChannelHandler { if (channel) await channel.edit({ parentID: state === 'read' ? this.readMail.id : this.newMail.id, lockPermissions: true }); if (!this.cache.updatedThreads.includes(target)) this.cache.updatedThreads.push(target); if (this.cache.queue.includes(target) && state === 'read') this.cache.queue.splice(this.cache.queue.indexOf(target), 1); - else if (!this.cache.queue.includes(target)) this.cache.queue.push(target); + else if (!this.cache.queue.includes(target) && state === 'unread') this.cache.queue.push(target); return {}; } diff --git a/structure/Modmail.js b/structure/Modmail.js index cd5e0a7..7ce7893 100644 --- a/structure/Modmail.js +++ b/structure/Modmail.js @@ -362,7 +362,6 @@ class Modmail { response = await this.channels.setReadState(userId, channel, author, state); } - if (response.error) return response; this.log({ author, action: `${author.tag} marked ${user.tag}'s thread as ${state}`, target: user }); return 'Done';