I'm making an order command for my food delivery bot. An error in the console occures when the command is used in outside of the main server, otherwise the command works inside the main channel.
The error is TypeError: Cannot read property 'id' of undefined code is
api.commands.add("claim", (msg) => {
let employeeRole = msg.guild.roles.get("745410836901789749");
if(msg.member.roles.has(employeeRole.id)) {
if(msg.channel.id == 746423099871985755) {
api.client.channels.get("746423099871985755").fetchMessages({
around: order.ticketChannelMessageID,
limit: 1
}).then(messages => {
const fetchedMsg = messages.first();
fetchedMsg.edit({embed: {
color: 0xFFFFFF,
title: api.client.users.get(order.userID).username,
fields: [{
name: "Order Description",
value: order,
}, {
name: "Order ID",
value: ticketID,
}, {
name: "Order Status",
value: "claimed",
}],
timestamp: new Date(),
footer: {
text: "Taco Bot"
}
}}).then((m) => {
m = m.id;
// Update Status
delete orderDB[ticketID];
orderDB[ticketID] = {
"orderID": order.orderID,
"userID": order.userID,
"guildID": order.guildID,
"channelID": order.channelID,
"order": order.order,
"status": "Claimed",
"ticketChannelMessageID": m,
"chef": msg.author.id
};