Foxii_80848
Foxii_80848

Reputation: 11

Discord Bot - Cannot send an empty message - Discord.js

I am currently working on a Discord Bot that should verify a Roblox account. My script is ready so far the command "-verify" can also be executed but then an error occurs:

(node:22872) DeprecationWarning: The message event is deprecated. Use messageCreate 
instead
(Use `node --trace-deprecation ...` to show where the warning was created)
C:\Users\Foxii\ExoConnect\node_modules\discord.js\src\rest\RequestHandler.js:298
    throw new DiscordAPIError(data, res.status, request);
        ^

DiscordAPIError: Cannot send an empty message
at RequestHandler.execute 
(C:\Users\Foxii\ExoConnect\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push 
(C:\Users\Foxii\ExoConnect\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async TextChannel.send (C:\Users\Foxii\ExoConnect\node_modules\discord.js\src\structures\interfaces\TextBasedChanne 
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...

I don't know how to fix it. How can I define them all? Could anyone help me? This is my script:

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;
...

The only thing I found to the topics (content, nonce, etc.) is in the 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

Upvotes: 0

Views: 933

Answers (1)

Christoph Blüm
Christoph Blüm

Reputation: 975

Sending embeds changed in V13 try this:

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

Upvotes: 1

Related Questions