I
I
Ilya Zholudev2021-04-09 14:28:40
JavaScript
Ilya Zholudev, 2021-04-09 14:28:40

Why can't the Discord bot find the message?

Good day,
my problem is that I added my code and it stopped working, later I changed it completely,
but it still didn’t want to work.

db.get() - get data from local file
db.set() - replace data in file
Msg - variable storing data in JSON format

Initially, working code looked like this:

var tokens = message.content.split(" ");
        const MTid = tokens[1];
        if (MTid == null || MTid == undefined) return message.author.send("Будьте добры указать ID сообщения, которого вы пытаетесь изменить.");
        else if (db.get(MTid)) {
            const Msg = db.get(MTid);

            const RID = parseInt(MTid, 10);

            async function EditMessage() {
                
            let someserver = client.guilds.cache.get('686225794766209088');
            let somechannel = someserver.channels.cache.get(Msg.channelid);
            let somemessage = await somechannel.messages.fetch(Msg.realid);
.
.
.
}
EditMessage();


And it worked great, now my code looks like this:
var tokens = message.content.split(" ");
        const MTid = tokens[1];
        if (MTid == null || MTid == undefined) return message.author.send("Будьте добры указать ID сообщения, которого вы пытаетесь изменить.");
        else if (db.get(MTid)) {
            const Msg = db.get(MTid);

            const RID = parseInt(MTid, 10);

            async function EditBugMessage() {
                
            let someserver = client.guilds.cache.get('686225794766209088');
            let somechannel = someserver.channels.cache.get(Msg.channelid);
            
            await somechannel.messages.fetch(Msg.realid).then(somemessage => {
.
.
.
});


Now the question itself:
So what has changed? Why did the code stop working?
I checked Msg myself, everything was perfectly recorded there and, in fact, the message can be found, but it does not find it.

An error is thrown: DiscordAPIError: Unknown Message

In this case, the error is always in one line of code:
await somechannel.messages.fetch(Msg.realid);

Please, point out my mistake.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Zholudev, 2021-05-25
@Astroreen

I don’t know why, but the whole construction decided to work, probably this is due to recent updates to the discord.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question