- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
#The code doesn't have a bug, but it doesn't work.
9 messages · Page 1 of 1 (latest)
if (message.attachments.size > 0) {
message.react(':x:');
return member.send("I cannot send this massage!")
}
const postChannel = guild.channels.cache.find(c => c.name === `${message.author.id}`);
if (postChannel) {
const embed = new EmbedBuilder()
.setColor("Orange")
.setAuthor({ name: `${message.author.username}`, iconURL: `${message.author.displayAvatarURL()}`})
.setDescription(`${message.content}`)
postChannel.send({ embeds: [embed] });
message.react(`📧`)
return;
}
const category = guild.channels.cache.get('1202044175198204016');
const channel = await guild.channels.create({
name: message.author.id,
type: ChannelType.GuildText,
parent: category,
topic: `A mail sent by ${message.author.tag}`
})
member.send(`Your modmail conversation has been started in ${guild.name}`).catch(err => {
return;
})
const embed = new EmbedBuilder()
.setTitle(`NEW MODMAIL`)
.setColor("Orange")
.setAuthor({ name: `${message.author.username}` , iconURL: `${message.author.displayAvatarURL()}`})
.setDescription(`${message.content}`)
.setTimestamp()
.setFooter({ text: "Use the button below to close this mail" })
const button = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('button')
.setStyle(ButtonStyle.Danger)
.setLabel('Close')
.setEmoji(':closed_lock_with_key:')
)
const m = await channel.send({ embeds: [embed], components: [buttons] });
const collector = m.createMessageComponentCollector();
collector.on('collect', async i => {
if (i.customId == 'buttons') {
await channel.delete();
member.send(`Your modmail conversation in ${guild.name} has been closed by a moderator`)
}
})
m.pin();
message.react('📧');
}
})
client.on(Events.MessageCreate, async message => {
if (message.channel.type === ChannelType.GuildText) {
const guildID = '1160869445988794418'
const guild = client.guilds.cache.get(guildID);
modSchema.findOne({ Guild: guild.id, User: message.channel.name }, async (err, data) => {
if (data == null) return;
const colChannel = guild.channels.cache.find(c => c.name === `${data.User}`);
if (message.channel === colChannel) {
if (message.author.bot) return;
const memberID = data.User;
const member = await client.users.fetch(memberID);
if (message.attachments.size > 0) {
message.react('❌');
return member.send("I cannot send this massage!")
}
message.react('📧')
const embed = new EmbedBuilder()
.setColor("Orange")
.setAuthor({ name: `${message.author.username}`, iconURL: `${message.author.displayAvatarURL()}` })
.setDescription(`${message.content}`)
member.send({ embeds: [embed] })
}
})
}
})
in what way does it not work?
how do you expect it to behave, and in what way does its current behavior not meet this?
have you logged throughout to see what executes and what doesn't?
does this event emit at all?
do you have the proper intents?
( #how-to-get-help )
as a side note, it appears that you have multiple MessageCreate listeners
in general, it's recommended to just have one listener per event and delegate work from there rather than multiple listeners
This is a mod mail code and I want the bot to send the message in the specified category by creating a channel and then retransmit the message to the DM after replying to the admin in it.
When the message is sent to the bot, the channel is not created and the message is not forwarded to the person
have you logged throughout to see what executes and what doesn't?
does this event emit at all?
do you have the proper intents?
( #how-to-get-help )
Check everything bot is connected to the data base correctly and all commands work perfectly and for this part of the program is not given any error merely bot does not work