你好,我收到一个错误,显示在 discord modal 中,它告诉我出了点问题。再试一次 discord.js
hello I am getting an error that shows up in discord modal it tells Something went wrong. try again discord.js
你好我做了一个邮件命令,它会从模态中获取消息并将其发送给提到的用户但是它在模态 window 中给出了这个错误并且没有在控制台中记录任何内容
const { Permissions } = require('discord.js');
const { Modal, TextInputComponent, showModal } = require('discord-modals')
const { Formatters } = require('discord.js');
module.exports.run = async (Client, message, args, prefix) => {
let member = message.mentions.members.first();
if(!message.content.includes(member)) {
embed = new MessageEmbed()
.setColor('RED')
.setTitle('Whome shd I send this mail to bruh')
.setDescription('Please mention the user whome you want to deliver the message')
await message.reply({embeds:[embed]})
}
else {
msg = new MessageEmbed()
.setColor('GREEN')
.setTitle('its time to type your message to your friend')
.setDescription('Please type your subject and message as you do while composing a normal mail using gmail just click the button and fill the subject and the message in their respective fields')
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('compose')
.setLabel('Fill up info and compose')
.setEmoji('')
.setStyle('SECONDARY')
);
const msg = await message.reply({embeds:[msg],components: [row]});
//defining intput text fields
let textinput = new TextInputComponent()
.setCustomId('textinput-customid')
.setLabel('Subject')
.setStyle('SHORT')
.setMinLength('1')
.setMaxLength('200')
.setPlaceholder('type your Subject here it can be anything in less than 200 words')
.setRequired(true)
let textinputl = new TextInputComponent()
.setCustomId('textinput-customidl')
.setLabel('Message')
.setStyle('LONG')
.setMinLength('1')
.setMaxLength('4000')
.setPlaceholder('type your message here it can be anything in less than 4000 words')
.setRequired(true)
//main modal
const modal = new Modal() // We create a Modal
.setCustomId('modal-customid')
.setTitle('Compose a mail')
.addComponents([ textinput, textinputl ])
Client.on('interactionCreate', (interaction) => {
if(interaction.isButton) {
if(interaction.customId === 'compose'){
showModal(modal, {
client: Client,
interaction: interaction
})
}
}
})
Client.on('modalSubmit', async (modal) => {
if(modal.customId === 'modal-customid'){
const subjectresponse = modal.getTextInputValue('textinput-customid')
const messageresponse = modal.getTextInputValue('textinput-customidl')
modal.followUp({ content: 'Done message delivered.' + Formatters.codeBlock('markdown', firstResponse), ephemeral: true })
const embed = new MessageEmbed()
.setTitle('You have a new mail')
.setDescription(`${message.author.username} has sent you an email`)
.addField('Subject:', `${subjectresponse}`, false)
.addField('Message:', `${messageresponse}`, false)
await message.reply({embeds:[embed]});
}
})
}
}
module.exports.help = {
name: 'mail',
aliases: []
}
这是代码,请检查并告诉错误是什么
在这个人的 git 错误页面上询问它,但我不明白
必须进行大量代码更改,下面是最终结果,基本上问题在于代码中存在很多差异以及代码的处理方式。需要向代码添加检查以帮助它继续前进。将成员 ID 添加到嵌入中,以帮助机器人在以后需要时获取该 ID。
command.js 文件
const mentionedMember = message.mentions.members.first();
if (!mentionedMember || mentionedMember.user.bot) {
const embed = new MessageEmbed()
.setColor('RED')
.setTitle('Whom should I send this mail to bruh')
.setDescription('Please mention the user whom you want to deliver the message, no bots');
message.reply({
embeds: [embed],
});
setTimeout(() => {
message.delete();
}, 100);
} else {
const rickrollmsg = new MessageEmbed()
.setColor('GREEN')
.setTitle('its time to type your message to your friend')
.setDescription('Please type your subject and message as you do while composing a normal mail using gmail just click the button and fill the subject and the message in their respective fields')
.setFooter({
text: mentionedMember.id,
});
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('compose')
.setLabel('Fill up info and compose')
.setEmoji('')
.setStyle('SECONDARY'),
);
message.reply({
embeds: [rickrollmsg],
components: [row],
});
setTimeout(() => {
message.delete();
}, 100);
}
interactionCreate 按钮代码
const textinput = new TextInputComponent()
.setCustomId('rickmail-subject')
.setLabel('Subject')
.setStyle('SHORT')
.setMinLength('1')
.setMaxLength('200')
.setPlaceholder('type your Subject here it can be anything in less than 200 words')
.setRequired(true);
const textinputl = new TextInputComponent()
.setCustomId('rickmail-message')
.setLabel('Message')
.setStyle('LONG')
.setMinLength('1')
.setMaxLength('4000')
.setPlaceholder('type your message here it can be anything in less than 4000 words')
.setRequired(true);
const modal = new Modal()
.setCustomId('rickmail')
.setTitle('Compose a rickmail')
.addComponents([textinput, textinputl]);
showModal(modal, {
client: client,
interaction: inter,
});
模态提交监听器
const member = modal.guild.members.cache.get(modal.message.embeds[0].footer.text);
const subject = modal.getTextInputValue('rickmail-subject');
const message = modal.getTextInputValue('rickmail-message');
const embed = new MessageEmbed()
.setColor('RANDOM')
.setTitle(`${subject}`)
.setDescription(`${message}`)
.setImage('https://www.icegif.com/wp-content/uploads/rick-roll-icegif-5.gif')
.setFooter({
text: `Message Received ${new Date().toLocaleString()}`,
});
modal.message.delete();
member.send({
embeds: [embed],
});
return modal.followUp({
content: 'Rickmail sent',
ephemeral: true,
});
你好我做了一个邮件命令,它会从模态中获取消息并将其发送给提到的用户但是它在模态 window 中给出了这个错误并且没有在控制台中记录任何内容
const { Permissions } = require('discord.js');
const { Modal, TextInputComponent, showModal } = require('discord-modals')
const { Formatters } = require('discord.js');
module.exports.run = async (Client, message, args, prefix) => {
let member = message.mentions.members.first();
if(!message.content.includes(member)) {
embed = new MessageEmbed()
.setColor('RED')
.setTitle('Whome shd I send this mail to bruh')
.setDescription('Please mention the user whome you want to deliver the message')
await message.reply({embeds:[embed]})
}
else {
msg = new MessageEmbed()
.setColor('GREEN')
.setTitle('its time to type your message to your friend')
.setDescription('Please type your subject and message as you do while composing a normal mail using gmail just click the button and fill the subject and the message in their respective fields')
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('compose')
.setLabel('Fill up info and compose')
.setEmoji('')
.setStyle('SECONDARY')
);
const msg = await message.reply({embeds:[msg],components: [row]});
//defining intput text fields
let textinput = new TextInputComponent()
.setCustomId('textinput-customid')
.setLabel('Subject')
.setStyle('SHORT')
.setMinLength('1')
.setMaxLength('200')
.setPlaceholder('type your Subject here it can be anything in less than 200 words')
.setRequired(true)
let textinputl = new TextInputComponent()
.setCustomId('textinput-customidl')
.setLabel('Message')
.setStyle('LONG')
.setMinLength('1')
.setMaxLength('4000')
.setPlaceholder('type your message here it can be anything in less than 4000 words')
.setRequired(true)
//main modal
const modal = new Modal() // We create a Modal
.setCustomId('modal-customid')
.setTitle('Compose a mail')
.addComponents([ textinput, textinputl ])
Client.on('interactionCreate', (interaction) => {
if(interaction.isButton) {
if(interaction.customId === 'compose'){
showModal(modal, {
client: Client,
interaction: interaction
})
}
}
})
Client.on('modalSubmit', async (modal) => {
if(modal.customId === 'modal-customid'){
const subjectresponse = modal.getTextInputValue('textinput-customid')
const messageresponse = modal.getTextInputValue('textinput-customidl')
modal.followUp({ content: 'Done message delivered.' + Formatters.codeBlock('markdown', firstResponse), ephemeral: true })
const embed = new MessageEmbed()
.setTitle('You have a new mail')
.setDescription(`${message.author.username} has sent you an email`)
.addField('Subject:', `${subjectresponse}`, false)
.addField('Message:', `${messageresponse}`, false)
await message.reply({embeds:[embed]});
}
})
}
}
module.exports.help = {
name: 'mail',
aliases: []
}
这是代码,请检查并告诉错误是什么 在这个人的 git 错误页面上询问它,但我不明白
必须进行大量代码更改,下面是最终结果,基本上问题在于代码中存在很多差异以及代码的处理方式。需要向代码添加检查以帮助它继续前进。将成员 ID 添加到嵌入中,以帮助机器人在以后需要时获取该 ID。
command.js 文件
const mentionedMember = message.mentions.members.first();
if (!mentionedMember || mentionedMember.user.bot) {
const embed = new MessageEmbed()
.setColor('RED')
.setTitle('Whom should I send this mail to bruh')
.setDescription('Please mention the user whom you want to deliver the message, no bots');
message.reply({
embeds: [embed],
});
setTimeout(() => {
message.delete();
}, 100);
} else {
const rickrollmsg = new MessageEmbed()
.setColor('GREEN')
.setTitle('its time to type your message to your friend')
.setDescription('Please type your subject and message as you do while composing a normal mail using gmail just click the button and fill the subject and the message in their respective fields')
.setFooter({
text: mentionedMember.id,
});
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId('compose')
.setLabel('Fill up info and compose')
.setEmoji('')
.setStyle('SECONDARY'),
);
message.reply({
embeds: [rickrollmsg],
components: [row],
});
setTimeout(() => {
message.delete();
}, 100);
}
interactionCreate 按钮代码
const textinput = new TextInputComponent()
.setCustomId('rickmail-subject')
.setLabel('Subject')
.setStyle('SHORT')
.setMinLength('1')
.setMaxLength('200')
.setPlaceholder('type your Subject here it can be anything in less than 200 words')
.setRequired(true);
const textinputl = new TextInputComponent()
.setCustomId('rickmail-message')
.setLabel('Message')
.setStyle('LONG')
.setMinLength('1')
.setMaxLength('4000')
.setPlaceholder('type your message here it can be anything in less than 4000 words')
.setRequired(true);
const modal = new Modal()
.setCustomId('rickmail')
.setTitle('Compose a rickmail')
.addComponents([textinput, textinputl]);
showModal(modal, {
client: client,
interaction: inter,
});
模态提交监听器
const member = modal.guild.members.cache.get(modal.message.embeds[0].footer.text);
const subject = modal.getTextInputValue('rickmail-subject');
const message = modal.getTextInputValue('rickmail-message');
const embed = new MessageEmbed()
.setColor('RANDOM')
.setTitle(`${subject}`)
.setDescription(`${message}`)
.setImage('https://www.icegif.com/wp-content/uploads/rick-roll-icegif-5.gif')
.setFooter({
text: `Message Received ${new Date().toLocaleString()}`,
});
modal.message.delete();
member.send({
embeds: [embed],
});
return modal.followUp({
content: 'Rickmail sent',
ephemeral: true,
});