Compare commits

..

No commits in common. "c325bf5ab4961c9ffbcba0ad5cb1558236820bf4" and "9d82f9dacbf930d3b273dca84e657a60eb269518" have entirely different histories.

8 changed files with 986 additions and 505 deletions

View File

@ -13,7 +13,6 @@ Contributions welcome.
> 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 \

View File

@ -8,8 +8,7 @@
"description": "Modmail bot with eventual integration with Galactic Bot's API",
"scripts": {
"start": "node index.js",
"dev": "nodemon --ignore *.json index.js",
"dockerpub": "tsc && docker build . --tag navydotgif/modmail:latest && docker push navydotgif/modmail:latest "
"dev": "nodemon --ignore *.json index.js"
},
"devDependencies": {
"eslint": "^7.28.0",
@ -19,7 +18,7 @@
"chalk": "^4.0.0",
"diagnostics": "^2.0.2",
"discord.js": "^12.5.3",
"moment": "^2.29.4",
"moment": "^2.29.2",
"winston": "^3.3.3",
"winston-transport": "^4.4.0"
}

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) && state === 'unread') this.cache.queue.push(target);
else if (!this.cache.queue.includes(target)) this.cache.queue.push(target);
return {};
}

View File

@ -102,11 +102,11 @@ class ModmailClient extends Client {
const roles = member.roles.cache.map((r) => r.id);
if (!roles.some((r) => this._options.staffRoles.includes(r)) && !member.hasPermission('ADMINISTRATOR')) return;
const [ rawCommand, ...args ] = content.split(/\s+/u);
const [ rawCommand, ...args ] = content.split(' ');
const commandName = rawCommand.substring(prefix.length);
const command = this.registry.find(commandName);
if (!command) return;
message._caller = commandName;
message._caller = commandName.toLowerCase();
if (command.showUsage && !args.length) {

View File

@ -362,6 +362,7 @@ 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';

View File

@ -13,7 +13,7 @@ class CannedReply extends Command {
async execute (message, { args }) {
const [ first, second ] = args.map((a) => a);
const [ first ] = args.map((a) => a);
// eslint-disable-next-line prefer-const
let { channel, content, _caller } = message,
anon = false;
@ -29,7 +29,6 @@ class CannedReply extends Command {
const list = Object.entries(this.client.modmail.replies);
let str = '';
if (second?.toLowerCase() !== '-here') channel = await message.author.createDM();
// eslint-disable-next-line no-shadow
for (const [ name, content ] of list) {
const substr = `**${name}:** ${content}\n`;

View File

@ -12,6 +12,7 @@ class Modmail extends Command {
}
async execute (message, { args }) {
// eslint-disable-next-line prefer-const
let [ first, second ] = args.map((a) => a);
// eslint-disable-next-line prefer-const
@ -36,14 +37,15 @@ class Modmail extends Command {
error: true,
msg: 'Cannot send modmail to a bot.'
};
content = content.replace(first, '').trim();
content = content.replace(first, '');
if (!content.length) return {
error: true,
msg: `Cannot send empty message`
};
return this.client.modmail.sendModmail({ message, content, anon, target: user });
return this.client.modmail.sendModmail({ message, content: content.trim(), anon, target: user });
}
}

1127
yarn.lock

File diff suppressed because it is too large Load Diff