Compare commits
11 Commits
9d82f9dacb
...
c325bf5ab4
Author | SHA1 | Date | |
---|---|---|---|
c325bf5ab4 | |||
88fdf4e7b9 | |||
6895018d24 | |||
fd1c4c9b85 | |||
3c3ea9d90d | |||
2892fd0f04 | |||
f1bd031544 | |||
d78c4f6687 | |||
67bb6309b8 | |||
|
bd5c8bd157 | ||
|
baf48f2747 |
@ -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 \
|
||||||
|
@ -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"
|
||||||
}
|
}
|
||||||
|
@ -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 {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
|
||||||
|
@ -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';
|
||||||
|
@ -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`;
|
||||||
|
@ -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 });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user