I've been using this sudo command in my test server and it works well but when I tried to use it in another server, I keep getting the DiscordAPIError: Two factors are required for this operation error.
Any way on how to fix this?
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'sudo',
description: 'sudo webhook',
userpermissions: ['MANAGE_WEBHOOKS'],
async run(client, message, args) {
if (!args[1])
return message.reply(
'Please provide a message to send \n ```\n usages: sudo [mention] [text]```'
);
const member = message.mentions.members.first();
if (!member) return message.reply('Please tag a user');
message.channel
.createWebhook(member.user.username, {
avatar: member.user.displayAvatarURL({ dynamic: true }),
})
.then((webhook) => {
webhook.send(args.slice(1).join(' '));
setTimeout(() => {
webhook.delete();
}, 3000);
});
},
};
You probably have 2FA enabled on the guild/account and it is asking since you're creating a webhook.
You need to enable two factor authentication on your own account for this action to work. Go into your user settings -> my account and click "Enable Two-Factor Auth". After following the steps you're prompted with everything should work fine.
https://support.discord.com/hc/en-us/articles/219576828-Setting-up-Two-Factor-Authentication