I'm working on improvements for my reaction based cart tracker for discord shops (ie in game items etc)
I'm having an issue where after getting a channel by id, i can't use the fetchMessage function on the variable i saved the channel to to get a specific message. i need this to automatically update the cart message ive already sent upon the user reacting to add an item.
heres my current code:
var cartchannel = messageReaction.message.guild.channels.get(curcart.orderchannelid)
var cartmsg = cartchannel.fetchMessage(curcart.cartmsgid)
channel.fetchMessage()
is an asynchronous function. It means you need to use await
or .then()
. For example with await:
var cartchannel = messageReaction.message.guild.channels.get(curcart.orderchannelid)
var cartmsg = await cartchannel.fetchMessage(curcart.cartmsgid)
console.log(cartmsg) // Discord.Message object
or with .then():
var cartchannel = messageReaction.message.guild.channels.get(curcart.orderchannelid)
cartchannel.fetchMessage(curcart.cartmsgid).then((cartmsg) => {
console.log(cartmsg) // Discord.Message object
});
If you use the await
way, you need to be in an async function.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments