D
D
darth_steam2020-08-22 17:19:01
Node.js
darth_steam, 2020-08-22 17:19:01

How to make the bot command to randomize the pages of the site?

I would like to implement so that the bot sends a random page from the site on command, that is, let's say there is a site with films and it has a random film button from where you can pull a link in the spirit of film ru/random.

The trouble is that if you insert a similar link with a simple message send, it displays the same page, that is, the same movie, but when you go to it, it shows that these are other movies.

Simplifying the question yet, some discord bots have functions to search random *mang* nsfw and now I would like to implement the same but not about manga.
Here's the code is quite simple, since I don't know much about it.

client.on('message', message => {
    if (message.author === client.user) return;
    if (message.content.startsWith(prefix + 't')) 
        message.channel.send("любой сайт/random")
       
})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shurshur, 2020-08-22
@shurshur

Well, the discord cached once what it received on the /random page the first time it was accessed, and it does not receive anything else. You must either give a link to something specific (then the preview will be the same as the link), or try to cheat caching by passing a parameter with a random value, something like /random?fake_arg=some_random_value (the preview will not be the same , which is the link, but at least different).

A
Alexander, 2020-08-22
@Alexandre888

hint: dig with Rest API

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question