Cat on the Mountain
Cat on the Mountain
DIAdiscord.js - Imagine an app
Created by Cat on the Mountain on 5/30/2024 in #djs-questions
Editing message
I am making a bot that will update a message every hour, the code works so far but when trying to edit the message it gives the error that the command or function is not found and wfter a bit of looking i couldn#t find the problem: Header:
const { Client, Intents, GatewayIntentBits, IntentsBitField} = require('discord.js');
const client = new Client({ intents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMessages, GatewayIntentBits.MessageContent], autoReconnect: true });
const { Client, Intents, GatewayIntentBits, IntentsBitField} = require('discord.js');
const client = new Client({ intents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMessages, GatewayIntentBits.MessageContent], autoReconnect: true });
Creating message:
countDownMsg = client.channels.cache.find(channel => channel.name === 'announcements-‧₊˚✩').send(`# NEXT STAIRCLIMB <t:${nextHourS}:R> #`);
countDownMsg = client.channels.cache.find(channel => channel.name === 'announcements-‧₊˚✩').send(`# NEXT STAIRCLIMB <t:${nextHourS}:R> #`);
Editing message:
countDownMsg.edit(`# NEXT STAIRCLIMB <t:${nextHourS}:R> #\nLast one <t:${lastHourS}:R>`)
.then(msg => console.log(`Updated the content of a message to ${msg.content}`))
.catch(console.error);
countDownMsg.edit(`# NEXT STAIRCLIMB <t:${nextHourS}:R> #\nLast one <t:${lastHourS}:R>`)
.then(msg => console.log(`Updated the content of a message to ${msg.content}`))
.catch(console.error);
Error:
C:\Discord.js\timerBot.js:14
countDownMsg.edit(`# NEXT STAIRCLIMB <t:${nextHourS}:R> #\nLast one <t:${lastHourS}:R>`)
^

TypeError: countDownMsg.edit is not a function
at Timeout.changeTime [as _onTimeout] (C:\Discord.js\timerBot.js:14:18)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)

Node.js v20.8.1
C:\Discord.js\timerBot.js:14
countDownMsg.edit(`# NEXT STAIRCLIMB <t:${nextHourS}:R> #\nLast one <t:${lastHourS}:R>`)
^

TypeError: countDownMsg.edit is not a function
at Timeout.changeTime [as _onTimeout] (C:\Discord.js\timerBot.js:14:18)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)

Node.js v20.8.1
8 replies