0

I am making a bot with Discord.Net that can update a voice channel name after a certain amount of time with a string that I provide it. I currently have this but this won't work and returns this exception "System.NullReferenceException: 'Object reference not set to an instance of an object.'

_client was null."

    public async Task set()
    {
           ulong id = idhere;
           var channel = _client.GetChannel(id) as IGuildChannel; //exception was thrown here
           if (channel == null) return;
                await channel.ModifyAsync(x =>
                {
                    x.Name = "NewName";
                    x.Position = channel.Position - 1;
                });
    }

Thanks, -Jack

0 Answers0