BakeWithMe
BakeWithMe
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 4/20/2024 in #djs-questions
Button message not working
i will try that thank you
6 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 4/20/2024 in #djs-questions
Button message not working
oh okay
6 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/23/2024 in #djs-questions
embed not working sometimes on random cat image command
i had to deferreply to give time to embed
6 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/23/2024 in #djs-questions
embed not working sometimes on random cat image command
yes the image isnt displaying in the embed
6 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
thank you
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
no the translation not, only the error messages should be ephemeral (see above)
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
This is my code now, i think deferreply fixed my error but now the error messages arent in ephemeral: true. these two: 'ℹ️ This text was already recently translated, please look back in chat' 'ℹ️ This message seems to be in English already or it might just be gibberish I cannot translate'
run: async (client, interaction) => {
try {
await interaction.deferReply();

const selectedMessage = await interaction.channel.messages.fetch(interaction.targetId);

// Detect the language of the original message
const detectedLanguageAbbreviation = (await translate(selectedMessage.content)).from.language.iso.toUpperCase();
const detectedLanguage = getLanguageName(detectedLanguageAbbreviation);

// Check if the detected language is English
if (detectedLanguageAbbreviation === 'EN') {
return await interaction.editReply({ content: 'ℹ️ This message seems to be in **English** already or it might just be gibberish I cannot translate', ephemeral: true });
}

// Check if the message was recently translated
if (recentlyTranslatedMessages[selectedMessage.id] && Date.now() - recentlyTranslatedMessages[selectedMessage.id] < 300000) {
return await interaction.editReply({ content: 'ℹ️ This text was already recently translated, please look back in chat', ephemeral: true });
}

// Store the current timestamp as the time the message was translated
recentlyTranslatedMessages[selectedMessage.id] = Date.now();

// Translate the message content to English
const translateResult = await translate(selectedMessage.content, { to: 'en' });

// Create a hyperlink to the original message content
const originalMessageLink = `[${selectedMessage.cleanContent}](${selectedMessage.url})`;

// Create an embed to display the translation
const translateEmbed = new EmbedBuilder()
.setTitle(`${detectedLanguage} to English`)
.setDescription(`❔ **${selectedMessage.author}** said: ${originalMessageLink}`)
.addFields(
{ name: '☑️ Translation:', value: translateResult.text }
)
.setColor(interaction.client.config.embedColor);

await new Promise(resolve => setTimeout(resolve, 1000));

// Send the translated message as a response
await interaction.editReply({ embeds: [translateEmbed], ephemeral: interaction.options.ephemeral });
} catch (e) {
console.error(e);
await interaction.editReply({ content: 'An error occurred while processing your command.', ephemeral: true });
}
},
};
run: async (client, interaction) => {
try {
await interaction.deferReply();

const selectedMessage = await interaction.channel.messages.fetch(interaction.targetId);

// Detect the language of the original message
const detectedLanguageAbbreviation = (await translate(selectedMessage.content)).from.language.iso.toUpperCase();
const detectedLanguage = getLanguageName(detectedLanguageAbbreviation);

// Check if the detected language is English
if (detectedLanguageAbbreviation === 'EN') {
return await interaction.editReply({ content: 'ℹ️ This message seems to be in **English** already or it might just be gibberish I cannot translate', ephemeral: true });
}

// Check if the message was recently translated
if (recentlyTranslatedMessages[selectedMessage.id] && Date.now() - recentlyTranslatedMessages[selectedMessage.id] < 300000) {
return await interaction.editReply({ content: 'ℹ️ This text was already recently translated, please look back in chat', ephemeral: true });
}

// Store the current timestamp as the time the message was translated
recentlyTranslatedMessages[selectedMessage.id] = Date.now();

// Translate the message content to English
const translateResult = await translate(selectedMessage.content, { to: 'en' });

// Create a hyperlink to the original message content
const originalMessageLink = `[${selectedMessage.cleanContent}](${selectedMessage.url})`;

// Create an embed to display the translation
const translateEmbed = new EmbedBuilder()
.setTitle(`${detectedLanguage} to English`)
.setDescription(`❔ **${selectedMessage.author}** said: ${originalMessageLink}`)
.addFields(
{ name: '☑️ Translation:', value: translateResult.text }
)
.setColor(interaction.client.config.embedColor);

await new Promise(resolve => setTimeout(resolve, 1000));

// Send the translated message as a response
await interaction.editReply({ embeds: [translateEmbed], ephemeral: interaction.options.ephemeral });
} catch (e) {
console.error(e);
await interaction.editReply({ content: 'An error occurred while processing your command.', ephemeral: true });
}
},
};
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
but then everything will be in ephemeral: true?
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
yes the translations, but not the error messages
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
ephemeral true doesnt show up as a view only message anymore then
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/22/2024 in #djs-questions
Error in translate command "Unknown interaction"
@astro its probably because of "Initial response took more than 3 seconds", but when i do deferreply, the ephemeral doesnt work anymore
14 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 3/18/2024 in #djs-questions
ephemeral not working
thank you
4 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 11/5/2022 in #djs-questions
Set slash command only visible by user
i get a error doing that Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
8 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 11/5/2022 in #djs-questions
Set slash command only visible by user
though of adding ephemeral: true }); but didnt work
8 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 11/5/2022 in #djs-questions
Set slash command only visible by user
i want a wait message to be only visible by the user doing the command again
8 replies
DIAdiscord.js - Imagine an app
Created by BakeWithMe on 11/5/2022 in #djs-questions
Set slash command only visible by user
else { const expirationTime = timestamps.get(interaction.user.id) + cooldownAmount; const timeLeft = (expirationTime - now) / 1000; if (now < expirationTime && timeLeft > 0.9) { return interaction.reply({ content: ⏰ Wait **\${timeLeft.toFixed(1)}` seconds to use the ${command.name}** command again!`, ephemeral: true }); } timestamps.set(interaction.user.id, now); setTimeout(() => timestamps.delete(interaction.user.id), cooldownAmount);
8 replies