SpikeHD / AmazonMonitor

Amazon price checker, item monitor and stock monitor, all shoved into a Discord bot
GNU General Public License v3.0
235 stars 39 forks source link

constant crashes due to "cannot send empty message" #92

Closed kekkodance closed 1 year ago

kekkodance commented 1 year ago

{ "prefix":"!", "token":"lol", "minutes_per_check":2, "search_response_ms": 30000, "url_params":{}, "guild_item_limit":100, "cache_limit": 25, "required_perms":[""], "tld":"it", "auto_cart_link":true, "debug_enabled":true }

there's no errors aside from discordjs's "cannot send empty messages", the bot stops at the end of checking one product fully, my watchlist is:

[{"guild_id":"1108038626253746277","channel_id":"1108056747303768104","link":"https://www.amazon.it/dp/B098LWQPRT/?","lastPrice":649,"item_name":"Sony Alpha ZV-E10 | Fotocamera Vlog con obiettivo intercambiabile mirrorless APS-C (schermo girevole per vlogging, video 4K, messa a fuoco automatica degli occhi in tempo reale) Nero","priceLimit":0,"type":"link"},{"guild_id":"1108038626253746277","channel_id":"1108038626761261149","link":"https://www.amazon.it/dp/B0BBJDS62N/?","lastPrice":243.5,"item_name":"","priceLimit":0,"type":"link"},{"guild_id":"1108038626253746277","channel_id":"1108056747303768104","link":"https://www.amazon.it/dp/0691180172/?","lastPrice":29.69,"item_name":"The Princeton Field Guide to Pterosaurs","priceLimit":0,"type":"link"}]

SpikeHD commented 1 year ago

Can you paste the whole logging output? Even if they aren't errors, the output can often give me clues. Please also paste the full error, not just the error message, or else I have no way of knowing where exactly the error is occurring.

Please also use the issue templates in the future.

kekkodance commented 1 year ago

trying to catch the crash again but i'm noticing that in debug the "query" items don't appear, is that normal?

SpikeHD commented 1 year ago

When adding them? Removing them? When they are being checked/fetched? If you mean when they are being fetched, yes it will likely only output stuff when it sees some items change (which it will then log X item(s) changed)

kekkodance commented 1 year ago

yah, when being checked, i'm just waiting for another crash

kekkodance commented 1 year ago
[MESSAGE]  Waiting a couple seconds for JavaScript to load...
[DEBUG]  Got page in 4932ms
[MESSAGE]  Type: libri

                scienze, tecnologia e medicina

                 scienze della terra
[DEBUG]  Detected as a regular item
[DEBUG]  Full object:
[DEBUG]  {
  full_title: 'The Princeton Field Guide to Pterosaurs',
  full_link: 'https://www.amazon.it/dp/0691180172/??',
  asin: '0691180172',
  seller: 'Edizione Inglese         \n' +
    '\t   di               \n' +
    '\t\t      Gregory S. Paul       \n' +
    '       \t\t\t(Autore)',
  price: '29.69',
  symbol: '$',
  shipping: '',
  rating: '4,8 su 5 stelle',
  features: [],
  availability: 'Disponibilità immediata',
  image: 'https://via.placeholder.com/300x300.png?text=No+Image',
  comparePrice: '29.98'
}
[WARNING]  Detected 2 empty values. Could potentially mean bot was flagged
[MESSAGE]  Type: headless
[MESSAGE]  Waiting a couple seconds for JavaScript to load...
[DEBUG]  Got page in 3429ms
[DEBUG]  1 item(s) changed
/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:152
                        throw new DiscordAPIError(data, 'code' in data ? data.code : data.error, status, method, url, requestData);
         ^
DiscordAPIError[50006]: Cannot send an empty message
    at handleErrors (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:152:10)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:399:20)
    at async SequentialHandler.queueRequest (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:169:11)
    at async REST.request (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/REST.ts:343:20)
    at async TextChannel.send (/home/ubuntu/AmazonMonitor/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:162:15) {
  requestBody: {
    files: [],
    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,
      thread_name: undefined
    }
  },
  rawError: { message: 'Cannot send an empty message', code: 50006 },
  code: 50006,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/1108038626761261149/messages'
}
ubuntu@maple:~/AmazonMonitor$ 
kekkodance commented 1 year ago

stackoverflow says it's because it's trying to send more embeds than what recent d.js versions allow?

SpikeHD commented 1 year ago

It only sends one embed per message, and if it was a rate-limiting issue (which it shouldn't be, only one item changed in your case) it would say so.

I've added additional debug logging in 69b080e, so make sure to pull. If it happens again, send the logs here.

kekkodance commented 1 year ago

will let you know

kekkodance commented 1 year ago
[WARNING]  Detected 2 empty values. Could potentially mean bot was flagged
[MESSAGE]  Type: headless
[MESSAGE]  URL: https://www.amazon.it/s?k=ddr5/
[MESSAGE]  Waiting a couple seconds for JavaScript to load...
[DEBUG]  Got page in 2871ms
[MESSAGE]  Sending price alert for Corsair Vengeance DDR5 32 GB (2x16 GB) 5600MHz C36 Memoria per Desktop (Regolazione della tensione a bordo, Profili XMP 3.0 personalizzati, Fattore di forma compatto, Compatibile con Intel) Nero
[MESSAGE]  {
  full_title: 'Corsair Vengeance DDR5 32 GB (2x16 GB) 5600MHz C36 Memoria per Desktop (Regolazione della tensione a bordo, Profili XMP 3.0 personalizzati, Fattore di forma compatto, Compatibile con Intel) Nero',
  ratings: '4,7 su 5 stelle',
  price: '130.98',
  lastPrice: 130.98,
  symbol: ' €',
  sale: '',
  asin: 'B09NCNF2ZQ',
  full_link: 'https://www.amazon.it/dp/B09NCNF2ZQ'
}
[DEBUG]  1 item(s) changed
/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:152
                        throw new DiscordAPIError(data, 'code' in data ? data.code : data.error, status, method, url, requestData);
         ^
DiscordAPIError[50006]: Cannot send an empty message
    at handleErrors (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:152:10)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:399:20)
    at async SequentialHandler.queueRequest (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:169:11)
    at async REST.request (/home/ubuntu/AmazonMonitor/node_modules/@discordjs/rest/src/lib/REST.ts:343:20)
    at async TextChannel.send (/home/ubuntu/AmazonMonitor/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:162:15) {
  requestBody: {
    files: [],
    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,
      thread_name: undefined
    }
  },
  rawError: { message: 'Cannot send an empty message', code: 50006 },
  code: 50006,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/1108038626761261149/messages'
}
ubuntu@maple:~/AmazonMonitor$