Unicorn.
Unicorn.
DIAdiscord.js - Imagine an app
Created by Unicorn. on 6/22/2024 in #djs-questions
How to send custom emoji in embed description
No description
12 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 5/30/2024 in #djs-questions
Can't use modal after button
const { ActionRowBuilder,PermissionFlagsBits,PermissionsBitField, ModalBuilder, TextInputBuilder, TextInputStyle, ButtonBuilder, ButtonStyle, SlashCommandBuilder,EmbedBuilder, } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ticketmessinit')
.setDescription('add')
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply();
await interaction.deleteReply();
const eventtic = new EmbedBuilder()
···
const create = new ButtonBuilder()
.setCustomId('ticketinit')
.setLabel('Create a ticket')
.setStyle(ButtonStyle.Primary);

const cancel = new ButtonBuilder()
.setCustomId('cancel')
.setLabel('Cancel')
.setStyle(ButtonStyle.Secondary);
const row = new ActionRowBuilder()
.addComponents(create,cancel);
const msg = await interaction.channel.send({
embeds:[eventtic],
components: [row],
});
const collector = msg.createMessageComponentCollector();
collector.on('collect',async i =>{
interaction.deferReply();
if (i.customId=='ticketinit'){
// Create the modal
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');
// Add components to modal
// Create the text input components
const favoriteColorInput = new TextInputBuilder()
.setCustomId('Eventid')
// The label is the prompt the user sees for this input
.setLabel("What's the ID of your VTC's event?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);
// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
// Add inputs to the modal
modal.addComponents(firstActionRow);
// Show the modal to the user
await interaction.showModal(modal);
const filter = (o) => o.customId === 'myModal';
interaction.awaitModalSubmit({ time: 50_000, filter })
.then(async(interaction) => {···
if (data.error == false){···
} else {
interaction.channel.send({content:'Can\'t find the event!',ephemeral:true});
}
})
.catch(err => console.log('No modal submit interaction was collected'));
} else if(i.customId=='cancel'){
interaction.update();
}
});
},
};
const { ActionRowBuilder,PermissionFlagsBits,PermissionsBitField, ModalBuilder, TextInputBuilder, TextInputStyle, ButtonBuilder, ButtonStyle, SlashCommandBuilder,EmbedBuilder, } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ticketmessinit')
.setDescription('add')
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply();
await interaction.deleteReply();
const eventtic = new EmbedBuilder()
···
const create = new ButtonBuilder()
.setCustomId('ticketinit')
.setLabel('Create a ticket')
.setStyle(ButtonStyle.Primary);

const cancel = new ButtonBuilder()
.setCustomId('cancel')
.setLabel('Cancel')
.setStyle(ButtonStyle.Secondary);
const row = new ActionRowBuilder()
.addComponents(create,cancel);
const msg = await interaction.channel.send({
embeds:[eventtic],
components: [row],
});
const collector = msg.createMessageComponentCollector();
collector.on('collect',async i =>{
interaction.deferReply();
if (i.customId=='ticketinit'){
// Create the modal
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');
// Add components to modal
// Create the text input components
const favoriteColorInput = new TextInputBuilder()
.setCustomId('Eventid')
// The label is the prompt the user sees for this input
.setLabel("What's the ID of your VTC's event?")
// Short means only a single line of text
.setStyle(TextInputStyle.Short);
// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
// Add inputs to the modal
modal.addComponents(firstActionRow);
// Show the modal to the user
await interaction.showModal(modal);
const filter = (o) => o.customId === 'myModal';
interaction.awaitModalSubmit({ time: 50_000, filter })
.then(async(interaction) => {···
if (data.error == false){···
} else {
interaction.channel.send({content:'Can\'t find the event!',ephemeral:true});
}
})
.catch(err => console.log('No modal submit interaction was collected'));
} else if(i.customId=='cancel'){
interaction.update();
}
});
},
};
28 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 4/23/2024 in #djs-questions
console shows promise pending
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('staffmember')
.setDescription('tee')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
const tagName = interaction.guild.roles.fetch('1224381394428498063')
.then(role => role.members)
.catch(console.error);
await console.log(tagName);
const tagDescription = interaction.user;

try {
// equivalent to: INSERT INTO tags (name, description, username) values (?, ?, ?);
const tag = await interaction.client.Tags.create({
name: '1',
description: '1',
username: interaction.user.id,
});
return interaction.reply(`Tag ${tag.name} added.`);
}
catch (error) {
if (error.name === 'SequelizeUniqueConstraintError') {
return interaction.reply('That tag already exists.');
}
console.log(error)
return interaction.reply('Something went wrong with adding a tag.');
}},
};
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('staffmember')
.setDescription('tee')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
const tagName = interaction.guild.roles.fetch('1224381394428498063')
.then(role => role.members)
.catch(console.error);
await console.log(tagName);
const tagDescription = interaction.user;

try {
// equivalent to: INSERT INTO tags (name, description, username) values (?, ?, ?);
const tag = await interaction.client.Tags.create({
name: '1',
description: '1',
username: interaction.user.id,
});
return interaction.reply(`Tag ${tag.name} added.`);
}
catch (error) {
if (error.name === 'SequelizeUniqueConstraintError') {
return interaction.reply('That tag already exists.');
}
console.log(error)
return interaction.reply('Something went wrong with adding a tag.');
}},
};
14 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 4/7/2024 in #djs-questions
contextmenubuilder
const { ContextMenuCommandBuilder,ApplicationCommandType, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('LOA Remove')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const message = interaction.targetMessage;
const member = message.member
member.roles.add('1187772116767100979');
await interaction.deferReply();
await interaction.deleteReply();
await message.react('');
},
};
const { ContextMenuCommandBuilder,ApplicationCommandType, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('LOA Remove')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const message = interaction.targetMessage;
const member = message.member
member.roles.add('1187772116767100979');
await interaction.deferReply();
await interaction.deleteReply();
await message.react('');
},
};
when using it console log channel.istextbase is not a fuction
27 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 4/1/2024 in #djs-questions
fetch the new created channel
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction) {
interaction.guild.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
});
channels.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at${newchannel}`);
},
};
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction) {
interaction.guild.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
});
channels.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at${newchannel}`);
},
};
9 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 2/4/2024 in #djs-questions
interaction deferreply
i used interaction.deferReply but console tells me haven't
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('eve')
.setDescription('Select status of event.')
.addSubcommand(subcommand =>
subcommand
.setName('status')
.setDescription('The status of the event.')
.addStringOption(option =>
option
.setName('sta')
.setDescription('Status of event.')
.setRequired(true)
.addChoices(
{ name: 'Accept', value: 'acc' },
{ name: 'Deny', value: 'deny' },
{ name: 'Pending', value: 'ped' },
)
)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
const sta = interaction.options.getString('sta');
const error = new EmbedBuilder()
.setColor('Red')
.setTitle(`Error`)
.setDescription(`Commmand error`);
function Accept() {
interaction.deferReply();
interaction.editReply('222222');
interaction.channel.send('111');
}
function Deny() {
interaction.channel.send('111133331');
interaction.editReply(
`Status of this ticket has been changed to 🟢 - **ACCEPT**.

We will offer Supervisions, when we are free to do that.
:pushpin: Our Staff are notified about this event at the right time !

>Please modify your event rules to the rules we need, and add our banner on the TMP event page

Thanks for your choose us understanding! :huge:

**Kind Regards,**
**1111**
**Marking | Event Manager / Event Supervisions**`);
}
function Pending() {
interaction.channel.send('222222');
interaction.deferReply();
interaction.editReply({ content: 'Success!', ephemeral: true });
}
if (sta == 'acc') {
Accept();
}
else if (sta == 'deny') {
Deny();
}
else if (sta == 'ped') {
Pending();
}
else
{
interaction.deferReply();
interaction.editReply(
{embed:[error],
});
return;
}
},
};
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('eve')
.setDescription('Select status of event.')
.addSubcommand(subcommand =>
subcommand
.setName('status')
.setDescription('The status of the event.')
.addStringOption(option =>
option
.setName('sta')
.setDescription('Status of event.')
.setRequired(true)
.addChoices(
{ name: 'Accept', value: 'acc' },
{ name: 'Deny', value: 'deny' },
{ name: 'Pending', value: 'ped' },
)
)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
const sta = interaction.options.getString('sta');
const error = new EmbedBuilder()
.setColor('Red')
.setTitle(`Error`)
.setDescription(`Commmand error`);
function Accept() {
interaction.deferReply();
interaction.editReply('222222');
interaction.channel.send('111');
}
function Deny() {
interaction.channel.send('111133331');
interaction.editReply(
`Status of this ticket has been changed to 🟢 - **ACCEPT**.

We will offer Supervisions, when we are free to do that.
:pushpin: Our Staff are notified about this event at the right time !

>Please modify your event rules to the rules we need, and add our banner on the TMP event page

Thanks for your choose us understanding! :huge:

**Kind Regards,**
**1111**
**Marking | Event Manager / Event Supervisions**`);
}
function Pending() {
interaction.channel.send('222222');
interaction.deferReply();
interaction.editReply({ content: 'Success!', ephemeral: true });
}
if (sta == 'acc') {
Accept();
}
else if (sta == 'deny') {
Deny();
}
else if (sta == 'ped') {
Pending();
}
else
{
interaction.deferReply();
interaction.editReply(
{embed:[error],
});
return;
}
},
};
11 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 2/4/2024 in #djs-questions
interaction defer
i used interaction.deferReply but console tells me haven't use
2 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 5/27/2023 in #djs-questions
how could roleat change with position(name of roleid) string change
const { roleMention , SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder, WebhookClient } = require('discord.js');
const { RoleID, webhookId, webhookToken } = require('../../config/plugins/promote.json');
const webhookClient = new WebhookClient({ id: webhookId, token: webhookToken });

module.exports = {
data: new SlashCommandBuilder()
.setName('promote')
.setDescription('Select a member and promote them.')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to promote')
.setRequired(true))
.addStringOption(option =>
option
.setName('position')
.setDescription('The position for pormoting')
.setRequired(true)
.addChoices(
{ name: 'Event Team', value: 'CC' },
{ name: 'Media Team', value: 'Media' },
{ name: 'Driver', value: 'Driver' },
{ name: 'Driver Trainee', value: 'Trainee' },
))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.setDMPermission(false),
async execute(interaction) {
const member = interaction.options.getMember('target');
const avatarURL = member.user.displayAvatarURL({size:4096});
const userID = member.id;
const position = interaction.options.getString('position');
const success = new EmbedBuilder()
.setColor('#AC00FF')
.setThumbnail(avatarURL)
.setTitle(`Member Role Change`)
.setDescription(`**<@${userID}>** has promoted to **${RoleID.position}**`)
const error = new EmbedBuilder()
.setColor('Red')
.setTitle(`Error`)
.setDescription(`Commmand error`);
function CC() {
member.roles.add(RoleID.Devide1);
member.roles.add(RoleID.CC);
webhookClient.send({
embeds: [success.setImage('https://cdn.discordapp.com/attachments/929319867457347636/1103853149745332285/ZmT1EEV2.png')],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
function Driver() {
member.roles.add(RoleID.Driver);
member.roles.remove(RoleID.Trainee);
webhookClient.send({
embeds: [success],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
function Media() {
member.roles.add(RoleID.Devide1);
member.roles.add(RoleID.Media);
webhookClient.send({
embeds: [success],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
function Trainee() {
member.roles.add(RoleID.Devide2);
member.roles.add(RoleID.Trainee);
webhookClient.send({
embeds: [success.setDescription(`**<@${userID}>** joins Federal Transport VTC as **<@${roleat}>**`)],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
if (position == 'CC') {
CC();
}
else if (position == 'Media') {
Media();
}
else if (position == 'Driver') {
Driver();
}
else if (position == 'Trainee'){
Trainee();
}
else
{
interaction.reply(
{embed:[error],
});
return;
}
},
};
const { roleMention , SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder, WebhookClient } = require('discord.js');
const { RoleID, webhookId, webhookToken } = require('../../config/plugins/promote.json');
const webhookClient = new WebhookClient({ id: webhookId, token: webhookToken });

module.exports = {
data: new SlashCommandBuilder()
.setName('promote')
.setDescription('Select a member and promote them.')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to promote')
.setRequired(true))
.addStringOption(option =>
option
.setName('position')
.setDescription('The position for pormoting')
.setRequired(true)
.addChoices(
{ name: 'Event Team', value: 'CC' },
{ name: 'Media Team', value: 'Media' },
{ name: 'Driver', value: 'Driver' },
{ name: 'Driver Trainee', value: 'Trainee' },
))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.setDMPermission(false),
async execute(interaction) {
const member = interaction.options.getMember('target');
const avatarURL = member.user.displayAvatarURL({size:4096});
const userID = member.id;
const position = interaction.options.getString('position');
const success = new EmbedBuilder()
.setColor('#AC00FF')
.setThumbnail(avatarURL)
.setTitle(`Member Role Change`)
.setDescription(`**<@${userID}>** has promoted to **${RoleID.position}**`)
const error = new EmbedBuilder()
.setColor('Red')
.setTitle(`Error`)
.setDescription(`Commmand error`);
function CC() {
member.roles.add(RoleID.Devide1);
member.roles.add(RoleID.CC);
webhookClient.send({
embeds: [success.setImage('https://cdn.discordapp.com/attachments/929319867457347636/1103853149745332285/ZmT1EEV2.png')],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
function Driver() {
member.roles.add(RoleID.Driver);
member.roles.remove(RoleID.Trainee);
webhookClient.send({
embeds: [success],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
function Media() {
member.roles.add(RoleID.Devide1);
member.roles.add(RoleID.Media);
webhookClient.send({
embeds: [success],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
function Trainee() {
member.roles.add(RoleID.Devide2);
member.roles.add(RoleID.Trainee);
webhookClient.send({
embeds: [success.setDescription(`**<@${userID}>** joins Federal Transport VTC as **<@${roleat}>**`)],
});
interaction.reply({ content: 'Success!', ephemeral: true });
}
if (position == 'CC') {
CC();
}
else if (position == 'Media') {
Media();
}
else if (position == 'Driver') {
Driver();
}
else if (position == 'Trainee'){
Trainee();
}
else
{
interaction.reply(
{embed:[error],
});
return;
}
},
};
8 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 5/1/2023 in #djs-questions
Why add role says invalidtype
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { teamchanegeChannelID, CCroelId } = require('../../config/plugins/promote.json')
module.exports = {
data: new SlashCommandBuilder()
.setName('promote')
.setDescription('Select a member and promote them.')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to promote')
.setRequired(true))
.addStringOption(option =>
option
.setName('position')
.setDescription('The position for pormoting')
.setRequired(true)
.addChoices(
{ name: 'Convoy Control', value: 'CC' },
{ name: 'Driver', value: 'Driver' },
{ name: 'Driver Trainee', value: 'Trainee' },
))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.setDMPermission(false),
async execute(interaction) {
const member = interaction.options.getMember('target');
member.roles.add(CCroelId);
},
};
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { teamchanegeChannelID, CCroelId } = require('../../config/plugins/promote.json')
module.exports = {
data: new SlashCommandBuilder()
.setName('promote')
.setDescription('Select a member and promote them.')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to promote')
.setRequired(true))
.addStringOption(option =>
option
.setName('position')
.setDescription('The position for pormoting')
.setRequired(true)
.addChoices(
{ name: 'Convoy Control', value: 'CC' },
{ name: 'Driver', value: 'Driver' },
{ name: 'Driver Trainee', value: 'Trainee' },
))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.setDMPermission(false),
async execute(interaction) {
const member = interaction.options.getMember('target');
member.roles.add(CCroelId);
},
};
11 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 4/13/2023 in #djs-questions
Why can't use async execute(interaction, client)
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
userPerms: [],
botPerms: [],
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Add someone to the ticket (Ticket Command) ')
.setDMPermission(false)
.addUserOption(option =>
option.setName('target')
.setDescription('Member to add to ticket')
.setRequired(true)),
async execute(interaction, client) {
//log
const commandName = "ADD";
client.std_log.error(client, commandName, interaction.user.id, interaction.channel.id);
const chan = client.channels.cache.get(interaction.channelId);
const user = interaction.options.getUser('target');
const userID = user.id;
let Support_Role;
function Fivem() {
return Support_Role = client.ticket.FIVEM_TICKET.ROLE_SUPPORT.ID;
}
function Redm() {
return Support_Role = client.ticket.REDM_TICKET.ROLE_SUPPORT.ID;
}
if (interaction.guild.id == client.ticket.FIVEM_TICKET.GUILDID) {
Fivem();
} else if (interaction.guild.id == client.ticket.REDM_TICKET.GUILDID) {
Redm();
} else {
return;
}
if (chan.name.includes('ticket')) {
chan.edit({
permissionOverwrites: [
{
id: userID,
allow: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel],
},
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
{
id: Support_Role,
allow: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel],
},
],
}).then(async () => {
interaction.reply({
content: `<@${user.id}> has been added to the ticket!`
});
});
} else {
const ReplyEmbed = new EmbedBuilder()
.setColor("Red")
.setDescription('You are not in a Ticket!')
await interaction.reply({
embeds: [ReplyEmbed],
ephemeral: true
});
};
},
};
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
userPerms: [],
botPerms: [],
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Add someone to the ticket (Ticket Command) ')
.setDMPermission(false)
.addUserOption(option =>
option.setName('target')
.setDescription('Member to add to ticket')
.setRequired(true)),
async execute(interaction, client) {
//log
const commandName = "ADD";
client.std_log.error(client, commandName, interaction.user.id, interaction.channel.id);
const chan = client.channels.cache.get(interaction.channelId);
const user = interaction.options.getUser('target');
const userID = user.id;
let Support_Role;
function Fivem() {
return Support_Role = client.ticket.FIVEM_TICKET.ROLE_SUPPORT.ID;
}
function Redm() {
return Support_Role = client.ticket.REDM_TICKET.ROLE_SUPPORT.ID;
}
if (interaction.guild.id == client.ticket.FIVEM_TICKET.GUILDID) {
Fivem();
} else if (interaction.guild.id == client.ticket.REDM_TICKET.GUILDID) {
Redm();
} else {
return;
}
if (chan.name.includes('ticket')) {
chan.edit({
permissionOverwrites: [
{
id: userID,
allow: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel],
},
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
{
id: Support_Role,
allow: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel],
},
],
}).then(async () => {
interaction.reply({
content: `<@${user.id}> has been added to the ticket!`
});
});
} else {
const ReplyEmbed = new EmbedBuilder()
.setColor("Red")
.setDescription('You are not in a Ticket!')
await interaction.reply({
embeds: [ReplyEmbed],
ephemeral: true
});
};
},
};
2 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 3/21/2023 in #djs-questions
How to create a channel ?
I wrote some codes but it always shows
Cannot read properties of undefined (reading 'guilds')
Cannot read properties of undefined (reading 'guilds')
But i defined it at first.like
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction,client) {
const { guildId } = require('../../config/main/config.json');
client.guilds.cache
.get(guildId)
.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at<#${newchannel}>`);
},
};
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction,client) {
const { guildId } = require('../../config/main/config.json');
client.guilds.cache
.get(guildId)
.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at<#${newchannel}>`);
},
};
4 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 1/10/2023 in #djs-questions
How to solve invalid form body
DiscordAPIError[50035]: Invalid Form Body
application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
at SequentialHandler.runRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:464:14)
at async REST.request (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:910:22)
at async E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\deploy-commands.js:24:16 {
requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] },
rawError: {
code: 50035,
errors: { application_id: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/undefined/commands'
}
[I] 2023/01/10 14:40:44 All Windows descendant process exited.
[I] 2023/01/10 14:40:44 Master exiting
DiscordAPIError[50035]: Invalid Form Body
application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
at SequentialHandler.runRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:464:14)
at async REST.request (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:910:22)
at async E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\deploy-commands.js:24:16 {
requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] },
rawError: {
code: 50035,
errors: { application_id: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/undefined/commands'
}
[I] 2023/01/10 14:40:44 All Windows descendant process exited.
[I] 2023/01/10 14:40:44 Master exiting
14 replies
DIAdiscord.js - Imagine an app
Created by Unicorn. on 12/29/2022 in #djs-questions
There's Something with running
8 replies