This commit is contained in:
Erik 2023-05-12 21:21:09 +03:00
parent 2892fd0f04
commit 3c3ea9d90d
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68
3 changed files with 16 additions and 16 deletions

View File

@ -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 <name> <the reply content here>`. Updating an existing entry is done by overwriting it.

View File

@ -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 {};
}

View File

@ -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';