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));
}
}
}
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));
}
}
}
No description
1 Reply
d.js toolkit
d.js toolkit7d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!