error Fetch user through user id

const { Events, WebhookClient, } = require('discord.js');
const { embedMessage, parse_money } = require("../../utils/Utils");

module.exports = {
    name: Events.InteractionCreate,
    async execute(interaction, client) {
        const { customId, fields } = interaction;

        if (!interaction.isModalSubmit()) return;


        if (customId === 'add-modal') {
            const idInput = fields.getTextInputValue('addmoney-idinput');
            const username = await client.users.fetch(idInput);
            const moneyInput = fields.getTextInputValue('addmoney-tieninput');

            if (username && !idInput.bot) {
                await main.getDataBaseMgr().addMoney(idInput, moneyInput);
                await interaction.reply(embedMessage(`Tiền của <@${idInput}> đã được thêm ${parse_money(moneyInput)}!`, true));

                const name = username;
                const avatar = interaction.user.displayAvatarURL();
                const webhook = new WebhookClient({ url: config.LOG_ADMIN });
                await webhook.send({
                    content: `# Tiền của <@${idInput}> đã được thêm ${parse_money(moneyInput)}!`,
                    username: name,
                    avatarURL: avatar,
                });
            } else {
                await interaction.reply(embedMessage(`Bạn không thể thêm tiền cho robot hoặc người dùng không hợp lệ!`, true));
            } 
    }
}
image.png
Was this page helpful?