Ignore account age/time on server requirements when using !newthread

master
Dragory 2019-04-15 19:26:14 +03:00
parent de8ce9bfea
commit ae3f3920e3
2 changed files with 4 additions and 4 deletions

View File

@ -56,7 +56,7 @@ function getHeaderGuildInfo(member) {
* @returns {Promise<Thread|undefined>} * @returns {Promise<Thread|undefined>}
* @throws {Error} * @throws {Error}
*/ */
async function createNewThreadForUser(user, quiet = false) { async function createNewThreadForUser(user, quiet = false, ignoreRequirements = false) {
const existingThread = await findOpenThreadByUserId(user.id); const existingThread = await findOpenThreadByUserId(user.id);
if (existingThread) { if (existingThread) {
throw new Error('Attempted to create a new thread for a user with an existing open thread!'); throw new Error('Attempted to create a new thread for a user with an existing open thread!');
@ -64,7 +64,7 @@ async function createNewThreadForUser(user, quiet = false) {
// If set in config, check that the user's account is old enough (time since they registered on Discord) // If set in config, check that the user's account is old enough (time since they registered on Discord)
// If the account is too new, don't start a new thread and optionally reply to them with a message // If the account is too new, don't start a new thread and optionally reply to them with a message
if (config.requiredAccountAge) { if (config.requiredAccountAge && ! ignoreRequirements) {
if (user.createdAt > moment() - config.requiredAccountAge * HOURS){ if (user.createdAt > moment() - config.requiredAccountAge * HOURS){
if (config.accountAgeDeniedMessage) { if (config.accountAgeDeniedMessage) {
const privateChannel = await user.getDMChannel(); const privateChannel = await user.getDMChannel();
@ -96,7 +96,7 @@ async function createNewThreadForUser(user, quiet = false) {
// If set in config, check that the user has been a member of one of the main guilds long enough // If set in config, check that the user has been a member of one of the main guilds long enough
// If they haven't, don't start a new thread and optionally reply to them with a message // If they haven't, don't start a new thread and optionally reply to them with a message
if (config.requiredTimeOnServer) { if (config.requiredTimeOnServer && ! ignoreRequirements) {
// Check if the user joined any of the main servers a long enough time ago // Check if the user joined any of the main servers a long enough time ago
// If we don't see this user on any of the main guilds (the size check below), assume we're just missing some data and give the user the benefit of the doubt // If we don't see this user on any of the main guilds (the size check below), assume we're just missing some data and give the user the benefit of the doubt
const isAllowed = userGuildData.size === 0 || Array.from(userGuildData.values()).some(({guild, member}) => { const isAllowed = userGuildData.size === 0 || Array.from(userGuildData.values()).some(({guild, member}) => {

View File

@ -23,7 +23,7 @@ module.exports = bot => {
return; return;
} }
const createdThread = await threads.createNewThreadForUser(user, true); const createdThread = await threads.createNewThreadForUser(user, true, true);
createdThread.postSystemMessage(`Thread was opened by ${msg.author.username}#${msg.author.discriminator}`); createdThread.postSystemMessage(`Thread was opened by ${msg.author.username}#${msg.author.discriminator}`);
if (thread) { if (thread) {