Compare commits

...

11 Commits

Author SHA1 Message Date
c325bf5ab4 bugfix for empty messages 2023-11-22 00:45:38 +02:00
88fdf4e7b9
invert 2023-08-13 20:44:51 +03:00
6895018d24
bugfix 2023-08-13 20:41:17 +03:00
fd1c4c9b85
arg to send cr list in dms 2023-08-13 20:34:04 +03:00
3c3ea9d90d
bugfix 2023-05-12 21:21:09 +03:00
2892fd0f04
fix dumb issue 2022-11-29 19:34:49 +02:00
f1bd031544
upgrade packages 2022-11-29 19:27:16 +02:00
d78c4f6687
Merge branch 'master' of https://github.com/GalacticBot/modmail 2022-11-29 19:18:48 +02:00
67bb6309b8
split string by whitespace (\s+) instead of ' ' 2022-11-29 19:18:37 +02:00
Erik
bd5c8bd157
Merge pull request #9 from GalacticBot/dependabot/npm_and_yarn/moment-2.29.4
Bump moment from 2.29.2 to 2.29.4
2022-11-21 23:20:29 +02:00
dependabot[bot]
baf48f2747
Bump moment from 2.29.2 to 2.29.4
Bumps [moment](https://github.com/moment/moment) from 2.29.2 to 2.29.4.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.29.2...2.29.4)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-21 21:20:17 +00:00
8 changed files with 505 additions and 986 deletions

View File

@ -13,6 +13,7 @@ Contributions welcome.
> Create a named volume `docker volume create ModmailStorage` > 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 Make sure to have a config.js ready to go, see the example file for a template
> Start the container > Start the container
``` ```
docker run -d --name modmail \ docker run -d --name modmail \
-v /path/to/config.js:/modmail/config.js \ -v /path/to/config.js:/modmail/config.js \

View File

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

View File

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

View File

@ -362,7 +362,6 @@ class Modmail {
response = await this.channels.setReadState(userId, channel, author, state); response = await this.channels.setReadState(userId, channel, author, state);
} }
if (response.error) return response; if (response.error) return response;
this.log({ author, action: `${author.tag} marked ${user.tag}'s thread as ${state}`, target: user }); this.log({ author, action: `${author.tag} marked ${user.tag}'s thread as ${state}`, target: user });
return 'Done'; return 'Done';

View File

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

View File

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

1127
yarn.lock

File diff suppressed because it is too large Load Diff