Xaphy
DIAdiscord.js - Imagine an app
•Created by Xaphy on 4/28/2024 in #djs-questions
interaction.channel is null in DM
it works for servers, but not in direct message as 'user app'.
I already use as suggestions of others similar questions, but I am not sure what I am missing:
command is as follow:
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: ['MESSAGE', 'CHANNEL', 'REACTION']
});
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: ['MESSAGE', 'CHANNEL', 'REACTION']
});
const { ContextMenuCommandBuilder, ApplicationCommandType, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('Translate It v2')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('translate-en')
.setLabel('Translate to English')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId('translate-es')
.setLabel('Translate to Spanish')
.setStyle(ButtonStyle.Primary)
);
await interaction.reply({ content: 'Choose the language to translate:', components: [row], ephemeral: true });
try {
const filter = i => i.user.id === interaction.user.id;
const buttonInteraction = await interaction.channel.awaitMessageComponent({ filter, time: 15000 });
...
const { ContextMenuCommandBuilder, ApplicationCommandType, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('Translate It v2')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('translate-en')
.setLabel('Translate to English')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId('translate-es')
.setLabel('Translate to Spanish')
.setStyle(ButtonStyle.Primary)
);
await interaction.reply({ content: 'Choose the language to translate:', components: [row], ephemeral: true });
try {
const filter = i => i.user.id === interaction.user.id;
const buttonInteraction = await interaction.channel.awaitMessageComponent({ filter, time: 15000 });
...
4 replies