Discord Bot -不能发送空消息- Discord.js



我目前正在制作一个应该验证Roblox帐户的Discord Bot。到目前为止,我的脚本已经准备好了命令"-verify"也可以执行,但随后出现错误:

(node:22872) DeprecationWarning: The message event is deprecated. Use messageCreate 
instead
(Use `node --trace-deprecation ...` to show where the warning was created)
C:UsersFoxiiExoConnectnode_modulesdiscord.jssrcrestRequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute 
(C:UsersFoxiiExoConnectnode_modulesdiscord.jssrcrestRequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push 
(C:UsersFoxiiExoConnectnode_modulesdiscord.jssrcrestRequestHandler.js:50:14)
at async TextChannel.send (C:UsersFoxiiExoConnectnode_modulesdiscord.jssrcstructuresinterfacesTextBasedChanne 
l.js:171:15) {
method: 'post',
path: '/channels/684428068579966976/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
[nodemon] app crashed - waiting for file changes before starting...

我不知道如何修理它。我该如何定义它们呢?有人能帮我吗?这是我的脚本:

const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require('discord.js');
const noblox = require('noblox.js');
module.exports = class VerifyCommand extends BaseCommand {
constructor() {
super('verify', 'verification', []);
}
async run(client, message, args) {
function sendVerificationMessage(Title, Description, Color) {
const Embed = new Discord.Message.Embed()
.setAuthor('Exo Game Studios Verification')
.setTitle(Title)
.setDescription(Description)
.setColor(Color)
.setFooter('This prompt will cancel in 2 minutes.')
.setTimestamp()
message.channel.send(Embed);
}
message.channel.send('**Starting verification process...**').then(editedMsg => {
editedMsg.edit('**Awaiting prompt**');
editedMsg.delete();
function Generate() {
let text = '';
let randomstuff = ['ExoConnectToken BvVha1XjRJxJ8h', 'ExoConnectToken ghBFuuEw6Zfa72 ', 'ExoConnectToken 1f85xQswyfMgz7', 'ExoConnectToken WLMY59s7ujKysj', 'ExoConnectToken G7GrQNbWNjDqck', 'ExoConnectToken Gh7eTusmu5gKDk', 'ExoConnectToken K1pPedqyfZ8Z2r', 'ExoConnectToken pSkr6x6VWWaWMw', 'ExoConnectToken 1Qp3HgRJuZvHrj', 'ExoConnectToken Q6b4Qg6QG7TBSH',];
text += randomstuff[Math.floor(Math.random() * randomstuff.length)];
return text;
}
const filter = m => m.author.id === message.author.id;
const collector = message.channel.createMessageCollector(filter, {
max: '1',
maxMatches: '1',
time: '120000',
errors: ['time']
})
const embed = new Discord.MessageEmbed()
.setTitle('Exo Game Studios Verification')
.setDescription('Please enter your ROBLOX username.')
.setColor('BLUE')
.setFooter('This prompt will cancel in 2 minutes.')
.setTimestamp()
message.channel.send(embed);
collector.on('collect', m => {
if (m.content.toLowerCase() === 'cancel') {
sendVerificationMessage('Prompt', 'Cancelled the verification prompt.', 'RED')
return;
...

我唯一发现的主题(内容,nonce等)是在TextBasedChannel.js:

Base options provided when sending.
@typedef {Object} BaseMessageOptions
@property {boolean} [tts=false] Whether or not the message should be spoken aloud
@property {string} [nonce=''] The nonce for the message
@property {string} [content=''] The content for the message
@property {MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message
(see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details)
@property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
(see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details)
@property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] Files to send with the message
@property {MessageActionRow[]|MessageActionRowOptions[]} [components]
Action rows containing interactive components for the message (buttons, select menus)
@property {StickerResolvable[]} [stickers=[]] Stickers to send in the message

发送嵌入在V13中更改试试这个:

message.channel.send({embeds: [embed]});

最新更新