#Modify existing message without created in instance

1 messages · Page 1 of 1 (latest)

echo osprey
#

Hey! I have one issue currently.
Casting an IMessage get from textchannel.getmessage to an IUserMessage only works when the message was created within that bot instance, if the bot is getting rebooted the cast is invalid.
I wanted to ask, is there an way to prevent this or modifying the message without the cast needed to IUserMessage?

#
            message = ClientInteractionService.GetMessage(ChannelId, MessageId) as IUserMessage;
            if (message == null)
            {
                var temp = ClientInteractionService.SendEmbedToChannel(ChannelId, GetUpdatedEmbed());
                message = (ClientInteractionService.GetMessage(ChannelId, temp.Id) as IUserMessage)!;
                MessageId = temp.Id;```
message is always null on initial boot
#
        public static SocketTextChannel GetTextChannel(ulong channelId)
        {
            return GetGuild().GetTextChannel(channelId);
        }

        public static IMessage GetMessage(ulong channelId, ulong messageId)
        {
            return GetTextChannel(channelId).GetMessageAsync(messageId).Result;
        }```
in ClientInteractionService
echo osprey
#

Why isn't there an option to modify on IMessage anyway? I mean it can just throw an error if the author is not the bot no?

echo osprey
#

@bright rune master, any ideas? pwettyplease

bright rune
#

Casting an IMessage get from textchannel.getmessage to an IUserMessage only works when the message was created within that bot instance, if the bot is getting rebooted the cast is invalid.
that's not how that works

#

.Result this is bad

#

await it instead