tryfyfu
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
anyways, thanks for your help :love:
17 replies
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
nvm :uuh: i think my ip just changed
17 replies
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
Error handling interaction: TypeError: fetch failed
at node:internal/deps/undici/undici:12500:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\User\OneDrive\Desktop\secret\events\LinkAccount.js:39:30) {
[cause]: ConnectTimeoutError: Connect Timeout Error (attempted address: ip, timeout: 10000ms)
at onConnectTimeout (C:\Users\User\OneDrive\Desktop\secret\node_modules\undici\lib\core\connect.js:237:24)
at Immediate._onImmediate (C:\Users\User\OneDrive\Desktop\secret\node_modules\undici\lib\core\connect.js:188:35)
at process.processImmediate (node:internal/timers:478:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
Error handling interaction: TypeError: fetch failed
at node:internal/deps/undici/undici:12500:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\User\OneDrive\Desktop\secret\events\LinkAccount.js:39:30) {
[cause]: ConnectTimeoutError: Connect Timeout Error (attempted address: ip, timeout: 10000ms)
at onConnectTimeout (C:\Users\User\OneDrive\Desktop\secret\node_modules\undici\lib\core\connect.js:237:24)
at Immediate._onImmediate (C:\Users\User\OneDrive\Desktop\secret\node_modules\undici\lib\core\connect.js:188:35)
at process.processImmediate (node:internal/timers:478:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
17 replies
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
# receiving, part 2
else {
return interaction.reply({
content: "Error",
ephemeral: true
});
}
} else {
const howToVerify = new Discord.EmbedBuilder()
.setColor("Aqua")
.setTitle("How To Verify")
.setDescription(`You are trying to link the in-game account ${nameShow} to your Discord account.\n\nTo complete the connection, you need to verify yourself.\nEquip the **Mr. Stumble :MrStumble:** skin in-game and then click the **Verify** button.\n\nIf you want to cancel this process, click the **Cancel** button.`);
const btns1 = new Discord.ButtonBuilder()
.setLabel("Verify")
.setCustomId("register_account_verify")
.setStyle(Discord.ButtonStyle.Success);
const btns2 = new Discord.ButtonBuilder()
.setLabel("Cancel")
.setCustomId("cancel_process")
.setStyle(Discord.ButtonStyle.Danger);
const btns = new Discord.ActionRowBuilder().addComponents(btns1, btns2);
return interaction.reply({
embeds: [howToVerify],
components: [btns],
ephemeral: true
});
}
} catch (error) {
return interaction.reply({ content: "Invalid User", ephemeral: true });
}
}
})
# receiving, part 2
else {
return interaction.reply({
content: "Error",
ephemeral: true
});
}
} else {
const howToVerify = new Discord.EmbedBuilder()
.setColor("Aqua")
.setTitle("How To Verify")
.setDescription(`You are trying to link the in-game account ${nameShow} to your Discord account.\n\nTo complete the connection, you need to verify yourself.\nEquip the **Mr. Stumble :MrStumble:** skin in-game and then click the **Verify** button.\n\nIf you want to cancel this process, click the **Cancel** button.`);
const btns1 = new Discord.ButtonBuilder()
.setLabel("Verify")
.setCustomId("register_account_verify")
.setStyle(Discord.ButtonStyle.Success);
const btns2 = new Discord.ButtonBuilder()
.setLabel("Cancel")
.setCustomId("cancel_process")
.setStyle(Discord.ButtonStyle.Danger);
const btns = new Discord.ActionRowBuilder().addComponents(btns1, btns2);
return interaction.reply({
embeds: [howToVerify],
components: [btns],
ephemeral: true
});
}
} catch (error) {
return interaction.reply({ content: "Invalid User", ephemeral: true });
}
}
})
17 replies
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
# receiving, part 1
client.on("interactionCreate", async interaction => {
if (interaction.customId === "modal_register_account") {
const ingamename = interaction.fields.getTextInputValue('text_in_game_name')
const userid = interaction.user.id
try {
const payload = { username: ingamename };
const response = await fetch(requestUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": authy,
"X-Forwarded-For": ip
},
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
}
const stats = await response.json();
const uid = stats.user_data.userId;
const name = stats.user_data.userName
const nameShow = processIngameName(stats.user_data.userName);
setCachedVerificationData(interaction.user.id, { stats, uid, name });
const existingAccount = await PlayerSchema.findOne({ stumble_uid: uid });
if (existingAccount) {
const linkedAccount = await PlayerSchema.findOne({ discord_user_id: userid });
if (linkedAccount) {
if (linkedAccount.stumble_uid != uid) {
const alreadyConnected = new Discord.EmbedBuilder()
.setColor("Red")
.setTitle("Account Already Connected")
.setDescription(`It seems that someone with ${nameShow} is already connected!\n\nIf this wasn't you, please contact support!`);
return interaction.reply({
embeds: [alreadyConnected],
ephemeral: true
});
} else if (linkedAccount.stumble_uid === uid) {
const changeAccount = new Discord.EmbedBuilder()
.setColor("Aqua")
.setTitle("Request Account Change")
.setDescription(`The in-game account ${nameShow} is already linked to your account!\n\nIf you want to cancel this process, click the **Cancel** button.`);
const btns1 = new Discord.ButtonBuilder()
.setLabel("Change")
.setCustomId("register_account_change")
.setStyle(Discord.ButtonStyle.Primary);
const btns2 = new Discord.ButtonBuilder()
.setLabel("Cancel")
.setCustomId("cancel_process")
.setStyle(Discord.ButtonStyle.Danger);
const btns = new Discord.ActionRowBuilder().addComponents(btns1, btns2);
return interaction.reply({
embeds: [changeAccount],
components: [btns],
ephemeral: true
});
}
}
# receiving, part 1
client.on("interactionCreate", async interaction => {
if (interaction.customId === "modal_register_account") {
const ingamename = interaction.fields.getTextInputValue('text_in_game_name')
const userid = interaction.user.id
try {
const payload = { username: ingamename };
const response = await fetch(requestUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": authy,
"X-Forwarded-For": ip
},
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
}
const stats = await response.json();
const uid = stats.user_data.userId;
const name = stats.user_data.userName
const nameShow = processIngameName(stats.user_data.userName);
setCachedVerificationData(interaction.user.id, { stats, uid, name });
const existingAccount = await PlayerSchema.findOne({ stumble_uid: uid });
if (existingAccount) {
const linkedAccount = await PlayerSchema.findOne({ discord_user_id: userid });
if (linkedAccount) {
if (linkedAccount.stumble_uid != uid) {
const alreadyConnected = new Discord.EmbedBuilder()
.setColor("Red")
.setTitle("Account Already Connected")
.setDescription(`It seems that someone with ${nameShow} is already connected!\n\nIf this wasn't you, please contact support!`);
return interaction.reply({
embeds: [alreadyConnected],
ephemeral: true
});
} else if (linkedAccount.stumble_uid === uid) {
const changeAccount = new Discord.EmbedBuilder()
.setColor("Aqua")
.setTitle("Request Account Change")
.setDescription(`The in-game account ${nameShow} is already linked to your account!\n\nIf you want to cancel this process, click the **Cancel** button.`);
const btns1 = new Discord.ButtonBuilder()
.setLabel("Change")
.setCustomId("register_account_change")
.setStyle(Discord.ButtonStyle.Primary);
const btns2 = new Discord.ButtonBuilder()
.setLabel("Cancel")
.setCustomId("cancel_process")
.setStyle(Discord.ButtonStyle.Danger);
const btns = new Discord.ActionRowBuilder().addComponents(btns1, btns2);
return interaction.reply({
embeds: [changeAccount],
components: [btns],
ephemeral: true
});
}
}
17 replies
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
# creating modal
client.on("interactionCreate", async interaction => {
if(interaction.customId === "register_account_connect") {
const getAccountNameModal = new Discord.ModalBuilder()
.setTitle("Register Account")
.setCustomId("modal_register_account")
const TextInputAccount = new Discord.TextInputBuilder()
.setCustomId("text_in_game_name")
.setLabel("In-game Name")
.setRequired(true)
.setPlaceholder("<#820>tryfyfu")
.setStyle(Discord.TextInputStyle.Short)
const actionRow = new Discord.ActionRowBuilder().addComponents(TextInputAccount);
getAccountNameModal.addComponents(actionRow);
return interaction.showModal(getAccountNameModal)
}
});
# creating modal
client.on("interactionCreate", async interaction => {
if(interaction.customId === "register_account_connect") {
const getAccountNameModal = new Discord.ModalBuilder()
.setTitle("Register Account")
.setCustomId("modal_register_account")
const TextInputAccount = new Discord.TextInputBuilder()
.setCustomId("text_in_game_name")
.setLabel("In-game Name")
.setRequired(true)
.setPlaceholder("<#820>tryfyfu")
.setStyle(Discord.TextInputStyle.Short)
const actionRow = new Discord.ActionRowBuilder().addComponents(TextInputAccount);
getAccountNameModal.addComponents(actionRow);
return interaction.showModal(getAccountNameModal)
}
});
17 replies
DIAdiscord.js - Imagine an app
•Created by tryfyfu on 2/25/2025 in #djs-questions
Unknown interaction, what could be the reason?
// index.js Slash Commands Handler
client.on('interactionCreate', async interaction => {
if (interaction.type !== Discord.InteractionType.ApplicationCommand) return;
if (!interaction.guild) return interaction.reply({
content: "You can't use `/` commands in private messages",
});
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await interaction.deferReply();
await command.execute(interaction);
} catch (err) {
console.error(err);
await interaction.followUp({ content: "An error occurred while executing this command.", ephemeral: true });
}
});
// index.js Slash Commands Handler
client.on('interactionCreate', async interaction => {
if (interaction.type !== Discord.InteractionType.ApplicationCommand) return;
if (!interaction.guild) return interaction.reply({
content: "You can't use `/` commands in private messages",
});
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await interaction.deferReply();
await command.execute(interaction);
} catch (err) {
console.error(err);
await interaction.followUp({ content: "An error occurred while executing this command.", ephemeral: true });
}
});
17 replies