const Revolt = require('revolt.js'); const { client, logger, config } = require('..'); const { OTP, evalEnabled, OTPTimer } = require('./eval'); const banIntervals = [ 5, 10, 15, 30, 60, 120, 300 ]; const failedAttempts = []; const failedTimeouts = []; module.exports.meta = { name: 'verify', aliases: [ 'v' ], description: 'Verify dev actions.', devLevel: 1 } /** * * @param { Revolt.Message } message * @param { string[] } args */ module.exports.run = async (message, args) => new Promise(async (resolve, reject) => { if (failedAttempts[message.author] == null) failedAttempts[message.author] = 0; if (failedAttempts[message.author] > 0 && failedTimeouts[message.author] != null) { let timeout = (banIntervals[failedAttempts[message.author] - 1] ?? Infinity) * 1000; if (failedTimeouts[message.author] + timeout > Date.now()) { if (timeout == Infinity) return client.channels.sendMessage(message.channel, `❌ Blocked`); else return client.channels.sendMessage(message.channel, `❌ Blocked for ${timeout / 1000} seconds`); } } let otp = OTP[message.author]; let code = args[0]; if (!otp) return client.channels.sendMessage(message.channel, 'There is nothing to verify right now.'); if (!code) return client.channels.sendMessage(message.channel, 'You need to specify a code.'); if (code != otp) { failedAttempts[message.author]++; failedTimeouts[message.author] = Date.now(); return client.channels.sendMessage(message.channel, '❌ Invalid code'); } logger.warn('Enabled eval for ' + message.author); clearTimeout(OTPTimer[message.author]); evalEnabled[message.author] = true; client.channels.sendMessage(message.channel, `Authenticated - Use \`${config.prefix}evaloff\` to disable`); });