Gerben
Gerben
DIAdiscord.js - Imagine an app
Created by Gerben on 2/20/2024 in #djs-questions
Always read a modal InputTextValue but when it doesn't exist it makes a null value of it.
Does anyone know how to always read a modal InputTextValue but when it doesn't exist it makes a null value of it?
const vraag1 = interaction.fields.getTextInputValue('vraag1' || null);
const vraag1 = interaction.fields.getTextInputValue('vraag1') || null;
const vraag1 = interaction.fields.getTextInputValue('vraag1' || null);
const vraag1 = interaction.fields.getTextInputValue('vraag1') || null;
Here is my code with 2 different ways but they all get error with the following:
Connect. ERROR | (Uncaught Exception) TypeError [ModalSubmitInteractionFieldNotFound]: Required field with custom id "vraag1" not found.
at ModalSubmitFields.getField (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:36:23)
at ModalSubmitFields.getTextInputValue (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:51:17)
at Object.execute (/home/container/events/ticket-system/interactionTicketEmbed.js:238:38)
at Client.<anonymous> (/home/container/index.js:74:50)
at Client.emit (node:events:525:35)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31) {
code: 'ModalSubmitInteractionFieldNotFound'
Connect. ERROR | (Uncaught Exception) TypeError [ModalSubmitInteractionFieldNotFound]: Required field with custom id "vraag1" not found.
at ModalSubmitFields.getField (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:36:23)
at ModalSubmitFields.getTextInputValue (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:51:17)
at Object.execute (/home/container/events/ticket-system/interactionTicketEmbed.js:238:38)
at Client.<anonymous> (/home/container/index.js:74:50)
at Client.emit (node:events:525:35)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31) {
code: 'ModalSubmitInteractionFieldNotFound'
9 replies
DIAdiscord.js - Imagine an app
Created by Gerben on 1/27/2024 in #djs-questions
Channel user permissions
Does anyone knows what the problem is that I am currently having within a slash command file? I would like to add a person to a channel when the command is executed. At the moment I manage to add the user within the channel permissions but fail to add the correct permissions to this person. This is because I am getting the following error in my console.
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: SEND_MESSAGES.
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: SEND_MESSAGES.
const { SlashCommandBuilder, EmbedBuilder, Permissions } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Wil je een persoon toevoegen aan de ticket?')
.addUserOption(option =>
option.setName('persoon')
.setDescription('Geef de persoon op die je wilt toevoegen aan de ticket.')
.setRequired(true)),
async execute(interaction) {
const user = interaction.options.getUser('persoon');
const ticket = interaction.channel;

await ticket.permissionOverwrites.create(user, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true,
});

console.log(`Gebruiker ${persoon.tag} toegevoegd aan ${ticket.name}`);

const AddEmbed = new EmbedBuilder()
.setColor('#1C6FFF')
.setTitle('Add')
.setDescription('test')
.addFields(
{ name: `Added user:`, value: `${persoon}`},
{ name: `Added by`, value: `<@${interaction.user.id}>`},
{ name: `Ticket:`, value: `<#${interaction.channel.id}>`}
)
.setTimestamp()

await interaction.reply({
content: `${persoon} added to this ticket.`
})
await interaction.guild.channels.cache.get('1193826954655313940').send({
embeds: [AddEmbed]
})
},
};
const { SlashCommandBuilder, EmbedBuilder, Permissions } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Wil je een persoon toevoegen aan de ticket?')
.addUserOption(option =>
option.setName('persoon')
.setDescription('Geef de persoon op die je wilt toevoegen aan de ticket.')
.setRequired(true)),
async execute(interaction) {
const user = interaction.options.getUser('persoon');
const ticket = interaction.channel;

await ticket.permissionOverwrites.create(user, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true,
});

console.log(`Gebruiker ${persoon.tag} toegevoegd aan ${ticket.name}`);

const AddEmbed = new EmbedBuilder()
.setColor('#1C6FFF')
.setTitle('Add')
.setDescription('test')
.addFields(
{ name: `Added user:`, value: `${persoon}`},
{ name: `Added by`, value: `<@${interaction.user.id}>`},
{ name: `Ticket:`, value: `<#${interaction.channel.id}>`}
)
.setTimestamp()

await interaction.reply({
content: `${persoon} added to this ticket.`
})
await interaction.guild.channels.cache.get('1193826954655313940').send({
embeds: [AddEmbed]
})
},
};
4 replies
DIAdiscord.js - Imagine an app
Created by Gerben on 1/16/2024 in #djs-questions
moving Chanels between category’s without permissions loss.
Does anyone know the proper way to move a channel from one category to another without removing the role permissions added within this channel?
6 replies