Allow direct usage of block, unblock, and logs from modmail threads (without specifying the id)
parent
e12996f4b7
commit
7249e04790
23
index.js
23
index.js
|
@ -359,6 +359,7 @@ bot.on('messageCreate', msg => {
|
||||||
// These messages get relayed back to the DM thread between the bot and the user
|
// These messages get relayed back to the DM thread between the bot and the user
|
||||||
// Attachments are shown as URLs
|
// Attachments are shown as URLs
|
||||||
bot.registerCommand('reply', (msg, args) => {
|
bot.registerCommand('reply', (msg, args) => {
|
||||||
|
if (! (msg.channel instanceof Eris.GuildChannel)) return;
|
||||||
if (msg.channel.guild.id !== modMailGuild.id) return;
|
if (msg.channel.guild.id !== modMailGuild.id) return;
|
||||||
if (! msg.member.permission.has('manageRoles')) return;
|
if (! msg.member.permission.has('manageRoles')) return;
|
||||||
|
|
||||||
|
@ -411,6 +412,7 @@ bot.registerCommand('reply', (msg, args) => {
|
||||||
bot.registerCommandAlias('r', 'reply');
|
bot.registerCommandAlias('r', 'reply');
|
||||||
|
|
||||||
bot.registerCommand('close', (msg, args) => {
|
bot.registerCommand('close', (msg, args) => {
|
||||||
|
if (! (msg.channel instanceof Eris.GuildChannel)) return;
|
||||||
if (msg.channel.guild.id !== modMailGuild.id) return;
|
if (msg.channel.guild.id !== modMailGuild.id) return;
|
||||||
if (! msg.member.permission.has('manageRoles')) return;
|
if (! msg.member.permission.has('manageRoles')) return;
|
||||||
|
|
||||||
|
@ -441,17 +443,22 @@ Logs: <${logurl}>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.registerCommand('block', (msg, args) => {
|
bot.registerCommand('block', (msg, args) => {
|
||||||
|
if (! (msg.channel instanceof Eris.GuildChannel)) return;
|
||||||
if (msg.channel.guild.id !== modMailGuild.id) return;
|
if (msg.channel.guild.id !== modMailGuild.id) return;
|
||||||
if (! msg.member.permission.has('manageRoles')) return;
|
if (! msg.member.permission.has('manageRoles')) return;
|
||||||
if (args.length !== 1) return;
|
|
||||||
|
|
||||||
let userId;
|
let userId;
|
||||||
|
if (args[0]) {
|
||||||
if (args[0].match(/^[0-9]+$/)) {
|
if (args[0].match(/^[0-9]+$/)) {
|
||||||
userId = args[0];
|
userId = args[0];
|
||||||
} else {
|
} else {
|
||||||
let mentionMatch = args[0].match(userMentionRegex);
|
let mentionMatch = args[0].match(userMentionRegex);
|
||||||
if (mentionMatch) userId = mentionMatch[1];
|
if (mentionMatch) userId = mentionMatch[1];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const modmailChannelInfo = getModmailChannelInfo(msg.channel);
|
||||||
|
if (modmailChannelInfo) userId = modmailChannelInfo.userId;
|
||||||
|
}
|
||||||
|
|
||||||
if (! userId) return;
|
if (! userId) return;
|
||||||
|
|
||||||
|
@ -461,17 +468,22 @@ bot.registerCommand('block', (msg, args) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.registerCommand('unblock', (msg, args) => {
|
bot.registerCommand('unblock', (msg, args) => {
|
||||||
|
if (! (msg.channel instanceof Eris.GuildChannel)) return;
|
||||||
if (msg.channel.guild.id !== modMailGuild.id) return;
|
if (msg.channel.guild.id !== modMailGuild.id) return;
|
||||||
if (! msg.member.permission.has('manageRoles')) return;
|
if (! msg.member.permission.has('manageRoles')) return;
|
||||||
if (args.length !== 1) return;
|
|
||||||
|
|
||||||
let userId;
|
let userId;
|
||||||
|
if (args[0]) {
|
||||||
if (args[0].match(/^[0-9]+$/)) {
|
if (args[0].match(/^[0-9]+$/)) {
|
||||||
userId = args[0];
|
userId = args[0];
|
||||||
} else {
|
} else {
|
||||||
let mentionMatch = args[0].match(userMentionRegex);
|
let mentionMatch = args[0].match(userMentionRegex);
|
||||||
if (mentionMatch) userId = mentionMatch[1];
|
if (mentionMatch) userId = mentionMatch[1];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const modmailChannelInfo = getModmailChannelInfo(msg.channel);
|
||||||
|
if (modmailChannelInfo) userId = modmailChannelInfo.userId;
|
||||||
|
}
|
||||||
|
|
||||||
if (! userId) return;
|
if (! userId) return;
|
||||||
|
|
||||||
|
@ -481,17 +493,22 @@ bot.registerCommand('unblock', (msg, args) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.registerCommand('logs', (msg, args) => {
|
bot.registerCommand('logs', (msg, args) => {
|
||||||
|
if (! (msg.channel instanceof Eris.GuildChannel)) return;
|
||||||
if (msg.channel.guild.id !== modMailGuild.id) return;
|
if (msg.channel.guild.id !== modMailGuild.id) return;
|
||||||
if (! msg.member.permission.has('manageRoles')) return;
|
if (! msg.member.permission.has('manageRoles')) return;
|
||||||
if (args.length !== 1) return;
|
|
||||||
|
|
||||||
let userId;
|
let userId;
|
||||||
|
if (args[0]) {
|
||||||
if (args[0].match(/^[0-9]+$/)) {
|
if (args[0].match(/^[0-9]+$/)) {
|
||||||
userId = args[0];
|
userId = args[0];
|
||||||
} else {
|
} else {
|
||||||
let mentionMatch = args[0].match(userMentionRegex);
|
let mentionMatch = args[0].match(userMentionRegex);
|
||||||
if (mentionMatch) userId = mentionMatch[1];
|
if (mentionMatch) userId = mentionMatch[1];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const modmailChannelInfo = getModmailChannelInfo(msg.channel);
|
||||||
|
if (modmailChannelInfo) userId = modmailChannelInfo.userId;
|
||||||
|
}
|
||||||
|
|
||||||
if (! userId) return;
|
if (! userId) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue