Retrieving Guild Version of Channel/User from DiscordSocketClient

227 Views Asked by At

I need SocketGuildUser and SocketGuildChannel when a message arrives. I don't see a straightforward way of getting these without downcasting.

    private void downCast(SocketMessage msg)
        {
            SocketUser user = msg.Author;
            ISocketMessageChannel channel = msg.Channel;
            var gUser = (SocketGuildUser)user;
            var Channel = (SocketGuildChannel) channel;
        }

Not sure under what circumstances the downcast will fail...

This all leaves me really scratching my head. Why is there no link between a SocketMessage and a SocketGuild? There isn't even a field for the Guild's ID to enable a subsequent call to DiscordSocketClient.GetGuild(uint64 ID).

0

There are 0 best solutions below